本文整理汇总了PHP中CRM_Core_BAO_UFMatch类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFMatch类的具体用法?PHP CRM_Core_BAO_UFMatch怎么用?PHP CRM_Core_BAO_UFMatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_UFMatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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);
}
示例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);
}
示例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']);
}
示例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'));
}
示例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;
}
示例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'));
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
}
}
示例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]));
}
}
}