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


PHP CRM_Contact_BAO_Contact::matchContactOnEmail方法代码示例

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


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

示例1: testMailchimpWebhookSubscribeNewContact

 function testMailchimpWebhookSubscribeNewContact()
 {
     $sync_settings = CRM_CiviMailchimp_BAO_SyncSettingsTest::createTestGroupAndSyncSettings('test_group_mailchimp_webhook_subscribe_new_contact');
     $sample_data = self::sampleRequestSubscribeOrProfileUpdate();
     CRM_CiviMailchimp_Page_Webhook::mailchimpWebhookSubscribe($sample_data);
     $new_contact = CRM_Contact_BAO_Contact::matchContactOnEmail($sample_data['email']);
     $this->assertTrue(CRM_Contact_BAO_GroupContact::isContactInGroup($new_contact->contact_id, $sync_settings->civicrm_group_id));
 }
开发者ID:jaapjansma,项目名称:com.giantrabbit.civimailchimp,代码行数:8,代码来源:WebhookTest.php

示例2: testMatchContactOnEmail

 /**
  * Test case for matchContactOnEmail( ).
  */
 public function testMatchContactOnEmail()
 {
     //get the contact params
     $params = $this->contactParams();
     //create contact
     $contact = CRM_Contact_BAO_Contact::create($params);
     $contactId = $contact->id;
     //get the matching contact.
     $match = CRM_Contact_BAO_Contact::matchContactOnEmail(CRM_Utils_Array::value('email', $params['email'][1]), 'Individual');
     $this->assertEquals($contactId, $match->contact_id, 'Check For Matching Contact');
     //cleanup DB by deleting the contact
     $this->contactDelete($contactId);
     $this->quickCleanup(array('civicrm_contact'));
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:17,代码来源:ContactTest.php

示例3: getContactID

 /**
  * Retrieve a contact ID and if not present.
  *
  * Create one with this email
  *
  * @param string $email
  * @param string $name
  * @param bool $create
  * @param string $mail
  *
  * @return int|null
  */
 public static function getContactID($email, $name = NULL, $create = TRUE, &$mail)
 {
     $dao = CRM_Contact_BAO_Contact::matchContactOnEmail($email, 'Individual');
     $contactID = NULL;
     if ($dao) {
         $contactID = $dao->contact_id;
     }
     $result = NULL;
     CRM_Utils_Hook::emailProcessorContact($email, $contactID, $result);
     if (!empty($result)) {
         if ($result['action'] == self::EMAILPROCESSOR_IGNORE) {
             return NULL;
         }
         if ($result['action'] == self::EMAILPROCESSOR_OVERRIDE) {
             return $result['contactID'];
         }
         // else this is now create individual
         // so we just fall out and do what we normally do
     }
     if ($contactID) {
         return $contactID;
     }
     if (!$create) {
         return NULL;
     }
     // contact does not exist, lets create it
     $params = array('contact_type' => 'Individual', 'email-Primary' => $email);
     CRM_Utils_String::extractName($name, $params);
     return CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:42,代码来源:Incoming.php

示例4: CRM_Core_DAO_UFMatch

 /**
  * Synchronize the object with the UF Match entry. Can be called stand-alone from
  * the drupalUsers script
  *
  * @param Object $user
  *   The drupal user object.
  * @param string $userKey
  *   The id of the user from the uf object.
  * @param string $uniqId
  *   The OpenID of the user.
  * @param string $uf
  *   The name of the user framework.
  * @param int $status
  *   Returns the status if user created or already exits (used for CMS sync).
  * @param string $ctype
  *   contact type
  * @param bool $isLogin
  *
  * @return CRM_Core_DAO_UFMatch|bool
  */
 public static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $status = NULL, $ctype = NULL, $isLogin = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     if (!CRM_Utils_Rule::email($uniqId)) {
         $retVal = $status ? NULL : FALSE;
         return $retVal;
     }
     $newContact = FALSE;
     // make sure that a contact id exists for this user id
     $ufmatch = new CRM_Core_DAO_UFMatch();
     $ufmatch->domain_id = CRM_Core_Config::domainID();
     $ufmatch->uf_id = $userKey;
     if (!$ufmatch->find(TRUE)) {
         $transaction = new CRM_Core_Transaction();
         $dao = NULL;
         if (!empty($_POST) && !$isLogin) {
             $params = $_POST;
             $params['email'] = $uniqId;
             $dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
             $dedupeParams['check_permission'] = FALSE;
             $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
             if (!empty($ids) && Civi::settings()->get('uniq_email_per_site')) {
                 // restrict dupeIds to ones that belong to current domain/site.
                 $siteContacts = CRM_Core_BAO_Domain::getContactList();
                 foreach ($ids as $index => $dupeId) {
                     if (!in_array($dupeId, $siteContacts)) {
                         unset($ids[$index]);
                     }
                 }
                 // re-index the array
                 $ids = array_values($ids);
             }
             if (!empty($ids)) {
                 $dao = new CRM_Core_DAO();
                 $dao->contact_id = $ids[0];
             }
         } else {
             $dao = CRM_Contact_BAO_Contact::matchContactOnEmail($uniqId, $ctype);
         }
         $found = FALSE;
         if ($dao) {
             // ensure there does not exists a contact_id / uf_id pair
             // in the DB. This might be due to multiple emails per contact
             // CRM-9091
             $sql = "\nSELECT id\nFROM   civicrm_uf_match\nWHERE  contact_id = %1\nAND    domain_id = %2\n";
             $params = array(1 => array($dao->contact_id, 'Integer'), 2 => array(CRM_Core_Config::domainID(), 'Integer'));
             $conflict = CRM_Core_DAO::singleValueQuery($sql, $params);
             if (!$conflict) {
                 $found = TRUE;
                 $ufmatch->contact_id = $dao->contact_id;
                 $ufmatch->uf_name = $uniqId;
             }
         }
         if (!$found) {
             if ($config->userSystem->is_drupal) {
                 $mail = 'mail';
             } elseif ($uf == 'WordPress') {
                 $mail = 'user_email';
             } else {
                 $mail = 'email';
             }
             if (is_object($user)) {
                 $params = array('email-Primary' => $user->{$mail});
             }
             if ($ctype == 'Organization') {
                 $params['organization_name'] = $uniqId;
             } elseif ($ctype == 'Household') {
                 $params['household_name'] = $uniqId;
             }
             if (!$ctype) {
                 $ctype = "Individual";
             }
             $params['contact_type'] = $ctype;
             // extract first / middle / last name
             // for joomla
             if ($uf == 'Joomla' && $user->name) {
                 CRM_Utils_String::extractName($user->name, $params);
             }
             if ($uf == 'WordPress') {
                 if ($user->first_name) {
//.........这里部分代码省略.........
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:101,代码来源:UFMatch.php

示例5: checkRegistration

 /**
  * Method to check if the user is already registered for the event
  * and if result found redirect to the event info page
  *
  * @param array $fields  the input form values(anonymous user)
  * @param array $self    event data
  * @param boolean $isAdditional treat isAdditional participants a bit differently
  * @param boolean $returnContactId just find and return the contactID match to use
  * @param boolean $useDedupeRules force usage of dedupe rules
  *
  * @return void
  * @access public
  */
 static function checkRegistration($fields, &$self, $isAdditional = FALSE, $returnContactId = FALSE, $useDedupeRules = FALSE)
 {
     // CRM-3907, skip check for preview registrations
     // CRM-4320 participant need to walk wizard
     if (!$returnContactId && ($self->_mode == 'test' || $self->_allowConfirmation)) {
         return FALSE;
     }
     $contactID = NULL;
     $session = CRM_Core_Session::singleton();
     if (!$isAdditional) {
         $contactID = $self->getContactID();
     }
     if (!$contactID && is_array($fields) && $fields) {
         //CRM-6996
         //as we are allowing w/ same email address,
         //lets check w/ other contact params.
         if ($self->_values['event']['allow_same_participant_emails']) {
             $params = $fields;
             $level = $isAdditional ? 'Supervised' : 'Unsupervised';
             $dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
             // disable permission based on cache since event registration is public page/feature.
             $dedupeParams['check_permission'] = FALSE;
             $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual', $level);
             $contactID = CRM_Utils_Array::value(0, $ids);
         } else {
             foreach ($fields as $fieldname => $fieldvalue) {
                 if (substr($fieldname, 0, 6) == 'email-') {
                     $emailString = trim($fieldvalue);
                     if (!empty($emailString)) {
                         $match = CRM_Contact_BAO_Contact::matchContactOnEmail($emailString, 'Individual');
                         if (!empty($match)) {
                             $contactID = $match->contact_id;
                         }
                     }
                 }
             }
         }
     }
     if ($returnContactId) {
         // CRM-7377
         // return contactID if contact already exists
         return $contactID;
     }
     if ($contactID) {
         $participant = new CRM_Event_BAO_Participant();
         $participant->contact_id = $contactID;
         $participant->event_id = $self->_values['event']['id'];
         if (!empty($fields['participant_role']) && is_numeric($fields['participant_role'])) {
             $participant->role_id = $fields['participant_role'];
         } else {
             $participant->role_id = $self->_values['event']['default_role_id'];
         }
         $participant->is_test = 0;
         $participant->find();
         $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
         while ($participant->fetch()) {
             if (array_key_exists($participant->status_id, $statusTypes)) {
                 if (!$isAdditional && !$self->_values['event']['allow_same_participant_emails']) {
                     $registerUrl = CRM_Utils_System::url('civicrm/event/register', "reset=1&id={$self->_values['event']['id']}&cid=0");
                     if ($self->_pcpId) {
                         $registerUrl .= '&pcpId=' . $self->_pcpId;
                     }
                     $status = ts("It looks like you are already registered for this event. If you want to change your registration, or you feel that you've gotten this message in error, please contact the site administrator.") . ' ' . ts('You can also <a href="%1">register another participant</a>.', array(1 => $registerUrl));
                     $session->setStatus($status, ts('Oops.'), 'alert');
                     $url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$self->_values['event']['id']}&noFullMsg=true");
                     if ($self->_action & CRM_Core_Action::PREVIEW) {
                         $url .= '&action=preview';
                     }
                     if ($self->_pcpId) {
                         $url .= '&pcpId=' . $self->_pcpId;
                     }
                     CRM_Utils_System::redirect($url);
                 }
                 if ($isAdditional) {
                     $status = ts("It looks like this participant is already registered for this event. If you want to change your registration, or you feel that you've gotten this message in error, please contact the site administrator.");
                     $session->setStatus($status, ts('Oops.'), 'alert');
                     return $participant->id;
                 }
             }
         }
     }
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:95,代码来源:Register.php

示例6: getContactID

 /**
  * retrieve a contact ID and if not present
  * create one with this email
  */
 function getContactID($email, $name = null, $create = true)
 {
     require_once 'CRM/Contact/BAO/Contact.php';
     $dao = CRM_Contact_BAO_Contact::matchContactOnEmail($email, 'Individual');
     if ($dao) {
         return $dao->contact_id;
     }
     if (!$create) {
         return null;
     }
     // contact does not exist, lets create it
     $params = array('contact_type' => 'Individual', 'email-Primary' => $email);
     require_once 'CRM/Utils/String.php';
     CRM_Utils_String::extractName($name, $params);
     return CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:20,代码来源:Incoming.php

示例7: checkProfileComplete

 /**
  * Check whether profile (name, email) is complete
  *
  * return $contact_id
  */
 public static function checkProfileComplete($fields, &$errors, $self)
 {
     $email = '';
     foreach ($fields as $fieldname => $fieldvalue) {
         if (substr($fieldname, 0, 5) == 'email' && $fieldvalue) {
             $email = $fieldvalue;
         }
     }
     if (!$email && !(CRM_Utils_Array::value('first_name', $fields) && CRM_Utils_Array::value('last_name', $fields))) {
         $defaults = $params = array('id' => $eventId);
         CRM_Event_BAO_Event::retrieve($params, $defaults);
         $message = ts("Mandatory fields (first name and last name, OR email address) are missing from this form.");
         $errors['_qf_default'] = $message;
     }
     $contact = CRM_Contact_BAO_Contact::matchContactOnEmail($email, "");
     $contact_id = empty($contact->contact_id) ? NULL : $contact->contact_id;
     if (!CRM_Utils_Rule::email($fields['email'])) {
         $errors['email'] = ts('Enter valid email address.');
     }
     if (empty($errors) && empty($contact_id)) {
         $params = array('email-Primary' => CRM_Utils_Array::value('email', $fields, NULL), 'first_name' => CRM_Utils_Array::value('first_name', $fields, NULL), 'last_name' => CRM_Utils_Array::value('last_name', $fields, NULL), 'is_deleted' => CRM_Utils_Array::value('is_deleted', $fields, FALSE));
         //create new contact for this name/email pair
         //if new contact, no need to check for contact already registered
         $contact_id = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $contact_id);
     }
     return $contact_id;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:32,代码来源:SelfSvcTransfer.php

示例8: CRM_Core_DAO_UFMatch

 /**
  * Synchronize the object with the UF Match entry. Can be called stand-alone from
  * the drupalUsers script
  *
  * @param Object  $user    the drupal user object
  * @param string  $userKey the id of the user from the uf object
  * @param string  $uniqId    the OpenID of the user
  * @param string  $uf      the name of the user framework
  * @param integer $status  returns the status if user created or already exits (used for CMS sync)
  *
  * @return the ufmatch object that was found or created
  * @access public
  * @static
  */
 static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $status = null, $ctype = null, $isLogin = false)
 {
     // validate that uniqId is a valid url. it will either be
     // an OpenID (which should always be a valid url) or a
     // http://uf_username/ construction (so that it can
     // be used as an OpenID in the future)
     require_once 'CRM/Utils/Rule.php';
     if ($uf == 'Standalone') {
         if (!CRM_Utils_Rule::url($uniqId)) {
             return $status ? null : false;
         }
     } else {
         if (!CRM_Utils_Rule::email($uniqId)) {
             return $status ? null : false;
         }
     }
     $newContact = false;
     // make sure that a contact id exists for this user id
     $ufmatch =& new CRM_Core_DAO_UFMatch();
     if (CRM_Core_DAO::checkFieldExists('civicrm_uf_match', 'domain_id')) {
         // FIXME: if() condition check was required especially for upgrade cases (2.2.x -> 3.0.x),
         // where folks if happen to logout, would encounter a column not found fatal error
         $ufmatch->domain_id = CRM_Core_Config::domainID();
     }
     $ufmatch->uf_id = $userKey;
     if (!$ufmatch->find(true)) {
         require_once 'CRM/Core/Transaction.php';
         $transaction = new CRM_Core_Transaction();
         if (!empty($_POST) && !$isLogin) {
             $params = $_POST;
             $params['email'] = $uniqId;
             require_once 'CRM/Dedupe/Finder.php';
             $dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
             $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
             if (!empty($ids) && defined('CIVICRM_UNIQ_EMAIL_PER_SITE') && CIVICRM_UNIQ_EMAIL_PER_SITE) {
                 // restrict dupeIds to ones that belong to current domain/site.
                 require_once 'CRM/Core/BAO/Domain.php';
                 $siteContacts = CRM_Core_BAO_Domain::getContactList();
                 foreach ($ids as $index => $dupeId) {
                     if (!in_array($dupeId, $siteContacts)) {
                         unset($ids[$index]);
                     }
                 }
                 $ids = array_values($ids);
                 //re-index the array
             }
             if (!empty($ids)) {
                 $dao = new CRM_Core_DAO();
                 $dao->contact_id = $ids[0];
             }
         } else {
             require_once 'CRM/Contact/BAO/Contact.php';
             if ($uf == 'Standalone') {
                 $dao =& CRM_Contact_BAO_Contact::matchContactOnOpenId($uniqId, $ctype);
             } else {
                 $dao =& CRM_Contact_BAO_Contact::matchContactOnEmail($uniqId, $ctype);
             }
         }
         if ($dao) {
             //print "Found contact with uniqId $uniqId<br/>";
             $ufmatch->contact_id = $dao->contact_id;
             $ufmatch->uf_name = $uniqId;
         } else {
             if ($uf == 'Drupal') {
                 $mail = 'mail';
             } else {
                 $mail = 'email';
             }
             if (is_Object($user)) {
                 $params = array('email-Primary' => $user->{$mail});
             }
             if ($ctype == 'Organization') {
                 $params['organization_name'] = $uniqId;
             } else {
                 if ($ctype == 'Household') {
                     $params['household_name'] = $uniqId;
                 }
             }
             if (!$ctype) {
                 $ctype = "Individual";
             }
             $params['contact_type'] = $ctype;
             // extract first / middle / last name
             // for joomla
             if ($uf == 'Joomla' && $user->name) {
                 require_once 'CRM/Utils/String.php';
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:UFMatch.php

示例9: CRM_Core_DAO_UFMatch

 /**
  * Synchronize the object with the UF Match entry. Can be called stand-alone from
  * the drupalUsers script
  *
  * @param Object  $user    the drupal user object
  * @param string  $userKey the id of the user from the uf object
  * @param string  $uniqId    the OpenID of the user
  * @param string  $uf      the name of the user framework
  * @param integer $status  returns the status if user created or already exits (used for CMS sync)
  *
  * @return the ufmatch object that was found or created
  * @access public
  * @static
  */
 static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $status = null, $ctype = null)
 {
     // validate that uniqId is a valid url. it will either be
     // an OpenID (which should always be a valid url) or a
     // http://uf_username/ construction (so that it can
     // be used as an OpenID in the future)
     require_once 'CRM/Utils/Rule.php';
     if ($uf == 'Standalone') {
         if (!CRM_Utils_Rule::url($uniqId)) {
             return $status ? null : false;
         }
     } else {
         if (!CRM_Utils_Rule::email($uniqId)) {
             return $status ? null : false;
         }
     }
     $newContact = false;
     // make sure that a contact id exists for this user id
     $ufmatch =& new CRM_Core_DAO_UFMatch();
     if (CRM_Core_DAO::checkFieldExists('civicrm_uf_match', 'domain_id')) {
         // FIXME: if() condition check was required especially for upgrade cases (2.2.x -> 3.0.x),
         // where folks if happen to logout, would encounter a column not found fatal error
         $ufmatch->domain_id = CRM_Core_Config::domainID();
     }
     $ufmatch->uf_id = $userKey;
     if (!$ufmatch->find(true)) {
         require_once 'CRM/Core/Transaction.php';
         $transaction = new CRM_Core_Transaction();
         if (!empty($_POST)) {
             $params = $_POST;
             $params['email'] = $uniqId;
             require_once 'CRM/Dedupe/Finder.php';
             $dedupeParams = CRM_Dedupe_Finder::formatParams($params, 'Individual');
             $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
             if (!empty($ids)) {
                 $dao = new CRM_Core_DAO();
                 $dao->contact_id = $ids[0];
             }
         } else {
             require_once 'CRM/Contact/BAO/Contact.php';
             if ($uf == 'Standalone') {
                 $dao =& CRM_Contact_BAO_Contact::matchContactOnOpenId($uniqId, $ctype);
             } else {
                 $dao =& CRM_Contact_BAO_Contact::matchContactOnEmail($uniqId, $ctype);
             }
         }
         if ($dao) {
             //print "Found contact with uniqId $uniqId<br/>";
             $ufmatch->contact_id = $dao->contact_id;
             $ufmatch->uf_name = $uniqId;
         } else {
             if ($uf == 'Drupal') {
                 $mail = 'mail';
             } else {
                 $mail = 'email';
             }
             if (is_Object($user)) {
                 $params = array('email-Primary' => $user->{$mail});
             }
             if ($ctype == 'Organization') {
                 $params['organization_name'] = $uniqId;
             } else {
                 if ($ctype == 'Household') {
                     $params['household_name'] = $uniqId;
                 }
             }
             if (!$ctype) {
                 $ctype = "Individual";
             }
             $params['contact_type'] = $ctype;
             // extract first / middle / last name
             // for joomla
             if ($uf == 'Joomla' && $user->name) {
                 require_once 'CRM/Utils/String.php';
                 CRM_Utils_String::extractName($user->name, $params);
             }
             if ($uf == 'Standalone') {
                 $params['openid-Primary'] = $uniqId;
                 //need to delete below code once profile is
                 //exposed on signup page
                 if (!empty($user->first_name) || !empty($user->last_name)) {
                     $params['first_name'] = $user->first_name;
                     $params['last_name'] = $user->last_name;
                 } elseif (!empty($user->name)) {
                     require_once 'CRM/Utils/String.php';
                     CRM_Utils_String::extractName($user->name, $params);
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:civicrm,代码行数:101,代码来源:UFMatch.php

示例10: testMatchContactOnEmail

 /**
  * test case for matchContactOnEmail( ) 
  * 
  */
 function testMatchContactOnEmail()
 {
     //get the contact params
     $params = $this->contactParams();
     //create contact
     require_once 'CRM/Contact/BAO/Contact.php';
     $contact = CRM_Contact_BAO_Contact::create($params);
     $contactId = $contact->id;
     //get the matching contact.
     $match = CRM_Contact_BAO_Contact::matchContactOnEmail(CRM_Utils_Array::value('email', $params['email'][1]), 'Individual');
     $this->assertEquals($contactId, $match->contact_id, 'Check For Matching Contact');
     //cleanup DB by deleting the contact
     Contact::delete($contactId);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:18,代码来源:ContactTest.php


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