本文整理汇总了PHP中CRM_Core_BAO_UFMatch类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFMatch类的具体用法?PHP CRM_Core_BAO_UFMatch怎么用?PHP CRM_Core_BAO_UFMatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_UFMatch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: check
/**
* Given a permission string, check for access requirements
*
* @param string $str
* The permission to check.
*
* @return bool
* true if yes, else false
*/
public function check($str)
{
$config = CRM_Core_Config::singleton();
$translated = $this->translateJoomlaPermission($str);
if ($translated === CRM_Core_Permission::ALWAYS_DENY_PERMISSION) {
return FALSE;
}
if ($translated === CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) {
return TRUE;
}
// ensure that we are running in a joomla context
// we've not yet figured out how to bootstrap joomla, so we should
// not execute hooks if joomla is not loaded
if (defined('_JEXEC')) {
$user = JFactory::getUser();
$api_key = CRM_Utils_Request::retrieve('api_key', 'String', $store, FALSE, NULL, 'REQUEST');
// If we are coming from REST we don't have a user but we do have the api_key for a user.
if ($user->id === 0 && !is_null($api_key)) {
// This is a codeblock copied from /Civicrm/Utils/REST
$uid = NULL;
if (!$uid) {
$store = NULL;
$contact_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key');
if ($contact_id) {
$uid = CRM_Core_BAO_UFMatch::getUFId($contact_id);
}
$user = JFactory::getUser($uid);
}
}
return $user->authorise($translated[0], $translated[1]);
} else {
return FALSE;
}
}
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:43,代码来源:Joomla.php
示例2: civicrm_invoke
function civicrm_invoke()
{
civicrm_init();
plugin_init();
$user = JFactory::getUser();
/* bypass synchronize if running upgrade
* to avoid any serious non-recoverable error
* which might hinder the upgrade process.
*/
require_once 'CRM/Utils/Array.php';
if (CRM_Utils_Array::value('task', $_REQUEST) != 'civicrm/upgrade') {
require_once 'CRM/Core/BAO/UFMatch.php';
CRM_Core_BAO_UFMatch::synchronize($user, FALSE, 'Joomla', 'Individual', TRUE);
}
require_once 'CRM/Utils/System/Joomla.php';
CRM_Utils_System_Joomla::addHTMLHead(NULL, TRUE);
if (isset($_GET['task'])) {
$args = explode('/', trim($_GET['task']));
} else {
$_GET['task'] = 'civicrm/dashboard';
$_GET['reset'] = 1;
$args = array('civicrm', 'dashboard');
}
CRM_Core_Invoke::invoke($args);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:25,代码来源:admin.civicrm.php
示例3: civicrm_invoke
function civicrm_invoke()
{
civicrm_init();
global $my;
require_once 'CRM/Core/BAO/UFMatch.php';
CRM_Core_BAO_UFMatch::synchronize($my, false, 'Mambo');
$args = explode('/', trim($_GET['task']));
CRM_Core_Invoke::invoke($args);
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:9,代码来源:admin.civicrm.php
示例4: onUserAfterDelete
function onUserAfterDelete($user, $succes, $msg)
{
$app = JFactory::getApplication();
// Instantiate CiviCRM
require_once JPATH_ROOT . '/administrator/components/com_civicrm/civicrm.settings.php';
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton();
// Delete UFMatch
CRM_Core_BAO_UFMatch::deleteUser($user['id']);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:10,代码来源:civicrm.php
示例5: synchronize
/**
* Function for synchronizing cms users with CiviCRM contacts
*
* @param NULL
*
* @return void
*
* @static
* @access public
*/
static function synchronize()
{
//start of schronization code
$config =& CRM_Core_Config::singleton();
CRM_Core_Error::ignoreException();
$db_uf =& self::dbHandle($config);
if ($config->userFramework == 'Drupal') {
$id = 'uid';
$mail = 'mail';
$name = 'name';
} else {
if ($config->userFramework == 'Joomla') {
$id = 'id';
$mail = 'email';
$name = 'name';
} else {
CRM_Core_Error::fatal("CMS user creation not supported for this framework");
}
}
set_time_limit(300);
$sql = "SELECT {$id}, {$mail}, {$name} FROM {$config->userFrameworkUsersTableName} where {$mail} != ''";
$query = $db_uf->query($sql);
$user = new StdClass();
$uf = $config->userFramework;
$contactCount = 0;
$contactCreated = 0;
$contactMatching = 0;
while ($row = $query->fetchRow(DB_FETCHMODE_ASSOC)) {
$user->{$id} = $row[$id];
$user->{$mail} = $row[$mail];
$user->{$name} = $row[$name];
$contactCount++;
if ($match = CRM_Core_BAO_UFMatch::synchronizeUFMatch($user, $row[$id], $row[$mail], $uf, 1)) {
$contactCreated++;
} else {
$contactMatching++;
}
if (is_object($match)) {
$match->free();
}
}
$db_uf->disconnect();
//end of schronization code
$status = ts('Synchronize Users to Contacts completed.');
$status .= ' ' . ts('Checked one user record.', array('count' => $contactCount, 'plural' => 'Checked %count user records.'));
if ($contactMatching) {
$status .= ' ' . ts('Found one matching contact record.', array('count' => $contactMatching, 'plural' => 'Found %count matching contact records.'));
}
$status .= ' ' . ts('Created one new contact record.', array('count' => $contactCreated, 'plural' => 'Created %count new contact records.'));
CRM_Core_Session::setStatus($status, true);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:62,代码来源:CMSUser.php
示例6: 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;
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:24,代码来源:CMSUser.php
示例7: synchronize
/**
* Function for synchronizing drupal users with CiviCRM contacts
*
* @param NULL
*
* @return void
*
* @static
* @access public
*/
function synchronize()
{
//start of schronization code
$config =& CRM_Core_Config::singleton();
/**
* Update the next line with the correct Drupal database user, password, db_server and db name
* for your Drupal installation.
*/
$db_drupal = DB::connect($config->userFrameworkDSN);
if (DB::isError($db_drupal)) {
die("Cannot connect to UF db via {$dsn}, " . $db_drupal->getMessage());
}
if ($config->userFramework == 'Drupal') {
$id = 'uid';
$mail = 'mail';
} else {
if ($config->userFramework == 'Mambo') {
$id = 'id';
$mail = 'email';
} else {
die("Unknown user framework");
}
}
$sql = "SELECT {$id}, {$mail} FROM {$config->userFrameworkUsersTableName} where {$mail} != ''";
$query = $db_drupal->query($sql);
$user = null;
$uf = 'Drupal';
$contactCount = 0;
$contactCreated = 0;
$contactMatching = 0;
while ($row = $query->fetchRow(DB_FETCHMODE_ASSOC)) {
$contactCount++;
if (CRM_Core_BAO_UFMatch::synchronizeUFMatch($user, $row[$id], $row[$mail], $uf, 1)) {
$contactCreated++;
} else {
$contactMatching++;
}
}
$db_drupal->disconnect();
//end of schronization code
$status = ts('Synchronize Users to Contacts completed.');
$status .= ' ' . ts('Checked one user record.', array('count' => $contactCount, 'plural' => 'Checked %count user records.'));
if ($contactMatching) {
$status .= ' ' . ts('Found one matching contact record.', array('count' => $contactMatching, 'plural' => 'Found %count matching contact records.'));
}
$status .= ' ' . ts('Created one new contact record.', array('count' => $contactCreated, 'plural' => 'Created %count new contact records.'));
CRM_Core_Session::setStatus($status);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:59,代码来源:DrupalUser.php
示例8: contactID
static function contactID($ufID)
{
$contactID = CRM_Core_BAO_UFMatch::getContactId($ufID);
if ($contactID) {
return $contactID;
}
// else synchronize contact for this user
$account = user_load($ufID);
CRM_Core_BAO_UFMatch::synchronizeUFMatch($account, $ufID, $account->mail, 'Drupal');
$contactID = CRM_Core_BAO_UFMatch::getContactId($ufID);
if (!$contactID) {
CRM_Core_Error::fatal();
}
return $contactID;
}
开发者ID:hguru,项目名称:224Civi,代码行数:15,代码来源:Utils.php
示例9: civicrm_invoke
function civicrm_invoke()
{
civicrm_init();
plugin_init();
$user = JFactory::getUser();
require_once 'CRM/Core/BAO/UFMatch.php';
CRM_Core_BAO_UFMatch::synchronize($user, false, 'Joomla', 'Individual');
if (isset($_GET['task'])) {
$args = explode('/', trim($_GET['task']));
CRM_Core_Invoke::invoke($args);
} else {
$_GET['task'] = 'civicrm/dashboard';
$_GET['reset'] = 1;
$args = array('civicrm', 'dashboard');
CRM_Core_Invoke::invoke($args);
}
}
开发者ID:ksecor,项目名称:civicrm,代码行数:17,代码来源:admin.civicrm.php
示例10: groupContact
static function groupContact($groupID, $contactIDs, $op)
{
$config = CRM_Core_Config::singleton();
$ogID = CRM_Bridge_OG_Utils::ogID($groupID, FALSE);
if (!$ogID) {
return;
}
foreach ($contactIDs as $contactID) {
$drupalID = CRM_Core_BAO_UFMatch::getUFId($contactID);
if ($drupalID) {
if ($op == 'add') {
$group_membership = $config->userSystem->og_membership_create($ogID, $drupalID);
} else {
$group_membership = $config->userSystem->og_membership_delete($ogID, $drupalID);
}
}
}
}
开发者ID:hguru,项目名称:224Civi,代码行数:18,代码来源:CiviCRM.php
示例11: civicrm_invoke
function civicrm_invoke()
{
civicrm_init();
// check and ensure that we have a valid session
if (!empty($_POST)) {
// the session should not be empty
// however for standalone forms, it will not have any CiviCRM variables in the
// session either, so dont check for it
if (count($_SESSION) <= 1) {
require_once 'CRM/Utils/System.php';
$config =& CRM_Core_Config::singleton();
CRM_Utils_System::redirect($config->userFrameworkBaseURL);
}
}
// add all the values from the itemId param
// overrride the GET values if conflict
if (CRM_Utils_Array::value('Itemid', $_GET)) {
$component =& JComponentHelper::getComponent('com_civicrm');
$menu =& JSite::getMenu();
$item = $menu->getItems('componentid', $component->id, true);
$params = $menu->getParams($_GET['Itemid']);
$args = array('task', 'id', 'gid', 'reset', 'pageId', 'action');
foreach ($args as $a) {
$val = $params->get($a, null);
if ($val !== null) {
$_GET[$a] = $val;
}
}
}
$task = CRM_Utils_Array::value('task', $_GET, '');
$args = explode('/', trim($task));
// check permission
if (!civicrm_check_permission($args)) {
echo "You do not have permission to execute this url.";
return;
}
require_once 'CRM/Utils/System/Joomla.php';
CRM_Utils_System_Joomla::addHTMLHead(null, true);
$user = JFactory::getUser();
require_once 'CRM/Core/BAO/UFMatch.php';
CRM_Core_BAO_UFMatch::synchronize($user, false, 'Joomla', 'Individual');
CRM_Core_Invoke::invoke($args);
}
开发者ID:bhirsch,项目名称:civicrm,代码行数:43,代码来源:civicrm.php
示例12: run
function run()
{
$openid = getOpenIDURL();
$consumer = getConsumer();
// Begin the OpenID authentication process.
$auth_request = $consumer->begin($openid);
// No auth request means we can't begin OpenID.
if (!$auth_request) {
// check for new install, if no, go to index, else goto new-install page
require_once 'CRM/Core/BAO/UFMatch.php';
$contactIds = CRM_Core_BAO_UFMatch::getContactIDs();
if (count($contactIds) > 0) {
displayError("Authentication error; not a valid OpenID.");
} else {
$session =& CRM_Core_Session::singleton();
$session->set('new_install', true);
include 'new_install.html';
exit(1);
}
}
$sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
if ($sreg_request) {
$auth_request->addExtension($sreg_request);
}
$policy_uris = null;
if (isset($_REQUEST['policies'])) {
$policy_uris = $_REQUEST['policies'];
}
$pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
if ($pape_request) {
$auth_request->addExtension($pape_request);
}
$redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
// If the redirect URL can't be built, display an error
// message.
if (Auth_OpenID::isFailure($redirect_url)) {
displayError("Could not redirect to server: " . $redirect_url->message);
} else {
// Send redirect.
header("Location: " . $redirect_url);
exit(2);
}
}
开发者ID:ksecor,项目名称:civicrm,代码行数:43,代码来源:try_auth.php
示例13: civicrm_invoke
function civicrm_invoke()
{
civicrm_init();
// check and ensure that we have a valid session
if (!empty($_POST)) {
// the session should not be empty
// however for standalone forms, it will not have any CiviCRM variables in the
// session either, so dont check for it
if (count($_SESSION) <= 1) {
require_once 'CRM/Utils/System.php';
$config = CRM_Core_Config::singleton();
CRM_Utils_System::redirect($config->userFrameworkBaseURL);
}
}
// add all the values from the itemId param
// overrride the GET values if conflict
if (CRM_Utils_Array::value('Itemid', $_GET)) {
$component = JComponentHelper::getComponent('com_civicrm');
$menu = JSite::getMenu();
$params = $menu->getParams($_GET['Itemid']);
$args = array('task', 'id', 'gid', 'pageId', 'action', 'csid');
$view = CRM_Utils_Array::value('view', $_GET);
if ($view) {
$args[] = 'reset';
}
foreach ($args as $a) {
$val = $params->get($a, NULL);
if ($val !== NULL && $view) {
$_GET[$a] = $val;
}
}
}
$task = CRM_Utils_Array::value('task', $_GET, '');
$args = explode('/', trim($task));
require_once 'CRM/Utils/System/Joomla.php';
CRM_Utils_System_Joomla::addHTMLHead(NULL, TRUE);
$user = JFactory::getUser();
require_once 'CRM/Core/BAO/UFMatch.php';
CRM_Core_BAO_UFMatch::synchronize($user, FALSE, 'Joomla', 'Individual', TRUE);
CRM_Core_Invoke::invoke($args);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:41,代码来源:civicrm.php
示例14: groupContact
static function groupContact($groupID, $contactIDs, $op)
{
$ogID = CRM_Bridge_OG_Utils::ogID($groupID, FALSE);
if (!$ogID) {
return;
}
foreach ($contactIDs as $contactID) {
$drupalID = CRM_Core_BAO_UFMatch::getUFId($contactID);
if ($drupalID) {
if ($op == 'add') {
$group_membership = og_membership_create($ogID, 'user', $drupalID, array('is_active' => 1));
$group_membership->save();
} else {
$membership = og_get_group_membership($ogID, 'user', $drupalID);
if ($membership) {
og_membership_delete($membership->id);
}
}
}
}
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:21,代码来源:CiviCRM.php
示例15: invoke
function invoke()
{
$session =& CRM_Core_Session::singleton();
$config =& CRM_Core_Config::singleton();
// display error if any
showError($session);
$urlVar = $config->userFrameworkURLVar;
require_once 'CRM/Core/Invoke.php';
if ($session->get('userID') == null || $session->get('userID') == '') {
if ($_GET[$urlVar] == "") {
require_once "CRM/Core/BAO/UFMatch.php";
if (CRM_Core_BAO_UFMatch::isEmptyTable() == false) {
include 'login.html';
} else {
$session->set('new_install', true);
include 'new_install.html';
}
exit(1);
} else {
$str = '';
if ($session->get('new_install') !== true && $_GET[$urlVar] !== "civicrm/standalone/register") {
$str = "<a href=\"{$config->userFrameworkBaseURL}\">Login here</a> if you have an account.\n";
} elseif ($_GET[$urlVar] == "civicrm/standalone/register" && isset($_GET['reset'])) {
// this is when user first registers with civicrm
print "<head><style type=\"text/css\"> body {border: 1px #CCC solid;margin: 3em;padding: 1em 1em 1em 2em;} </style></head>\n";
}
print $str . CRM_Core_Invoke::invoke(explode('/', $_GET[$urlVar]));
}
} else {
if ($_GET[$urlVar] == "") {
print CRM_Core_Invoke::invoke(array("civicrm", "dashboard"));
} else {
print CRM_Core_Invoke::invoke(explode('/', $_GET[$urlVar]));
}
}
}
开发者ID:ksecor,项目名称:civicrm,代码行数:36,代码来源:index.php
示例16: authenticate
/**
* Authenticate the user against the wordpress db
*
* @param string $name the user name
* @param string $password the password for the above user name
*
* @return mixed false if no auth
* array(
contactID, ufID, unique string ) if success
* @access public
* @static
*/
function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL)
{
$config = CRM_Core_Config::singleton();
if ($loadCMSBootstrap) {
$config->userSystem->loadBootStrap($name, $password);
}
$user = wp_authenticate($name, $password);
if (is_a($user, 'WP_Error')) {
return FALSE;
}
// need to change this to make sure we matched only one row
CRM_Core_BAO_UFMatch::synchronizeUFMatch($user->data, $user->data->ID, $user->data->user_email, 'WordPress');
$contactID = CRM_Core_BAO_UFMatch::getContactId($user->data->ID);
if (!$contactID) {
return FALSE;
}
return array($contactID, $user->data->ID, mt_rand());
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:30,代码来源:WordPress.php
示例17: loadCMSBootstrap
/**
* @return array|NULL
* NULL if execution should proceed; array if the response is already known
*/
public function loadCMSBootstrap()
{
$requestParams = CRM_Utils_Request::exportValues();
$q = CRM_Utils_array::value('q', $requestParams);
$args = explode('/', $q);
// Proceed with bootstrap for "?entity=X&action=Y"
// Proceed with bootstrap for "?q=civicrm/X/Y" but not "?q=civicrm/ping"
if (!empty($q)) {
if (count($args) == 2 && $args[1] == 'ping') {
return NULL;
// this is pretty wonky but maybe there's some reason I can't see
}
if (count($args) != 3) {
return self::error('ERROR: Malformed REST path');
}
if ($args[0] != 'civicrm') {
return self::error('ERROR: Malformed REST path');
}
// Therefore we have reasonably well-formed "?q=civicrm/X/Y"
}
if (!CRM_Utils_System::authenticateKey(FALSE)) {
// FIXME: At time of writing, this doesn't actually do anything because
// authenticateKey abends, but that's a bad behavior which sends a
// malformed response.
return self::error('Failed to authenticate key');
}
$uid = NULL;
if (!$uid) {
$store = NULL;
$api_key = CRM_Utils_Request::retrieve('api_key', 'String', $store, FALSE, NULL, 'REQUEST');
if (empty($api_key)) {
return self::error("FATAL: mandatory param 'api_key' (user key) missing");
}
$contact_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key');
if ($contact_id) {
$uid = CRM_Core_BAO_UFMatch::getUFId($contact_id);
}
}
if ($uid) {
CRM_Utils_System::loadBootStrap(array('uid' => $uid), TRUE, FALSE);
return NULL;
} else {
return self::error('ERROR: No CMS user associated with given api-key');
}
}
开发者ID:kidaa30,项目名称:yes,代码行数:49,代码来源:REST.php
示例18: synchronizeUsers
/**
* @inheritDoc
*/
public function synchronizeUsers()
{
$config = CRM_Core_Config::singleton();
if (PHP_SAPI != 'cli') {
set_time_limit(300);
}
$id = 'ID';
$mail = 'user_email';
$uf = $config->userFramework;
$contactCount = 0;
$contactCreated = 0;
$contactMatching = 0;
global $wpdb;
$wpUserIds = $wpdb->get_col("SELECT {$wpdb->users}.ID FROM {$wpdb->users}");
foreach ($wpUserIds as $wpUserId) {
$wpUserData = get_userdata($wpUserId);
$contactCount++;
if ($match = CRM_Core_BAO_UFMatch::synchronizeUFMatch($wpUserData, $wpUserData->{$id}, $wpUserData->{$mail}, $uf, 1, 'Individual', TRUE)) {
$contactCreated++;
} else {
$contactMatching++;
}
if (is_object($match)) {
$match->free();
}
}
return array('contactCount' => $contactCount, 'contactMatching' => $contactMatching, 'contactCreated' => $contactCreated);
}
开发者ID:sarehag,项目名称:civicrm-core,代码行数:31,代码来源:WordPress.php
示例19: preProcess
function preProcess()
{
if (!CRM_Core_Permission::check('merge duplicate contacts')) {
CRM_Core_Error::fatal(ts('You do not have access to this page'));
}
$rows = array();
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, TRUE);
$flip = CRM_Utils_Request::retrieve('flip', 'Positive', $this, FALSE);
$this->_rgid = $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE);
$this->_gid = $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE);
$this->_mergeId = CRM_Utils_Request::retrieve('mergeId', 'Positive', $this, FALSE);
if (!CRM_Dedupe_BAO_Rule::validateContacts($cid, $oid)) {
CRM_Core_Error::statusBounce(ts('The selected pair of contacts are marked as non duplicates. If these records should be merged, you can remove this exception on the <a href=\'%1\'>Dedupe Exceptions</a> page.', array(1 => CRM_Utils_System::url('civicrm/dedupe/exception', 'reset=1'))));
}
//load cache mechanism
$contactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'contact_type');
$cacheKey = "merge {$contactType}";
$cacheKey .= $rgid ? "_{$rgid}" : '_0';
$cacheKey .= $gid ? "_{$gid}" : '_0';
$join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND\n pn.entity_id2 = de.contact_id2 )";
$where = "de.id IS NULL";
$pos = CRM_Core_BAO_PrevNextCache::getPositions($cacheKey, $cid, $oid, $this->_mergeId, $join, $where, $flip);
// Block access if user does not have EDIT permissions for both contacts.
if (!(CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT) && CRM_Contact_BAO_Contact_Permission::allow($oid, CRM_Core_Permission::EDIT))) {
CRM_Utils_System::permissionDenied();
}
// get user info of main contact.
$config = CRM_Core_Config::singleton();
$config->doNotResetCache = 1;
$viewUser = CRM_Core_Permission::check('access user profiles');
$mainUfId = CRM_Core_BAO_UFMatch::getUFId($cid);
$mainUser = NULL;
if ($mainUfId) {
// d6 compatible
if ($config->userSystem->is_drupal == '1') {
$mainUser = user_load($mainUfId);
} elseif ($config->userFramework == 'Joomla') {
$mainUser = JFactory::getUser($mainUfId);
}
$this->assign('mainUfId', $mainUfId);
$this->assign('mainUfName', $mainUser ? $mainUser->name : NULL);
}
$flipUrl = CRM_Utils_System::url('civicrm/contact/merge', "reset=1&action=update&cid={$oid}&oid={$cid}&rgid={$rgid}&gid={$gid}");
if (!$flip) {
$flipUrl .= '&flip=1';
}
$this->assign('flip', $flipUrl);
$this->prev = $this->next = NULL;
foreach (array('prev', 'next') as $position) {
if (!empty($pos[$position])) {
if ($pos[$position]['id1'] && $pos[$position]['id2']) {
$urlParam = "reset=1&cid={$pos[$position]['id1']}&oid={$pos[$position]['id2']}&mergeId={$pos[$position]['mergeId']}&action=update";
if ($rgid) {
$urlParam .= "&rgid={$rgid}";
}
if ($gid) {
$urlParam .= "&gid={$gid}";
}
$this->{$position} = CRM_Utils_System::url('civicrm/contact/merge', $urlParam);
$this->assign($position, $this->{$position});
}
}
}
// get user info of other contact.
$otherUfId = CRM_Core_BAO_UFMatch::getUFId($oid);
$otherUser = NULL;
if ($otherUfId) {
// d6 compatible
if ($config->userSystem->is_drupal == '1') {
$otherUser = user_load($otherUfId);
} elseif ($config->userFramework == 'Joomla') {
$otherUser = JFactory::getUser($otherUfId);
}
$this->assign('otherUfId', $otherUfId);
$this->assign('otherUfName', $otherUser ? $otherUser->name : NULL);
}
$cmsUser = $mainUfId && $otherUfId ? TRUE : FALSE;
$this->assign('user', $cmsUser);
$session = CRM_Core_Session::singleton();
// context fixed.
if ($rgid) {
$urlParam = "reset=1&action=browse&rgid={$rgid}";
if ($gid) {
$urlParam .= "&gid={$gid}";
}
$session->pushUserContext(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlParam));
}
// ensure that oid is not the current user, if so refuse to do the merge
if ($session->get('userID') == $oid) {
$display_name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $oid, 'display_name');
$message = ts('The contact record which is linked to the currently logged in user account - \'%1\' - cannot be deleted.', array(1 => $display_name));
CRM_Core_Error::statusBounce($message);
}
$rowsElementsAndInfo = CRM_Dedupe_Merger::getRowsElementsAndInfo($cid, $oid);
$main =& $rowsElementsAndInfo['main_details'];
$other =& $rowsElementsAndInfo['other_details'];
if ($main['contact_id'] != $cid) {
CRM_Core_Error::fatal(ts('The main contact record does not exist'));
}
//.........这里部分代码省略.........
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:Merge.php
示例20: getUserID
static function getUserID($user)
{
//FIXME: look here a bit closer when testing UFMatch
require_once 'CRM/Core/BAO/UFMatch.php';
// this puts the appropriate values in the session, so
// no need to return anything
CRM_Core_BAO_UFMatch::synchronize($user, true, 'Standalone', 'Individual');
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:8,代码来源:UnitTests.php
注:本文中的CRM_Core_BAO_UFMatch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论