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


PHP CRM_Core_BAO_Email::allEmails方法代码示例

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


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

示例1: preProcessSingle

 static function preProcessSingle(&$form, $cid)
 {
     // TO DO: need to check where and why we use this function
     $form->_single = true;
     $form->_emails = array();
     if ($form->_context != 'standalone') {
         $form->_contactIds = array($cid);
         $emails = CRM_Core_BAO_Email::allEmails($cid);
         $form->_onHold = array();
         $toName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name');
         foreach ($emails as $emailId => $item) {
             $email = $item['email'];
             if (!$email && count($emails) <= 1) {
                 $form->_emails[$email] = '"' . $toName . '"';
                 $form->_noEmails = true;
             } else {
                 if ($email) {
                     if (isset($form->_emails[$email])) {
                         // CRM-3624
                         continue;
                     }
                     $form->_emails[$email] = '"' . $toName . '" <' . $email . '> ' . $item['locationType'];
                     $form->_onHold[$email] = $item['on_hold'];
                 }
             }
             if ($item['is_primary']) {
                 $form->_emails[$email] .= ' ' . ts('(preferred)');
             }
             $form->_emails[$email] = htmlspecialchars($form->_emails[$email]);
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:32,代码来源:EmailCommon.php

示例2: testAllEmails

 /**
  * AllEmails() method - get all emails for our contact, with primary email first
  */
 public function testAllEmails()
 {
     $contactParams = array('first_name' => 'Alan', 'last_name' => 'Smith', 'email-1' => 'alan.smith1@example.com', 'email-2' => 'alan.smith2@example.com', 'email-3' => 'alan.smith3@example.com');
     $contactId = Contact::createIndividual($contactParams);
     $emails = CRM_Core_BAO_Email::allEmails($contactId);
     $this->assertEquals(count($emails), 3, 'Checking number of returned emails.');
     $firstEmailValue = array_slice($emails, 0, 1);
     $this->assertEquals('alan.smith1@example.com', $firstEmailValue[0]['email'], 'Confirm primary email address value.');
     $this->assertEquals(1, $firstEmailValue[0]['is_primary'], 'Confirm first email address is primary.');
     Contact::delete($contactId);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:14,代码来源:EmailTest.php

示例3: testAllEmails

 /**
  * AllEmails() method - get all emails for our contact, with primary email first
  */
 public function testAllEmails()
 {
     $contactParams = array('first_name' => 'Alan', 'last_name' => 'Smith', 'email' => 'alan.smith1@example.com', 'api.email.create.0' => array('email' => 'alan.smith2@example.com', 'location_type_id' => 'Home'), 'api.email.create.1' => array('email' => 'alan.smith3@example.com', 'location_type_id' => 'Main'));
     $contactId = $this->individualCreate($contactParams);
     $emails = CRM_Core_BAO_Email::allEmails($contactId);
     $this->assertEquals(count($emails), 3, 'Checking number of returned emails.');
     $firstEmailValue = array_slice($emails, 0, 1);
     $this->assertEquals('alan.smith1@example.com', $firstEmailValue[0]['email'], 'Confirm primary email address value.');
     $this->assertEquals(1, $firstEmailValue[0]['is_primary'], 'Confirm first email address is primary.');
     $this->contactDelete($contactId);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:14,代码来源:EmailTest.php

示例4: preProcessFromAddress

 /**
  * @param $form
  */
 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) {
             // set it if no emails are present at all
             $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->_noEmails = FALSE;
             }
         }
         $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_OptionGroup::values('from_email_address');
     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:prashantgajare,项目名称:civicrm-core,代码行数:54,代码来源:EmailCommon.php

示例5: getFromEmailIds

 /**
  * Build From Email as the combination of all the email ids of the logged in user,
  * the domain email id and the email id configured for the event
  * 
  * @param int $eventId   the id of the event
  * 
  * @return array         an array of email ids
  * @access public
  * @static
  */
 static function getFromEmailIds($eventId = null)
 {
     static $emails;
     $session = CRM_Core_Session::singleton();
     $contactID = $session->get('userID');
     $cacheKey = 'd';
     if ($eventId) {
         $cacheKey .= '_eid_' . $eventId;
     }
     if ($contactID) {
         $cacheKey .= '_cid_' . $contactID;
     }
     $fromEmailValues = $fromEmailIds = $eventEmail = $contactEmails = array();
     if (isset($emails[$cacheKey])) {
         return $emails[$cacheKey];
     }
     if ($eventId) {
         // add the email id configured for the event
         $params = array('id' => $eventId);
         $returnProperties = array('confirm_from_name', 'confirm_from_email', 'cc_confirm', 'bcc_confirm');
         CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $params, $eventEmail, $returnProperties);
         if (CRM_Utils_Array::value('confirm_from_name', $eventEmail) && CRM_Utils_Array::value('confirm_from_email', $eventEmail)) {
             $fromEmailValues[] = $fromEmailIds[] = "{$eventEmail['confirm_from_name']} <{$eventEmail['confirm_from_email']}>";
         }
     }
     // add the domain email id
     require_once 'CRM/Core/BAO/Domain.php';
     $domainEmail = CRM_Core_BAO_Domain::getNameAndEmail();
     $domainEmail = "{$domainEmail['0']} <{$domainEmail['1']}>";
     if (!in_array($domainEmail, $fromEmailIds)) {
         $fromEmailValues[] = $fromEmailIds[] = $domainEmail;
     }
     require_once 'CRM/Core/BAO/Email.php';
     // add logged in user's active email ids
     if ($contactID) {
         $contactEmails = CRM_Core_BAO_Email::allEmails($contactID);
         $fromDisplayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'display_name');
         foreach ($contactEmails as $emailId => $emailVal) {
             $email = trim($emailVal['email']);
             if (!$email || $emailVal['on_hold']) {
                 continue;
             }
             $fromEmail = "{$fromDisplayName} <{$email}>";
             if (!in_array($fromEmail, $fromEmailIds)) {
                 $fromEmailValues[$emailId] = $fromEmailIds[] = $fromEmail;
                 $fromEmailValues[$emailId] .= $emailVal['locationType'];
                 if (CRM_Utils_Array::value('is_primary', $emailVal)) {
                     $fromEmailValues[$emailId] .= ' ' . ts('(preferred)');
                 }
             }
         }
     }
     foreach ($fromEmailValues as $key => $value) {
         $emailValues[] = htmlspecialchars($value);
     }
     $emails[$cacheKey] = array('name' => $fromEmailIds, 'label' => $emailValues, 'cc' => CRM_Utils_Array::value('cc_confirm', $eventEmail), 'bcc' => CRM_Utils_Array::value('bcc_confirm', $eventEmail));
     return $emails[$cacheKey];
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:68,代码来源:Event.php

示例6: printPDF


//.........这里部分代码省略.........
         }
         $source = $contribution->source;
         $config = CRM_Core_Config::singleton();
         if (!isset($params['forPage'])) {
             $config->doNotAttachPDFReceipt = 1;
         }
         // get organization address
         $domain = CRM_Core_BAO_Domain::getDomain();
         $locParams = array('contact_id' => $domain->id);
         $locationDefaults = CRM_Core_BAO_Location::getValues($locParams);
         if (isset($locationDefaults['address'][1]['state_province_id'])) {
             $stateProvinceAbbreviationDomain = CRM_Core_PseudoConstant::stateProvinceAbbreviation($locationDefaults['address'][1]['state_province_id']);
         } else {
             $stateProvinceAbbreviationDomain = '';
         }
         if (isset($locationDefaults['address'][1]['country_id'])) {
             $countryDomain = CRM_Core_PseudoConstant::country($locationDefaults['address'][1]['country_id']);
         } else {
             $countryDomain = '';
         }
         // parameters to be assign for template
         $tplParams = array('title' => $title, 'component' => $input['component'], 'id' => $contribution->id, 'source' => $source, 'invoice_id' => $invoiceId, 'resourceBase' => $config->userFrameworkResourceURL, 'defaultCurrency' => $config->defaultCurrency, 'amount' => $contribution->total_amount, 'amountDue' => $amountDue, 'invoice_date' => $invoiceDate, 'dueDate' => $dueDate, 'notes' => CRM_Utils_Array::value('notes', $prefixValue), 'display_name' => $contribution->_relatedObjects['contact']->display_name, 'lineItem' => $lineItem, 'dataArray' => $dataArray, 'refundedStatusId' => $refundedStatusId, 'contribution_status_id' => $contribution->contribution_status_id, 'subTotal' => $subTotal, 'street_address' => CRM_Utils_Array::value('street_address', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'supplemental_address_2' => CRM_Utils_Array::value('supplemental_address_2', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'city' => CRM_Utils_Array::value('city', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'stateProvinceAbbreviation' => $stateProvinceAbbreviation, 'postal_code' => CRM_Utils_Array::value('postal_code', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'is_pay_later' => $contribution->is_pay_later, 'organization_name' => $contribution->_relatedObjects['contact']->organization_name, 'domain_organization' => $domain->name, 'domain_street_address' => CRM_Utils_Array::value('street_address', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_supplemental_address_2' => CRM_Utils_Array::value('supplemental_address_2', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_city' => CRM_Utils_Array::value('city', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_postal_code' => CRM_Utils_Array::value('postal_code', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_state' => $stateProvinceAbbreviationDomain, 'domain_country' => $countryDomain, 'domain_email' => CRM_Utils_Array::value('email', CRM_Utils_Array::value('1', $locationDefaults['email'])), 'domain_phone' => CRM_Utils_Array::value('phone', CRM_Utils_Array::value('1', $locationDefaults['phone'])));
         if (isset($creditNoteId)) {
             $tplParams['creditnote_id'] = $creditNoteId;
         }
         $sendTemplateParams = array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_invoice_receipt', 'contactId' => $contribution->contact_id, 'tplParams' => $tplParams, 'PDFFilename' => 'Invoice.pdf');
         $session = CRM_Core_Session::singleton();
         $contactID = $session->get('userID');
         //CRM-16319 - we dont store in userID in case the user is doing multiple
         //transactions etc
         if (empty($contactID)) {
             $contactID = $session->get('transaction.userID');
         }
         $contactEmails = CRM_Core_BAO_Email::allEmails($contactID);
         $emails = array();
         $fromDisplayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'display_name');
         foreach ($contactEmails as $emailId => $item) {
             $email = $item['email'];
             if ($email) {
                 $emails[$emailId] = '"' . $fromDisplayName . '" <' . $email . '> ';
             }
         }
         $fromEmail = CRM_Utils_Array::crmArrayMerge($emails, CRM_Core_OptionGroup::values('from_email_address'));
         // from email address
         if (isset($params['from_email_address'])) {
             $fromEmailAddress = CRM_Utils_Array::value($params['from_email_address'], $fromEmail);
         }
         // condition to check for download PDF Invoice or email Invoice
         if ($invoiceElements['createPdf']) {
             list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
             if (isset($params['forPage'])) {
                 return $html;
             } else {
                 $mail = array('subject' => $subject, 'body' => $message, 'html' => $html);
                 if ($mail['html']) {
                     $messageInvoice[] = $mail['html'];
                 } else {
                     $messageInvoice[] = nl2br($mail['body']);
                 }
             }
         } elseif ($contribution->_component == 'contribute') {
             $email = CRM_Contact_BAO_Contact::getPrimaryEmail($contribution->contact_id);
             $sendTemplateParams['tplParams'] = array_merge($tplParams, array('email_comment' => $invoiceElements['params']['email_comment']));
             $sendTemplateParams['from'] = $fromEmailAddress;
             $sendTemplateParams['toEmail'] = $email;
             $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_receipt', $values);
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:67,代码来源:Invoice.php

示例7: getPrimaryEmail

 /**
  * @todo Is there a better way to do this?
  * @return string
  */
 private function getPrimaryEmail()
 {
     $session =& CRM_Core_Session::singleton();
     $uid = $session->get('userID');
     $primary = '';
     $emails = CRM_Core_BAO_Email::allEmails($uid);
     foreach ($emails as $eid => $e) {
         if ($e['is_primary']) {
             if ($e['email']) {
                 $primary = $e['email'];
                 break;
             }
         }
         if (count($emails) == 1) {
             $primary = $e['email'];
             break;
         }
     }
     return $primary;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:24,代码来源:ICalendar.php

示例8: preProcessFromAddress

 /**
  * Pre Process Form Addresses to be used in QUickfomr
  * @param CRM_Core_Form $form
  * @param bool $bounce determine if we want to throw a status bounce.
  */
 public static function preProcessFromAddress(&$form, $bounce = TRUE)
 {
     $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) {
             // set it if no emails are present at all
             $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->_noEmails = FALSE;
             }
         }
         if (!empty($email)) {
             $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 ($bounce) {
         if ($form->_noEmails) {
             CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address'));
         }
     }
     // now add domain from addresses
     $domainEmails = self::domainEmails();
     foreach ($domainEmails as $domainEmail => $email) {
         $form->_emails[$domainEmail] = $domainEmail;
     }
     $form->_fromEmails = CRM_Utils_Array::crmArrayMerge($emails, $domainEmails);
     $form->_fromEmails = array_filter($form->_fromEmails);
     if (is_numeric(key($form->_fromEmails))) {
         // Add signature
         $defaultEmail = civicrm_api3('email', 'getsingle', array('id' => key($form->_fromEmails)));
         $defaults = array();
         if (!empty($defaultEmail['signature_html'])) {
             $defaults['html_message'] = '<br/><br/>--' . $defaultEmail['signature_html'];
         }
         if (!empty($defaultEmail['signature_text'])) {
             $defaults['text_message'] = "\n\n--\n" . $defaultEmail['signature_text'];
         }
         $form->setDefaults($defaults);
     }
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:70,代码来源:EmailCommon.php

示例9: getPrimaryEmail

 /**
  * @todo Is there a better way to do this?
  * @return string
  */
 private function getPrimaryEmail()
 {
     $uid = CRM_Core_Session::getLoggedInContactID();
     $primary = '';
     $emails = CRM_Core_BAO_Email::allEmails($uid);
     foreach ($emails as $eid => $e) {
         if ($e['is_primary']) {
             if ($e['email']) {
                 $primary = $e['email'];
                 break;
             }
         }
         if (count($emails) == 1) {
             $primary = $e['email'];
             break;
         }
     }
     return $primary;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:23,代码来源:ICalendar.php


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