本文整理汇总了PHP中FlexicontentHelperPerm::returnAllCats方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentHelperPerm::returnAllCats方法的具体用法?PHP FlexicontentHelperPerm::returnAllCats怎么用?PHP FlexicontentHelperPerm::returnAllCats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentHelperPerm
的用法示例。
在下文中一共展示了FlexicontentHelperPerm::returnAllCats方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getAllowedCats
static function _getAllowedCats($user_id, $actions_allowed, $require_all, $check_published, $specific_catids, $find_first)
{
global $globalcats;
$db = JFactory::getDBO();
$usercats = array();
// We ignore the user_id in the case FLEXIaccess, because FLEXIaccess only calculates access for current user,
// this is ok since, because we pass the user_id only for the purpose of being able to cache this function call
// -- passing by different user_id parameter this function call can be cached properly
$user = FLEXI_ACCESS ? JFactory::getUser() : JFactory::getUser($user_id);
if (FLEXI_J16GE) {
// *** J1.6+ ***
$allcats = FlexicontentHelperPerm::returnAllCats($check_published, $specific_catids);
foreach ($allcats as $category_id) {
// Construct asset name for the category
$asset = 'com_content.category.' . $category_id;
// Check all actions with Logical OR or Logical AND
// We start with FALSE for OR and TRUE for AND
$has_access = $require_all ? true : false;
foreach ($actions_allowed as $action_name) {
$has_access = $require_all ? $has_access && $user->authorise($action_name, $asset) : $has_access || $user->authorise($action_name, $asset);
}
if ($has_access) {
$usercats[] = $category_id;
if ($find_first) {
break;
}
// J1.6+ performance consideration skip checking permissions of remaining categories
}
}
return $usercats;
} else {
if (!FLEXI_ACCESS || $user->gid == 25) {
// *** J1.5 without FLEXIaccess or user is super admin, return all category ids ***
if ($user->gid < 19) {
return array();
}
// Less than J1.5 Author
return FlexicontentHelperPerm::returnAllCats($check_published, $specific_catids);
} else {
// *** J1.5 with FLEXIaccess ***
$aro_value = $user->gmid;
// FLEXIaccess group
// Create a limit for aco (ACTION privilege)
$limit_aco = array();
if (in_array('core.create', $actions_allowed)) {
$limit_aco[] = 'aco = ' . $db->Quote('add');
}
if (in_array('core.edit', $actions_allowed)) {
$limit_aco[] = 'aco = ' . $db->Quote('edit');
}
if (in_array('core.edit.own', $actions_allowed)) {
$limit_aco[] = 'aco = ' . $db->Quote('editown');
}
$oper = $require_all ? ' AND ' : ' OR ';
if (count($limit_aco)) {
$limit_aco = implode($oper, $limit_aco);
} else {
$limit_aco = 'aco = ' . $db->Quote('add') . $oper . ' aco = ' . $db->Quote('edit') . $oper . ' aco = ' . $db->Quote('editown');
}
// We will search for permission all on the given permission (add,edit,editown),
// if found it means that there are no ACL limitations for given user, aka return all cats
$query = 'SELECT COUNT(*) FROM #__flexiaccess_acl' . ' WHERE acosection = ' . $db->Quote('com_content') . ' AND ( ' . $limit_aco . ' )' . ' AND arosection = ' . $db->Quote('users') . ' AND aro IN ( ' . $aro_value . ' )' . ' AND axosection = ' . $db->Quote('content') . ' AND axo = ' . $db->Quote('all');
$db->setQuery($query);
// *** No limitations found, return all category ids ***
if ($db->loadResult()) {
return FlexicontentHelperPerm::returnAllCats($check_published, $specific_catids);
}
// *** Limitations found, check and return category ids with 'create' permission ***
// creating for -content- axosection is 'add' but for -category- axosection is 'submit'
$limit_aco = str_replace('add', 'submit', $limit_aco);
$query = 'SELECT axo FROM #__flexiaccess_acl' . ' WHERE acosection = ' . $db->Quote('com_content') . ' AND ( ' . $limit_aco . ' )' . ' AND arosection = ' . $db->Quote('users') . ' AND aro IN ( ' . $aro_value . ' )' . ' AND axosection = ' . $db->Quote('category') . ($specific_catids ? ' AND axo IN (' . implode(",", $specific_catids) . ')' : '');
$db->setQuery($query);
$allowedcats = $db->loadColumn();
$allowedcats = $allowedcats ? $allowedcats : array();
// we add all descendent to the array
foreach ($allowedcats as $allowedcat) {
$usercats[] = $allowedcat;
if ($globalcats[$allowedcat]->children) {
foreach ($globalcats[$allowedcat]->descendantsarray as $k => $v) {
if (!$check_published || $globalcats[$v]->published) {
$usercats[] = $v;
}
}
}
}
$usercats = array_unique($usercats);
return $usercats;
}
}
}
示例2: onDisplayField
//.........这里部分代码省略.........
$onlypublished = $field->parameters->get('onlypublished', 1);
$ownedbyuser = $field->parameters->get('ownedbyuser', 0);
// ******************
// EDITING PARAMETERS
// ******************
// some parameters shortcuts
$size = $field->parameters->get('size', 12);
$size = $size ? ' size="' . $size . '"' : '';
$prepend_item_state = $field->parameters->get('prepend_item_state', 1);
$maxtitlechars = $field->parameters->get('maxtitlechars', 40);
$title_filter = $field->parameters->get('title_filter', 1);
$required = $field->parameters->get('required', 0);
$required = $required ? ' required' : '';
$select_items_prompt = $field->parameters->get('select_items_prompt', 'FLEXI_RIFLD_SELECT_ITEMS_PROMPT');
$selected_items_label = $field->parameters->get('selected_items_label', 'FLEXI_RIFLD_SELECTED_ITEMS_LABEL');
$display_cat_filter_label = $field->parameters->get('display_cat_filter_label', 1);
$display_title_filter_label = $field->parameters->get('display_title_filter_label', 1);
$default_value_title_filter = $field->parameters->get('default_value_title_filter', '');
// ***********************************************
// Get & check Global category related permissions
// ***********************************************
require_once JPATH_ROOT . DS . 'components' . DS . 'com_flexicontent' . DS . 'helpers' . DS . 'permission.php';
$viewallcats = FlexicontentHelperPerm::getPerm()->ViewAllCats;
$viewtree = FlexicontentHelperPerm::getPerm()->ViewTree;
if (!$viewtree) {
$field->html = '<div class="alert alert-info fc-small fc-iblock">' . JText::_('FLEXI_NO_ACCESS_LEVEL_TO_VIEW_CATEGORY_TREE') . '</div><div class="clear"></div>';
return;
}
// ****************************************************
// Calculate categories to use for retrieving the items
// ****************************************************
$allowed_cats = $disallowed_cats = false;
// Get user allowed categories
$usercats = FLEXI_J16GE || FLEXI_ACCESS ? FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create', 'core.edit', 'core.edit.own'), $require_all = false, $check_published = true) : FlexicontentHelperPerm::returnAllCats($check_published = true, $specific_catids = null);
// Find (if configured) , descendants of the categories
if ($usesubcats) {
global $globalcats;
$_catids = array();
foreach ($catids as $catid) {
$subcats = $globalcats[$catid]->descendantsarray;
foreach ($subcats as $subcat) {
$_catids[(int) $subcat] = 1;
}
}
$catids = array_keys($_catids);
}
// ... TODO: retrieve items via AJAX
// *********************************************
// Item retrieving query ... CREATE WHERE CLAUSE
// *********************************************
$where = array();
// **************
// CATEGORY SCOPE
// **************
// Include method
if ($method_cat == 3) {
$allowed_cats = $viewallcats ? $catids : array_intersect($usercats, $catids);
if (!empty($allowed_cats)) {
$where[] = " rel.catid IN (" . implode(',', $allowed_cats) . ") ";
} else {
$field->html = JText::_('FLEXI_CANNOT_EDIT_FIELD') . ': <br/> ' . JText::_('FLEXI_NO_ACCESS_TO_USE_CONFIGURED_CATEGORIES');
return;
}
} else {
if ($method_cat == 2) {
$disallowed_cats = $viewallcats ? $catids : array_diff($usercats, $catids);