本文整理汇总了PHP中CRM_Utils_Hook::links方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Hook::links方法的具体用法?PHP CRM_Utils_Hook::links怎么用?PHP CRM_Utils_Hook::links使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Hook
的用法示例。
在下文中一共展示了CRM_Utils_Hook::links方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addUrls
/**
* Add urls for display in the actions menu.
* @param CRM_Core_Page $obj
* @param int $cid
*/
public static function addUrls(&$obj, $cid)
{
$uid = CRM_Core_BAO_UFMatch::getUFId($cid);
if ($uid) {
$userRecordUrl = CRM_Core_Config::singleton()->userSystem->getUserRecordUrl($cid);
$obj->assign('userRecordUrl', $userRecordUrl);
$obj->assign('userRecordId', $uid);
} elseif (CRM_Core_Config::singleton()->userSystem->checkPermissionAddUser()) {
$userAddUrl = CRM_Utils_System::url('civicrm/contact/view/useradd', 'reset=1&action=add&cid=' . $cid);
$obj->assign('userAddUrl', $userAddUrl);
}
if (CRM_Core_Permission::check('access Contact Dashboard')) {
$dashboardURL = CRM_Utils_System::url('civicrm/user', "reset=1&id={$cid}");
$obj->assign('dashboardURL', $dashboardURL);
}
// See if other modules want to add links to the activtity bar
$hookLinks = array();
CRM_Utils_Hook::links('view.contact.activity', 'Contact', $cid, $hookLinks, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject);
if (is_array($hookLinks)) {
$obj->assign('hookLinks', $hookLinks);
}
}
示例2: formLink
/**
* given a set of links and a mask, return the html action string for
* the links associated with the mask
*
* @param array $links the set of link items
* @param int $mask the mask to be used. a null mask means all items
* @param array $values the array of values for parameter substitution in the link items
* @param string $extraULName enclosed extra links in this UL.
* @param boolean $enclosedAllInSingleUL force to enclosed all links in single UL.
*
* @param null $op
* @param null $objectName
* @param null $objectId
*
* @return string the html string
* @access public
* @static
*/
static function formLink($links, $mask, $values, $extraULName = 'more', $enclosedAllInSingleUL = FALSE, $op = NULL, $objectName = NULL, $objectId = NULL)
{
$config = CRM_Core_Config::singleton();
if (empty($links)) {
return NULL;
}
// make links indexed sequentially instead of by bitmask
// otherwise it's next to impossible to reliably add new ones
$seqLinks = array();
foreach ($links as $bit => $link) {
$link['bit'] = $bit;
$seqLinks[] = $link;
}
if ($op && $objectName && $objectId) {
CRM_Utils_Hook::links($op, $objectName, $objectId, $seqLinks, $mask, $values);
}
$url = array();
foreach ($seqLinks as $i => $link) {
if (!$mask || !array_key_exists('bit', $link) || $mask & $link['bit']) {
$extra = isset($link['extra']) ? self::replace($link['extra'], $values) : NULL;
$frontend = isset($link['fe']) ? TRUE : FALSE;
if (isset($link['qs']) && !CRM_Utils_System::isNull($link['qs'])) {
$urlPath = CRM_Utils_System::url(self::replace($link['url'], $values), self::replace($link['qs'], $values), TRUE, NULL, TRUE, $frontend);
} else {
$urlPath = CRM_Utils_Array::value('url', $link, '#');
}
$classes = 'action-item crm-hover-button';
if (isset($link['ref'])) {
$classes .= ' ' . strtolower($link['ref']);
}
//get the user specified classes in.
if (isset($link['class'])) {
$className = is_array($link['class']) ? implode(' ', $link['class']) : $link['class'];
$classes .= ' ' . strtolower($className);
}
if ($urlPath !== '#' && $frontend) {
$extra .= ' target="_blank"';
}
// Hack to make delete dialogs smaller
if (strpos($urlPath, '/delete') || strpos($urlPath, 'action=delete')) {
$classes .= " small-popup";
}
$url[] = sprintf('<a href="%s" class="%s" %s' . $extra . '>%s</a>', $urlPath, $classes, !empty($link['title']) ? "title='{$link['title']}' " : '', $link['name']);
}
}
$mainLinks = $url;
if ($enclosedAllInSingleUL) {
$allLinks = '';
CRM_Utils_String::append($allLinks, '</li><li>', $mainLinks);
$allLinks = "{$extraULName}<ul class='panel'><li>{$allLinks}</li></ul>";
$result = "<span class='btn-slide crm-hover-button'>{$allLinks}</span>";
} else {
$extra = '';
$extraLinks = array_splice($url, 2);
if (count($extraLinks) > 1) {
$mainLinks = array_slice($url, 0, 2);
CRM_Utils_String::append($extra, '</li><li>', $extraLinks);
$extra = "{$extraULName}<ul class='panel'><li>{$extra}</li></ul>";
}
$resultLinks = '';
CRM_Utils_String::append($resultLinks, '', $mainLinks);
if ($extra) {
$result = "<span>{$resultLinks}</span><span class='btn-slide crm-hover-button'>{$extra}</span>";
} else {
$result = "<span>{$resultLinks}</span>";
}
}
return $result;
}
示例3: setTemplateShortcutValues
/**
* Create the list of options to create New objects for the application and format is as a block.
*
* @return void
*/
private static function setTemplateShortcutValues()
{
$config = CRM_Core_Config::singleton();
static $shortCuts = array();
if (!$shortCuts) {
if (CRM_Core_Permission::check('add contacts')) {
if (CRM_Core_Permission::giveMeAllACLs()) {
$shortCuts = CRM_Contact_BAO_ContactType::getCreateNewList();
}
}
// new activity (select target contact)
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/activity', 'query' => 'action=add&reset=1&context=standalone', 'ref' => 'new-activity', 'title' => ts('Activity'))));
$components = CRM_Core_Component::getEnabledComponents();
if (!empty($config->enableComponents)) {
// check if we can process credit card contribs
$newCredit = CRM_Core_Config::isEnabledBackOfficeCreditCardPayments();
foreach ($components as $componentName => $obj) {
if (in_array($componentName, $config->enableComponents)) {
$obj->creatNewShortcut($shortCuts, $newCredit);
}
}
}
// new email (select recipients)
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/activity/email/add', 'query' => 'atype=3&action=add&reset=1&context=standalone', 'ref' => 'new-email', 'title' => ts('Email'))));
if (CRM_Core_Permission::check('edit groups')) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/group/add', 'query' => 'reset=1', 'ref' => 'new-group', 'title' => ts('Group'))));
}
if (CRM_Core_Permission::check('administer CiviCRM')) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/admin/tag', 'query' => 'reset=1&action=add', 'ref' => 'new-tag', 'title' => ts('Tag'))));
}
if (empty($shortCuts)) {
return NULL;
}
}
$values = array();
foreach ($shortCuts as $key => $short) {
$values[$key] = self::setShortCutValues($short);
}
// call links hook to add user defined links
CRM_Utils_Hook::links('create.new.shorcuts', NULL, CRM_Core_DAO::$_nullObject, $values, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject);
foreach ($values as $key => $val) {
if (!empty($val['title'])) {
$values[$key]['name'] = CRM_Utils_Array::value('name', $val, $val['title']);
}
}
self::setProperty(self::CREATE_NEW, 'templateValues', array('shortCuts' => $values));
}
示例4: formLink
/**
* given a set of links and a mask, return the html action string for
* the links associated with the mask
*
* @param array $links the set of link items
* @param int $mask the mask to be used. a null mask means all items
* @param array $values the array of values for parameter substitution in the link items
* @param string $extraULName enclosed extra links in this UL.
* @param boolean $enclosedAllInSingleUL force to enclosed all links in single UL.
*
* @return string the html string
* @access public
* @static
*/
static function formLink($links, $mask, $values, $extraULName = 'more', $enclosedAllInSingleUL = FALSE, $op = NULL, $objectName = NULL, $objectId = NULL)
{
$config = CRM_Core_Config::singleton();
if (empty($links)) {
return NULL;
}
if ($op && $objectName && $objectId) {
CRM_Utils_Hook::links($op, $objectName, $objectId, $links, $mask);
}
$url = array();
$firstLink = TRUE;
foreach ($links as $m => $link) {
if (!$mask || $mask & $m) {
$extra = isset($link['extra']) ? self::replace($link['extra'], $values) : NULL;
$frontend = isset($link['fe']) ? TRUE : FALSE;
$urlPath = NULL;
if (CRM_Utils_Array::value('qs', $link) && !CRM_Utils_System::isNull($link['qs'])) {
$urlPath = CRM_Utils_System::url(self::replace($link['url'], $values), self::replace($link['qs'], $values), TRUE, NULL, TRUE, $frontend);
} else {
$urlPath = CRM_Utils_Array::value('url', $link);
}
$classes = 'action-item';
if ($firstLink) {
$firstLink = FALSE;
$classes .= " action-item-first";
}
if (isset($link['ref'])) {
$classes .= ' ' . strtolower($link['ref']);
}
//get the user specified classes in.
if (isset($link['class'])) {
$className = $link['class'];
if (is_array($className)) {
$className = implode(' ', $className);
}
$classes .= ' ' . strtolower($className);
}
$linkClasses = 'class = "' . $classes . '"';
if ($urlPath) {
if ($frontend) {
$extra .= "target=_blank";
}
$url[] = sprintf('<a href="%s" %s title="%s"' . $extra . '>%s</a>', $urlPath, $linkClasses, CRM_Utils_Array::value('title', $link), $link['name']);
} else {
$url[] = sprintf('<a title="%s" %s ' . $extra . '>%s</a>', CRM_Utils_Array::value('title', $link), $linkClasses, $link['name']);
}
}
}
$result = '';
$mainLinks = $url;
if ($enclosedAllInSingleUL) {
$allLinks = '';
CRM_Utils_String::append($allLinks, '</li><li>', $mainLinks);
$allLinks = "{$extraULName}<ul class='panel'><li>{$allLinks}</li></ul>";
$result = "<span class='btn-slide'>{$allLinks}</span>";
} else {
$extra = '';
$extraLinks = array_splice($url, 2);
if (count($extraLinks) > 1) {
$mainLinks = array_slice($url, 0, 2);
CRM_Utils_String::append($extra, '</li><li>', $extraLinks);
$extra = "{$extraULName}<ul class='panel'><li>{$extra}</li></ul>";
}
$resultLinks = '';
CRM_Utils_String::append($resultLinks, '', $mainLinks);
if ($extra) {
$result = "<span>{$resultLinks}</span><span class='btn-slide'>{$extra}</span>";
} else {
$result = "<span>{$resultLinks}</span>";
}
}
return $result;
}
示例5: ts
/**
* Get action links
*
* @return array (reference) of action links
* @static
*/
static function &links()
{
if (!self::$_links) {
$disableExtra = ts('Are you sure you want to disable this relationship?');
self::$_links = array(CRM_Core_Action::UPDATE => array('name' => ts('Edit Contact Information'), 'url' => 'civicrm/contact/relatedcontact', 'qs' => 'action=update&reset=1&cid=%%cbid%%&rcid=%%cid%%', 'title' => ts('Edit Relationship')), CRM_Core_Action::VIEW => array('name' => ts('Dashboard'), 'url' => 'civicrm/user', 'qs' => 'reset=1&id=%%cbid%%', 'title' => ts('View Relationship')));
if (CRM_Core_Permission::check('access CiviCRM')) {
self::$_links = array_merge(self::$_links, array(CRM_Core_Action::DISABLE => array('name' => ts('Disable'), 'url' => 'civicrm/contact/view/rel', 'qs' => 'action=disable&reset=1&cid=%%cid%%&id=%%id%%&rtype=%%rtype%%&selectedChild=rel&context=dashboard', 'extra' => 'onclick = "return confirm(\'' . $disableExtra . '\');"', 'title' => ts('Disable Relationship'))));
}
}
// call the hook so we can modify it
CRM_Utils_Hook::links('view.contact.userDashBoard', 'Contact', CRM_Core_DAO::$_nullObject, self::$_links, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject);
return self::$_links;
}
示例6: addUrls
/**
* Add urls for display in the actions menu
*/
static function addUrls(&$obj, $cid)
{
// TODO rewrite without so many hard-coded CMS bits; use abstractions like CRM_Core_Permission::check('cms:...') and CRM_Utils_System
$config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
$uid = CRM_Core_BAO_UFMatch::getUFId($cid);
$userRecordUrl = NULL;
if ($uid) {
if ($config->userSystem->is_drupal == '1' && ($session->get('userID') == $cid || CRM_Core_Permission::checkAnyPerm(array('cms:administer users', 'cms:view user account')))) {
$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') == $cid) {
$userRecordUrl = $config->userFrameworkBaseURL . "index.php?option=com_admin&view=profile&layout=edit&id=" . $uid;
}
} elseif ($config->userFramework == 'WordPress' && ($session->get('userID') == $cid || CRM_Core_Permission::checkAnyPerm(array('cms:administer users')))) {
$userRecordUrl = $config->userFrameworkBaseURL . "wp-admin/user-edit.php?user_id=" . $uid;
}
$obj->assign('userRecordUrl', $userRecordUrl);
$obj->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=' . $cid);
$obj->assign('userAddUrl', $userAddUrl);
}
if (CRM_Core_Permission::check('access Contact Dashboard')) {
$dashboardURL = CRM_Utils_System::url('civicrm/user', "reset=1&id={$cid}");
$obj->assign('dashboardURL', $dashboardURL);
}
// See if other modules want to add links to the activtity bar
$hookLinks = array();
CRM_Utils_Hook::links('view.contact.activity', 'Contact', $cid, $hookLinks, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject);
if (is_array($hookLinks)) {
$obj->assign('hookLinks', $hookLinks);
}
}
示例7: setTemplateShortcutValues
/**
* create the list of options to create New objects for the application and format is as a block
*
* @return void
* @access private
*/
private function setTemplateShortcutValues()
{
$config = CRM_Core_Config::singleton();
static $shortCuts = array();
if (!$shortCuts) {
if (CRM_Core_Permission::check('add contacts')) {
if (CRM_Core_Permission::giveMeAllACLs()) {
$shortCuts = CRM_Contact_BAO_ContactType::getCreateNewList();
}
if (CRM_Core_Permission::access('Quest')) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/quest/search', 'query' => 'reset=1', 'ref' => 'quest-search', 'title' => ts('Quest Search'))));
}
}
// new activity (select target contact)
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/activity', 'query' => 'action=add&reset=1&context=standalone', 'ref' => 'new-activity', 'title' => ts('Activity'))));
$components = CRM_Core_Component::getEnabledComponents();
if (!empty($config->enableComponents)) {
foreach ($components as $componentName => $obj) {
if (in_array($componentName, $config->enableComponents)) {
eval('$obj->creatNewShortcut( $shortCuts );');
}
}
}
// new email (select recipients)
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/activity/email/add', 'query' => 'atype=3&action=add&reset=1&context=standalone', 'ref' => 'new-email', 'title' => ts('Email'))));
if (CRM_Core_Permission::check('edit groups')) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/group/add', 'query' => 'reset=1', 'ref' => 'new-group', 'title' => ts('Group'))));
}
if (CRM_Core_Permission::check('administer CiviCRM')) {
$shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/admin/tag', 'query' => 'reset=1&action=add', 'ref' => 'new-tag', 'title' => ts('Tag'))));
}
if (empty($shortCuts)) {
return NULL;
}
}
$values = array();
foreach ($shortCuts as $short) {
$value = array();
if (isset($short['url'])) {
$value['url'] = $short['url'];
} else {
$value['url'] = CRM_Utils_System::url($short['path'], $short['query'], FALSE);
}
$value['title'] = $short['title'];
$value['ref'] = $short['ref'];
$values[] = $value;
}
// call links hook to add user defined links
CRM_Utils_Hook::links('create.new.shorcuts', NULL, CRM_Core_DAO::$_nullObject, $values, CRM_Core_DAO::$_nullObject);
self::setProperty(self::CREATE_NEW, 'templateValues', array('shortCuts' => $values));
}
示例8: 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);
$qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
//validate the qfKey
if (!CRM_Utils_Rule::qfKey($qfKey)) {
$qfKey = NULL;
}
$this->assign('searchKey', $qfKey);
// 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.'), CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
}
// ensure that the id does exist
if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'id') != $this->_contactId) {
CRM_Core_Error::statusBounce(ts('A Contact with that ID does not exist: %1', array(1 => $this->_contactId)), CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
}
$this->assign('contactId', $this->_contactId);
// see if we can get prev/next positions from qfKey
$navContacts = array('prevContactID' => NULL, 'prevContactName' => NULL, 'nextContactID' => NULL, 'nextContactName' => NULL, 'nextPrevError' => 0);
if ($qfKey) {
$pos = CRM_Core_BAO_PrevNextCache::getPositions("civicrm search {$qfKey}", $this->_contactId, $this->_contactId);
$found = FALSE;
if (isset($pos['prev'])) {
$navContacts['prevContactID'] = $pos['prev']['id1'];
$navContacts['prevContactName'] = $pos['prev']['data'];
$found = TRUE;
}
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) {
//.........这里部分代码省略.........
示例9: 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);
}
}
}
示例10: 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);
}
}
}