$form->_emails = $emails = array();
- $session = CRM_Core_Session::singleton();
- $contactID = $session->get('userID');
+ $contactID = CRM_Core_Session::singleton()->getLoggedInContactID();
+ $fromDisplayName = CRM_Core_Session::singleton()->getLoggedInContactDisplayName();
$form->_contactIds = array($contactID);
$contactEmails = CRM_Core_BAO_Email::allEmails($contactID);
$form->_onHold = array();
- $fromDisplayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact',
- $contactID, 'display_name'
- );
-
foreach ($contactEmails as $emailId => $item) {
$email = $item['email'];
if (!$email && (count($emails) < 1)) {
// check and ensure that
$formValues = $form->controller->exportValues($form->getName());
- $fromEmail = $formValues['fromEmailAddress'];
- $from = CRM_Utils_Array::value($fromEmail, $form->_emails);
+ self::saveMessageTemplate($formValues);
+
+ $from = CRM_Utils_Array::value($formValues['fromEmailAddress'], $form->_emails);
$subject = $formValues['subject'];
// CRM-13378: Append CC and BCC information at the end of Activity Details and format cc and bcc fields
$subject = "[case #$hash] $subject";
}
- // process message template
- if (!empty($formValues['saveTemplate']) || !empty($formValues['updateTemplate'])) {
- $messageTemplate = array(
- 'msg_text' => $formValues['text_message'],
- 'msg_html' => $formValues['html_message'],
- 'msg_subject' => $formValues['subject'],
- 'is_active' => TRUE,
- );
-
- if (!empty($formValues['saveTemplate'])) {
- $messageTemplate['msg_title'] = $formValues['saveTemplateName'];
- CRM_Core_BAO_MessageTemplate::add($messageTemplate);
- }
-
- if (!empty($formValues['template']) && !empty($formValues['updateTemplate'])) {
- $messageTemplate['id'] = $formValues['template'];
- unset($messageTemplate['msg_title']);
- CRM_Core_BAO_MessageTemplate::add($messageTemplate);
- }
- }
-
$attachments = array();
CRM_Core_BAO_File::formatAttachment($formValues,
$attachments,
}
}
+ /**
+ * Save the template if update selected.
+ *
+ * @param array $formValues
+ */
+ protected static function saveMessageTemplate($formValues) {
+ if (!empty($formValues['saveTemplate']) || !empty($formValues['updateTemplate'])) {
+ $messageTemplate = array(
+ 'msg_text' => $formValues['text_message'],
+ 'msg_html' => $formValues['html_message'],
+ 'msg_subject' => $formValues['subject'],
+ 'is_active' => TRUE,
+ );
+
+ if (!empty($formValues['saveTemplate'])) {
+ $messageTemplate['msg_title'] = $formValues['saveTemplateName'];
+ CRM_Core_BAO_MessageTemplate::add($messageTemplate);
+ }
+
+ if (!empty($formValues['template']) && !empty($formValues['updateTemplate'])) {
+ $messageTemplate['id'] = $formValues['template'];
+ unset($messageTemplate['msg_title']);
+ CRM_Core_BAO_MessageTemplate::add($messageTemplate);
+ }
+ }
+ }
+
}