Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
fa938177 | 31 | * @copyright CiviCRM LLC (c) 2004-2016 |
6a488035 TO |
32 | */ |
33 | class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { | |
34 | ||
9b09f418 J |
35 | protected $_customGroupExtends = array( |
36 | 'Contact', | |
37 | 'Individual', | |
38 | 'Household', | |
39 | 'Organization', | |
40 | ); | |
41 | ||
6a488035 | 42 | protected $_exposeContactID = FALSE; |
2f4c2f5d | 43 | |
74cf4551 | 44 | /** |
1728e9a0 | 45 | * This report has not been optimised for group filtering. |
46 | * | |
47 | * The functionality for group filtering has been improved but not | |
48 | * all reports have been adjusted to take care of it. This report has not | |
49 | * and will run an inefficient query until fixed. | |
50 | * | |
51 | * CRM-19170 | |
52 | * | |
53 | * @var bool | |
54 | */ | |
55 | protected $groupFilterNotOptimised = TRUE; | |
56 | ||
57 | /** | |
58 | * Class constructor. | |
74cf4551 | 59 | */ |
00be9182 | 60 | public function __construct() { |
6a488035 TO |
61 | $this->_columns = array(); |
62 | ||
63 | $this->_columns['civicrm_contact'] = array( | |
64 | 'dao' => 'CRM_Contact_DAO_Contact', | |
9d72cede EM |
65 | 'fields' => array( |
66 | 'id' => array( | |
6a488035 TO |
67 | 'name' => 'id', |
68 | 'title' => ts('Contact ID'), | |
69 | 'required' => TRUE, | |
70 | 'no_display' => TRUE, | |
71 | ), | |
9d72cede | 72 | 'sort_name' => array( |
6a488035 TO |
73 | 'title' => ts('Contact Name'), |
74 | 'required' => TRUE, | |
75 | ), | |
76 | ), | |
9d72cede EM |
77 | 'filters' => array( |
78 | 'sort_name' => array( | |
6a488035 TO |
79 | 'title' => ts('Contact Name'), |
80 | ), | |
9d72cede | 81 | 'id' => array( |
6a488035 TO |
82 | 'title' => ts('Contact ID'), |
83 | 'no_display' => TRUE, | |
84 | ), | |
85 | ), | |
9d72cede EM |
86 | 'order_bys' => array( |
87 | 'sort_name' => array( | |
88 | 'title' => ts('Contact Name'), | |
6a488035 TO |
89 | 'default' => TRUE, |
90 | 'default_order' => 'ASC', | |
91 | ), | |
92 | ), | |
93 | 'grouping' => 'contact-fields', | |
94 | ); | |
95 | ||
96 | $this->_columns['civicrm_mailing'] = array( | |
97 | 'dao' => 'CRM_Mailing_DAO_Mailing', | |
9d72cede EM |
98 | 'fields' => array( |
99 | 'mailing_name' => array( | |
6a488035 TO |
100 | 'name' => 'name', |
101 | 'title' => ts('Mailing'), | |
102 | 'default' => TRUE, | |
103 | ), | |
104 | ), | |
9d72cede EM |
105 | 'filters' => array( |
106 | 'mailing_id' => array( | |
6a488035 TO |
107 | 'name' => 'id', |
108 | 'title' => ts('Mailing'), | |
109 | 'operatorType' => CRM_Report_Form::OP_MULTISELECT, | |
110 | 'type' => CRM_Utils_Type::T_INT, | |
111 | 'options' => CRM_Mailing_BAO_Mailing::getMailingsList(), | |
112 | ), | |
113 | ), | |
9d72cede EM |
114 | 'order_bys' => array( |
115 | 'mailing_name' => array( | |
6a488035 TO |
116 | 'name' => 'name', |
117 | 'title' => ts('Mailing'), | |
118 | ), | |
119 | ), | |
120 | 'grouping' => 'mailing-fields', | |
121 | ); | |
122 | ||
123 | // adding dao just to have alias | |
124 | $this->_columns['civicrm_mailing_event_bounce'] = array( | |
125 | 'dao' => 'CRM_Mailing_Event_DAO_Bounce', | |
126 | ); | |
127 | ||
128 | $this->_columns['civicrm_mailing_event_delivered'] = array( | |
129 | 'dao' => 'CRM_Mailing_Event_DAO_Delivered', | |
9d72cede EM |
130 | 'fields' => array( |
131 | 'delivery_id' => array( | |
6a488035 TO |
132 | 'name' => 'id', |
133 | 'title' => ts('Delivery Status'), | |
134 | 'default' => TRUE, | |
135 | ), | |
136 | ), | |
9d72cede EM |
137 | 'filters' => array( |
138 | 'delivery_status' => array( | |
6a488035 TO |
139 | 'name' => 'delivery_status', |
140 | 'title' => ts('Delivery Status'), | |
141 | 'operatorType' => CRM_Report_Form::OP_SELECT, | |
142 | 'type' => CRM_Utils_Type::T_STRING, | |
143 | 'options' => array( | |
144 | '' => 'Any', | |
145 | 'successful' => 'Successful', | |
146 | 'bounced' => 'Bounced', | |
147 | ), | |
148 | ), | |
149 | ), | |
150 | 'grouping' => 'mailing-fields', | |
151 | ); | |
152 | ||
153 | $this->_columns['civicrm_mailing_event_unsubscribe'] = array( | |
154 | 'dao' => 'CRM_Mailing_Event_DAO_Unsubscribe', | |
9d72cede EM |
155 | 'fields' => array( |
156 | 'unsubscribe_id' => array( | |
6a488035 TO |
157 | 'name' => 'id', |
158 | 'title' => ts('Unsubscribe'), | |
159 | 'default' => TRUE, | |
160 | ), | |
9d72cede | 161 | 'optout_id' => array( |
6a488035 TO |
162 | 'name' => 'id', |
163 | 'title' => ts('Opt-out'), | |
164 | 'default' => TRUE, | |
165 | 'alias' => 'mailing_event_unsubscribe_civireport2', | |
166 | ), | |
167 | ), | |
9d72cede EM |
168 | 'filters' => array( |
169 | 'is_unsubscribed' => array( | |
6a488035 TO |
170 | 'name' => 'id', |
171 | 'title' => ts('Unsubscribed'), | |
172 | 'type' => CRM_Utils_Type::T_INT, | |
173 | 'operatorType' => CRM_Report_Form::OP_SELECT, | |
9d72cede EM |
174 | 'options' => array( |
175 | '' => ts('Any'), | |
176 | '0' => ts('No'), | |
21dfd5f5 | 177 | '1' => ts('Yes'), |
9d72cede | 178 | ), |
6a488035 TO |
179 | 'clause' => 'mailing_event_unsubscribe_civireport.id IS NULL', |
180 | ), | |
9d72cede | 181 | 'is_optout' => array( |
6a488035 TO |
182 | 'title' => ts('Opted-out'), |
183 | 'type' => CRM_Utils_Type::T_INT, | |
184 | 'operatorType' => CRM_Report_Form::OP_SELECT, | |
9d72cede EM |
185 | 'options' => array( |
186 | '' => ts('Any'), | |
187 | '0' => ts('No'), | |
21dfd5f5 | 188 | '1' => ts('Yes'), |
9d72cede | 189 | ), |
6a488035 TO |
190 | 'clause' => 'mailing_event_unsubscribe_civireport2.id IS NULL', |
191 | ), | |
192 | ), | |
193 | 'grouping' => 'mailing-fields', | |
194 | ); | |
195 | ||
196 | $this->_columns['civicrm_mailing_event_reply'] = array( | |
197 | 'dao' => 'CRM_Mailing_Event_DAO_Reply', | |
9d72cede EM |
198 | 'fields' => array( |
199 | 'reply_id' => array( | |
6a488035 TO |
200 | 'name' => 'id', |
201 | 'title' => ts('Reply'), | |
202 | ), | |
203 | ), | |
9d72cede EM |
204 | 'filters' => array( |
205 | 'is_replied' => array( | |
6a488035 TO |
206 | 'name' => 'id', |
207 | 'title' => ts('Replied'), | |
208 | 'type' => CRM_Utils_Type::T_INT, | |
209 | 'operatorType' => CRM_Report_Form::OP_SELECT, | |
9d72cede EM |
210 | 'options' => array( |
211 | '' => ts('Any'), | |
212 | '0' => ts('No'), | |
21dfd5f5 | 213 | '1' => ts('Yes'), |
9d72cede | 214 | ), |
6a488035 TO |
215 | 'clause' => 'mailing_event_reply_civireport.id IS NULL', |
216 | ), | |
217 | ), | |
218 | 'grouping' => 'mailing-fields', | |
219 | ); | |
220 | ||
221 | $this->_columns['civicrm_mailing_event_forward'] = array( | |
222 | 'dao' => 'CRM_Mailing_Event_DAO_Forward', | |
9d72cede EM |
223 | 'fields' => array( |
224 | 'forward_id' => array( | |
6a488035 TO |
225 | 'name' => 'id', |
226 | 'title' => ts('Forwarded to Email'), | |
227 | ), | |
228 | ), | |
9d72cede EM |
229 | 'filters' => array( |
230 | 'is_forwarded' => array( | |
6a488035 TO |
231 | 'name' => 'id', |
232 | 'title' => ts('Forwarded'), | |
233 | 'type' => CRM_Utils_Type::T_INT, | |
234 | 'operatorType' => CRM_Report_Form::OP_SELECT, | |
9d72cede EM |
235 | 'options' => array( |
236 | '' => ts('Any'), | |
237 | '0' => ts('No'), | |
21dfd5f5 | 238 | '1' => ts('Yes'), |
9d72cede | 239 | ), |
6a488035 TO |
240 | 'clause' => 'mailing_event_forward_civireport.id IS NULL', |
241 | ), | |
242 | ), | |
243 | 'grouping' => 'mailing-fields', | |
244 | ); | |
245 | ||
246 | $this->_columns['civicrm_email'] = array( | |
247 | 'dao' => 'CRM_Core_DAO_Email', | |
9d72cede EM |
248 | 'fields' => array( |
249 | 'email' => array( | |
6a488035 | 250 | 'title' => ts('Email'), |
6a488035 TO |
251 | ), |
252 | ), | |
253 | 'grouping' => 'contact-fields', | |
254 | ); | |
255 | ||
256 | $this->_columns['civicrm_phone'] = array( | |
257 | 'dao' => 'CRM_Core_DAO_Phone', | |
258 | 'fields' => array('phone' => NULL), | |
259 | 'grouping' => 'contact-fields', | |
260 | ); | |
261 | ||
16e2e80c CW |
262 | $this->_groupFilter = TRUE; |
263 | $this->_tagFilter = TRUE; | |
6a488035 TO |
264 | |
265 | parent::__construct(); | |
266 | } | |
267 | ||
00be9182 | 268 | public function select() { |
6a488035 TO |
269 | $select = $columns = array(); |
270 | foreach ($this->_columns as $tableName => $table) { | |
271 | if (array_key_exists('fields', $table)) { | |
272 | foreach ($table['fields'] as $fieldName => $field) { | |
9d72cede EM |
273 | if (!empty($field['required']) || |
274 | !empty($this->_params['fields'][$fieldName]) | |
275 | ) { | |
6a488035 | 276 | if (in_array($fieldName, array( |
9d72cede EM |
277 | 'unsubscribe_id', |
278 | 'optout_id', | |
279 | 'forward_id', | |
21dfd5f5 | 280 | 'reply_id', |
9d72cede | 281 | ))) { |
6a488035 TO |
282 | $select[] = "IF({$field['dbAlias']} IS NULL, 'No', 'Yes') as {$tableName}_{$fieldName}"; |
283 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); | |
284 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); | |
285 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); | |
286 | unset($this->_columns[$tableName]['fields'][$fieldName]); | |
287 | $columns[$tableName][$fieldName] = $field; | |
288 | } | |
289 | elseif ($fieldName == 'delivery_id') { | |
939c5588 | 290 | $select[] = "IF(mailing_event_bounce_civireport.id IS NOT NULL, 'Bounced', IF(mailing_event_delivered_civireport.id IS NOT NULL, 'Successful', 'Unknown')) as {$tableName}_{$fieldName}"; |
6a488035 TO |
291 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); |
292 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); | |
293 | $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); | |
294 | unset($this->_columns[$tableName]['fields'][$fieldName]); | |
295 | $columns[$tableName][$fieldName] = $field; | |
296 | } | |
297 | } | |
298 | } | |
299 | } | |
300 | } | |
301 | ||
302 | parent::select(); | |
303 | if (!empty($select)) { | |
304 | $this->_select .= ', ' . implode(', ', $select) . " "; | |
305 | } | |
306 | ||
307 | // put the fields that were unset, back in place | |
308 | foreach ($columns as $tableName => $table) { | |
309 | foreach ($table as $fieldName => $fields) { | |
310 | $this->_columns[$tableName]['fields'][$fieldName] = $fields; | |
311 | } | |
312 | } | |
313 | ||
314 | // simple sort | |
315 | ksort($this->_columnHeaders); | |
316 | } | |
317 | ||
00be9182 | 318 | public function from() { |
6a488035 TO |
319 | $this->_from = " |
320 | FROM civicrm_contact {$this->_aliases['civicrm_contact']}"; | |
321 | ||
322 | $this->_from .= " | |
2f4c2f5d | 323 | INNER JOIN civicrm_mailing_event_queue |
324 | ON civicrm_mailing_event_queue.contact_id = {$this->_aliases['civicrm_contact']}.id | |
d2c742e9 | 325 | LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']} |
2f4c2f5d | 326 | ON civicrm_mailing_event_queue.email_id = {$this->_aliases['civicrm_email']}.id"; |
6a488035 TO |
327 | |
328 | if (array_key_exists('delivery_id', $this->_params['fields'])) { | |
329 | $this->_from .= " | |
330 | LEFT JOIN civicrm_mailing_event_delivered {$this->_aliases['civicrm_mailing_event_delivered']} | |
331 | ON {$this->_aliases['civicrm_mailing_event_delivered']}.event_queue_id = civicrm_mailing_event_queue.id | |
2f4c2f5d | 332 | LEFT JOIN civicrm_mailing_event_bounce {$this->_aliases['civicrm_mailing_event_bounce']} |
333 | ON {$this->_aliases['civicrm_mailing_event_bounce']}.event_queue_id = civicrm_mailing_event_queue.id"; | |
9d72cede EM |
334 | if (CRM_Utils_Array::value('delivery_status_value', $this->_params) == |
335 | 'bounced' | |
336 | ) { | |
6a488035 TO |
337 | $this->_columns['civicrm_mailing_event_delivered']['filters']['delivery_status']['clause'] = "{$this->_aliases['civicrm_mailing_event_bounce']}.id IS NOT NULL"; |
338 | } | |
9d72cede EM |
339 | elseif (CRM_Utils_Array::value('delivery_status_value', $this->_params) == |
340 | 'successful' | |
341 | ) { | |
939c5588 | 342 | $this->_columns['civicrm_mailing_event_delivered']['filters']['delivery_status']['clause'] = "{$this->_aliases['civicrm_mailing_event_delivered']}.id IS NOT NULL AND {$this->_aliases['civicrm_mailing_event_bounce']}.id IS NULL"; |
6a488035 TO |
343 | } |
344 | } | |
345 | else { | |
346 | unset($this->_columns['civicrm_mailing_event_delivered']['filters']['delivery_status']); | |
347 | } | |
348 | ||
349 | if (array_key_exists('reply_id', $this->_params['fields']) || | |
350 | is_numeric(CRM_Utils_Array::value('is_replied_value', $this->_params)) | |
351 | ) { | |
352 | if (CRM_Utils_Array::value('is_replied_value', $this->_params) == 1) { | |
353 | $joinType = 'INNER'; | |
354 | $this->_columns['civicrm_mailing_event_reply']['filters']['is_replied']['clause'] = '(1)'; | |
355 | } | |
356 | else { | |
357 | $joinType = 'LEFT'; | |
358 | } | |
359 | $this->_from .= " | |
360 | {$joinType} JOIN civicrm_mailing_event_reply {$this->_aliases['civicrm_mailing_event_reply']} | |
361 | ON {$this->_aliases['civicrm_mailing_event_reply']}.event_queue_id = civicrm_mailing_event_queue.id"; | |
362 | } | |
363 | else { | |
364 | unset($this->_columns['civicrm_mailing_event_reply']['filters']['is_replied']); | |
365 | } | |
366 | ||
367 | if (array_key_exists('unsubscribe_id', $this->_params['fields']) || | |
368 | is_numeric(CRM_Utils_Array::value('is_unsubscribed_value', $this->_params)) | |
369 | ) { | |
9d72cede EM |
370 | if (CRM_Utils_Array::value('is_unsubscribed_value', $this->_params) == 1 |
371 | ) { | |
6a488035 TO |
372 | $joinType = 'INNER'; |
373 | $this->_columns['civicrm_mailing_event_unsubscribe']['filters']['is_unsubscribed']['clause'] = '(1)'; | |
374 | } | |
375 | else { | |
376 | $joinType = 'LEFT'; | |
377 | } | |
378 | $this->_from .= " | |
379 | {$joinType} JOIN civicrm_mailing_event_unsubscribe {$this->_aliases['civicrm_mailing_event_unsubscribe']} | |
380 | ON {$this->_aliases['civicrm_mailing_event_unsubscribe']}.event_queue_id = civicrm_mailing_event_queue.id | |
381 | AND {$this->_aliases['civicrm_mailing_event_unsubscribe']}.org_unsubscribe = 0"; | |
382 | } | |
383 | else { | |
384 | unset($this->_columns['civicrm_mailing_event_unsubscribe']['filters']['is_unsubscribed']); | |
385 | } | |
386 | ||
387 | if (array_key_exists('optout_id', $this->_params['fields']) || | |
388 | is_numeric(CRM_Utils_Array::value('is_optout_value', $this->_params)) | |
389 | ) { | |
390 | if (CRM_Utils_Array::value('is_optout_value', $this->_params) == 1) { | |
391 | $joinType = 'INNER'; | |
392 | $this->_columns['civicrm_mailing_event_unsubscribe']['filters']['is_optout']['clause'] = '(1)'; | |
393 | } | |
394 | else { | |
395 | $joinType = 'LEFT'; | |
396 | } | |
397 | $this->_from .= " | |
398 | {$joinType} JOIN civicrm_mailing_event_unsubscribe {$this->_aliases['civicrm_mailing_event_unsubscribe']}2 | |
399 | ON {$this->_aliases['civicrm_mailing_event_unsubscribe']}2.event_queue_id = civicrm_mailing_event_queue.id | |
400 | AND {$this->_aliases['civicrm_mailing_event_unsubscribe']}2.org_unsubscribe = 1"; | |
401 | } | |
402 | else { | |
403 | unset($this->_columns['civicrm_mailing_event_unsubscribe']['filters']['is_optout']); | |
404 | } | |
405 | ||
406 | if (array_key_exists('forward_id', $this->_params['fields']) || | |
407 | is_numeric(CRM_Utils_Array::value('is_forwarded_value', $this->_params)) | |
408 | ) { | |
409 | if (CRM_Utils_Array::value('is_forwarded_value', $this->_params) == 1) { | |
410 | $joinType = 'INNER'; | |
411 | $this->_columns['civicrm_mailing_event_forward']['filters']['is_forwarded']['clause'] = '(1)'; | |
412 | } | |
413 | else { | |
414 | $joinType = 'LEFT'; | |
415 | } | |
416 | $this->_from .= " | |
417 | {$joinType} JOIN civicrm_mailing_event_forward {$this->_aliases['civicrm_mailing_event_forward']} | |
418 | ON {$this->_aliases['civicrm_mailing_event_forward']}.event_queue_id = civicrm_mailing_event_queue.id"; | |
419 | } | |
420 | else { | |
421 | unset($this->_columns['civicrm_mailing_event_forward']['filters']['is_forwarded']); | |
422 | } | |
423 | ||
424 | $this->_from .= " | |
2f4c2f5d | 425 | INNER JOIN civicrm_mailing_job |
426 | ON civicrm_mailing_event_queue.job_id = civicrm_mailing_job.id | |
427 | INNER JOIN civicrm_mailing {$this->_aliases['civicrm_mailing']} | |
428 | ON civicrm_mailing_job.mailing_id = {$this->_aliases['civicrm_mailing']}.id | |
429 | AND civicrm_mailing_job.is_test = 0"; | |
6a488035 TO |
430 | |
431 | if ($this->_phoneField) { | |
432 | $this->_from .= " | |
2f4c2f5d | 433 | LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']} |
434 | ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND | |
6a488035 TO |
435 | {$this->_aliases['civicrm_phone']}.is_primary = 1 "; |
436 | } | |
437 | } | |
438 | ||
00be9182 | 439 | public function where() { |
6a488035 TO |
440 | parent::where(); |
441 | $this->_where .= " AND {$this->_aliases['civicrm_mailing']}.sms_provider_id IS NULL"; | |
442 | } | |
443 | ||
74cf4551 EM |
444 | /** |
445 | * @return array | |
446 | */ | |
00be9182 | 447 | public function mailingList() { |
6a488035 | 448 | |
9d72cede | 449 | $data = array(); |
6a488035 | 450 | $mailing = new CRM_Mailing_BAO_Mailing(); |
9d72cede | 451 | $query = "SELECT name FROM civicrm_mailing "; |
6a488035 TO |
452 | $mailing->query($query); |
453 | ||
454 | while ($mailing->fetch()) { | |
8f56d1f5 | 455 | $data[CRM_Core_DAO::escapeString($mailing->name)] = $mailing->name; |
6a488035 TO |
456 | } |
457 | ||
458 | return $data; | |
459 | } | |
460 | ||
74cf4551 | 461 | /** |
ced9bfed EM |
462 | * Alter display of rows. |
463 | * | |
464 | * Iterate through the rows retrieved via SQL and make changes for display purposes, | |
465 | * such as rendering contacts as links. | |
466 | * | |
467 | * @param array $rows | |
468 | * Rows generated by SQL, with an array for each row. | |
74cf4551 | 469 | */ |
00be9182 | 470 | public function alterDisplay(&$rows) { |
6a488035 TO |
471 | $entryFound = FALSE; |
472 | foreach ($rows as $rowNum => $row) { | |
d2c742e9 J |
473 | |
474 | // If the email address has been deleted | |
475 | if (array_key_exists('civicrm_email_email', $row)) { | |
476 | if (empty($rows[$rowNum]['civicrm_email_email'])) { | |
477 | $rows[$rowNum]['civicrm_email_email'] = '<del>Email address deleted</del>'; | |
478 | } | |
479 | $entryFound = TRUE; | |
480 | } | |
481 | ||
6a488035 TO |
482 | // make count columns point to detail report |
483 | // convert display name to links | |
484 | if (array_key_exists('civicrm_contact_sort_name', $row) && | |
485 | array_key_exists('civicrm_contact_id', $row) | |
486 | ) { | |
487 | $url = CRM_Utils_System::url('civicrm/contact/view', | |
488 | 'reset=1&cid=' . $row['civicrm_contact_id'], | |
489 | $this->_absoluteUrl | |
490 | ); | |
491 | $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url; | |
492 | $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contact details for this contact."); | |
493 | $entryFound = TRUE; | |
494 | } | |
495 | ||
496 | // skip looking further in rows, if first row itself doesn't | |
497 | // have the column we need | |
498 | if (!$entryFound) { | |
499 | break; | |
500 | } | |
501 | } | |
502 | } | |
96025800 | 503 | |
6a488035 | 504 | } |