本文整理汇总了PHP中CRM_Core_BAO_UFMatch::create方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFMatch::create方法的具体用法?PHP CRM_Core_BAO_UFMatch::create怎么用?PHP CRM_Core_BAO_UFMatch::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFMatch
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFMatch::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Create CMS user using Profile.
*
* @param array $params
* @param string $mail
* Email id for cms user.
*
* @return int
* contact id that has been created
*/
public static function create(&$params, $mail)
{
$config = CRM_Core_Config::singleton();
$ufID = $config->userSystem->createUser($params, $mail);
//if contact doesn't already exist create UF Match
if ($ufID !== FALSE && isset($params['contactID'])) {
// create the UF Match record
$ufmatch['uf_id'] = $ufID;
$ufmatch['contact_id'] = $params['contactID'];
$ufmatch['uf_name'] = $params[$mail];
CRM_Core_BAO_UFMatch::create($ufmatch);
}
return $ufID;
}
示例2: testContactGetByUsername
/**
* Test for Contact.get id=@user:username.
*/
public function testContactGetByUsername()
{
// Setup - create contact with a uf-match.
$cid = $this->individualCreate(array('contact_type' => 'Individual', 'first_name' => 'testGetByUsername', 'last_name' => 'testGetByUsername'));
$ufMatchParams = array('domain_id' => CRM_Core_Config::domainID(), 'uf_id' => 99, 'uf_name' => 'the-email-matching-key-is-not-really-the-username', 'contact_id' => $cid);
$ufMatch = CRM_Core_BAO_UFMatch::create($ufMatchParams);
$this->assertTrue(is_numeric($ufMatch->id));
// setup - mock the calls to CRM_Utils_System_*::getUfId
$userSystem = $this->getMock('CRM_Utils_System_UnitTests', array('getUfId'));
$userSystem->expects($this->once())->method('getUfId')->with($this->equalTo('exampleUser'))->will($this->returnValue(99));
CRM_Core_Config::singleton()->userSystem = $userSystem;
// perform a lookup
$result = $this->callAPISuccess('Contact', 'get', array('id' => '@user:exampleUser'));
$this->assertEquals('testGetByUsername', $result['values'][$cid]['first_name']);
}
示例3: updateContactEmail
/**
* Update the email value for the contact and user profile.
*
* @param int $contactId
* Contact ID of the user.
* @param string $emailAddress
* Email to be modified for the user.
*/
public static function updateContactEmail($contactId, $emailAddress)
{
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
$emailAddress = $strtolower($emailAddress);
$ufmatch = new CRM_Core_DAO_UFMatch();
$ufmatch->contact_id = $contactId;
$ufmatch->domain_id = CRM_Core_Config::domainID();
if ($ufmatch->find(TRUE)) {
// Save the email in UF Match table
$ufmatch->uf_name = $emailAddress;
CRM_Core_BAO_UFMatch::create((array) $ufmatch);
//check if the primary email for the contact exists
//$contactDetails[1] - email
//$contactDetails[3] - email id
$contactDetails = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactId);
if (trim($contactDetails[1])) {
$emailID = $contactDetails[3];
//update if record is found
$query = "UPDATE civicrm_email\n SET email = %1\n WHERE id = %2";
$p = array(1 => array($emailAddress, 'String'), 2 => array($emailID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $p);
} else {
//else insert a new email record
$email = new CRM_Core_DAO_Email();
$email->contact_id = $contactId;
$email->is_primary = 1;
$email->email = $emailAddress;
$email->save();
$emailID = $email->id;
}
CRM_Core_BAO_Log::register($contactId, 'civicrm_email', $emailID);
}
}