From c1c1b937a8ad8cfd2f5abe79cbe3a0193e751aa7 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Mon, 22 Apr 2019 13:38:00 +0100 Subject: [PATCH] Refactor-Don't pass activity object to addCaseActivityLinks --- CRM/Case/BAO/Case.php | 26 ++++++++++++++++---------- CRM/Case/Selector/Search.php | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index 091b4e9f04..58db056780 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -1151,9 +1151,18 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c // Activity Status Label for Case activities list $caseActivities[$caseActivityId]['status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_status_id', $dao->status); + $deleted = ''; + if ($dao->deleted) { + $deleted = '
' . ts('(deleted)'); + } + $caseActivities[$caseActivityId]['status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_status_id', $dao->status) . $deleted; + // if there are file attachments we will return how many + if (!empty($dao->attachment_ids)) { + $attachmentIDs = array_unique(explode(',', $dao->attachment_ids)); + $caseActivity['no_attachments'] = count($attachmentIDs); + } - $caseActivities[$caseActivityId] - = self::addCaseActivityLinks($caseID, $contactID, $userID, $context, $dao, $caseActivities[$caseActivityId]); + $caseActivities[$caseActivityId]['links'] = self::addCaseActivityLinks($caseID, $contactID, $userID, $context, $dao); } $caseActivitiesDT = array(); @@ -1173,11 +1182,11 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c * @param int $userID * @param string $context * @param \CRM_Core_DAO $dao - * @param array $caseActivity * - * @return array caseActivity + * @return string + * HTML formatted Link */ - public static function addCaseActivityLinks($caseID, $contactID, $userID, $context, $dao, $caseActivity) { + private static function addCaseActivityLinks($caseID, $contactID, $userID, $context, $dao) { // FIXME: Why are we not using CRM_Core_Action for these links? This is too much manual work and likely to get out-of-sync with core markup. $caseActivityId = $dao->id; $allowView = self::checkPermission($caseActivityId, 'view', $dao->activity_type_id, $userID); @@ -1221,7 +1230,6 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c } elseif (!$caseDeleted) { $url = ' ' . ts('Restore') . ''; - $caseActivity['status_id'] = $caseActivity['status_id'] . '
(deleted)'; } //check for operations. @@ -1233,12 +1241,10 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c } // if there are file attachments we will return how many and, if only one, add a link to it if (!empty($dao->attachment_ids)) { - $attachmentIDs = array_unique(explode(',', $dao->attachment_ids)); - $caseActivity['no_attachments'] = count($attachmentIDs); $url .= implode(' ', CRM_Core_BAO_File::paperIconAttachment('civicrm_activity', $caseActivityId)); } - $caseActivity['links'] = $url; - return $caseActivity; + + return $url; } /** diff --git a/CRM/Case/Selector/Search.php b/CRM/Case/Selector/Search.php index 55c396e60e..8d63a8ea29 100644 --- a/CRM/Case/Selector/Search.php +++ b/CRM/Case/Selector/Search.php @@ -322,7 +322,7 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base { $isDeleted = FALSE; if ($result->case_deleted) { $isDeleted = TRUE; - $row['case_status_id'] = empty($row['case_status_id']) ? "" : $row['case_status_id'] . '
(deleted)'; + $row['case_status_id'] = empty($row['case_status_id']) ? "" : $row['case_status_id'] . '
' . ts('(deleted)'); } $scheduledInfo['case_id'][] = $result->case_id; -- 2.25.1