From 9cb404b42103f07852384a2f5647e6f8332448a3 Mon Sep 17 00:00:00 2001 From: Nileema Date: Wed, 16 Apr 2014 19:36:41 +0530 Subject: [PATCH] --HR-339 Pre-populate "email" activity with case contact(s) --- CRM/Contact/Form/Task/Email.php | 12 +++++++----- CRM/Contact/Form/Task/EmailCommon.php | 22 +++++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CRM/Contact/Form/Task/Email.php b/CRM/Contact/Form/Task/Email.php index b0a0cd7c13..6b24cf325d 100644 --- a/CRM/Contact/Form/Task/Email.php +++ b/CRM/Contact/Form/Task/Email.php @@ -100,15 +100,17 @@ class CRM_Contact_Form_Task_Email extends CRM_Contact_Form_Task { */ function preProcess() { // store case id if present - $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Positive', $this, FALSE); + $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'String', $this, FALSE); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); - $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE); - if ($cid) { - $displayName = CRM_Contact_BAO_Contact::displayName($cid); - CRM_Utils_System::setTitle($displayName . ' - ' . ts('Email')); + $cid = CRM_Utils_Request::retrieve('cid', 'String', $this, FALSE); + $cid = explode(',',$cid); + + foreach ($cid as $key => $val) { + $displayName[] = CRM_Contact_BAO_Contact::displayName($val); } + CRM_Utils_System::setTitle(implode(',',$displayName) . ' - ' . ts('Email')); CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this); if (!$cid && $this->_context != 'standalone') { diff --git a/CRM/Contact/Form/Task/EmailCommon.php b/CRM/Contact/Form/Task/EmailCommon.php index 38d5b238b0..3bb690fa9e 100644 --- a/CRM/Contact/Form/Task/EmailCommon.php +++ b/CRM/Contact/Form/Task/EmailCommon.php @@ -128,7 +128,10 @@ class CRM_Contact_Form_Task_EmailCommon { //here we are getting logged in user id as array but we need target contact id. CRM-5988 $cid = $form->get('cid'); if ($cid) { - $form->_contactIds = array($cid); + $form->_contactIds = explode(',',$cid); + } + if (count($form->_contactIds) > 1) { + $form->_single = FALSE; } $to = $form->add('text', 'to', ts('To'), '', TRUE); @@ -469,13 +472,18 @@ class CRM_Contact_Form_Task_EmailCommon { CRM_Core_Session::setStatus($status, ts('One Message Not Sent', array('count' => count($emailsNotSent), 'plural' => '%count Messages Not Sent')), 'info'); } - if (isset($form->_caseId) && is_numeric($form->_caseId)) { + if (isset($form->_caseId)) { // if case-id is found in the url, create case activity record - $caseParams = array( - 'activity_id' => $activityId, - 'case_id' => $form->_caseId, - ); - CRM_Case_BAO_Case::processCaseActivity($caseParams); + $cases = explode(',', $form->_caseId); + foreach($cases as $key => $val) { + if (is_numeric($val)) { + $caseParams = array( + 'activity_id' => $activityId, + 'case_id' => $val, + ); + CRM_Case_BAO_Case::processCaseActivity($caseParams); + } + } } } //end of function -- 2.25.1