本文整理汇总了PHP中CRM_Core_Permission::getComponentName方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Permission::getComponentName方法的具体用法?PHP CRM_Core_Permission::getComponentName怎么用?PHP CRM_Core_Permission::getComponentName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Permission
的用法示例。
在下文中一共展示了CRM_Core_Permission::getComponentName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMenuName
/**
* Get Menu name
*
* @param $value
* @param $skipMenuItems
* @return bool|string
*/
static function getMenuName(&$value, &$skipMenuItems)
{
// we need to localise the menu labels (CRM-5456) and don’t
// want to use ts() as it would throw the ts-extractor off
$i18n = CRM_Core_I18n::singleton();
$name = $i18n->crm_translate($value['attributes']['label'], array('context' => 'menu'));
$url = $value['attributes']['url'];
$permission = $value['attributes']['permission'];
$operator = $value['attributes']['operator'];
$parentID = $value['attributes']['parentID'];
$navID = $value['attributes']['navID'];
$active = $value['attributes']['active'];
$menuName = $value['attributes']['name'];
$target = CRM_Utils_Array::value('target', $value['attributes']);
if (in_array($parentID, $skipMenuItems) || !$active) {
$skipMenuItems[] = $navID;
return FALSE;
}
//we need to check core view/edit or supported acls.
if (in_array($menuName, array('Search...', 'Contacts'))) {
if (!CRM_Core_Permission::giveMeAllACLs()) {
$skipMenuItems[] = $navID;
return FALSE;
}
}
$config = CRM_Core_Config::singleton();
$makeLink = FALSE;
if (isset($url) && $url) {
if (substr($url, 0, 4) === 'http') {
$url = $url;
} else {
//CRM-7656 --make sure to separate out url path from url params,
//as we'r going to validate url path across cross-site scripting.
$urlParam = CRM_Utils_System::explode('&', str_replace('?', '&', $url), 2);
$url = CRM_Utils_System::url($urlParam[0], $urlParam[1], FALSE, NULL, TRUE);
}
$makeLink = TRUE;
}
static $allComponents;
if (!$allComponents) {
$allComponents = CRM_Core_Component::getNames();
}
if (isset($permission) && $permission) {
$permissions = explode(',', $permission);
$hasPermission = FALSE;
foreach ($permissions as $key) {
$key = trim($key);
$showItem = TRUE;
//get the component name from permission.
$componentName = CRM_Core_Permission::getComponentName($key);
if ($componentName) {
if (!in_array($componentName, $config->enableComponents) || !CRM_Core_Permission::check($key)) {
$showItem = FALSE;
if ($operator == 'AND') {
$skipMenuItems[] = $navID;
return $showItem;
}
} else {
$hasPermission = TRUE;
}
} elseif (!CRM_Core_Permission::check($key)) {
$showItem = FALSE;
if ($operator == 'AND') {
$skipMenuItems[] = $navID;
return $showItem;
}
} else {
$hasPermission = TRUE;
}
}
if (!$showItem && !$hasPermission) {
$skipMenuItems[] = $navID;
return FALSE;
}
}
if ($makeLink) {
if ($target) {
$name = "<a href=\"{$url}\" target=\"{$target}\">{$name}</a>";
} else {
$name = "<a href=\"{$url}\">{$name}</a>";
}
}
return $name;
}
示例2: getMenuName
/**
* Get Menu name
*/
function getMenuName(&$value, &$skipMenuItems)
{
// we need to localise the menu labels (CRM-5456) and don’t
// want to use ts() as it would throw the ts-extractor off
$i18n =& CRM_Core_I18n::singleton();
$name = $i18n->crm_translate($value['attributes']['label'], array('context' => 'menu'));
$url = str_replace('&', '&', $value['attributes']['url']);
$permission = $value['attributes']['permission'];
$operator = $value['attributes']['operator'];
$parentID = $value['attributes']['parentID'];
$navID = $value['attributes']['navID'];
$active = $value['attributes']['active'];
$menuName = $value['attributes']['name'];
if (in_array($parentID, $skipMenuItems) || !$active) {
$skipMenuItems[] = $navID;
return false;
}
//we need to check core view/edit or supported acls.
require_once 'CRM/Core/Permission.php';
if (in_array($menuName, array('Search...', 'Contacts'))) {
if (!CRM_Core_Permission::giveMeAllACLs()) {
$skipMenuItems[] = $navID;
return false;
}
}
$config = CRM_Core_Config::singleton();
$makeLink = false;
if (isset($url) && $url) {
if (substr($url, 0, 4) === 'http') {
$url = $url;
} else {
$url = CRM_Utils_System::url($url);
}
$makeLink = true;
}
static $allComponents;
if (!$allComponents) {
$allComponents = CRM_Core_Component::getNames();
}
if (isset($permission) && $permission) {
$permissions = explode(',', $permission);
$hasPermission = false;
foreach ($permissions as $key) {
$key = trim($key);
$showItem = true;
//get the component name from permission.
$componentName = CRM_Core_Permission::getComponentName($key);
if ($componentName) {
if (!in_array($componentName, $config->enableComponents) || !CRM_Core_Permission::check($key)) {
$showItem = false;
if ($operator == 'AND') {
$skipMenuItems[] = $navID;
return $showItem;
}
} else {
$hasPermission = true;
}
} else {
if (!CRM_Core_Permission::check($key)) {
$showItem = false;
if ($operator == 'AND') {
$skipMenuItems[] = $navID;
return $showItem;
}
} else {
$hasPermission = true;
}
}
}
if (!$showItem && !$hasPermission) {
$skipMenuItems[] = $navID;
return false;
}
}
if ($makeLink) {
return $name = "<a href=\"{$url}\">{$name}</a>";
}
return $name;
}