CRM-16665: more cleanup
authoryashodha <yashodha.chaku@webaccessglobal.com>
Tue, 23 Jun 2015 06:34:49 +0000 (12:04 +0530)
committeryashodha <yashodha.chaku@webaccessglobal.com>
Tue, 23 Jun 2015 06:34:49 +0000 (12:04 +0530)
----------------------------------------
* CRM-16665: Add followup activity to "Send Email" form
  https://issues.civicrm.org/jira/browse/CRM-16665

CRM/Activity/BAO/Activity.php
CRM/Case/Form/Activity.php

index 7d5bbc92809d309668fd9b0fcecd4b43ac36c871..473435d505a49f75f0bc35075fb9d8a916f6466f 100644 (file)
@@ -2732,18 +2732,22 @@ INNER JOIN  civicrm_option_group grp ON ( grp.id = val.option_group_id AND grp.n
    *
    * @param object $activity
    * @param array $mailToContacts
+   * @param array $params
    *
    * @return bool
    */
-  public static function sendToAssignee($activity, $mailToContacts) {
-    if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
+  public static function sendToAssignee($activity, $mailToContacts, $params = array()) {
+    if (!CRM_Utils_Array::crmIsEmptyArray($mailToContacts)) {
+      $clientID = CRM_Utils_Array::value('client_id', $params);  
+      $caseID = CRM_Utils_Array::value('case_id', $params);
+
       $ics = new CRM_Activity_BAO_ICalendar($activity);
       $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
       $ics->addAttachment($attachments, $mailToContacts);
 
-      CRM_Case_BAO_Case::sendActivityCopy(NULL, $activity->id, $mailToContacts, $attachments, NULL);
+      $result = CRM_Case_BAO_Case::sendActivityCopy($clientID, $activity->id, $mailToContacts, $attachments, $caseID);
       $ics->cleanup();
-      return TRUE;
+      return $result;
     }
     return FALSE;
   }
index 5ad909a51be3a5af493e38ca29f924f4b4783cf4..00b849ad30e8474787665dd5cd70fb1c8b253290 100644 (file)
@@ -663,23 +663,9 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
         }
       }
 
-      if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
-        //include attachments while sending a copy of activity.
-        $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity',
-          $vval['actId']
-        );
-
-        $ics = new CRM_Activity_BAO_ICalendar($activity);
-        $ics->addAttachment($attachments, $mailToContacts);
-        $result = CRM_Case_BAO_Case::sendActivityCopy($this->_currentlyViewedContactId,
-          $vval['actId'], $mailToContacts, $attachments, $vval['case_id']
-        );
-        $ics->cleanup();
-        if (empty($result)) {
-          $mailStatus = '';
-        }
-      }
-      else {
+      $params = array('case_id' => $vval['case_id'], 'client_id' => $this->_currentlyViewedContactId);
+      $result = CRM_Activity_BAO_Activity::sendToAssignee($activity, $mailToContacts, $params);
+      if (empty($result)) {
         $mailStatus = '';
       }