X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCase%2FSelector%2FSearch.php;h=c1a4e68536612c70b4aa663ba5caab77cc42f855;hb=a83adcb238f4edb54ec9c080625c47582eb4fecc;hp=8d63a8ea2923221bb55f0d399c4bdb65c2e1f959;hpb=f38692208a64d52597c7f1377341c1ac6b080bd9;p=civicrm-core.git
diff --git a/CRM/Case/Selector/Search.php b/CRM/Case/Selector/Search.php
index 8d63a8ea29..c1a4e68536 100644
--- a/CRM/Case/Selector/Search.php
+++ b/CRM/Case/Selector/Search.php
@@ -72,14 +72,14 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base {
/**
* Are we restricting ourselves to a single contact
*
- * @var boolean
+ * @var bool
*/
protected $_single = FALSE;
/**
* Are we restricting ourselves to a single contact
*
- * @var boolean
+ * @var bool
*/
protected $_limit = NULL;
@@ -479,4 +479,77 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base {
return ts('Case Search');
}
+ /**
+ * Add the set of "actionLinks" to the case activity
+ *
+ * @param int $caseID
+ * @param int $contactID
+ * @param int $userID
+ * @param string $context
+ * @param \CRM_Core_DAO $dao
+ *
+ * @return string
+ * HTML formatted Link
+ */
+ public 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 = CRM_Case_BAO_Case::checkPermission($caseActivityId, 'view', $dao->activity_type_id, $userID);
+ $allowEdit = CRM_Case_BAO_Case::checkPermission($caseActivityId, 'edit', $dao->activity_type_id, $userID);
+ $allowDelete = CRM_Case_BAO_Case::checkPermission($caseActivityId, 'delete', $dao->activity_type_id, $userID);
+ $emailActivityTypeIDs = [
+ 'Email' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Email'),
+ 'Inbound Email' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Inbound Email'),
+ ];
+ $url = CRM_Utils_System::url("civicrm/case/activity",
+ "reset=1&cid={$contactID}&caseid={$caseID}", FALSE, NULL, FALSE
+ );
+ $contextUrl = '';
+ if ($context == 'fulltext') {
+ $contextUrl = "&context={$context}";
+ }
+ $editUrl = "{$url}&action=update{$contextUrl}";
+ $deleteUrl = "{$url}&action=delete{$contextUrl}";
+ $restoreUrl = "{$url}&action=renew{$contextUrl}";
+ $viewTitle = ts('View activity');
+ $caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted');
+
+ $url = "";
+ $css = 'class="action-item crm-hover-button"';
+ if ($allowView) {
+ $viewUrl = CRM_Utils_System::url('civicrm/case/activity/view', array('cid' => $contactID, 'aid' => $caseActivityId));
+ $url = '' . ts('View') . '';
+ }
+ $additionalUrl = "&id={$caseActivityId}";
+ if (!$dao->deleted) {
+ //hide edit link of activity type email.CRM-4530.
+ if (!in_array($dao->type, $emailActivityTypeIDs)) {
+ //hide Edit link if activity type is NOT editable (special case activities).CRM-5871
+ if ($allowEdit) {
+ $url .= '' . ts('Edit') . ' ';
+ }
+ }
+ if ($allowDelete) {
+ $url .= ' ' . ts('Delete') . '';
+ }
+ }
+ elseif (!$caseDeleted) {
+ $url = ' ' . ts('Restore') . '';
+ }
+
+ //check for operations.
+ if (CRM_Case_BAO_Case::checkPermission($caseActivityId, 'Move To Case', $dao->activity_type_id)) {
+ $url .= ' ' . ts('Move To Case') . ' ';
+ }
+ if (CRM_Case_BAO_Case::checkPermission($caseActivityId, 'Copy To Case', $dao->activity_type_id)) {
+ $url .= ' ' . ts('Copy To Case') . ' ';
+ }
+ // if there are file attachments we will return how many and, if only one, add a link to it
+ if (!empty($dao->attachment_ids)) {
+ $url .= implode(' ', CRM_Core_BAO_File::paperIconAttachment('civicrm_activity', $caseActivityId));
+ }
+
+ return $url;
+ }
+
}