3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
35 class CRM_Report_Form_Activity
extends CRM_Report_Form
{
36 protected $_selectAliasesTotal = array();
38 protected $_customGroupExtends = array(
42 protected $_nonDisplayFields = array();
50 function __construct() {
51 // There could be multiple contacts. We not clear on which contact id to display.
52 // Lets hide it for now.
53 $this->_exposeContactID
= FALSE;
55 $config = CRM_Core_Config
::singleton();
56 $campaignEnabled = in_array("CiviCampaign", $config->enableComponents
);
57 if ($campaignEnabled) {
58 $getCampaigns = CRM_Campaign_BAO_Campaign
::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
59 $this->activeCampaigns
= $getCampaigns['campaigns'];
60 asort($this->activeCampaigns
);
61 $this->engagementLevels
= CRM_Campaign_PseudoConstant
::engagementLevel();
63 $this->activityTypes
= CRM_Core_PseudoConstant
::activityType(TRUE, FALSE, FALSE, 'label', TRUE);
64 asort($this->activityTypes
);
66 $this->_columns
= array(
69 'dao' => 'CRM_Contact_DAO_Contact',
74 'name' => 'sort_name',
75 'title' => ts('Source Contact Name'),
76 'alias' => 'civicrm_contact_source',
81 'name' => 'sort_name',
82 'title' => ts('Assignee Contact Name'),
83 'alias' => 'civicrm_contact_assignee',
84 'dbAlias' => "civicrm_contact_assignee.sort_name",
89 'name' => 'sort_name',
90 'title' => ts('Target Contact Name'),
91 'alias' => 'civicrm_contact_target',
92 'dbAlias' => "civicrm_contact_target.sort_name",
95 'contact_source_id' =>
98 'alias' => 'civicrm_contact_source',
99 'dbAlias' => "civicrm_contact_source.id",
100 'no_display' => TRUE,
104 'contact_assignee_id' =>
107 'alias' => 'civicrm_contact_assignee',
108 'dbAlias' => "civicrm_contact_assignee.id",
109 'no_display' => TRUE,
113 'contact_target_id' =>
116 'alias' => 'civicrm_contact_target',
117 'dbAlias' => "civicrm_contact_target.id",
118 'no_display' => TRUE,
127 'name' => 'sort_name',
128 'alias' => 'civicrm_contact_source',
129 'title' => ts('Source Contact Name'),
130 'operator' => 'like',
131 'type' => CRM_Report_Form
::OP_STRING
,
133 'contact_assignee' =>
135 'name' => 'sort_name',
136 'alias' => 'civicrm_contact_assignee',
137 'title' => ts('Assignee Contact Name'),
138 'operator' => 'like',
139 'type' => CRM_Report_Form
::OP_STRING
,
143 'name' => 'sort_name',
144 'alias' => 'civicrm_contact_target',
145 'title' => ts('Target Contact Name'),
146 'operator' => 'like',
147 'type' => CRM_Report_Form
::OP_STRING
,
151 'name' => 'current_user',
152 'title' => ts('Limit To Current User'),
153 'type' => CRM_Utils_Type
::T_INT
,
154 'operatorType' => CRM_Report_Form
::OP_SELECT
,
155 'options' => array('0' => ts('No'), '1' => ts('Yes')),
158 'grouping' => 'contact-fields',
162 'dao' => 'CRM_Core_DAO_Email',
165 'contact_source_email' =>
168 'title' => ts('Source Contact Email'),
169 'alias' => 'civicrm_email_source',
171 'contact_assignee_email' =>
174 'title' => ts('Assignee Contact Email'),
175 'alias' => 'civicrm_email_assignee',
177 'contact_target_email' =>
180 'title' => ts('Target Contact Email'),
181 'alias' => 'civicrm_email_target',
186 'source_contact_email' =>
189 'title' => ts('Source Contact Email'),
190 'dbAlias' => 'civicrm_email_contact_source_email',
194 'civicrm_activity' =>
196 'dao' => 'CRM_Activity_DAO_Activity',
201 'no_display' => TRUE,
202 'title' => ts('Activity ID'),
205 'source_record_id' =>
207 'no_display' => TRUE,
210 'activity_type_id' =>
211 array('title' => ts('Activity Type'),
213 'type' => CRM_Utils_Type
::T_STRING
,
215 'activity_subject' =>
216 array('title' => ts('Subject'),
219 'activity_date_time' =>
220 array('title' => ts('Activity Date'),
224 array('title' => ts('Activity Status'),
226 'type' => CRM_Utils_Type
::T_STRING
,
229 array('title' => ts('Duration'),
230 'type' => CRM_Utils_Type
::T_INT
,
233 'title' => ts('Activity Details'),
237 'activity_date_time' => array(
238 'default' => 'this.month',
239 'operatorType' => CRM_Report_Form
::OP_DATE
,
241 'activity_subject' =>
242 array('title' => ts('Activity Subject')),
243 'activity_type_id' =>
244 array('title' => ts('Activity Type'),
245 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
246 'options' => $this->activityTypes
,
249 array('title' => ts('Activity Status'),
250 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
251 'options' => CRM_Core_PseudoConstant
::activityStatus(),
254 'title' => ts('Activity Details'),
255 'type' => CRM_Utils_Type
::T_TEXT
,
258 'order_bys' => array(
259 'activity_date_time' =>
260 array('title' => ts('Activity Date'), 'default_weight' => '1', 'dbAlias' => 'civicrm_activity_activity_date_time'),
261 'activity_type_id' =>
262 array('title' => ts('Activity Type'), 'default_weight' => '2', 'dbAlias' => 'civicrm_activity_activity_type_id'),
264 'grouping' => 'activity-fields',
265 'alias' => 'activity',
267 'civicrm_activity_contact' =>
269 'dao' => 'CRM_Activity_DAO_ActivityContact',
272 // so we have $this->_alias populated
275 ) +
$this->addAddressFields(FALSE, TRUE);
277 if ($campaignEnabled) {
278 // Add display column and filter for Survey Results, Campaign and Engagement Index if CiviCampaign is enabled
280 $this->_columns
['civicrm_activity']['fields']['result'] = array(
281 'title' => 'Survey Result',
282 'default' => 'false',
284 $this->_columns
['civicrm_activity']['filters']['result'] = array('title' => ts('Survey Result'),
285 'operator' => 'like',
286 'type' => CRM_Utils_Type
::T_STRING
,
288 if (!empty($this->activeCampaigns
)) {
289 $this->_columns
['civicrm_activity']['fields']['campaign_id'] = array(
290 'title' => 'Campaign',
291 'default' => 'false',
293 $this->_columns
['civicrm_activity']['filters']['campaign_id'] = array('title' => ts('Campaign'),
294 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
295 'options' => $this->activeCampaigns
,
298 if (!empty($this->engagementLevels
)) {
299 $this->_columns
['civicrm_activity']['fields']['engagement_level'] = array(
300 'title' => 'Engagement Index',
301 'default' => 'false',
303 $this->_columns
['civicrm_activity']['filters']['engagement_level'] = array('title' => ts('Engagement Index'),
304 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
305 'options' => $this->engagementLevels
,
309 $this->_groupFilter
= TRUE;
310 $this->_tagFilter
= TRUE;
311 parent
::__construct();
315 * @param null $recordType
317 function select($recordType = NULL) {
318 if (!array_key_exists("contact_{$recordType}", $this->_params
['fields']) && $recordType != 'final') {
319 $this->_nonDisplayFields
[] = "civicrm_contact_contact_{$recordType}";
323 if ($recordType == 'final' && !empty($this->_nonDisplayFields
)) {
324 foreach ($this->_nonDisplayFields
as $fieldName) {
325 unset($this->_columnHeaders
[$fieldName]);
329 if (empty($this->_selectAliasesTotal
)) {
330 $this->_selectAliasesTotal
= $this->_selectAliases
;
333 $removeKeys = array();
334 if ($recordType == 'target') {
335 foreach ($this->_selectClauses
as $key => $clause) {
336 if (strstr($clause, 'civicrm_contact_assignee.') ||
337 strstr($clause, 'civicrm_contact_source.') ||
338 strstr($clause, 'civicrm_email_assignee.') ||
339 strstr($clause, 'civicrm_email_source.')
341 $removeKeys[] = $key;
342 unset($this->_selectClauses
[$key]);
345 } else if ($recordType == 'assignee') {
346 foreach ($this->_selectClauses
as $key => $clause) {
347 if (strstr($clause, 'civicrm_contact_target.') ||
348 strstr($clause, 'civicrm_contact_source.') ||
349 strstr($clause, 'civicrm_email_target.') ||
350 strstr($clause, 'civicrm_email_source.')
352 $removeKeys[] = $key;
353 unset($this->_selectClauses
[$key]);
356 } else if ($recordType == 'source') {
357 foreach ($this->_selectClauses
as $key => $clause) {
358 if (strstr($clause, 'civicrm_contact_target.') ||
359 strstr($clause, 'civicrm_contact_assignee.') ||
360 strstr($clause, 'civicrm_email_target.') ||
361 strstr($clause, 'civicrm_email_assignee.')
363 $removeKeys[] = $key;
364 unset($this->_selectClauses
[$key]);
367 } else if ($recordType == 'final') {
368 $this->_selectClauses
= $this->_selectAliasesTotal
;
369 foreach ($this->_selectClauses
as $key => $clause) {
370 if (strstr($clause, 'civicrm_contact_contact_target') ||
371 strstr($clause, 'civicrm_contact_contact_assignee') ||
372 strstr($clause, 'civicrm_contact_contact_source') ) {
373 $this->_selectClauses
[$key] = "GROUP_CONCAT($clause SEPARATOR ';') as $clause";
379 foreach ($removeKeys as $key) {
380 unset($this->_selectAliases
[$key]);
383 $this->_select
= "SELECT " . implode(', ', $this->_selectClauses
) . " ";
390 function from($recordType) {
391 $activityContacts = CRM_Core_OptionGroup
::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
392 $assigneeID = CRM_Utils_Array
::key('Activity Assignees', $activityContacts);
393 $targetID = CRM_Utils_Array
::key('Activity Targets', $activityContacts);
394 $sourceID = CRM_Utils_Array
::key('Activity Source', $activityContacts);
396 if ($recordType == 'target') {
398 FROM civicrm_activity {$this->_aliases['civicrm_activity']}
399 INNER JOIN civicrm_activity_contact {$this->_aliases['civicrm_activity_contact']}
400 ON {$this->_aliases['civicrm_activity']}.id = {$this->_aliases['civicrm_activity_contact']}.activity_id AND
401 {$this->_aliases['civicrm_activity_contact']}.record_type_id = {$targetID}
402 INNER JOIN civicrm_contact civicrm_contact_target
403 ON {$this->_aliases['civicrm_activity_contact']}.contact_id = civicrm_contact_target.id
406 if ($this->isTableSelected('civicrm_email')) {
408 LEFT JOIN civicrm_email civicrm_email_target
409 ON {$this->_aliases['civicrm_activity_contact']}.contact_id = civicrm_email_target.contact_id AND
410 civicrm_email_target.is_primary = 1";
412 $this->_aliases
['civicrm_contact'] = 'civicrm_contact_target';
415 if ($recordType == 'assignee') {
417 FROM civicrm_activity {$this->_aliases['civicrm_activity']}
418 INNER JOIN civicrm_activity_contact {$this->_aliases['civicrm_activity_contact']}
419 ON {$this->_aliases['civicrm_activity']}.id = {$this->_aliases['civicrm_activity_contact']}.activity_id AND
420 {$this->_aliases['civicrm_activity_contact']}.record_type_id = {$assigneeID}
421 INNER JOIN civicrm_contact civicrm_contact_assignee
422 ON {$this->_aliases['civicrm_activity_contact']}.contact_id = civicrm_contact_assignee.id
425 if ($this->isTableSelected('civicrm_email')) {
427 LEFT JOIN civicrm_email civicrm_email_assignee
428 ON {$this->_aliases['civicrm_activity_contact']}.contact_id = civicrm_email_assignee.contact_id AND
429 civicrm_email_assignee.is_primary = 1";
431 $this->_aliases
['civicrm_contact'] = 'civicrm_contact_assignee';
434 if ($recordType == 'source') {
436 FROM civicrm_activity {$this->_aliases['civicrm_activity']}
437 INNER JOIN civicrm_activity_contact {$this->_aliases['civicrm_activity_contact']}
438 ON {$this->_aliases['civicrm_activity']}.id = {$this->_aliases['civicrm_activity_contact']}.activity_id AND
439 {$this->_aliases['civicrm_activity_contact']}.record_type_id = {$sourceID}
440 INNER JOIN civicrm_contact civicrm_contact_source
441 ON {$this->_aliases['civicrm_activity_contact']}.contact_id = civicrm_contact_source.id
444 if ($this->isTableSelected('civicrm_email')) {
446 LEFT JOIN civicrm_email civicrm_email_source
447 ON {$this->_aliases['civicrm_activity_contact']}.contact_id = civicrm_email_source.contact_id AND
448 civicrm_email_source.is_primary = 1";
450 $this->_aliases
['civicrm_contact'] = 'civicrm_contact_source';
452 $this->addAddressFromClause();
456 * @param null $recordType
458 function where($recordType = NULL) {
459 $this->_where
= " WHERE {$this->_aliases['civicrm_activity']}.is_test = 0 AND
460 {$this->_aliases['civicrm_activity']}.is_deleted = 0 AND
461 {$this->_aliases['civicrm_activity']}.is_current_revision = 1";
464 foreach ($this->_columns
as $tableName => $table) {
465 if (array_key_exists('filters', $table)) {
467 foreach ($table['filters'] as $fieldName => $field) {
469 if ($fieldName != 'contact_' . $recordType &&
470 (strstr($fieldName, '_target') ||
471 strstr($fieldName, '_assignee') ||
472 strstr($fieldName, '_source')
477 if (CRM_Utils_Array
::value('type', $field) & CRM_Utils_Type
::T_DATE
) {
478 $relative = CRM_Utils_Array
::value("{$fieldName}_relative", $this->_params
);
479 $from = CRM_Utils_Array
::value("{$fieldName}_from", $this->_params
);
480 $to = CRM_Utils_Array
::value("{$fieldName}_to", $this->_params
);
482 $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
485 $op = CRM_Utils_Array
::value("{$fieldName}_op", $this->_params
);
486 if ($op && ($op != 'nnll' ||
$op != 'nll')) {
487 $clause = $this->whereClause($field,
489 CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
),
490 CRM_Utils_Array
::value("{$fieldName}_min", $this->_params
),
491 CRM_Utils_Array
::value("{$fieldName}_max", $this->_params
)
493 if ($fieldName == 'activity_type_id' && empty($this->_params
['activity_type_id_value'])) {
494 $actTypes = array_flip(CRM_Core_PseudoConstant
::activityType(TRUE, FALSE, FALSE, 'label', TRUE));
495 $clause = "( {$this->_aliases['civicrm_activity']}.activity_type_id IN (".implode(',',$actTypes).") )";
500 if ($field['name'] == 'current_user') {
501 if (CRM_Utils_Array
::value("{$fieldName}_value", $this->_params
) == 1) {
503 $session = CRM_Core_Session
::singleton();
504 if ($contactID = $session->get('userID')) {
505 $clause = "{$this->_aliases['civicrm_activity_contact']}.activity_id IN
506 (SELECT activity_id FROM civicrm_activity_contact WHERE contact_id = {$contactID})";
516 if (!empty($clause)) {
517 $clauses[] = $clause;
523 if (empty($clauses)) {
524 $this->_where
.= " ";
527 $this->_where
.= " AND " . implode(' AND ', $clauses);
530 if ($this->_aclWhere
) {
531 $this->_where
.= " AND {$this->_aclWhere} ";
536 $this->_groupBy
= "GROUP BY {$this->_aliases['civicrm_activity']}.id";
540 * @param string $tableAlias
542 function buildACLClause($tableAlias = 'contact_a') {
543 //override for ACL( Since Contact may be source
544 //contact/assignee or target also it may be null )
546 if (CRM_Core_Permission
::check('view all contacts')) {
547 $this->_aclFrom
= $this->_aclWhere
= NULL;
551 $session = CRM_Core_Session
::singleton();
552 $contactID = $session->get('userID');
556 $contactID = CRM_Utils_Type
::escape($contactID, 'Integer');
558 CRM_Contact_BAO_Contact_Permission
::cache($contactID);
560 foreach ($tableAlias as $k => $alias) {
561 $clauses[] = " INNER JOIN civicrm_acl_contact_cache aclContactCache_{$k} ON ( {$alias}.id = aclContactCache_{$k}.contact_id OR {$alias}.id IS NULL ) AND aclContactCache_{$k}.user_id = $contactID ";
564 $this->_aclFrom
= implode(" ", $clauses);
565 $this->_aclWhere
= NULL;
573 function add2group($groupID) {
574 if (CRM_Utils_Array
::value("contact_target_op", $this->_params
) == 'nll') {
575 CRM_Core_Error
::fatal(ts('Current filter criteria didn\'t have any target contact to add to group'));
578 $query = "{$this->_select}
579 FROM civireport_activity_temp_target tar
580 GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy}";
581 $select = 'AS addtogroup_contact_id';
582 $query = str_ireplace('AS civicrm_contact_contact_target_id', $select, $query);
583 $dao = CRM_Core_DAO
::executeQuery($query);
585 $contactIDs = array();
586 // Add resulting contacts to group
587 while ($dao->fetch()) {
588 if ($dao->addtogroup_contact_id
) {
589 $contact_id = explode(';', $dao->addtogroup_contact_id
);
590 if ($contact_id[0]) {
591 $contactIDs[$contact_id[0]] = $contact_id[0];
596 if ( !empty($contactIDs) ) {
597 CRM_Contact_BAO_GroupContact
::addContactsToGroup($contactIDs, $groupID);
598 CRM_Core_Session
::setStatus(ts("Listed contact(s) have been added to the selected group."), ts('Contacts Added'), 'success');
601 CRM_Core_Session
::setStatus(ts("The listed records(s) cannot be added to the group."));
605 function postProcess() {
606 $this->beginPostProcess();
608 //Assign those recordtype to array which have filter operator as 'Is not empty' or 'Is empty'
609 $nullFilters = array();
610 foreach (array('target', 'source', 'assignee') as $type) {
611 if (CRM_Utils_Array
::value("contact_{$type}_op", $this->_params
) == 'nnll' ||
!empty($this->_params
["contact_{$type}_value"])) {
612 $nullFilters[] = " civicrm_contact_contact_{$type}_id IS NOT NULL ";
614 else if (CRM_Utils_Array
::value("contact_{$type}_op", $this->_params
) == 'nll') {
615 $nullFilters[] = " civicrm_contact_contact_{$type}_id IS NULL ";
619 // 1. fill temp table with target results
620 $this->buildACLClause(array('civicrm_contact_target'));
621 $this->select('target');
622 $this->from('target');
623 $this->customDataFrom();
624 $this->where('target');
625 $insertCols = implode(',', $this->_selectAliases
);
626 $tempQuery = "CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COLLATE utf8_unicode_ci AS
627 {$this->_select} {$this->_from} {$this->_where} ";
628 CRM_Core_DAO
::executeQuery($tempQuery);
630 // 2. add new columns to hold assignee and source results
631 // fixme: add when required
633 ALTER TABLE civireport_activity_temp_target
634 ADD COLUMN civicrm_contact_contact_assignee VARCHAR(128),
635 ADD COLUMN civicrm_contact_contact_source VARCHAR(128),
636 ADD COLUMN civicrm_contact_contact_assignee_id VARCHAR(128),
637 ADD COLUMN civicrm_contact_contact_source_id VARCHAR(128),
638 ADD COLUMN civicrm_email_contact_assignee_email VARCHAR(128),
639 ADD COLUMN civicrm_email_contact_source_email VARCHAR(128)";
640 CRM_Core_DAO
::executeQuery($tempQuery);
642 // 3. fill temp table with assignee results
643 $this->buildACLClause(array('civicrm_contact_assignee'));
644 $this->select('assignee');
645 $this->from('assignee');
646 $this->customDataFrom();
647 $this->where('assignee');
648 $insertCols = implode(',', $this->_selectAliases
);
649 $tempQuery = "INSERT INTO civireport_activity_temp_target ({$insertCols})
651 {$this->_from} {$this->_where}";
652 CRM_Core_DAO
::executeQuery($tempQuery);
654 // 4. fill temp table with source results
655 $this->buildACLClause(array('civicrm_contact_source'));
656 $this->select('source');
657 $this->from('source');
658 $this->customDataFrom();
659 $this->where('source');
660 $insertCols = implode(',', $this->_selectAliases
);
661 $tempQuery = "INSERT INTO civireport_activity_temp_target ({$insertCols})
663 {$this->_from} {$this->_where}";
664 CRM_Core_DAO
::executeQuery($tempQuery);
666 // 5. show final result set from temp table
668 $this->select('final');
670 if (!empty($nullFilters)) {
671 $this->_having
= "HAVING " . implode(' AND ', $nullFilters);
675 $sql = "{$this->_select}
676 FROM civireport_activity_temp_target tar
677 GROUP BY civicrm_activity_id {$this->_having} {$this->_orderBy} {$this->_limit}";
678 $this->buildRows($sql, $rows);
680 // format result set.
681 $this->formatDisplay($rows);
683 // assign variables to templates
684 $this->doTemplateAssignment($rows);
686 // do print / pdf / instance stuff if needed
687 $this->endPostProcess($rows);
693 function alterDisplay(&$rows) {
694 // custom code to alter rows
697 $activityType = CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
698 $activityStatus = CRM_Core_PseudoConstant
::activityStatus();
700 $seperator = CRM_Core_DAO
::VALUE_SEPARATOR
;
701 $context = CRM_Utils_Request
::retrieve('context', 'String', $this, FALSE, 'report');
704 if (CRM_Core_Permission
::check('access CiviCRM')) {
706 $onHover = ts('View Contact Summary for this Contact');
707 $onHoverAct = ts('View Activity Record');
710 foreach ($rows as $rowNum => $row) {
711 // if we have an activity type, format the View Activity link for use in various columns
712 if ($viewLinks && array_key_exists('civicrm_activity_activity_type_id', $row)) {
713 // Check for target contact id(s) and use the first contact id in that list for view activity link if found,
714 // else use source contact id
715 if (!empty($rows[$rowNum]['civicrm_contact_contact_target_id'])) {
716 $targets = explode(';', $rows[$rowNum]['civicrm_contact_contact_target_id']);
720 $cid = $rows[$rowNum]['civicrm_contact_contact_source_id'];
723 $actActionLinks = CRM_Activity_Selector_Activity
::actionLinks($row['civicrm_activity_activity_type_id'],
724 CRM_Utils_Array
::value('civicrm_activity_source_record_id', $rows[$rowNum]),
726 $rows[$rowNum]['civicrm_activity_id']
729 $actLinkValues = array(
730 'id' => $rows[$rowNum]['civicrm_activity_id'],
734 $actUrl = CRM_Utils_System
::url($actActionLinks[CRM_Core_Action
::VIEW
]['url'],
735 CRM_Core_Action
::replace($actActionLinks[CRM_Core_Action
::VIEW
]['qs'], $actLinkValues), TRUE
739 if (array_key_exists('civicrm_contact_contact_source', $row)) {
740 if ($value = $row['civicrm_contact_contact_source_id']) {
742 $url = CRM_Utils_System
::url("civicrm/contact/view",
743 'reset=1&cid=' . $value,
746 $rows[$rowNum]['civicrm_contact_contact_source_link'] = $url;
747 $rows[$rowNum]['civicrm_contact_contact_source_hover'] = $onHover;
753 if (array_key_exists('civicrm_contact_contact_assignee', $row)) {
754 $assigneeNames = explode(';', $row['civicrm_contact_contact_assignee']);
755 if ($value = $row['civicrm_contact_contact_assignee_id']) {
756 $assigneeContactIds = explode(';', $value);
759 foreach ($assigneeContactIds as $id => $value) {
760 if (isset($value) && isset($assigneeNames[$id])) {
761 $url = CRM_Utils_System
::url("civicrm/contact/view",
762 'reset=1&cid=' . $value,
765 $link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$assigneeNames[$id]}</a>";
768 $rows[$rowNum]['civicrm_contact_contact_assignee'] = implode('; ', $link);
774 if (array_key_exists('civicrm_contact_contact_target', $row)) {
775 $targetNames = explode(';', $row['civicrm_contact_contact_target']);
776 if ($value = $row['civicrm_contact_contact_target_id']) {
777 $targetContactIds = explode(';', $value);
780 foreach ($targetContactIds as $id => $value) {
781 if (isset($value) && isset($targetNames[$id])) {
782 $url = CRM_Utils_System
::url("civicrm/contact/view",
783 'reset=1&cid=' . $value,
786 $link[] = "<a title='" . $onHover . "' href='" . $url . "'>{$targetNames[$id]}</a>";
789 $rows[$rowNum]['civicrm_contact_contact_target'] = implode('; ', $link);
795 if (array_key_exists('civicrm_activity_activity_type_id', $row)) {
796 if ($value = $row['civicrm_activity_activity_type_id']) {
797 $rows[$rowNum]['civicrm_activity_activity_type_id'] = $activityType[$value];
799 $rows[$rowNum]['civicrm_activity_activity_type_id_link'] = $actUrl;
800 $rows[$rowNum]['civicrm_activity_activity_type_id_hover'] = $onHoverAct;
806 if (array_key_exists('civicrm_activity_status_id', $row)) {
807 if ($value = $row['civicrm_activity_status_id']) {
808 $rows[$rowNum]['civicrm_activity_status_id'] = $activityStatus[$value];
813 if (array_key_exists('civicrm_activity_details', $row)) {
814 if ($value = $row['civicrm_activity_details']) {
815 $fullDetails = $rows[$rowNum]['civicrm_activity_details'];
816 $rows[$rowNum]['civicrm_activity_details'] = substr($fullDetails, 0, strrpos(substr($fullDetails, 0, 80), ' '));
818 $rows[$rowNum]['civicrm_activity_details'] .= " <a href='{$actUrl}' title='{$onHoverAct}'>(more)</a>";
824 if (array_key_exists('civicrm_activity_campaign_id', $row)) {
825 if ($value = $row['civicrm_activity_campaign_id']) {
826 $rows[$rowNum]['civicrm_activity_campaign_id'] = $this->activeCampaigns
[$value];
831 if (array_key_exists('civicrm_activity_engagement_level', $row)) {
832 if ($value = $row['civicrm_activity_engagement_level']) {
833 $rows[$rowNum]['civicrm_activity_engagement_level'] = $this->engagementLevels
[$value];
838 if (array_key_exists('civicrm_activity_activity_date_time', $row) && array_key_exists('civicrm_activity_status_id', $row)) {
839 if (CRM_Utils_Date
::overdue($rows[$rowNum]['civicrm_activity_activity_date_time']) &&
840 $activityStatus[$row['civicrm_activity_status_id']] != 'Completed'
842 $rows[$rowNum]['class'] = "status-overdue";
847 $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'activity', 'List all activities for this ') ?
TRUE : $entryFound;