本文整理汇总了PHP中CRM_Core_Permission::giveMeAllACLs方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Permission::giveMeAllACLs方法的具体用法?PHP CRM_Core_Permission::giveMeAllACLs怎么用?PHP CRM_Core_Permission::giveMeAllACLs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Permission
的用法示例。
在下文中一共展示了CRM_Core_Permission::giveMeAllACLs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRelatedCases
/**
* Retrieve related cases for give case.
*
* @param int $mainCaseId id of main case
* @param int $contactId id of contact
* @param boolean $excludeDeleted do not include deleted cases.
*
* @return an array of related cases.
*
* @access public
*/
static function getRelatedCases($mainCaseId, $contactId, $excludeDeleted = TRUE)
{
//FIXME : do check for permissions.
$relatedCases = array();
if (!$mainCaseId || !$contactId) {
return $relatedCases;
}
$linkActType = array_search('Link Cases', CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'));
if (!$linkActType) {
return $relatedCases;
}
$whereClause = "mainCase.id = %2";
if ($excludeDeleted) {
$whereClause .= " AND ( relAct.is_deleted = 0 OR relAct.is_deleted IS NULL )";
}
//1. first fetch related case ids.
$query = "\n SELECT relCaseAct.case_id\n FROM civicrm_case mainCase\n INNER JOIN civicrm_case_activity mainCaseAct ON (mainCaseAct.case_id = mainCase.id)\n INNER JOIN civicrm_activity mainAct ON (mainCaseAct.activity_id = mainAct.id AND mainAct.activity_type_id = %1)\n INNER JOIN civicrm_case_activity relCaseAct ON (relCaseAct.activity_id = mainAct.id AND mainCaseAct.id != relCaseAct.id)\n INNER JOIN civicrm_activity relAct ON (relCaseAct.activity_id = relAct.id AND relAct.activity_type_id = %1)\n WHERE {$whereClause}";
$dao = CRM_Core_DAO::executeQuery($query, array(1 => array($linkActType, 'Integer'), 2 => array($mainCaseId, 'Integer')));
$relatedCaseIds = array();
while ($dao->fetch()) {
$relatedCaseIds[$dao->case_id] = $dao->case_id;
}
$dao->free();
// there are no related cases.
if (empty($relatedCaseIds)) {
return $relatedCases;
}
$whereClause = 'relCase.id IN ( ' . implode(',', $relatedCaseIds) . ' )';
if ($excludeDeleted) {
$whereClause .= " AND ( relCase.is_deleted = 0 OR relCase.is_deleted IS NULL )";
}
//filter for permissioned cases.
$filterCases = array();
$doFilterCases = FALSE;
if (!CRM_Core_Permission::check('access all cases and activities')) {
$doFilterCases = TRUE;
$session = CRM_Core_Session::singleton();
$filterCases = CRM_Case_BAO_Case::getCases(FALSE, $session->get('userID'));
}
//2. fetch the details of related cases.
$query = "\n SELECT relCase.id as id,\n civicrm_case_type.title as case_type,\n client.display_name as client_name,\n client.id as client_id\n FROM civicrm_case relCase\n INNER JOIN civicrm_case_contact relCaseContact ON ( relCase.id = relCaseContact.case_id )\n INNER JOIN civicrm_contact client ON ( client.id = relCaseContact.contact_id )\n LEFT JOIN civicrm_case_type ON relCase.case_type_id = civicrm_case_type.id\n WHERE {$whereClause}";
$dao = CRM_Core_DAO::executeQuery($query);
$contactViewUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid=");
$hasViewContact = CRM_Core_Permission::giveMeAllACLs();
while ($dao->fetch()) {
$caseView = NULL;
if (!$doFilterCases || array_key_exists($dao->id, $filterCases)) {
$caseViewStr = "reset=1&id={$dao->id}&cid={$dao->client_id}&action=view&context=case&selectedChild=case";
$caseViewUrl = CRM_Utils_System::url("civicrm/contact/view/case", $caseViewStr);
$caseView = "<a class='action-item no-popup crm-hover-button' href='{$caseViewUrl}'>" . ts('View Case') . "</a>";
}
$clientView = $dao->client_name;
if ($hasViewContact) {
$clientView = "<a href='{$contactViewUrl}{$dao->client_id}'>{$dao->client_name}</a>";
}
$relatedCases[$dao->id] = array('case_id' => $dao->id, 'case_type' => $dao->case_type, 'client_name' => $clientView, 'links' => $caseView);
}
$dao->free();
return $relatedCases;
}
示例2: getContent
/**
* Given an id creates a subject/content array
*
* @param int $id
* Id of the block.
*
* @return array
*/
public static function getContent($id)
{
// return if upgrade mode
$config = CRM_Core_Config::singleton();
if ($config->isUpgradeMode()) {
return NULL;
}
if (!self::getProperty($id, 'active')) {
return NULL;
}
if ($id == self::EVENT && CRM_Core_Permission::check('view event info')) {
// is CiviEvent enabled?
if (!CRM_Core_Permission::access('CiviEvent', FALSE)) {
return NULL;
}
// do nothing
} elseif (!CRM_Core_Permission::check('access CiviCRM') && $id != self::LANGSWITCH) {
return NULL;
} elseif ($id == self::ADD) {
$hasAccess = TRUE;
if (!CRM_Core_Permission::check('add contacts') && !CRM_Core_Permission::check('edit groups')) {
$hasAccess = FALSE;
}
//validate across edit/view - CRM-5666
if ($hasAccess) {
$hasAccess = CRM_Core_Permission::giveMeAllACLs();
}
if (!$hasAccess) {
return NULL;
}
}
self::setTemplateValues($id);
// Suppress Recent Items block if it's empty - CRM-5188
if ($id == self::RECENTLY_VIEWED) {
$recent = self::getProperty($id, 'templateValues');
if (CRM_Utils_Array::crmIsEmptyArray($recent)) {
return NULL;
}
}
// Suppress Language switcher if language is inherited from CMS - CRM-9971
$config = CRM_Core_Config::singleton();
if ($id == self::LANGSWITCH && property_exists($config, "inheritLocale") && $config->inheritLocale) {
return NULL;
}
$block = array();
$block['name'] = 'block-civicrm';
$block['id'] = $block['name'] . '_' . $id;
$block['subject'] = self::fetch($id, 'Subject.tpl', array('subject' => self::getProperty($id, 'subject')));
$block['content'] = self::fetch($id, self::getProperty($id, 'template'), self::getProperty($id, 'templateValues'));
return $block;
}
示例3: 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;
}
示例4: 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;
}
示例5: getContent
/**
* Given an id creates a subject/content array
*
* @param int $id id of the block
*
* @return array
* @access public
*/
static function getContent($id)
{
// return if upgrade mode
$config = CRM_Core_Config::singleton();
if (CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET) == 'civicrm/upgrade') {
return;
}
if (!self::getProperty($id, 'active')) {
return null;
}
if ($id == self::EVENT && CRM_Core_Permission::check('view event info')) {
// is CiviEvent enabled?
if (!CRM_Core_Permission::access('CiviEvent', false)) {
return null;
}
// do nothing
} else {
if (!CRM_Core_Permission::check('access CiviCRM')) {
return null;
} else {
if ($id == self::ADD) {
$hasAccess = true;
if (!CRM_Core_Permission::check('add contacts') && !CRM_Core_Permission::check('edit groups')) {
$hasAccess = false;
}
//validate across edit/view - CRM-5666
if ($hasAccess) {
$hasAccess = CRM_Core_Permission::giveMeAllACLs();
}
if (!$hasAccess) {
return null;
}
}
}
}
self::setTemplateValues($id);
// Suppress Recent Items block if it's empty - CRM-5188
if ($id == self::RECENTLY_VIEWED) {
$recent = self::getProperty($id, 'templateValues');
if (CRM_Utils_Array::crmIsEmptyArray($recent)) {
return null;
}
}
$block = array();
$block['name'] = 'block-civicrm';
$block['id'] = $block['name'] . '_' . $id;
$block['subject'] = self::fetch($id, 'Subject.tpl', array('subject' => self::getProperty($id, 'subject')));
$block['content'] = self::fetch($id, self::getProperty($id, 'template'), self::getProperty($id, 'templateValues'));
return $block;
}