+ // if we have an activity type, format the View Activity link for use in various columns
+ if ($viewLinks && array_key_exists('civicrm_activity_activity_type_id', $row)) {
+ // Check for target contact id(s) and use the first contact id in that list for view activity link if found,
+ // else use source contact id
+ if (!empty($rows[$rowNum]['civicrm_contact_contact_target_id'])) {
+ $targets = explode(';', $rows[$rowNum]['civicrm_contact_contact_target_id']);
+ $cid = $targets[0];
+ }
+ else {
+ $cid = $rows[$rowNum]['civicrm_contact_contact_source_id'];
+ }
+
+ $actActionLinks = CRM_Activity_Selector_Activity::actionLinks($row['civicrm_activity_activity_type_id'],
+ CRM_Utils_Array::value('civicrm_activity_source_record_id', $rows[$rowNum]),
+ FALSE,
+ $rows[$rowNum]['civicrm_activity_id']
+ );
+
+ $actLinkValues = array(
+ 'id' => $rows[$rowNum]['civicrm_activity_id'],
+ 'cid' => $cid,
+ 'cxt' => $context,
+ );
+ $actUrl = CRM_Utils_System::url($actActionLinks[CRM_Core_Action::VIEW]['url'],
+ CRM_Core_Action::replace($actActionLinks[CRM_Core_Action::VIEW]['qs'], $actLinkValues), TRUE
+ );
+ }
+