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


PHP CRM_Core_PseudoConstant::fromEmailAddress方法代码示例

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


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

示例1: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  * @return void
  */
 static function buildQuickForm(&$form)
 {
     $toArray = $ccArray = $bccArray = array();
     $suppressedEmails = 0;
     $to = $form->add('text', 'to', ts('To'), '', true);
     $cc = $form->add('text', 'cc_id', ts('CC'));
     $bcc = $form->add('text', 'bcc_id', ts('BCC'));
     $elements = array('cc', 'bcc');
     foreach ($elements as $element) {
         if (${$element}->getValue()) {
             preg_match_all('!"(.*?)"\\s+<\\s*(.*?)\\s*>!', ${$element}->getValue(), $matches);
             $elementValues = array();
             for ($i = 0; $i < count($matches[0]); $i++) {
                 $name = '"' . $matches[1][$i] . '" &lt;' . $matches[2][$i] . '&gt;';
                 $elementValues[] = array('name' => $name, 'id' => $matches[0][$i]);
             }
             $var = "{$element}Contact";
             $form->assign($var, json_encode($elementValues));
         }
     }
     // when form is submitted recompute contactIds
     $allToEmails = array();
     if ($to->getValue()) {
         $allToEmails = explode(',', $to->getValue());
         $form->_contactIds = array();
         foreach ($allToEmails as $value) {
             list($contactId, $email) = explode('::', $value);
             $form->_contactIds[] = $contactId;
             $form->_toContactEmails[] = $email;
         }
     }
     if (is_array($form->_contactIds)) {
         $returnProperties = array('sort_name' => 1, 'email' => 1, 'do_not_email' => 1, 'on_hold' => 1, 'display_name' => 1, 'preferred_mail_format' => 1);
         require_once 'CRM/Mailing/BAO/Mailing.php';
         list($form->_contactDetails) = CRM_Mailing_BAO_Mailing::getDetails($form->_contactIds, $returnProperties, false, false);
         // make a copy of all contact details
         $form->_allContactDetails = $form->_contactDetails;
         foreach ($form->_contactIds as $key => $contactId) {
             $value = $form->_contactDetails[$contactId];
             if ($value['do_not_email'] || empty($value['email']) || $value['is_deceased'] || $value['on_hold']) {
                 $suppressedEmails++;
                 // unset contact details for contacts that we won't be sending email. This is prevent extra computation
                 // during token evaluation etc.
                 unset($form->_contactDetails[$contactId]);
             } else {
                 if (empty($form->_toContactEmails)) {
                     $email = $value['email'];
                 } else {
                     $email = $form->_toContactEmails[$key];
                 }
                 $toArray[] = array('name' => '"' . $value['sort_name'] . '" &lt;' . $email . '&gt;', 'id' => "{$contactId}::{$email}");
             }
         }
         if (empty($toArray)) {
             CRM_Core_Error::statusBounce(ts('Selected contact(s) do not have a valid email address, or communication preferences specify DO NOT EMAIL, or they are deceased or Primary email address is On Hold).'));
         }
     }
     $form->assign('toContact', json_encode($toArray));
     $form->assign('suppressedEmails', $suppressedEmails);
     $form->assign('noEmails', $form->_noEmails);
     $session =& CRM_Core_Session::singleton();
     $userID = $session->get('userID');
     list($fromDisplayName, $fromEmail, $fromDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID);
     if (!$fromEmail) {
         CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address'));
     }
     if (!trim($fromDisplayName)) {
         $fromDisplayName = $fromEmail;
     }
     $form->assign('totalSelectedContacts', count($form->_contactIds));
     $from = "{$fromDisplayName} <{$fromEmail}>";
     $form->_fromEmails = array('0' => $from) + CRM_Core_PseudoConstant::fromEmailAddress();
     $form->add('text', 'subject', ts('Subject'), 'size=50 maxlength=254', true);
     $selectEmails = $form->_fromEmails;
     foreach (array_keys($selectEmails) as $k) {
         $selectEmails[$k] = htmlspecialchars($selectEmails[$k]);
     }
     $form->add('select', 'fromEmailAddress', ts('From'), $selectEmails, true);
     require_once "CRM/Mailing/BAO/Mailing.php";
     CRM_Mailing_BAO_Mailing::commonCompose($form);
     // add attachments
     require_once 'CRM/Core/BAO/File.php';
     CRM_Core_BAO_File::buildAttachment($form, null);
     if ($form->_single) {
         // also fix the user context stack
         if ($form->_caseId) {
             $ccid = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseContact', $form->_caseId, 'contact_id', 'case_id');
             $url = CRM_Utils_System::url('civicrm/contact/view/case', "&reset=1&action=view&cid={$ccid}&id={$form->_caseId}");
         } else {
             if ($form->_context) {
                 $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
             } else {
                 $url = CRM_Utils_System::url('civicrm/contact/view', "&show=1&action=browse&cid={$form->_contactIds[0]}&selectedChild=activity");
             }
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:EmailCommon.php

示例2:

 /**
  * Get the all From Email Address from database.
  *
  * The static array $fromEmailAddress is returned, and if it's
  * called the first time, DAO is used 
  * to get all the From Email Address
  *
  * Note: any database errors will be trapped by the DAO.
  *
  * @access public
  * @static
  *
  * @return array - array reference of all From Email Address.
  */
 public static function &fromEmailAddress()
 {
     if (!self::$fromEmailAddress) {
         require_once 'CRM/Core/OptionGroup.php';
         self::$fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address');
     }
     return self::$fromEmailAddress;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:22,代码来源:PseudoConstant.php

示例3: preProcessFromAddress

 static function preProcessFromAddress(&$form)
 {
     $form->_single = false;
     $className = CRM_Utils_System::getClassName($form);
     if (property_exists($form, '_context') && $form->_context != 'search' && $className == 'CRM_Contact_Form_Task_Email') {
         $form->_single = true;
     }
     $form->_emails = $emails = array();
     $session = CRM_Core_Session::singleton();
     $contactID = $session->get('userID');
     $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) {
             $emails[$emailId] = '"' . $fromDisplayName . '"';
             $form->_noEmails = true;
         } else {
             if ($email) {
                 if (in_array($email, $emails)) {
                     // CRM-3624
                     continue;
                 }
                 $emails[$emailId] = '"' . $fromDisplayName . '" <' . $email . '> ';
                 $form->_onHold[$emailId] = $item['on_hold'];
             }
         }
         $form->_emails[$emailId] = $emails[$emailId];
         $emails[$emailId] .= $item['locationType'];
         if ($item['is_primary']) {
             $emails[$emailId] .= ' ' . ts('(preferred)');
         }
         $emails[$emailId] = htmlspecialchars($emails[$emailId]);
     }
     $form->assign('noEmails', $form->_noEmails);
     if ($form->_noEmails) {
         CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address'));
     }
     // now add domain from addresses
     $domainEmails = array();
     $domainFrom = CRM_Core_PseudoConstant::fromEmailAddress();
     foreach (array_keys($domainFrom) as $k) {
         $domainEmail = $domainFrom[$k];
         $domainEmails[$domainEmail] = htmlspecialchars($domainEmail);
         $form->_emails[$domainEmail] = $domainEmail;
     }
     $form->_fromEmails = CRM_Utils_Array::crmArrayMerge($emails, $domainEmails);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:50,代码来源:EmailCommon.php

示例4: 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 (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'] == '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';
             } 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:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Upload.php

示例5:

 /**
  * Get the all From Email Address from database.
  *
  * The static array $fromEmailAddress is returned, and if it's
  * called the first time, DAO is used
  * to get all the From Email Address
  *
  * Note: any database errors will be trapped by the DAO.
  *
  * @access public
  * @static
  *
  * @return array - array reference of all From Email Address.
  */
 public static function &fromEmailAddress()
 {
     if (!self::$fromEmailAddress) {
         self::$fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address');
     }
     return self::$fromEmailAddress;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:21,代码来源:PseudoConstant.php


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