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


PHP CRM_Core_BAO_Email::add方法代码示例

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


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

示例1: testHoldEmail

 /**
  * HoldEmail() method (set and reset on_hold condition)
  */
 public function testHoldEmail()
 {
     $contactId = Contact::createIndividual();
     $params = array();
     $params = array('email' => 'jane.doe@example.com', 'is_primary' => 1, 'location_type_id' => 1, 'contact_id' => $contactId);
     CRM_Core_BAO_Email::add($params);
     $emailId = $this->assertDBNotNull('CRM_Core_DAO_Email', 'jane.doe@example.com', 'id', 'email', 'Database check for created email address.');
     // Now call add() to update on_hold=true and check record state
     $params = array();
     $params = array('id' => $emailId, 'contact_id' => $contactId, 'on_hold' => 1);
     CRM_Core_BAO_Email::add($params);
     // Use assertDBNotNull to get back value of hold_date and check if it's in the current year.
     // NOTE: The assertEquals will fail IF this test is run just as the year is changing (low likelihood).
     $holdDate = $this->assertDBNotNull('CRM_Core_DAO_Email', $emailId, 'hold_date', 'id', 'Retrieve hold_date from the updated email record.');
     $this->assertEquals(substr($holdDate, 0, 4), substr(date('YmdHis'), 0, 4), 'Compare hold_date (' . $holdDate . ') in DB to current year.');
     $this->assertDBCompareValue('CRM_Core_DAO_Email', $emailId, 'on_hold', 'id', 1, 'Check if on_hold=1 in updated email record.');
     // Now call add() with on_hold=false and verify that reset_date is set.
     $params = array();
     $params = array('id' => $emailId, 'contact_id' => $contactId, 'on_hold' => 'null');
     CRM_Core_BAO_Email::add($params);
     $this->assertDBCompareValue('CRM_Core_DAO_Email', $emailId, 'on_hold', 'id', 0, 'Check if on_hold=0 in updated email record.');
     $this->assertDBCompareValue('CRM_Core_DAO_Email', $emailId, 'hold_date', 'id', '', 'Check if hold_date has been set to empty string.');
     // Use assertDBNotNull to get back value of reset_date and check if it's in the current year.
     // NOTE: The assertEquals will fail IF this test is run just as the year is changing (low likelihood).
     $resetDate = $this->assertDBNotNull('CRM_Core_DAO_Email', $emailId, 'reset_date', 'id', 'Retrieve reset_date from the updated email record.');
     $this->assertEquals(substr($resetDate, 0, 4), substr(date('YmdHis'), 0, 4), 'Compare reset_date (' . $resetDate . ') in DB to current year.');
     Contact::delete($contactId);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:31,代码来源:EmailTest.php

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

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

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

示例5: testTimestampsEmail

 /**
  * Ensure that civicrm_contact.modified_date is updated when manipulating a phone record.
  */
 public function testTimestampsEmail()
 {
     $test = $this;
     $this->_testTimestamps(array('INSERT' => function ($contactId) use($test) {
         $params = array('email' => 'ex-1@example.com', 'is_primary' => 1, 'location_type_id' => 1, 'contact_id' => $contactId);
         CRM_Core_BAO_Email::add($params);
         $test->assertDBQuery('ex-1@example.com', 'SELECT email FROM civicrm_email WHERE contact_id = %1 ORDER BY id DESC LIMIT 1', array(1 => array($contactId, 'Integer')));
     }, 'UPDATE' => function ($contactId) use($test) {
         CRM_Core_DAO::executeQuery('UPDATE civicrm_email SET email = "ex-2@example.com" WHERE contact_id = %1', array(1 => array($contactId, 'Integer')));
     }, 'DELETE' => function ($contactId) use($test) {
         CRM_Core_DAO::executeQuery('DELETE FROM civicrm_email WHERE contact_id = %1', array(1 => array($contactId, 'Integer')));
     }));
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:16,代码来源:ContactTest.php

示例6: mailchimpWebhookCleaned

 /**
  * Put a Mailchimp subscriber's email On Hold in CiviCRM.
  */
 static function mailchimpWebhookCleaned($request_data)
 {
     $mailchimp_contact = CRM_CiviMailchimp_Utils::getContactInMailchimpListByEmail($request_data['email'], $request_data['list_id']);
     foreach ($mailchimp_contact->email as $email) {
         if ($email->email === $request_data['email']) {
             // We have to go the circuitous route to saving so we can trigger
             // CiviCRM's hooks to allow other extensions to act.
             $params = array();
             CRM_Core_DAO::storeValues($email, $params);
             $params['on_hold'] = 1;
             CRM_Core_BAO_Email::add($params);
         }
     }
 }
开发者ID:kbrownell,项目名称:com.giantrabbit.civimailchimp,代码行数:17,代码来源:Webhook.php

示例7: 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 array  $locationId     
  *
  * @return object   CRM_Core_BAO_Location object on success, null otherwise
  * @access public
  * @static
  */
 function add(&$params, &$ids, $locationId)
 {
     if (!CRM_Core_BAO_Location::dataExists($params, $locationId, $ids)) {
         return null;
     }
     $location =& new CRM_Core_BAO_Location();
     if (!isset($params['contact_id'])) {
         require_once 'CRM/Core/BAO/Domain.php';
         $location->entity_table = CRM_Core_BAO_Domain::getTableName();
         $location->entity_id = $params['domain_id'];
     } else {
         $location->entity_table = CRM_Contact_BAO_Contact::getTableName();
         $location->entity_id = $params['contact_id'];
     }
     $location->location_type_id = CRM_Utils_Array::value('location_type_id', $params['location'][$locationId]);
     $location->name = CRM_Utils_Array::value('name', $params['location'][$locationId]);
     $location->is_primary = CRM_Utils_Array::value('is_primary', $params['location'][$locationId], false);
     // check if there exists another location has is_primary set, and if so reset that
     // if no location has is_primary, make this one is_primart
     if ($location->is_primary) {
         // reset all other locations with the same entity table entity id
         $sql = "UPDATE " . CRM_Core_BAO_Location::getTableName() . "\n SET is_primary = 0 WHERE \n entity_table = '{$location->entity_table}' AND\n entity_id    = '{$location->entity_id}' ";
         CRM_Core_DAO::executeQuery($sql);
     } else {
         // make sure there is at once location with is_primary set
         $sql = "SELECT count( " . CRM_Core_BAO_Location::getTableName() . ".id )\n FROM " . CRM_Core_BAO_Location::getTableName() . " WHERE\n entity_table = '{$location->entity_table}' AND\n entity_id    = '{$location->entity_id}'    AND\n is_primary   = 1";
         $count = CRM_Core_DAO::singleValueQuery($sql);
         if ($count == 0) {
             $location->is_primary = true;
         }
     }
     $location->id = CRM_Utils_Array::value('id', $ids['location'][$locationId]);
     $location->save();
     $params['location'][$locationId]['id'] = $location->id;
     $address_object = CRM_Core_BAO_Address::add($params, $ids, $locationId);
     $location->address = $address_object;
     // set this to true if this has been made the primary IM.
     // the rule is the first entered value is the primary object
     $isPrimaryPhone = $isPrimaryEmail = $isPrimaryIM = true;
     $location->phone = array();
     $location->email = array();
     $location->im = array();
     for ($i = 1; $i <= CRM_CONTACT_FORM_LOCATION_BLOCKS; $i++) {
         $location->phone[$i] = CRM_Core_BAO_Phone::add($params, $ids, $locationId, $i, $isPrimaryPhone);
         $location->email[$i] = CRM_Core_BAO_Email::add($params, $ids, $locationId, $i, $isPrimaryEmail);
         $location->im[$i] = CRM_Core_BAO_IM::add($params, $ids, $locationId, $i, $isPrimaryIM);
     }
     return $location;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:64,代码来源:Location.php


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