本文整理汇总了PHP中CRM_Core_BAO_UFMatch::getUFId方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFMatch::getUFId方法的具体用法?PHP CRM_Core_BAO_UFMatch::getUFId怎么用?PHP CRM_Core_BAO_UFMatch::getUFId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFMatch
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFMatch::getUFId方法的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: 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);
}
}
}
}
示例3: 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);
}
}
}
}
}
示例4: preProcess
public function preProcess()
{
if (!CRM_Core_Permission::check('merge duplicate contacts')) {
CRM_Core_Error::fatal(ts('You do not have access to this page'));
}
$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 = 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);
$this->limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this, FALSE);
$urlParams = "reset=1&rgid={$this->_rgid}&gid={$this->_gid}&limit=" . $this->limit;
// Sanity check
if ($cid == $oid) {
CRM_Core_Error::statusBounce(ts('Cannot merge a contact with itself.'));
}
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'))));
}
$this->_contactType = civicrm_api3('Contact', 'getvalue', array('id' => $cid, 'return' => 'contact_type'));
$isFromDedupeScreen = TRUE;
if (!$this->_rgid) {
$isFromDedupeScreen = FALSE;
$this->_rgid = civicrm_api3('RuleGroup', 'getvalue', array('contact_type' => $this->_contactType, 'used' => 'Supervised', 'return' => 'id'));
}
$cacheKey = CRM_Dedupe_Merger::getMergeCacheKeyString($this->_rgid, $gid);
$join = CRM_Dedupe_Merger::getJoinOnDedupeTable();
$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={$this->_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']) {
$urlParams .= "&cid={$pos[$position]['id1']}&oid={$pos[$position]['id2']}&mergeId={$pos[$position]['mergeId']}&action=update";
$this->{$position} = CRM_Utils_System::url('civicrm/contact/merge', $urlParams);
$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 ($isFromDedupeScreen) {
$browseUrl = CRM_Utils_System::url('civicrm/contact/dedupefind', $urlParams . '&action=browse');
$session->pushUserContext($browseUrl);
}
$this->assign('browseUrl', empty($browseUrl) ? '' : $browseUrl);
// 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 = $this->_mainDetails =& $rowsElementsAndInfo['main_details'];
$other = $this->_otherDetails =& $rowsElementsAndInfo['other_details'];
if ($main['contact_id'] != $cid) {
CRM_Core_Error::fatal(ts('The main contact record does not exist'));
}
if ($other['contact_id'] != $oid) {
//.........这里部分代码省略.........
示例5: getRowsElementsAndInfo
//.........这里部分代码省略.........
// Load the type options for this entity
$typeOptions = civicrm_api3($blockName, 'getoptions', array('field' => $blockInfo['hasType']));
// CRM-17556 Set up JS lookup of 'main' contact's value by type
if (!empty($locations['main'][$blockName])) {
$js = array('onChange' => "mergeBlock('{$blockName}', this, {$count}, 'typeTypeId' );");
}
$thisTypeId = $value[$blockInfo['hasType']];
// Put this field's location type at the top of the list
$tmpIdList = $typeOptions['values'];
$defaultTypeId = array($thisTypeId => $tmpIdList[$thisTypeId]);
unset($tmpIdList[$thisTypeId]);
// Add the element
$elements[] = array('select', "location[{$blockName}][{$count}][typeTypeId]", NULL, $defaultTypeId + $tmpIdList, $js);
// Add the information to the migrationInfo (@todo Why?)
$migrationInfo['location_blocks'][$blockName][$count]['typeTypeId'] = $thisTypeId;
}
// Set the label for this row
$rowTitle = $blockInfo['label'] . ' ' . ($count + 1);
if (!empty($thisLocId)) {
$rowTitle .= ' (' . $locationOptions['values'][$thisLocId] . ')';
}
if (!empty($thisTypeId)) {
$rowTitle .= ' (' . $typeOptions['values'][$thisTypeId] . ')';
}
$rows["move_location_{$blockName}_{$count}"]['title'] = $rowTitle;
}
// End loop through 'other' locations of this type
}
// End if 'other' location for this type exists
}
// End loop through each location block entity
// add the related tables and unset the ones that don't sport any of the duplicate contact's info
$config = CRM_Core_Config::singleton();
$mainUfId = CRM_Core_BAO_UFMatch::getUFId($mainId);
$mainUser = NULL;
if ($mainUfId) {
// d6 compatible
if ($config->userSystem->is_drupal == '1' && function_exists($mainUser)) {
$mainUser = user_load($mainUfId);
} elseif ($config->userFramework == 'Joomla') {
$mainUser = JFactory::getUser($mainUfId);
}
}
$otherUfId = CRM_Core_BAO_UFMatch::getUFId($otherId);
$otherUser = NULL;
if ($otherUfId) {
// d6 compatible
if ($config->userSystem->is_drupal == '1' && function_exists($mainUser)) {
$otherUser = user_load($otherUfId);
} elseif ($config->userFramework == 'Joomla') {
$otherUser = JFactory::getUser($otherUfId);
}
}
$relTables = CRM_Dedupe_Merger::relTables();
$activeRelTables = CRM_Dedupe_Merger::getActiveRelTables($otherId);
$activeMainRelTables = CRM_Dedupe_Merger::getActiveRelTables($mainId);
foreach ($relTables as $name => $null) {
if (!in_array($name, $activeRelTables) && !($name == 'rel_table_users' && in_array($name, $activeMainRelTables))) {
unset($relTables[$name]);
continue;
}
$relTableElements[] = array('checkbox', "move_{$name}");
$migrationInfo["move_{$name}"] = 1;
$relTables[$name]['main_url'] = str_replace('$cid', $mainId, $relTables[$name]['url']);
$relTables[$name]['other_url'] = str_replace('$cid', $otherId, $relTables[$name]['url']);
if ($name == 'rel_table_users') {
示例6: preProcess
/**
* Heart of the viewing process. The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
*
* @return void
* @access public
*
*/
function preProcess()
{
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->assign('id', $this->_id);
// retrieve the group contact id, so that we can get contact id
$gcid = CRM_Utils_Request::retrieve('gcid', 'Positive', $this);
if (!$gcid) {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
} else {
$this->_contactId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_GroupContact', $gcid, 'contact_id');
}
if (!$this->_contactId) {
CRM_Core_Error::statusBounce(ts('We could not find a contact id.'));
}
$this->assign('contactId', $this->_contactId);
$path = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('View Contact'), 'url' => $path)));
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Search Results'), 'url' => self::getSearchURL())));
// also store in session for future use
$session =& CRM_Core_Session::singleton();
$session->set('view.id', $this->_contactId);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
$this->assign('action', $this->_action);
// check for permissions
$this->_permission = null;
// automatically grant permissin for users on their own record. makes
// things easier in dashboard
require_once 'CRM/Contact/BAO/Contact/Permission.php';
if ($session->get('userID') == $this->_contactId) {
$this->assign('permission', 'edit');
$this->_permission = CRM_Core_Permission::EDIT;
} else {
if (CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
$this->assign('permission', 'edit');
$this->_permission = CRM_Core_Permission::EDIT;
} else {
if (CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::VIEW)) {
$this->assign('permission', 'view');
$this->_permission = CRM_Core_Permission::VIEW;
} else {
$session->pushUserContext(CRM_Utils_System::url('civicrm', 'reset=1'));
CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to view this contact.'));
}
}
}
$this->getContactDetails();
$contactImage = $this->get('contactImage');
$displayName = $this->get('displayName');
$contactType = $this->get('contactType');
$contactSubtype = $this->get('contactSubType');
$contactImageUrl = $this->get('contactImageUrl');
$this->assign('displayName', $displayName);
// see if other modules want to add a link activtity bar
require_once 'CRM/Utils/Hook.php';
$hookLinks = CRM_Utils_Hook::links('view.contact.activity', 'Contact', $this->_contactId);
if (is_array($hookLinks)) {
$this->assign('hookLinks', $hookLinks);
}
CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId), $this->_contactId, $contactType, $this->_contactId, $displayName, $contactImageUrl, $contactSubtype);
//display OtherActivity link
$otherAct = CRM_Core_PseudoConstant::activityType(false);
$activityNum = count($otherAct);
$this->assign('showOtherActivityLink', $activityNum);
$config =& CRM_Core_Config::singleton();
require_once 'CRM/Core/BAO/UFMatch.php';
if ($uid = CRM_Core_BAO_UFMatch::getUFId($this->_contactId)) {
if ($config->userFramework == 'Drupal') {
$url = CRM_Utils_System::url('user/' . $uid);
} else {
if ($config->userFramework == 'Joomla') {
$url = $config->userFrameworkBaseURL . 'index2.php?option=com_users&view=user&task=edit&cid[]=' . $uid;
} else {
$url = null;
}
}
$this->assign('url', $url);
}
if (CRM_Core_Permission::check('access Contact Dashboard')) {
$dashboardURL = CRM_Utils_System::url('civicrm/user', "reset=1&id={$this->_contactId}");
$this->assign('dashboardURL', $dashboardURL);
}
if ($contactType == 'Organization' && CRM_Core_Permission::check('administer Multiple Organizations')) {
require_once 'CRM/Contact/BAO/GroupOrganization.php';
//check is any relationship between the organization and groups
$groupOrg = CRM_Contact_BAO_GroupOrganization::hasGroupAssociated($this->_contactId);
if ($groupOrg) {
$groupOrganizationUrl = CRM_Utils_System::url('civicrm/group', "reset=1&oid={$this->_contactId}");
$this->assign('groupOrganizationUrl', $groupOrganizationUrl);
}
}
}
示例7: 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');
}
}
示例8: 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'));
}
//.........这里部分代码省略.........
示例9: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$session = CRM_Core_Session::singleton();
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$contributionParams = $requestParams = $_REQUEST;
$contactID = $session->get('userID');
if ($contactID && empty($contributionParams['email'])) {
$emailDetails = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
if (!empty($emailDetails)) {
$contributionParams['email'] = $emailDetails[1];
// for email to be prefilled
$this->assign('email', $emailDetails[1]);
}
}
$pageConfig = civicrm_api3('ContributionPage', 'getsingle', array('id' => $this->_id));
if (is_array($pageConfig['payment_processor'])) {
CRM_Core_Error::fatal(ts('Multiple payment processors not supported with quick donate.'));
}
$processorDetails = CRM_Financial_BAO_PaymentProcessor::getPayment($pageConfig['payment_processor'], 'live');
//MV: get amount details if other amount enabled for contribution page.
if ($pageConfig['amount_block_is_active']) {
$sql = "SELECT cpfv.amount, cpfv.is_default, cpfv.weight \n FROM civicrm_price_field_value cpfv \n INNER JOIN civicrm_price_field cpf ON (cpf.id = cpfv.price_field_id)\n INNER JOIN civicrm_price_set_entity cpse ON (cpse.price_set_id = cpf.price_set_id)\n WHERE cpse.entity_id = %1 AND cpf.name = 'contribution_amount'\n ";
$dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($pageConfig['id'], 'Integer')));
$amount = 0;
while ($dao->fetch()) {
if ($dao->weight == 1 || $dao->is_default == 1) {
$amount = $dao->amount;
}
}
}
$pageConfig['default_amount'] = $amount ? $amount : $pageConfig['min_amount'];
$pageConfig['currency_symbol'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_Currency', $pageConfig['currency'], 'symbol', 'name');
$this->assign('pageConfig', $pageConfig);
$this->assign('key', $processorDetails['password']);
$this->assign('currency', strtolower($pageConfig['currency']));
if (!empty($requestParams['stripe_token'])) {
//FIXME: could go in post process
if (!$contributionParams['email']) {
CRM_Core_Error::fatal(ts('Email address is required'));
}
$contributionParams['financial_type_id'] = $pageConfig['financial_type_id'];
if (!$contactID) {
$contactParams = array('email' => $contributionParams['email'], 'contact_type' => 'Individual');
$dedupeParams = CRM_Dedupe_Finder::formatParams($contactParams, 'Individual');
$dedupeParams['check_permission'] = FALSE;
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
// if we find more than one contact, use the first one
$contactID = CRM_Utils_Array::value(0, $ids);
if (!$contactID) {
$cont = civicrm_api3('Contact', 'create', $contactParams);
$contactID = $cont['id'];
}
}
$contributionParams['contact_id'] = $contactID;
$contributionParams['payment_processor_id'] = $pageConfig['payment_processor'];
$contributionParams['currencyID'] = $pageConfig['currency'];
//gift aid
//get gift aid custom field id
$sqlCF = "SELECT cf.id \n FROM civicrm_custom_field cf \n INNER JOIN civicrm_custom_group cg ON (cg.id = cf.custom_group_id) \n WHERE cg.name = %1 AND cf.name = %2";
$sqlCFParams = array(1 => array(self::C_CUSTOM_GROUP_GIFT_AID, 'String'), 2 => array(self::C_CUSTOM_FIELD_GIFT_AID, 'String'));
$cfId = CRM_Core_DAO::singleValueQuery($sqlCF, $sqlCFParams);
if ($cfId && $contributionParams['donation_form']['gift_aid']) {
$contributionParams["custom_{$cfId}"] = 1;
}
//gift aid end
//campaign
if ($pageConfig['campaign_id']) {
$contributionParams['campaign_id'] = $pageConfig['campaign_id'];
}
try {
$result = civicrm_api3('Contribution', 'transact', $contributionParams);
} catch (CiviCRM_API3_Exception $e) {
$error = $e->getMessage();
$this->assign('error', $error);
CRM_Utils_System::setTitle(ts('Oops! There was a problem'));
}
if (!empty($result['error'])) {
$this->assign('error', $result['error']);
CRM_Utils_System::setTitle(ts('Oops! There was a problem'));
} else {
if ($result) {
$contributionID = $result['id'];
$contactID = $result['values'][$contributionID]['contact_id'];
// Send receipt
civicrm_api3('contribution', 'sendconfirmation', array('id' => $contributionID) + $pageConfig);
CRM_Utils_System::setTitle(ts('Thank you'));
$this->assign('status', 'thankyou');
$profileID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'Supporter Profile', 'id', 'title');
// Link (button) for users to create their own Personal Campaign page
if ($profileID && !$session->get('userID')) {
$ufId = CRM_Core_BAO_UFMatch::getUFId($contactID);
if ($ufId) {
$config = CRM_Core_Config::singleton();
$loginURL = $config->userSystem->getLoginURL();
$this->assign('loginURL', $loginURL);
//.........这里部分代码省略.........
示例10: getUserRecordUrl
/**
* @inheritDoc
*/
public function getUserRecordUrl($contactID)
{
$uid = CRM_Core_BAO_UFMatch::getUFId($contactID);
$userRecordUrl = NULL;
// if logged in user is super user, then he can view other users joomla profile
if (JFactory::getUser()->authorise('core.admin')) {
return CRM_Core_Config::singleton()->userFrameworkBaseURL . "index.php?option=com_users&view=user&task=user.edit&id=" . $uid;
} elseif (CRM_Core_Session::singleton()->get('userID') == $contactID) {
return CRM_Core_Config::singleton()->userFrameworkBaseURL . "index.php?option=com_admin&view=profile&layout=edit&id=" . $uid;
}
}
示例11: woocommercecivicrm_civicrm_tabs
/**
* Implements hook_civicrm_tabs().
*/
function woocommercecivicrm_civicrm_tabs(&$tabs, $cid)
{
$uid = CRM_Core_BAO_UFMatch::getUFId($cid);
if (empty($uid)) {
return;
}
$orders = _woocommercecivicrm_customer_orders($uid);
//$history = woocommerce_civicrm_contact_transaction($uid, FALSE);
//$count = count($history['orders']['#rows']);
$url = CRM_Utils_System::url('civicrm/woocommerce/view/purchases', "reset=1&uid={$uid}&snippet=1&force=1");
$tabs[] = array('id' => 'woocommerce-orders', 'url' => $url, 'title' => 'Orders', 'count' => count($orders), 'weight' => 99);
}
开发者ID:rajeshrhino,项目名称:uk.co.vedaconsulting.module.woocommercecivicrm,代码行数:15,代码来源:woocommercecivicrm.php
示例12: preProcess
//.........这里部分代码省略.........
}
if (isset($pos['next'])) {
$navContacts['nextContactID'] = $pos['next']['id1'];
$navContacts['nextContactName'] = $pos['next']['data'];
$found = TRUE;
}
if (!$found) {
// seems like we did not find any contacts
// maybe due to bug CRM-9096
// however we should account for 1 contact results (which dont have prev next)
if (!$pos['foundEntry']) {
$navContacts['nextPrevError'] = 1;
}
}
}
$this->assign($navContacts);
$path = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('View Contact'), 'url' => $path)));
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Search Results'), 'url' => self::getSearchURL())));
if ($image_URL = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'image_URL')) {
//CRM-7265 --time being fix.
$config = CRM_Core_Config::singleton();
$image_URL = str_replace('https://', 'http://', $image_URL);
if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL')) {
$image_URL = str_replace('http://', 'https://', $image_URL);
}
list($imageWidth, $imageHeight) = getimagesize($image_URL);
list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
$this->assign("imageWidth", $imageWidth);
$this->assign("imageHeight", $imageHeight);
$this->assign("imageThumbWidth", $imageThumbWidth);
$this->assign("imageThumbHeight", $imageThumbHeight);
$this->assign("imageURL", $image_URL);
}
// also store in session for future use
$session = CRM_Core_Session::singleton();
$session->set('view.id', $this->_contactId);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->assign('action', $this->_action);
// check logged in user permission
self::checkUserPermission($this);
list($displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl) = self::getContactDetails($this->_contactId);
$this->assign('displayName', $displayName);
$this->set('contactType', $contactType);
$this->set('contactSubtype', $contactSubtype);
// see if other modules want to add a link activtity bar
$hookLinks = CRM_Utils_Hook::links('view.contact.activity', 'Contact', $this->_contactId, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject);
if (is_array($hookLinks)) {
$this->assign('hookLinks', $hookLinks);
}
// add to recently viewed block
$isDeleted = (bool) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'is_deleted');
$recentOther = array('imageUrl' => $contactImageUrl, 'subtype' => $contactSubtype, 'isDeleted' => $isDeleted);
if ($session->get('userID') == $this->_contactId || CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$this->_contactId}");
}
if ($session->get('userID') != $this->_contactId && CRM_Core_Permission::check('delete contacts') && !$isDeleted) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/delete', "reset=1&delete=1&cid={$this->_contactId}");
}
CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactId}"), $this->_contactId, $contactType, $this->_contactId, $displayName, $recentOther);
$this->assign('isDeleted', $isDeleted);
// set page title
self::setTitle($this->_contactId, $isDeleted);
$config = CRM_Core_Config::singleton();
$uid = CRM_Core_BAO_UFMatch::getUFId($this->_contactId);
if ($uid) {
// To do: we should also allow drupal users with CRM_Core_Permission::check( 'view user profiles' ) true to access $userRecordUrl
// but this is currently returning false regardless of permission set for the role. dgg
if ($config->userSystem->is_drupal == '1' && ($session->get('userID') == $this->_contactId || CRM_Core_Permission::check('administer users'))) {
$userRecordUrl = CRM_Utils_System::url('user/' . $uid);
} elseif ($config->userFramework == 'Joomla') {
$userRecordUrl = NULL;
// if logged in user is super user, then he can view other users joomla profile
if (JFactory::getUser()->authorise('core.admin')) {
$userRecordUrl = $config->userFrameworkBaseURL . "index.php?option=com_users&view=user&task=user.edit&id=" . $uid;
} elseif ($session->get('userID') == $this->_contactId) {
$userRecordUrl = $config->userFrameworkBaseURL . "index.php?option=com_admin&view=profile&layout=edit&id=" . $uid;
}
} else {
$userRecordUrl = NULL;
}
$this->assign('userRecordUrl', $userRecordUrl);
$this->assign('userRecordId', $uid);
} elseif ($config->userSystem->is_drupal == '1' && CRM_Core_Permission::check('administer users') || $config->userFramework == 'Joomla' && JFactory::getUser()->authorise('core.create', 'com_users')) {
$userAddUrl = CRM_Utils_System::url('civicrm/contact/view/useradd', 'reset=1&action=add&cid=' . $this->_contactId);
$this->assign('userAddUrl', $userAddUrl);
}
if (CRM_Core_Permission::check('access Contact Dashboard')) {
$dashboardURL = CRM_Utils_System::url('civicrm/user', "reset=1&id={$this->_contactId}");
$this->assign('dashboardURL', $dashboardURL);
}
if ($contactType == 'Organization' && CRM_Core_Permission::check('administer Multiple Organizations') && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME, 'is_enabled')) {
//check is any relationship between the organization and groups
$groupOrg = CRM_Contact_BAO_GroupOrganization::hasGroupAssociated($this->_contactId);
if ($groupOrg) {
$groupOrganizationUrl = CRM_Utils_System::url('civicrm/group', "reset=1&oid={$this->_contactId}");
$this->assign('groupOrganizationUrl', $groupOrganizationUrl);
}
}
}
示例13: view
/**
* View summary details of a contact
*
* @return void
* @access public
*/
function view()
{
$params = array();
$defaults = array();
$ids = array();
$params['id'] = $params['contact_id'] = $this->_contactId;
$contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, $ids);
CRM_Contact_BAO_Contact::resolveDefaults($defaults);
if (CRM_Utils_Array::value('gender_id', $defaults)) {
$gender = CRM_Core_PseudoConstant::gender();
$defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)];
}
// get the list of all the categories
$tag =& CRM_Core_PseudoConstant::tag();
// get categories for the contact id
require_once 'CRM/Core/BAO/EntityTag.php';
$entityTag =& CRM_Core_BAO_EntityTag::getTag('civicrm_contact', $this->_contactId);
if ($entityTag) {
$categories = array();
foreach ($entityTag as $key) {
$categories[] = $tag[$key];
}
$defaults['contactTag'] = implode(', ', $categories);
}
$defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
$this->assign($defaults);
$this->setShowHide($defaults);
// get the contributions, new style of doing stuff
// do the below only if the person has access to contributions
$config =& CRM_Core_Config::singleton();
if (CRM_Utils_System::accessCiviContribute()) {
$this->assign('accessContribution', true);
$controller =& new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), $this->_action);
$controller->setEmbedded(true);
$controller->reset();
$controller->set('limit', 3);
$controller->set('force', 1);
$controller->set('cid', $this->_contactId);
$controller->set('context', 'basic');
$controller->process();
$controller->run();
} else {
$this->assign('accessContribution', false);
}
//add link to CMS user
if ($uid = CRM_Core_BAO_UFMatch::getUFId($this->_contactId)) {
if ($config->userFramework == 'Drupal') {
$url = CRM_Utils_System::url('user/' . $uid);
} else {
//$url = CRM_Utils_System::url( 'option=com_users&task=editA&hidemainmenu=1&id=' . $uid );
$url = $config->userFrameworkBaseURL . 'index2.php?option=com_users&task=editA&hidemainmenu=1&id=' . $uid;
}
$this->assign('url', $url);
}
}
示例14: civi_contact_updated
/**
* Update a WP user when a CiviCRM contact is updated
*
* @param string $op The type of database operation
* @param string $objectName The type of object
* @param integer $objectId The ID of the object
* @param object $objectRef The object
* @return void
*/
public function civi_contact_updated($op, $objectName, $objectId, $objectRef)
{
// target our operation
if ($op != 'edit') {
return;
}
// target our object type
if ($objectName != 'Individual') {
return;
}
$this->_debug(array('function' => 'civi_contact_updated', 'op' => $op, 'objectName' => $objectName, 'objectId' => $objectId, 'objectRef' => $objectRef));
// check if we have a contact email
if (!isset($objectRef->email[0]->email)) {
// no, init CiviCRM to get WP user ID
if (!civi_wp()->initialize()) {
return;
}
// make sure Civi file is included
require_once 'CRM/Core/BAO/UFMatch.php';
// search using Civi's logic
$user_id = CRM_Core_BAO_UFMatch::getUFId($objectId);
// kick out if we didn't get one
if (empty($user_id)) {
return;
}
} else {
// yes, use it to get WP user
$user = get_user_by('email', $objectRef->email[0]->email);
// bail if not a WP user
if (!$user instanceof WP_User) {
return;
}
// assign ID
$user_id = $user->ID;
}
// update first name
update_user_meta($user_id, 'first_name', $objectRef->first_name);
// update last name
update_user_meta($user_id, 'last_name', $objectRef->last_name);
// compatibility with BP XProfile WordPress User Sync plugin
if (defined('BP_XPROFILE_WP_USER_SYNC_VERSION')) {
// access object
global $bp_xprofile_wordpress_user_sync;
// call the relevant sync method
$bp_xprofile_wordpress_user_sync->intercept_wp_user_update($user_id);
}
// avoid getting WP user unless we're debugging
if (CIVICRM_WP_PROFILE_SYNC_DEBUG) {
// for debugging, let get WP user
$user = new WP_User($user_id);
$this->_debug(array('user' => $user, 'first_name' => $user->first_name, 'last_name' => $user->last_name));
}
}
示例15: preProcess
/**
* Heart of the viewing process. The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
*
* @return void
* @access public
*
*/
function preProcess()
{
// process url params
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->assign('id', $this->_id);
// retrieve the group contact id, so that we can get contact id
$gcid = CRM_Utils_Request::retrieve('gcid', 'Positive', $this);
if (!$gcid) {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
} else {
$this->_contactId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_GroupContact', $gcid, 'contact_id');
}
if (!$this->_contactId) {
CRM_Core_Error::statusBounce(ts('We could not find a contact id.'));
}
$this->assign('contactId', $this->_contactId);
$path = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('View Contact'), 'url' => $path)));
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Search Results'), 'url' => self::getSearchURL())));
// also store in session for future use
$session =& CRM_Core_Session::singleton();
$session->set('view.id', $this->_contactId);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
$this->assign('action', $this->_action);
// check logged in url permission
self::checkUserPermission($this);
list($displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl) = $this->getContactDetails();
$this->assign('displayName', $displayName);
$this->set('contactType', $contactType);
$this->set('contactSubtype', $contactSubtype);
// see if other modules want to add a link activtity bar
require_once 'CRM/Utils/Hook.php';
$hookLinks = CRM_Utils_Hook::links('view.contact.activity', 'Contact', $this->_contactId);
if (is_array($hookLinks)) {
$this->assign('hookLinks', $hookLinks);
}
// set page title
CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
// add to recently viewed block
CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId), $this->_contactId, $contactType, $this->_contactId, $displayName, $contactImageUrl, $contactSubtype);
$config = CRM_Core_Config::singleton();
require_once 'CRM/Core/BAO/UFMatch.php';
if ($uid = CRM_Core_BAO_UFMatch::getUFId($this->_contactId)) {
if ($config->userFramework == 'Drupal') {
$url = CRM_Utils_System::url('user/' . $uid);
} else {
if ($config->userFramework == 'Joomla') {
$url = $config->userFrameworkBaseURL . 'index2.php?option=com_users&view=user&task=edit&cid[]=' . $uid;
} else {
$url = null;
}
}
$this->assign('url', $url);
}
if (CRM_Core_Permission::check('access Contact Dashboard')) {
$dashboardURL = CRM_Utils_System::url('civicrm/user', "reset=1&id={$this->_contactId}");
$this->assign('dashboardURL', $dashboardURL);
}
if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE && $contactType == 'Organization' && CRM_Core_Permission::check('administer Multiple Organizations')) {
require_once 'CRM/Contact/BAO/GroupOrganization.php';
//check is any relationship between the organization and groups
$groupOrg = CRM_Contact_BAO_GroupOrganization::hasGroupAssociated($this->_contactId);
if ($groupOrg) {
$groupOrganizationUrl = CRM_Utils_System::url('civicrm/group', "reset=1&oid={$this->_contactId}");
$this->assign('groupOrganizationUrl', $groupOrganizationUrl);
}
}
}