当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_Mail::pluckEmailFromHeader方法代码示例

本文整理汇总了PHP中CRM_Utils_Mail::pluckEmailFromHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Mail::pluckEmailFromHeader方法的具体用法?PHP CRM_Utils_Mail::pluckEmailFromHeader怎么用?PHP CRM_Utils_Mail::pluckEmailFromHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_Mail的用法示例。


在下文中一共展示了CRM_Utils_Mail::pluckEmailFromHeader方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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';
             }
//.........这里部分代码省略.........
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:101,代码来源:Upload.php

示例2: setDefaultValues

 function setDefaultValues()
 {
     require_once 'CRM/Core/BAO/Domain.php';
     $defaults = array();
     $params = array();
     $locParams = array();
     if (isset($this->_id)) {
         $params['id'] = $this->_id;
         CRM_Core_BAO_Domain::retrieve($params, $domainDefaults);
         //get the default domain from email address. fix CRM-3552
         require_once 'CRM/Utils/Mail.php';
         require_once 'CRM/Core/OptionValue.php';
         $optionValues = array();
         $grpParams['name'] = 'from_email_address';
         CRM_Core_OptionValue::getValues($grpParams, $optionValues);
         foreach ($optionValues as $Id => $value) {
             if ($value['is_default'] && $value['is_active']) {
                 $this->_fromEmailId = $Id;
                 $domainDefaults['email_name'] = CRM_Utils_Array::value(1, explode('"', $value['label']));
                 $domainDefaults['email_address'] = CRM_Utils_Mail::pluckEmailFromHeader($value['label']);
                 break;
             }
         }
         unset($params['id']);
         $locParams = $params + array('entity_id' => $this->_id, 'entity_table' => 'civicrm_domain');
         require_once 'CRM/Core/BAO/Location.php';
         $defaults = CRM_Core_BAO_Location::getValues($locParams);
         $config = CRM_Core_Config::singleton();
         if (!isset($defaults['address'][1]['country_id'])) {
             $defaults['address'][1]['country_id'] = $config->defaultContactCountry;
         }
         if (!empty($defaults['address'])) {
             foreach ($defaults['address'] as $key => $value) {
                 CRM_Contact_Form_Edit_Address::fixStateSelect($this, "address[{$key}][country_id]", "address[{$key}][state_province_id]", CRM_Utils_Array::value('country_id', $value, $config->defaultContactCountry));
             }
         }
     }
     $defaults = array_merge($defaults, $domainDefaults);
     return $defaults;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:40,代码来源:Domain.php

示例3: formRule

 /**
  * Global form rule.
  *
  * @param array $fields
  *   The input form values.
  * @param array $files
  *   The uploaded files if any.
  * @param array $self
  *   Current form object.
  *
  * @return array
  *   array of errors / empty array.
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     if ($self->_gName == 'case_status' && empty($fields['grouping'])) {
         $errors['grouping'] = ts('Status class is a required field');
     }
     if (in_array($self->_gName, array('email_greeting', 'postal_greeting', 'addressee')) && empty($self->_defaultValues['is_reserved'])) {
         $label = $fields['label'];
         $condition = " AND v.label = '{$label}' ";
         $values = CRM_Core_OptionGroup::values($self->_gName, FALSE, FALSE, FALSE, $condition, 'filter');
         $checkContactOptions = TRUE;
         if ($self->_id && $self->_defaultValues['contactOptions'] == $fields['contactOptions']) {
             $checkContactOptions = FALSE;
         }
         if ($checkContactOptions && in_array($fields['contactOptions'], $values)) {
             $errors['label'] = ts('This Label already exists in the database for the selected contact type.');
         }
     }
     if ($self->_gName == 'from_email_address') {
         $formEmail = CRM_Utils_Mail::pluckEmailFromHeader($fields['label']);
         if (!CRM_Utils_Rule::email($formEmail)) {
             $errors['label'] = ts('Please enter a valid email address.');
         }
         $formName = explode('"', $fields['label']);
         if (empty($formName[1]) || count($formName) != 3) {
             $errors['label'] = ts('Please follow the proper format for From Email Address');
         }
     }
     $dataType = self::getOptionGroupDataType($self->_gName);
     if ($dataType && $self->_gName !== 'activity_type') {
         $validate = CRM_Utils_Type::validate($fields['value'], $dataType, FALSE);
         if (!$validate) {
             CRM_Core_Session::setStatus(ts('Data Type of the value field for this option value does not match ' . $dataType), ts('Value field Data Type mismatch'));
         }
     }
     return $errors;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:50,代码来源:Options.php

示例4: 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);
 }
开发者ID:krishgopi,项目名称:uk.co.vedaconsulting.quickbulkemail,代码行数:49,代码来源:QuickBulkEmail.php

示例5: getNameAndEmail

 static function getNameAndEmail()
 {
     require_once 'CRM/Core/OptionGroup.php';
     $fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address', null, null, null, ' AND is_default = 1');
     if (!empty($fromEmailAddress)) {
         require_once 'CRM/Utils/Mail.php';
         foreach ($fromEmailAddress as $key => $value) {
             $email = CRM_Utils_Mail::pluckEmailFromHeader($value);
             $fromName = CRM_Utils_Array::value(1, explode('"', $value));
             break;
         }
         return array($fromName, $email);
     }
     $url = CRM_Utils_System::url('civicrm/contact/domain', 'action=update&reset=1');
     $status = ts("There is no valid default from email address configured for the domain. You can configure here <a href='%1'>Configure From Email Address.</a>", array(1 => $url));
     CRM_Core_Error::fatal($status);
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:17,代码来源:Domain.php

示例6: setDefaultValues

 /**
  * This virtual function is used to set the default values of.
  * various form elements
  *
  * @return array
  *   reference to the array of default values
  *
  */
 public function setDefaultValues()
 {
     $defaults = array();
     $params = array();
     if (isset($this->_id)) {
         $params['id'] = $this->_id;
         CRM_Core_BAO_Domain::retrieve($params, $domainDefaults);
         $this->_contactId = $domainDefaults['contact_id'];
         //get the default domain from email address. fix CRM-3552
         $optionValues = array();
         $grpParams['name'] = 'from_email_address';
         CRM_Core_OptionValue::getValues($grpParams, $optionValues);
         foreach ($optionValues as $Id => $value) {
             if ($value['is_default'] && $value['is_active']) {
                 $this->_fromEmailId = $Id;
                 $list = explode('"', $value['label']);
                 $domainDefaults['email_name'] = CRM_Utils_Array::value(1, $list);
                 $domainDefaults['email_address'] = CRM_Utils_Mail::pluckEmailFromHeader($value['label']);
                 break;
             }
         }
         unset($params['id']);
         $locParams = array('contact_id' => $domainDefaults['contact_id']);
         $this->_locationDefaults = $defaults = CRM_Core_BAO_Location::getValues($locParams);
         $config = CRM_Core_Config::singleton();
         if (!isset($defaults['address'][1]['country_id'])) {
             $defaults['address'][1]['country_id'] = $config->defaultContactCountry;
         }
         if (!isset($defaults['address'][1]['state_province_id'])) {
             $defaults['address'][1]['state_province_id'] = $config->defaultContactStateProvince;
         }
     }
     $defaults = array_merge($defaults, $domainDefaults);
     return $defaults;
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:43,代码来源:Domain.php

示例7: getNameAndEmail

 static function getNameAndEmail($skipFatal = FALSE)
 {
     $fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
     if (!empty($fromEmailAddress)) {
         foreach ($fromEmailAddress as $key => $value) {
             $email = CRM_Utils_Mail::pluckEmailFromHeader($value);
             $fromArray = explode('"', $value);
             $fromName = CRM_Utils_Array::value(1, $fromArray);
             break;
         }
         return array($fromName, $email);
     } elseif ($skipFatal) {
         return array('', '');
     }
     $url = CRM_Utils_System::url('civicrm/admin/domain', 'action=update&reset=1');
     $status = ts("There is no valid default from email address configured for the domain. You can configure here <a href='%1'>Configure From Email Address.</a>", array(1 => $url));
     CRM_Core_Error::fatal($status);
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:18,代码来源:Domain.php

示例8: formRule

 /**  
  * global form rule  
  *  
  * @param array $fields the input form values  
  * @param array $files  the uploaded files if any  
  * @param array $self   current form object. 
  *  
  * @return array array of errors / empty array.   
  * @access public  
  * @static  
  */
 static function formRule(&$fields, &$files, $self)
 {
     $errors = array();
     if ($self->_gName == 'from_email_address') {
         require_once 'CRM/Utils/Mail.php';
         $formEmail = CRM_Utils_Mail::pluckEmailFromHeader($fields['label']);
         if (!CRM_Utils_Rule::email($formEmail)) {
             $errors['label'] = ts('Please enter the valid email address.');
         }
         $formName = explode('"', $fields['label']);
         if (!CRM_Utils_Array::value(1, $formName) || count($formName) != 3) {
             $errors['label'] = ts('Please follow the proper format for From Email Address');
         }
     }
     return $errors;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:27,代码来源:Options.php

示例9: 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';
                     }
                 }
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:Upload.php

示例10: formRule

 /**
  * global form rule
  *
  * @param array $fields the input form values
  * @param array $files  the uploaded files if any
  * @param array $self   current form object.
  *
  * @return array array of errors / empty array.
  * @access public
  * @static
  */
 static function formRule($fields, $files, $self)
 {
     $errors = array();
     if ($self->_gName == 'case_status' && !CRM_Utils_Array::value('grouping', $fields)) {
         $errors['grouping'] = ts('Status class is a required field');
     }
     if (in_array($self->_gName, array('email_greeting', 'postal_greeting', 'addressee')) && !CRM_Utils_Array::value('is_reserved', $self->_defaultValues)) {
         $label = $fields['label'];
         $condition = " AND v.label = '{$label}' ";
         $values = CRM_Core_OptionGroup::values($self->_gName, FALSE, FALSE, FALSE, $condition, 'filter');
         $checkContactOptions = TRUE;
         if ($self->_id && $self->_defaultValues['contactOptions'] == $fields['contactOptions']) {
             $checkContactOptions = FALSE;
         }
         if ($checkContactOptions && in_array($fields['contactOptions'], $values)) {
             $errors['label'] = ts('This Label already exists in the database for the selected contact type.');
         }
     }
     if ($self->_gName == 'from_email_address') {
         $formEmail = CRM_Utils_Mail::pluckEmailFromHeader($fields['label']);
         if (!CRM_Utils_Rule::email($formEmail)) {
             $errors['label'] = ts('Please enter the valid email address.');
         }
         $formName = explode('"', $fields['label']);
         if (!CRM_Utils_Array::value(1, $formName) || count($formName) != 3) {
             $errors['label'] = ts('Please follow the proper format for From Email Address');
         }
     }
     return $errors;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:41,代码来源:Options.php


注:本文中的CRM_Utils_Mail::pluckEmailFromHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。