本文整理汇总了PHP中CRM_Core_BAO_File::formatAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_File::formatAttachment方法的具体用法?PHP CRM_Core_BAO_File::formatAttachment怎么用?PHP CRM_Core_BAO_File::formatAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_File
的用法示例。
在下文中一共展示了CRM_Core_BAO_File::formatAttachment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* Process the form submission.
*
*
* @param array $params
*
* @return void
*/
public function postProcess($params = NULL)
{
$transaction = new CRM_Core_Transaction();
if ($this->_action & CRM_Core_Action::DELETE) {
$statusMsg = NULL;
//block deleting activities which affects
//case attributes.CRM-4543
$activityCondition = " AND v.name IN ('Open Case', 'Change Case Type', 'Change Case Status', 'Change Case Start Date')";
$caseAttributeActivities = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, $activityCondition);
if (!array_key_exists($this->_activityTypeId, $caseAttributeActivities)) {
$params = array('id' => $this->_activityId);
$activityDelete = CRM_Activity_BAO_Activity::deleteActivity($params, TRUE);
if ($activityDelete) {
$statusMsg = ts('The selected activity has been moved to the Trash. You can view and / or restore deleted activities by checking "Deleted Activities" from the Case Activities search filter (under Manage Case).<br />');
}
} else {
$statusMsg = ts("Selected Activity cannot be deleted.");
}
$tagParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId);
CRM_Core_BAO_EntityTag::del($tagParams);
CRM_Core_Session::setStatus('', $statusMsg, 'info');
return;
}
if ($this->_action & CRM_Core_Action::RENEW) {
$statusMsg = NULL;
$params = array('id' => $this->_activityId);
$activityRestore = CRM_Activity_BAO_Activity::restoreActivity($params);
if ($activityRestore) {
$statusMsg = ts('The selected activity has been restored.<br />');
}
CRM_Core_Session::setStatus('', $statusMsg, 'info');
return;
}
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
//set parent id if its edit mode
if ($parentId = CRM_Utils_Array::value('parent_id', $this->_defaults)) {
$params['parent_id'] = $parentId;
}
// store the dates with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
$params['activity_type_id'] = $this->_activityTypeId;
// format with contact (target contact) values
if (isset($params['target_contact_id'])) {
$params['target_contact_id'] = explode(',', $params['target_contact_id']);
} else {
$params['target_contact_id'] = array();
}
// format activity custom data
if (!empty($params['hidden_custom'])) {
if ($this->_activityId) {
// unset custom fields-id from params since we want custom
// fields to be saved for new activity.
foreach ($params as $key => $value) {
$match = array();
if (preg_match('/^(custom_\\d+_)(\\d+)$/', $key, $match)) {
$params[$match[1] . '-1'] = $params[$key];
// for autocomplete transfer hidden value instead of label
if ($params[$key] && isset($params[$key . '_id'])) {
$params[$match[1] . '-1_id'] = $params[$key . '_id'];
unset($params[$key . '_id']);
}
unset($params[$key]);
}
}
}
// build custom data getFields array
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_activityId, 'Activity');
}
// assigning formatted value
if (!empty($params['assignee_contact_id'])) {
$params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
} else {
$params['assignee_contact_id'] = array();
}
if (isset($this->_activityId)) {
// activity which hasn't been modified by a user yet
if ($this->_defaults['is_auto'] == 1) {
$params['is_auto'] = 0;
}
// always create a revision of an case activity. CRM-4533
$newActParams = $params;
// add target contact values in update mode
if (empty($params['target_contact_id']) && !empty($this->_defaults['target_contact'])) {
$newActParams['target_contact_id'] = $this->_defaults['target_contact'];
}
}
if (!isset($newActParams)) {
// add more attachments if needed for old activity
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity');
//.........这里部分代码省略.........
示例2: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
require_once 'CRM/Grant/BAO/Grant.php';
CRM_Grant_BAO_Grant::del($this->_id);
return;
}
if ($this->_action & CRM_Core_Action::UPDATE) {
$ids['grant'] = $this->_id;
}
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
if (!$params['grant_report_received']) {
$params['grant_report_received'] = "null";
}
// set the contact, when contact is selected
if (CRM_Utils_Array::value('contact_select_id', $params)) {
$this->_contactID = $params['contact_select_id'][1];
}
$params['contact_id'] = $this->_contactID;
$dates = array('application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
foreach ($dates as $d) {
$params[$d] = CRM_Utils_Date::processDate($params[$d], null, true);
}
$ids['note'] = array();
if ($this->_noteId) {
$ids['note']['id'] = $this->_noteId;
}
// process custom data
$customFields = CRM_Core_BAO_CustomField::getFields('Grant');
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Grant');
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_grant', $this->_id);
require_once 'CRM/Grant/BAO/Grant.php';
$grant = CRM_Grant_BAO_Grant::create($params, $ids);
$buttonName = $this->controller->getButtonName();
$session = CRM_Core_Session::singleton();
if ($this->_context == 'standalone') {
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/grant/add', 'reset=1&action=add&context=standalone'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=grant"));
}
} else {
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/grant', "reset=1&action=add&context=grant&cid={$this->_contactID}"));
}
}
}
示例3: postProcess
/**
* Process the form submission.
*
*
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
$checkBoxes = array('is_thermometer', 'is_honor_roll', 'is_active', 'is_notify');
foreach ($checkBoxes as $key) {
if (!isset($params[$key])) {
$params[$key] = 0;
}
}
$session = CRM_Core_Session::singleton();
$contactID = isset($this->_contactID) ? $this->_contactID : $session->get('userID');
if (!$contactID) {
$contactID = $this->get('contactID');
}
$params['title'] = $params['pcp_title'];
$params['intro_text'] = $params['pcp_intro_text'];
$params['contact_id'] = $contactID;
$params['page_id'] = $this->get('component_page_id') ? $this->get('component_page_id') : $this->_contriPageId;
$params['page_type'] = $this->_component;
// since we are allowing html input from the user
// we also need to purify it, so lets clean it up
$htmlFields = array('intro_text', 'page_text', 'title');
foreach ($htmlFields as $field) {
if (!empty($params[$field])) {
$params[$field] = CRM_Utils_String::purifyHTML($params[$field]);
}
}
$entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($params['page_type']);
$pcpBlock = new CRM_PCP_DAO_PCPBlock();
$pcpBlock->entity_table = $entity_table;
$pcpBlock->entity_id = $params['page_id'];
$pcpBlock->find(TRUE);
$params['pcp_block_id'] = $pcpBlock->id;
$params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
$approval_needed = $pcpBlock->is_approval_needed;
$approvalMessage = NULL;
if ($this->get('action') & CRM_Core_Action::ADD) {
$params['status_id'] = $approval_needed ? 1 : 2;
$approvalMessage = $approval_needed ? ts('but requires administrator review before you can begin promoting your campaign. You will receive an email confirmation shortly which includes a link to return to this page.') : ts('and is ready to use.');
}
$params['id'] = $this->_pageId;
$pcp = CRM_PCP_BAO_PCP::add($params, FALSE);
//create page in wordpress
create_wp_campaign($pcp->title, $pcp->contact_id, $pcp->id);
CRM_Core_Error::debug_log_message("Calling create_wp_campaign.... Params title: {$pcp->title}, contact_id: {$pcp->contact_id}, pcp_id: {$pcp->id} ");
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_pcp', $pcp->id);
$pageStatus = isset($this->_pageId) ? ts('updated') : ts('created');
$statusId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcp->id, 'status_id');
//send notification of PCP create/update.
$pcpParams = array('entity_table' => $entity_table, 'entity_id' => $pcp->page_id);
$notifyParams = array();
$notifyStatus = "";
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $pcpParams, $notifyParams, array('notify_email'));
if ($emails = $pcpBlock->notify_email) {
$this->assign('pcpTitle', $pcp->title);
if ($this->_pageId) {
$this->assign('mode', 'Update');
} else {
$this->assign('mode', 'Add');
}
$pcpStatus = CRM_Core_OptionGroup::getLabel('pcp_status', $statusId);
$this->assign('pcpStatus', $pcpStatus);
$this->assign('pcpId', $pcp->id);
$supporterUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$pcp->contact_id}", TRUE, NULL, FALSE, FALSE);
$this->assign('supporterUrl', $supporterUrl);
$supporterName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $pcp->contact_id, 'display_name');
$this->assign('supporterName', $supporterName);
if ($this->_component == 'contribute') {
$pageUrl = CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpBlock->entity_id}", TRUE, NULL, FALSE, TRUE);
$contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $pcpBlock->entity_id, 'title');
} elseif ($this->_component == 'event') {
$pageUrl = CRM_Utils_System::url('civicrm/event', "reset=1&id={$pcpBlock->entity_id}", TRUE, NULL, FALSE, TRUE);
$contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $pcpBlock->entity_id, 'title');
}
$this->assign('contribPageUrl', $pageUrl);
$this->assign('contribPageTitle', $contribPageTitle);
$managePCPUrl = CRM_Utils_System::url('civicrm/admin/pcp', "reset=1", TRUE, NULL, FALSE, FALSE);
$this->assign('managePCPUrl', $managePCPUrl);
//get the default domain email address.
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
$fixUrl = CRM_Utils_System::url('civicrm/admin/domain', 'action=update&reset=1');
CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Communications » FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
}
//if more than one email present for PCP notification ,
//first email take it as To and other as CC and First email
//address should be sent in users email receipt for
//support purpose.
$emailArray = explode(',', $emails);
$to = $emailArray[0];
unset($emailArray[0]);
$cc = implode(',', $emailArray);
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'pcp_notify', 'contactId' => $contactID, 'from' => "{$domainEmailName} <{$domainEmailAddress}>", 'toEmail' => $to, 'cc' => $cc));
//.........这里部分代码省略.........
示例4: beginPostProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
static function beginPostProcess(&$form, &$params)
{
if ($form->_context == 'caseActivity') {
return;
}
// set the contact, when contact is selected
if (isset($params['contact_select_id']) && CRM_Utils_Array::value(1, $params['contact_select_id'])) {
$params['contact_id'] = $params['contact_select_id'][1];
$form->_currentlyViewedContactId = $params['contact_id'];
} elseif ($form->_allowMultiClient && $form->_context != 'case') {
$clients = explode(',', $params['contact'][1]);
$form->_currentlyViewedContactId = $clients[0];
}
// for open case start date should be set to current date
$params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
$caseStatus = CRM_Case_PseudoConstant::caseStatus('name');
// for resolved case the end date should set to now
if ($params['status_id'] == array_search('Closed', $caseStatus)) {
$params['end_date'] = $params['now'];
}
// rename activity_location param to the correct column name for activity DAO
$params['location'] = CRM_Utils_Array::value('activity_location', $params);
// Add attachments
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $form->_activityId);
}
示例5: postProcess
/**
* Process the form after the input has been submitted and validated.
*
* @param CRM_Core_Form $form
*/
public static function postProcess(&$form)
{
if (count($form->_contactIds) > self::MAX_EMAILS_KILL_SWITCH) {
CRM_Core_Error::fatal(ts('Please do not use this task to send a lot of emails (greater than %1). We recommend using CiviMail instead.', array(1 => self::MAX_EMAILS_KILL_SWITCH)));
}
// check and ensure that
$formValues = $form->controller->exportValues($form->getName());
$fromEmail = $formValues['fromEmailAddress'];
$from = CRM_Utils_Array::value($fromEmail, $form->_emails);
$subject = $formValues['subject'];
// CRM-13378: Append CC and BCC information at the end of Activity Details and format cc and bcc fields
$elements = array('cc_id', 'bcc_id');
$additionalDetails = NULL;
$ccValues = $bccValues = array();
foreach ($elements as $element) {
if (!empty($formValues[$element])) {
$allEmails = explode(',', $formValues[$element]);
foreach ($allEmails as $value) {
list($contactId, $email) = explode('::', $value);
$contactURL = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$contactId}", TRUE);
switch ($element) {
case 'cc_id':
$ccValues['email'][] = '"' . $form->_contactDetails[$contactId]['sort_name'] . '" <' . $email . '>';
$ccValues['details'][] = "<a href='{$contactURL}'>" . $form->_contactDetails[$contactId]['display_name'] . "</a>";
break;
case 'bcc_id':
$bccValues['email'][] = '"' . $form->_contactDetails[$contactId]['sort_name'] . '" <' . $email . '>';
$bccValues['details'][] = "<a href='{$contactURL}'>" . $form->_contactDetails[$contactId]['display_name'] . "</a>";
break;
}
}
}
}
$cc = $bcc = '';
if (!empty($ccValues)) {
$cc = implode(',', $ccValues['email']);
$additionalDetails .= "\ncc : " . implode(", ", $ccValues['details']);
}
if (!empty($bccValues)) {
$bcc = implode(',', $bccValues['email']);
$additionalDetails .= "\nbcc : " . implode(", ", $bccValues['details']);
}
// CRM-5916: prepend case id hash to CiviCase-originating emails’ subjects
if (isset($form->_caseId) && is_numeric($form->_caseId)) {
$hash = substr(sha1(CIVICRM_SITE_KEY . $form->_caseId), 0, 7);
$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, NULL, NULL);
// format contact details array to handle multiple emails from same contact
$formattedContactDetails = array();
$tempEmails = array();
foreach ($form->_contactIds as $key => $contactId) {
// if we dont have details on this contactID, we should ignore
// potentially this is due to the contact not wanting to receive email
if (!isset($form->_contactDetails[$contactId])) {
continue;
}
$email = $form->_toContactEmails[$key];
// prevent duplicate emails if same email address is selected CRM-4067
// we should allow same emails for different contacts
$emailKey = "{$contactId}::{$email}";
if (!in_array($emailKey, $tempEmails)) {
$tempEmails[] = $emailKey;
$details = $form->_contactDetails[$contactId];
$details['email'] = $email;
unset($details['email_id']);
$formattedContactDetails[] = $details;
}
}
// send the mail
list($sent, $activityId) = CRM_Activity_BAO_Activity::sendEmail($formattedContactDetails, $subject, $formValues['text_message'], $formValues['html_message'], NULL, NULL, $from, $attachments, $cc, $bcc, array_keys($form->_toContactDetails), $additionalDetails);
$followupStatus = '';
if ($sent) {
$followupActivity = NULL;
if (!empty($formValues['followup_activity_type_id'])) {
$params['followup_activity_type_id'] = $formValues['followup_activity_type_id'];
$params['followup_activity_subject'] = $formValues['followup_activity_subject'];
$params['followup_date'] = $formValues['followup_date'];
$params['followup_date_time'] = $formValues['followup_date_time'];
$params['target_contact_id'] = $form->_contactIds;
$params['followup_assignee_contact_id'] = explode(',', $formValues['followup_assignee_contact_id']);
//.........这里部分代码省略.........
示例6: postProcess
public function postProcess()
{
$params = $ids = array();
$uploadParams = array('header_id', 'footer_id', 'subject', 'from_name', 'from_email', 'override_verp');
$fileType = array('textFile', 'htmlFile');
$formValues = $this->controller->exportValues($this->_name);
foreach ($uploadParams as $key) {
if (CRM_Utils_Array::value($key, $formValues) || in_array($key, array('header_id', 'footer_id'))) {
$params[$key] = $formValues[$key];
$this->set($key, $formValues[$key]);
}
}
if (!$formValues['upload_type']) {
foreach ($fileType as $key) {
$contents = null;
if (isset($formValues[$key]) && !empty($formValues[$key])) {
$contents = file_get_contents($formValues[$key]['name']);
$this->set($key, $formValues[$key]['name']);
}
if ($contents) {
$params['body_' . substr($key, 0, 4)] = $contents;
} else {
$params['body_' . substr($key, 0, 4)] = 'NULL';
}
}
} else {
$text_message = $formValues['text_message'];
$params['body_text'] = $text_message;
$this->set('textFile', $params['body_text']);
$this->set('text_message', $params['body_text']);
$html_message = $formValues['html_message'];
// dojo editor does some html conversion when tokens are
// inserted as links. Hence token replacement fails.
// this is hack to revert html conversion for { to %7B and
// } to %7D by dojo editor
$html_message = str_replace('%7B', '{', str_replace('%7D', '}', $html_message));
$params['body_html'] = $html_message;
$this->set('htmlFile', $params['body_html']);
$this->set('html_message', $params['body_html']);
}
$params['name'] = $this->get('name');
$session =& CRM_Core_Session::singleton();
$params['contact_id'] = $session->get('userID');
$composeFields = array('template', 'saveTemplate', 'updateTemplate', 'saveTemplateName');
$msgTemplate = null;
//mail template is composed
if ($formValues['upload_type']) {
foreach ($composeFields as $key) {
if (CRM_Utils_Array::value($key, $formValues)) {
$composeParams[$key] = $formValues[$key];
$this->set($key, $formValues[$key]);
}
}
if (CRM_Utils_Array::value('updateTemplate', $composeParams)) {
$templateParams = array('msg_text' => $text_message, 'msg_html' => $html_message, 'msg_subject' => $params['subject'], 'is_active' => true);
$templateParams['id'] = $formValues['template'];
$msgTemplate = CRM_Core_BAO_MessageTemplates::add($templateParams);
}
if (CRM_Utils_Array::value('saveTemplate', $composeParams)) {
$templateParams = array('msg_text' => $text_message, 'msg_html' => $html_message, 'msg_subject' => $params['subject'], 'is_active' => true);
$templateParams['msg_title'] = $composeParams['saveTemplateName'];
$msgTemplate = CRM_Core_BAO_MessageTemplates::add($templateParams);
}
if (isset($msgTemplate->id)) {
$params['msg_template_id'] = $msgTemplate->id;
} else {
$params['msg_template_id'] = CRM_Utils_Array::value('template', $formValues);
}
$this->set('template', $params['msg_template_id']);
}
CRM_Core_BAO_File::formatAttachment($formValues, $params, 'civicrm_mailing', $this->_mailingID);
$ids['mailing_id'] = $this->_mailingID;
//handle mailing from name & address.
$formEmailAddress = CRM_Utils_Array::value($formValues['from_email_address'], CRM_Core_PseudoConstant::fromEmailAddress("from_email_address"));
//get the from email address
require_once 'CRM/Utils/Mail.php';
$params['from_email'] = CRM_Utils_Mail::pluckEmailFromHeader($formEmailAddress);
//get the from Name
$params['from_name'] = CRM_Utils_Array::value(1, explode('"', $formEmailAddress));
/* Build the mailing object */
require_once 'CRM/Mailing/BAO/Mailing.php';
CRM_Mailing_BAO_Mailing::create($params, $ids);
if ($this->_submitValues['_qf_Upload_upload'] == 'Save & Continue Later') {
//when user perform mailing from search context
//redirect it to search result CRM-3711.
$ssID = $this->get('ssID');
$context = $this->get('context');
if ($ssID && $context == 'search') {
if ($this->_action == CRM_Core_Action::BASIC) {
$fragment = 'search';
} else {
if ($this->_action == CRM_Core_Action::PROFILE) {
$fragment = 'search/builder';
} else {
if ($this->_action == CRM_Core_Action::ADVANCED) {
$fragment = 'search/advanced';
} else {
$fragment = 'search/custom';
}
}
//.........这里部分代码省略.........
示例7: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
static function postProcess(&$form)
{
if (count($form->_contactIds) > self::MAX_EMAILS_KILL_SWITCH) {
CRM_Core_Error::fatal(ts('Please do not use this task to send a lot of emails (greater than %1). We recommend using CiviMail instead.', array(1 => self::MAX_EMAILS_KILL_SWITCH)));
}
// check and ensure that
$formValues = $form->controller->exportValues($form->getName());
$fromEmail = $formValues['fromEmailAddress'];
$from = CRM_Utils_Array::value($fromEmail, $form->_fromEmails);
$cc = CRM_Utils_Array::value('cc_id', $formValues);
$bcc = CRM_Utils_Array::value('bcc_id', $formValues);
$subject = $formValues['subject'];
// process message template
require_once 'CRM/Core/BAO/MessageTemplates.php';
if (CRM_Utils_Array::value('saveTemplate', $formValues) || CRM_Utils_Array::value('updateTemplate', $formValues)) {
$messageTemplate = array('msg_text' => $formValues['text_message'], 'msg_html' => $formValues['html_message'], 'msg_subject' => $formValues['subject'], 'is_active' => true);
if ($formValues['saveTemplate']) {
$messageTemplate['msg_title'] = $formValues['saveTemplateName'];
CRM_Core_BAO_MessageTemplates::add($messageTemplate);
}
if ($formValues['template'] && $formValues['updateTemplate']) {
$messageTemplate['id'] = $formValues['template'];
unset($messageTemplate['msg_title']);
CRM_Core_BAO_MessageTemplates::add($messageTemplate);
}
}
$attachments = array();
CRM_Core_BAO_File::formatAttachment($formValues, $attachments, null, null);
// format contact details array to handle multiple emails from same contact
$formattedContactDetails = array();
$tempEmails = array();
foreach ($form->_contactIds as $key => $contactId) {
$email = $form->_toContactEmails[$key];
// prevent duplicate emails if same email address is selected CRM-4067
// we should allow same emails for different contacts
$emailKey = "{$contactId}::{$email}";
if (!in_array($emailKey, $tempEmails)) {
$tempEmails[] = $emailKey;
$details = $form->_contactDetails[$contactId];
$details['email'] = $email;
unset($details['email_id']);
$formattedContactDetails[] = $details;
}
}
// send the mail
require_once 'CRM/Activity/BAO/Activity.php';
list($sent, $activityId) = CRM_Activity_BAO_Activity::sendEmail($formattedContactDetails, $subject, $formValues['text_message'], $formValues['html_message'], null, null, $from, $attachments, $cc, $bcc, array_keys($form->_contactDetails));
if ($sent) {
$status = array('', ts('Your message has been sent.'));
}
//Display the name and number of contacts for those email is not sent.
$emailsNotSent = array_diff_assoc($form->_allContactDetails, $form->_contactDetails);
if (!empty($emailsNotSent)) {
$statusOnHold = '';
$statusDisplay = ts('Email not sent to contact(s) (no email address on file or communication preferences specify DO NOT EMAIL or Contact is deceased or Primary email address is On Hold): %1', array(1 => count($emailsNotSent))) . '<br />' . ts('Details') . ': ';
foreach ($emailsNotSent as $contactId => $values) {
$displayName = $values['display_name'];
$email = $values['email'];
$contactViewUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$contactId}");
$statusDisplay .= "<a href='{$contactViewUrl}'>{$displayName}</a>, ";
// build separate status for on hold messages
if ($values['on_hold']) {
$statusOnHold .= ts('Email was not sent to %1 because primary email address (%2) is On Hold.', array(1 => "<a href='{$contactViewUrl}'>{$displayName}</a>", 2 => "<strong>{$email}</strong>")) . '<br />';
}
}
$status[] = $statusDisplay;
}
if ($form->_caseId) {
// if case-id is found in the url, create case activity record
$caseParams = array('activity_id' => $activityId, 'case_id' => $form->_caseId);
require_once 'CRM/Case/BAO/Case.php';
CRM_Case_BAO_Case::processCaseActivity($caseParams);
}
if (strlen($statusOnHold)) {
$status[] = $statusOnHold;
}
CRM_Core_Session::setStatus($status);
}
示例8: postProcess
/**
* Function to process the form
*
* @access public
*
* @return void
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Grant_BAO_Grant::del($this->_id);
return;
}
if ($this->_action & CRM_Core_Action::UPDATE) {
$ids['grant_id'] = $this->_id;
}
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
if (empty($params['grant_report_received'])) {
$params['grant_report_received'] = "null";
}
// set the contact, when contact is selected
if ($this->_context == 'standalone') {
$this->_contactID = $params['contact_id'];
}
$params['contact_id'] = $this->_contactID;
$ids['note'] = array();
if ($this->_noteId) {
$ids['note']['id'] = $this->_noteId;
}
// build custom data getFields array
$customFieldsGrantType = CRM_Core_BAO_CustomField::getFields('Grant', FALSE, FALSE, CRM_Utils_Array::value('grant_type_id', $params));
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsGrantType, CRM_Core_BAO_CustomField::getFields('Grant', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Grant');
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_grant', $this->_id);
$grant = CRM_Grant_BAO_Grant::create($params, $ids);
$buttonName = $this->controller->getButtonName();
$session = CRM_Core_Session::singleton();
if ($this->_context == 'standalone') {
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/grant/add', 'reset=1&action=add&context=standalone'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=grant"));
}
} elseif ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/grant', "reset=1&action=add&context=grant&cid={$this->_contactID}"));
}
}
示例9: updateTemplateOptions
function updateTemplateOptions()
{
// Update the templates and upload options
$params = $ids = array();
$uploadParams = array('header_id', 'footer_id', 'subject', 'from_name', 'from_email');
$fileType = array('textFile', 'htmlFile');
$formValues = $this->controller->exportValues($this->_name);
foreach ($uploadParams as $key) {
if (CRM_Utils_Array::value($key, $formValues) || in_array($key, array('header_id', 'footer_id'))) {
$params[$key] = $formValues[$key];
$this->set($key, $formValues[$key]);
}
}
$text_message = $formValues['text_message'];
$params['body_text'] = $text_message;
$this->set('textFile', $params['body_text']);
$this->set('text_message', $params['body_text']);
$html_message = $formValues['html_message'];
// dojo editor does some html conversion when tokens are
// inserted as links. Hence token replacement fails.
// this is hack to revert html conversion for { to %7B and
// } to %7D by dojo editor
$html_message = str_replace('%7B', '{', str_replace('%7D', '}', $html_message));
$params['body_html'] = $html_message;
$this->set('htmlFile', $params['body_html']);
$this->set('html_message', $params['body_html']);
$params['name'] = $this->get('name');
$session = CRM_Core_Session::singleton();
$params['contact_id'] = $session->get('userID');
$composeFields = array('template', 'saveTemplate', 'updateTemplate', 'saveTemplateName');
CRM_Core_BAO_File::formatAttachment($formValues, $params, 'civicrm_mailing', $this->get('mailing_id'));
$ids['mailing_id'] = $this->get('mailing_id');
//set msg_template_id
$params['msg_template_id'] = CRM_Utils_Array::value('template', $formValues);
$this->set('template', $params['msg_template_id']);
//handle mailing from name & address.
$fromEmailAddress = CRM_Utils_Array::value($formValues['from_email_address'], CRM_Core_OptionGroup::values('from_email_address'));
//get the from email address
$params['from_email'] = CRM_Utils_Mail::pluckEmailFromHeader($fromEmailAddress);
//get the from Name
$params['from_name'] = CRM_Utils_Array::value(1, explode('"', $fromEmailAddress));
//Add Reply-To to headers
if (CRM_Utils_Array::value('reply_to_address', $formValues)) {
$replyToEmail = CRM_Core_OptionGroup::values('from_email_address');
$params['replyto_email'] = CRM_Utils_Array::value($formValues['reply_to_address'], $replyToEmail);
}
/* Build the mailing object */
CRM_Mailing_BAO_Mailing::create($params, $ids);
}
示例10: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess($params = null)
{
if ($this->_action & CRM_Core_Action::DELETE) {
$deleteParams = array('id' => $this->_activityId);
CRM_Activity_BAO_Activity::deleteActivity($deleteParams);
CRM_Core_Session::setStatus(ts("Selected Activity has been deleted sucessfully."));
return;
}
// store the submitted values in an array
if (!$params) {
$params = $this->controller->exportValues($this->_name);
}
//set activity type id
if (!CRM_Utils_Array::value('activity_type_id', $params)) {
$params['activity_type_id'] = $this->_activityTypeId;
}
if (CRM_Utils_Array::value('hidden_custom', $params) && !isset($params['custom'])) {
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', false, false, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', false, false, null, null, true));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
}
// store the date with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
// assigning formated value to related variable
if (CRM_Utils_Array::value('target_contact_id', $params)) {
$params['target_contact_id'] = explode(',', $params['target_contact_id']);
} else {
$params['target_contact_id'] = array();
}
if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
$params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
} else {
$params['assignee_contact_id'] = array();
}
// get ids for associated contacts
if (!$params['source_contact_id']) {
$params['source_contact_id'] = $this->_currentUserId;
} else {
$params['source_contact_id'] = $this->_submitValues['source_contact_qid'];
}
if (isset($this->_activityId)) {
$params['id'] = $this->_activityId;
}
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $this->_activityId);
// format target params
if (!$this->_single) {
$params['target_contact_id'] = $this->_contactIds;
}
$activityAssigned = array();
// format assignee params
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
//skip those assignee contacts which are already assigned
//while sending a copy.CRM-4509.
$activityAssigned = array_flip($params['assignee_contact_id']);
if ($this->_activityId) {
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($this->_activityId);
$activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
}
}
// call begin post process. Idea is to let injecting file do
// any processing before the activity is added/updated.
$this->beginPostProcess($params);
$activity = CRM_Activity_BAO_Activity::create($params);
// call end post process. Idea is to let injecting file do any
// processing needed, after the activity has been added/updated.
$this->endPostProcess($params, $activity);
// create follow up activity if needed
$followupStatus = '';
if (CRM_Utils_Array::value('followup_activity_type_id', $params)) {
$followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
$followupStatus = "A followup activity has been scheduled.";
}
// send copy to assignee contacts.CRM-4509
$mailStatus = '';
$config =& CRM_Core_Config::singleton();
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id']) && $config->activityAssigneeNotification) {
$mailToContacts = array();
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id, true, false);
//build an associative array with unique email addresses.
foreach ($activityAssigned as $id => $dnc) {
if (isset($id) && array_key_exists($id, $assigneeContacts)) {
$mailToContacts[$assigneeContacts[$id]['email']] = $assigneeContacts[$id];
}
}
if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
//include attachments while sendig a copy of activity.
$attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
require_once "CRM/Case/BAO/Case.php";
$result = CRM_Case_BAO_Case::sendActivityCopy(null, $activity->id, $mailToContacts, $attachments, null);
$mailStatus .= ts("A copy of the activity has also been sent to assignee contacts(s).");
}
}
// set status message
//.........这里部分代码省略.........
示例11: postProcess
/**
*
* @access public
*
* @return void
*/
public function postProcess()
{
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$session = CRM_Core_Session::singleton();
$params['contact_id'] = $session->get('userID');
if ($params['parent_id']) {
$params['entity_table'] = 'civicrm_note';
$params['entity_id'] = $params['parent_id'];
} else {
$params['entity_table'] = $this->_entityTable;
$params['entity_id'] = $this->_entityId;
}
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Core_BAO_Note::del($this->_id);
return;
}
$params['id'] = null;
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
}
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_note', $params['id']);
$ids = array();
$note = CRM_Core_BAO_Note::add($params, $ids);
CRM_Core_Session::setStatus(ts('Your Note has been saved.'), ts('Saved'), 'success');
}
示例12: postProcess
/**
* Function to process the form
*
* @access public
*
* @return void
*/
public function postProcess($params = NULL)
{
if ($this->_action & CRM_Core_Action::DELETE) {
$deleteParams = array('id' => $this->_activityId);
$moveToTrash = CRM_Case_BAO_Case::isCaseActivity($this->_activityId);
CRM_Activity_BAO_Activity::deleteActivity($deleteParams, $moveToTrash);
// delete tags for the entity
$tagParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId);
CRM_Core_BAO_EntityTag::del($tagParams);
CRM_Core_Session::setStatus(ts("Selected Activity has been deleted successfully."), ts('Record Deleted'), 'success');
return;
}
// store the submitted values in an array
if (!$params) {
$params = $this->controller->exportValues($this->_name);
}
//set activity type id
if (empty($params['activity_type_id'])) {
$params['activity_type_id'] = $this->_activityTypeId;
}
if (!empty($params['hidden_custom']) && !isset($params['custom'])) {
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
}
// store the date with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
// format with contact (target contact) values
if (isset($params['contact'][1])) {
$params['target_contact_id'] = explode(',', $params['contact'][1]);
} else {
$params['target_contact_id'] = array();
}
// assigning formated value to related variable
if (!empty($params['assignee_contact_id'])) {
$params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
} else {
$params['assignee_contact_id'] = array();
}
// civicrm-10043 - 14/12/13
if (!empty($params['followup_assignee_contact_id'])) {
$params['followup_assignee_contact_id'] = explode(',', $params['followup_assignee_contact_id']);
} else {
$params['followup_assignee_contact_id'] = array();
}
// get ids for associated contacts
if (!$params['source_contact_id']) {
$params['source_contact_id'] = $this->_currentUserId;
}
if (isset($this->_activityId)) {
$params['id'] = $this->_activityId;
}
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $this->_activityId);
// format target params
if (!$this->_single) {
$params['target_contact_id'] = $this->_contactIds;
}
$activity = array();
if (!empty($params['is_multi_activity']) && !CRM_Utils_Array::crmIsEmptyArray($params['target_contact_id'])) {
$targetContacts = $params['target_contact_id'];
foreach ($targetContacts as $targetContactId) {
$params['target_contact_id'] = array($targetContactId);
// save activity
$activity[] = $this->processActivity($params);
}
} else {
// save activity
$activity = $this->processActivity($params);
}
return array('activity' => $activity);
}
示例13: add
/**
* function to add the auction
*
* @param array $params reference array contains the values submitted by the form
*
* @access public
* @static
*
* @return object
*/
static function add(&$params)
{
require_once 'CRM/Utils/Hook.php';
if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'Auction_Item', $params['id'], $params);
} else {
CRM_Utils_Hook::pre('create', 'Auction_Item', NULL, $params);
}
$auction = new CRM_Auction_DAO_Item();
$auction->copyValues($params);
$auction->save();
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_auction_item', $auction->id);
// add attachments as needed
CRM_Core_BAO_File::processAttachment($params, 'civicrm_auction_item', $auction->id);
if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'Auction_Item', $auction->id, $auction);
} else {
CRM_Utils_Hook::post('create', 'Auction_Item', $auction->id, $auction);
}
return $result;
}
示例14: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess($params = NULL)
{
if ($this->_action & CRM_Core_Action::DELETE) {
$deleteParams = array('id' => $this->_activityId);
$moveToTrash = CRM_Case_BAO_Case::isCaseActivity($this->_activityId);
CRM_Activity_BAO_Activity::deleteActivity($deleteParams, $moveToTrash);
// delete tags for the entity
$tagParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId);
CRM_Core_BAO_EntityTag::del($tagParams);
CRM_Core_Session::setStatus(ts("Selected Activity has been deleted successfully."));
return;
}
// store the submitted values in an array
if (!$params) {
$params = $this->controller->exportValues($this->_name);
}
//set activity type id
if (!CRM_Utils_Array::value('activity_type_id', $params)) {
$params['activity_type_id'] = $this->_activityTypeId;
}
if (CRM_Utils_Array::value('hidden_custom', $params) && !isset($params['custom'])) {
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
}
// store the date with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
// assigning formated value to related variable
if (CRM_Utils_Array::value('target_contact_id', $params)) {
$params['target_contact_id'] = explode(',', $params['target_contact_id']);
} else {
$params['target_contact_id'] = array();
}
if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
$params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
} else {
$params['assignee_contact_id'] = array();
}
// get ids for associated contacts
if (!$params['source_contact_id']) {
$params['source_contact_id'] = $this->_currentUserId;
} else {
$params['source_contact_id'] = $this->_submitValues['source_contact_qid'];
}
if (isset($this->_activityId)) {
$params['id'] = $this->_activityId;
}
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $this->_activityId);
// format target params
if (!$this->_single) {
$params['target_contact_id'] = $this->_contactIds;
}
$activityAssigned = array();
// format assignee params
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
//skip those assignee contacts which are already assigned
//while sending a copy.CRM-4509.
$activityAssigned = array_flip($params['assignee_contact_id']);
if ($this->_activityId) {
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($this->_activityId);
$activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
}
}
// call begin post process. Idea is to let injecting file do
// any processing before the activity is added/updated.
$this->beginPostProcess($params);
$activity = CRM_Activity_BAO_Activity::create($params);
// add tags if exists
$tagParams = array();
if (!empty($params['tag'])) {
foreach ($params['tag'] as $tag) {
$tagParams[$tag] = 1;
}
}
//save static tags
CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
//save free tags
if (isset($params['activity_taglist']) && !empty($params['activity_taglist'])) {
CRM_Core_Form_Tag::postProcess($params['activity_taglist'], $activity->id, 'civicrm_activity', $this);
}
// call end post process. Idea is to let injecting file do any
// processing needed, after the activity has been added/updated.
$this->endPostProcess($params, $activity);
// CRM-9590
$this->_activityId = $activity->id;
// create follow up activity if needed
$followupStatus = '';
if (CRM_Utils_Array::value('followup_activity_type_id', $params)) {
$followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
$followupStatus = ts('A followup activity has been scheduled.');
}
// send copy to assignee contacts.CRM-4509
//.........这里部分代码省略.........
示例15: postProcess
public function postProcess()
{
$params = $ids = array();
$uploadParams = array('header_id', 'footer_id', 'subject', 'from_name', 'from_email');
$fileType = array('textFile', 'htmlFile');
$formValues = $this->controller->exportValues($this->_name);
foreach ($uploadParams as $key) {
if (!empty($formValues[$key]) || in_array($key, array('header_id', 'footer_id'))) {
$params[$key] = $formValues[$key];
$this->set($key, $formValues[$key]);
}
}
if (!$formValues['upload_type']) {
foreach ($fileType as $key) {
$contents = NULL;
if (isset($formValues[$key]) && !empty($formValues[$key])) {
$contents = file_get_contents($formValues[$key]['name']);
$this->set($key, $formValues[$key]['name']);
}
if ($contents) {
$params['body_' . substr($key, 0, 4)] = $contents;
} else {
$params['body_' . substr($key, 0, 4)] = 'NULL';
}
}
} else {
$text_message = $formValues['text_message'];
$params['body_text'] = $text_message;
$this->set('textFile', $params['body_text']);
$this->set('text_message', $params['body_text']);
$html_message = $formValues['html_message'];
// dojo editor does some html conversion when tokens are
// inserted as links. Hence token replacement fails.
// this is hack to revert html conversion for { to %7B and
// } to %7D by dojo editor
$html_message = str_replace('%7B', '{', str_replace('%7D', '}', $html_message));
$params['body_html'] = $html_message;
$this->set('htmlFile', $params['body_html']);
$this->set('html_message', $params['body_html']);
}
$params['name'] = $this->get('name');
$session = CRM_Core_Session::singleton();
$params['contact_id'] = $session->get('userID');
$composeFields = array('template', 'saveTemplate', 'updateTemplate', 'saveTemplateName');
$msgTemplate = NULL;
//mail template is composed
if ($formValues['upload_type']) {
$composeParams = array();
foreach ($composeFields as $key) {
if (!empty($formValues[$key])) {
$composeParams[$key] = $formValues[$key];
$this->set($key, $formValues[$key]);
}
}
if (!empty($composeParams['updateTemplate'])) {
$templateParams = array('msg_text' => $text_message, 'msg_html' => $html_message, 'msg_subject' => $params['subject'], 'is_active' => TRUE);
$templateParams['id'] = $formValues['template'];
$msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
}
if (!empty($composeParams['saveTemplate'])) {
$templateParams = array('msg_text' => $text_message, 'msg_html' => $html_message, 'msg_subject' => $params['subject'], 'is_active' => TRUE);
$templateParams['msg_title'] = $composeParams['saveTemplateName'];
$msgTemplate = CRM_Core_BAO_MessageTemplate::add($templateParams);
}
if (isset($msgTemplate->id)) {
$params['msg_template_id'] = $msgTemplate->id;
} else {
$params['msg_template_id'] = CRM_Utils_Array::value('template', $formValues);
}
$this->set('template', $params['msg_template_id']);
}
CRM_Core_BAO_File::formatAttachment($formValues, $params, 'civicrm_mailing', $this->_mailingID);
$ids['mailing_id'] = $this->_mailingID;
//handle mailing from name & address.
$fromEmailAddress = CRM_Utils_Array::value($formValues['from_email_address'], CRM_Core_OptionGroup::values('from_email_address'));
//get the from email address
$params['from_email'] = CRM_Utils_Mail::pluckEmailFromHeader($fromEmailAddress);
//get the from Name
$params['from_name'] = CRM_Utils_Array::value(1, explode('"', $fromEmailAddress));
//Add Reply-To to headers
if (!empty($formValues['reply_to_address'])) {
$replyToEmail = CRM_Core_OptionGroup::values('from_email_address');
$params['replyto_email'] = CRM_Utils_Array::value($formValues['reply_to_address'], $replyToEmail);
}
/* Build the mailing object */
CRM_Mailing_BAO_Mailing::create($params, $ids);
if (isset($this->_submitValues['_qf_Upload_upload_save']) && $this->_submitValues['_qf_Upload_upload_save'] == 'Save & Continue Later') {
//when user perform mailing from search context
//redirect it to search result CRM-3711.
$ssID = $this->get('ssID');
if ($ssID && $this->_searchBasedMailing) {
if ($this->_action == CRM_Core_Action::BASIC) {
$fragment = 'search';
} elseif ($this->_action == CRM_Core_Action::PROFILE) {
$fragment = 'search/builder';
} elseif ($this->_action == CRM_Core_Action::ADVANCED) {
$fragment = 'search/advanced';
} else {
$fragment = 'search/custom';
}
//.........这里部分代码省略.........