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


PHP CRM_Core_BAO_Email类代码示例

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


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

示例1: run

 /**
  * Run the page.
  *
  * This method is called after the page is created.
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
     $entityBlock = array('contact_id' => $contactId);
     $emails = CRM_Core_BAO_Email::getValues($entityBlock);
     if (!empty($emails)) {
         foreach ($emails as $key => &$value) {
             $value['location_type'] = $locationTypes[$value['location_type_id']];
         }
     }
     $contact = new CRM_Contact_BAO_Contact();
     $contact->id = $contactId;
     $contact->find(TRUE);
     $privacy = array();
     foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) {
         if (isset($contact->{$name})) {
             $privacy[$name] = $contact->{$name};
         }
     }
     $this->assign('contactId', $contactId);
     $this->assign('email', $emails);
     $this->assign('privacy', $privacy);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:34,代码来源:Email.php

示例2: 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

示例3: create

 static function create($params)
 {
     if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) {
         CRM_Core_BAO_Block::handlePrimary($params, get_class());
     }
     $email = CRM_Core_BAO_Email::add($params);
     return $email;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:8,代码来源:Email.php

示例4: preProcess

 public function preProcess()
 {
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->_component = CRM_Utils_Request::retrieve('component', 'String', $this, TRUE);
     $this->_view = CRM_Utils_Request::retrieve('view', 'String', $this, FALSE);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
     $this->assign('component', $this->_component);
     $this->assign('id', $this->_id);
     $this->assign('suppressPaymentFormButtons', $this->isBeingCalledFromSelectorContext());
     if ($this->_view == 'transaction' && $this->_action & CRM_Core_Action::BROWSE) {
         $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, TRUE);
         $transactionRows = $paymentInfo['transaction'];
         $title = ts('View Payment');
         if ($this->_component == 'event') {
             $info = CRM_Event_BAO_Participant::participantDetails($this->_id);
             $title .= " - {$info['title']}";
         }
         CRM_Utils_System::setTitle($title);
         $this->assign('transaction', TRUE);
         $this->assign('rows', $transactionRows);
         return;
     }
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
     $this->_formType = CRM_Utils_Array::value('formType', $_GET);
     $enitityType = NULL;
     if ($this->_component == 'event') {
         $enitityType = 'participant';
         $this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id');
     }
     $eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
     $this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($eventId);
     $paymentInfo = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($this->_id, $enitityType);
     $paymentDetails = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, FALSE, TRUE);
     $this->_amtPaid = $paymentDetails['paid'];
     $this->_amtTotal = $paymentDetails['total'];
     if (!empty($paymentInfo['refund_due'])) {
         $paymentAmt = $this->_refund = $paymentInfo['refund_due'];
         $this->_paymentType = 'refund';
     } elseif (!empty($paymentInfo['amount_owed'])) {
         $paymentAmt = $this->_owed = $paymentInfo['amount_owed'];
         $this->_paymentType = 'owed';
     } else {
         CRM_Core_Error::fatal(ts('No payment information found for this record'));
     }
     //set the payment mode - _mode property is defined in parent class
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     if (!empty($this->_mode) && $this->_paymentType == 'refund') {
         CRM_Core_Error::fatal(ts('Credit card payment is not for Refund payments use'));
     }
     list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
     $this->assignPaymentRelatedVariables();
     $this->assign('contributionMode', $this->_mode);
     $this->assign('contactId', $this->_contactId);
     $this->assign('paymentType', $this->_paymentType);
     $this->assign('paymentAmt', abs($paymentAmt));
     $this->setPageTitle($this->_refund ? ts('Refund') : ts('Payment'));
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:58,代码来源:AdditionalPayment.php

示例5: create

 /**
  * Create email address - note that the create function calls 'add' but
  * has more business logic
  *
  * @param array $params
  *   Input parameters.
  *
  * @return object
  */
 public static function create($params)
 {
     // if id is set & is_primary isn't we can assume no change
     if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) {
         CRM_Core_BAO_Block::handlePrimary($params, get_class());
     }
     $email = CRM_Core_BAO_Email::add($params);
     return $email;
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:18,代码来源:Email.php

示例6: 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

示例7: 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

示例8: 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

示例9: preProcess

 public function preProcess()
 {
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->_component = CRM_Utils_Request::retrieve('component', 'String', $this, TRUE);
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
     $this->_formType = CRM_Utils_Array::value('formType', $_GET);
     $enitityType = NULL;
     if ($this->_component == 'event') {
         $enitityType = 'participant';
         $this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id');
     }
     $eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
     $this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($eventId);
     $paymentInfo = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($this->_id, $enitityType);
     $paymentDetails = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component);
     $this->_amtPaid = $paymentDetails['paid'];
     $this->_amtTotal = $paymentDetails['total'];
     if (!empty($paymentInfo['refund_due'])) {
         $paymentAmt = $this->_refund = $paymentInfo['refund_due'];
         $this->_paymentType = 'refund';
     } elseif (!empty($paymentInfo['amount_owed'])) {
         $paymentAmt = $this->_owed = $paymentInfo['amount_owed'];
         $this->_paymentType = 'owed';
     } else {
         CRM_Core_Error::fatal(ts('No payment information found for this record'));
     }
     //set the payment mode - _mode property is defined in parent class
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     if (!empty($this->_mode) && $this->_paymentType == 'refund') {
         CRM_Core_Error::fatal(ts('Credit card payment is not for Refund payments use'));
     }
     list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
     if (!$this->_refund) {
         $this->assignProcessors();
         // also check for billing information
         // get the billing location type
         $this->assignBillingType();
     }
     $this->assign('contributionMode', $this->_mode);
     $this->assign('contactId', $this->_contactId);
     $this->assign('component', $this->_component);
     $this->assign('id', $this->_id);
     $this->assign('paymentType', $this->_paymentType);
     $this->assign('paymentAmt', abs($paymentAmt));
     $this->_paymentProcessor = array('billing_mode' => 1);
     $title = $this->_refund ? "Refund for {$this->_contributorDisplayName}" : "Payment from {$this->_contributorDisplayName}";
     if ($title) {
         CRM_Utils_System::setTitle(ts('%1', array(1 => $title)));
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:51,代码来源:AdditionalPayment.php

示例10: buildQuickForm

 /**
  * Build the form object elements for an email object.
  *
  * @param CRM_Core_Form $form
  *   Reference to the form object.
  * @param int $blockCount
  *   Block number to build.
  * @param bool $blockEdit
  *   Is it block edit.
  */
 public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE)
 {
     // passing this via the session is AWFUL. we need to fix this
     if (!$blockCount) {
         $blockId = $form->get('Email_Block_Count') ? $form->get('Email_Block_Count') : 1;
     } else {
         $blockId = $blockCount;
     }
     $form->applyFilter('__ALL__', 'trim');
     //Email box
     $form->addField("email[{$blockId}][email]", array('entity' => 'email'));
     $form->addRule("email[{$blockId}][email]", ts('Email is not valid.'), 'email');
     if (isset($form->_contactType) || $blockEdit) {
         //Block type
         $form->addField("email[{$blockId}][location_type_id]", array('entity' => 'email', 'placeholder' => NULL, 'class' => 'eight'));
         //TODO: Refactor on_hold field to select.
         $multipleBulk = CRM_Core_BAO_Email::isMultipleBulkMail();
         //On-hold select
         if ($multipleBulk) {
             $holdOptions = array(0 => ts('- select -'), 1 => ts('On Hold Bounce'), 2 => ts('On Hold Opt Out'));
             $form->addElement('select', "email[{$blockId}][on_hold]", '', $holdOptions);
         } else {
             $form->addField("email[{$blockId}][on_hold]", array('entity' => 'email', 'type' => 'advcheckbox'));
         }
         //Bulkmail checkbox
         $form->assign('multipleBulk', $multipleBulk);
         if ($multipleBulk) {
             $js = array('id' => "Email_" . $blockId . "_IsBulkmail");
             $form->addElement('advcheckbox', "email[{$blockId}][is_bulkmail]", NULL, '', $js);
         } else {
             $js = array('id' => "Email_" . $blockId . "_IsBulkmail");
             if (!$blockEdit) {
                 $js['onClick'] = 'singleSelect( this.id );';
             }
             $form->addElement('radio', "email[{$blockId}][is_bulkmail]", '', '', '1', $js);
         }
         //is_Primary radio
         $js = array('id' => "Email_" . $blockId . "_IsPrimary");
         if (!$blockEdit) {
             $js['onClick'] = 'singleSelect( this.id );';
         }
         $form->addElement('radio', "email[{$blockId}][is_primary]", '', '', '1', $js);
         if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') {
             $form->add('textarea', "email[{$blockId}][signature_text]", ts('Signature (Text)'), array('rows' => 2, 'cols' => 40));
             $form->add('wysiwyg', "email[{$blockId}][signature_html]", ts('Signature (HTML)'), array('rows' => 2, 'cols' => 40));
         }
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:58,代码来源:Email.php

示例11: testFindReferences

 function testFindReferences()
 {
     $params = array('first_name' => 'Testy', 'last_name' => 'McScallion', 'contact_type' => 'Individual');
     $contact = CRM_Contact_BAO_Contact::add($params);
     $this->assertNotNull($contact->id);
     $params = array('email' => 'spam@dev.null', 'contact_id' => $contact->id, 'is_primary' => 0, 'location_type_id' => 1);
     $email = CRM_Core_BAO_Email::add($params);
     $refs = $contact->findReferences();
     $refsByTable = array();
     foreach ($refs as $refObj) {
         $refsByTable[$refObj->__table] = $refObj;
     }
     $this->assertTrue(array_key_exists('civicrm_email', $refsByTable));
     $refDao = $refsByTable['civicrm_email'];
     $refDao->find(TRUE);
     $this->assertEquals($contact->id, $refDao->contact_id);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:17,代码来源:DAOTest.php

示例12: preProcess

 public function preProcess()
 {
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'membership');
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->assign('context', $this->_context);
     $this->assign('membershipMode', $this->_mode);
     $this->assign('contactID', $this->_contactID);
     if ($this->_mode) {
         $this->assignPaymentRelatedVariables();
     }
     if ($this->_id) {
         $this->_memType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id, 'membership_type_id');
         $this->_membershipIDs[] = $this->_id;
     }
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
 }
开发者ID:kidaa30,项目名称:yes,代码行数:19,代码来源:Form.php

示例13: add

 /**
  * takes an associative array and creates a contact object
  *
  * the function extract all the params it needs to initialize the create a
  * contact object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params         (reference ) an assoc array of name/value pairs
  * @param array  $ids            the array that holds all the db ids
  * @param int    $locationId
  * @param int    $emailId
  * @param bool   $isPrimary      Has any previous entry been marked as isPrimary?
  *
  * @return object    CRM_Core_BAO_Email object if successful 
  *                   else null will be returned
  * @access public
  * @static
  */
 function add(&$params, &$ids, $locationId, $emailId, &$isPrimary)
 {
     // if no data and we are not updating an exisiting record
     if (!CRM_Core_BAO_Email::dataExists($params, $locationId, $emailId, $ids)) {
         return null;
     }
     $email =& new CRM_Core_DAO_Email();
     $email->id = CRM_Utils_Array::value($emailId, $ids['location'][$locationId]['email']);
     $email->email = $params['location'][$locationId]['email'][$emailId]['email'];
     if (empty($email->email)) {
         $email->delete();
         return null;
     }
     $email->location_id = $params['location'][$locationId]['id'];
     // set this object to be the value of isPrimary and make sure no one else can be isPrimary
     $email->is_primary = $isPrimary;
     $isPrimary = false;
     return $email->save();
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:37,代码来源:Email.php

示例14: array

 /**
  * Register a subscription event.  Create a new contact if one does not
  * already exist.
  *
  * @param int $domain_id        The domain id of the new subscription
  * @param int $group_id         The group id to subscribe to
  * @param string $email         The email address of the (new) contact
  * @return int|null $se_id      The id of the subscription event, null on failure
  * @access public
  * @static
  */
 function &subscribe($domain_id, $group_id, $email)
 {
     /* First, find out if the contact already exists */
     $params = array('email' => $email, 'domain_id' => $domain_id);
     require_once 'CRM/Core/BAO/UFGroup.php';
     $contact_id = CRM_Core_BAO_UFGroup::findContact($params);
     CRM_Core_DAO::transaction('BEGIN');
     if (is_a($contact_id, CRM_Core_Error)) {
         require_once 'CRM/Core/BAO/LocationType.php';
         /* If the contact does not exist, create one. */
         $formatted = array('contact_type' => 'Individual');
         $value = array('email' => $email, 'location_type' => CRM_Core_BAO_LocationType::getDefaultID());
         _crm_add_formatted_param($value, $formatted);
         $contact =& crm_create_contact_formatted($formatted, CRM_IMPORT_PARSER_DUPLICATE_SKIP);
         if (is_a($contact, CRM_Core_Error)) {
             return null;
         }
         $contact_id = $contact->id;
     }
     require_once 'CRM/Core/BAO/Email.php';
     require_once 'CRM/Core/BAO/Location.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     /* Get the primary email id from the contact to use as a hash input */
     $dao =& new CRM_Core_DAO();
     $emailTable = CRM_Core_BAO_Email::getTableName();
     $locTable = CRM_Core_BAO_Location::getTableName();
     $contactTable = CRM_Contact_BAO_Contact::getTableName();
     $dao->query("SELECT {$emailTable}.id as email_id\n                    FROM {$emailTable}\n                    INNER JOIN {$locTable}\n                        ON  {$emailTable}.location_id = {$locTable}.id\n                    WHERE   {$emailTable}.is_primary = 1\n                    AND     {$locTable}.is_primary = 1\n                    AND     {$locTable}.entity_table = '{$contactTable}'\n                    AND     {$locTable}.entity_id = " . CRM_Utils_Type::escape($contact_id, 'Integer'));
     $dao->fetch();
     $se =& new CRM_Mailing_Event_BAO_Subscribe();
     $se->group_id = $group_id;
     $se->contact_id = $contact_id;
     $se->time_stamp = date('YmdHis');
     $se->hash = sha1("{$group_id}:{$contact_id}:{$dao->email_id}");
     $se->save();
     $contacts = array($contact_id);
     require_once 'CRM/Contact/BAO/GroupContact.php';
     CRM_Contact_BAO_GroupContact::addContactsToGroup($contacts, $group_id, 'Email', 'Pending', $se->id);
     CRM_Core_DAO::transaction('COMMIT');
     return $se;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:52,代码来源:Subscribe.php

示例15: 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


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