CRM-19551 - Display multiple case activity attachments
authorColeman Watts <coleman@civicrm.org>
Thu, 27 Oct 2016 18:59:53 +0000 (14:59 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 27 Oct 2016 18:59:53 +0000 (14:59 -0400)
CRM/Case/BAO/Case.php

index 00f09efc5504b7966d96d4032f6d88ae27cc1f24..5fb8c314879689ffb7f35caeb6ae9ed1903ffd97 100644 (file)
@@ -1192,19 +1192,9 @@ 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 = explode(',', $dao->attachment_ids);
+        $attachmentIDs = array_unique(explode(',', $dao->attachment_ids));
         $caseActivity['no_attachments'] = count($attachmentIDs);
-        if ($caseActivity['no_attachments'] == 1) {
-          // if there is only one it's easy to do a link - otherwise just flag it
-          $attachmentViewUrl = CRM_Utils_System::url(
-            "civicrm/file",
-            "reset=1&eid=" . $caseActivityId . "&id=" . $dao->attachment_ids,
-            FALSE,
-            NULL,
-            FALSE
-          );
-          $url .= " <a href='$attachmentViewUrl' ><i class='crm-i fa-paperclip'></i></a>";
-        }
+        $url .= implode(' ', CRM_Core_BAO_File::paperIconAttachment('civicrm_activity', $caseActivityId));
       }
 
       $caseActivity['links'] = $url;