Newer
Older
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
use CRM_Dataprocessor_ExtensionUtil as E;
class CRM_DataprocessorSearch_Form_CaseSearch extends CRM_DataprocessorSearch_Form_AbstractSearch {
/**
* Returns the name of the default Entity
*
* @return string
*/
public function getDefaultEntity() {
return 'Contact';
}
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* Returns the url for view of the record action
*
* @param $row
*
* @return false|string
*/
protected function link($row) {
$record = $row['record'];
$idFieldName = $this->getIdFieldName();
$contactIdFieldName = $this->getContactIdFieldName();
$caseId = $record[$idFieldName]->formattedValue;
$contactId = $record[$contactIdFieldName]->formattedValue;
return CRM_Utils_System::url('civicrm/contact/view/case', 'reset=1&action=view&id='.$caseId.'&cid='.$contactId.'&context=search');
}
/**
* Returns the link text for view of the record action
*
* @param $row
*
* @return false|string
*/
protected function linkText($row) {
return E::ts('Manage case');
}
/**
* Return the data processor name
*
* @return String
*/
protected function getDataProcessorName() {
$dataProcessorName = str_replace('civicrm/dataprocessor_case_search/', '', CRM_Utils_System::getUrlPath());
return $dataProcessorName;
}
/**
* Returns the name of the output for this search
*
* @return string
*/
protected function getOutputName() {
return 'case_search';
}
/**
* Checks whether the output has a valid configuration
*
* @return bool
*/
protected function isConfigurationValid() {
if (!isset($this->dataProcessorOutput['configuration']['case_id_field'])) {
return false;
}
if (!isset($this->dataProcessorOutput['configuration']['contact_id_field'])) {
return false;
}
return true;
}
/**
* Returns the name of the ID field in the dataset.
*
* @return string
*/
protected function getIdFieldName() {
return $this->dataProcessorOutput['configuration']['case_id_field'];
}
/**
* Returns the name of the ID field in the dataset.
*
* @return string
*/
protected function getContactIdFieldName() {
return $this->dataProcessorOutput['configuration']['contact_id_field'];
}
/**
* @return string
*/
protected function getEntityTable() {
return 'civicrm_case';
}
/**
* Builds the list of tasks or actions that a searcher can perform on a result set.
*
* @return array
*/
public function buildTaskList() {
if (!$this->_taskList) {
$this->_taskList = CRM_Case_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission());
}
return $this->_taskList;
}
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* Returns whether the ID field is Visible
*
* @return bool
*/
protected function isIdFieldVisible() {
if (isset($this->dataProcessorOutput['configuration']['hide_id_fields']) && $this->dataProcessorOutput['configuration']['hide_id_fields']) {
return false;
}
return true;
}
/**
* Returns an array with hidden columns
*
* @return array
*/
protected function getHiddenFields() {
$hiddenFields = array();
if (!$this->isIdFieldVisible()) {
$hiddenFields[] = $this->getIdFieldName();
$hiddenFields[] = $this->getContactIdFieldName();
}
return $hiddenFields;
}
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/**
* Return altered rows
*
* Save the ids into the queryParams value. So that when an action is done on the selected record
* or on all records, the queryParams will hold all the activity ids so that in the next step only the selected record, or the first
* 50 records are populated.
*
* @param array $rows
* @param array $ids
*
*/
protected function alterRows(&$rows, $ids) {
$this->entityIDs = $ids;
$this->_queryParams[0] = array(
'case_id',
'=',
array(
'IN' => $this->entityIDs,
),
0,
0
);
$this->controller->set('queryParams', $this->_queryParams);
}
}