本文整理匯總了PHP中JAccess::assetRules方法的典型用法代碼示例。如果您正苦於以下問題:PHP JAccess::assetRules方法的具體用法?PHP JAccess::assetRules怎麽用?PHP JAccess::assetRules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JAccess
的用法示例。
在下文中一共展示了JAccess::assetRules方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: clearStatics
/**
* Method for clearing static caches.
*
* @return void
*
* @since 11.3
*/
public static function clearStatics()
{
self::$viewLevels = array();
self::$assetRules = array();
self::$userGroups = array();
self::$userGroupPaths = array();
self::$groupsByUser = array();
}
示例2: preloadComponents
/**
* Method to preload the JAccessRules objects for all components.
*
* Note: This will only get the base permissions for the component.
* e.g. it will get 'com_content', but not 'com_content.article.1' or
* any more specific asset type rules.
*
* @return array Array of component names that were preloaded.
*
* @since 1.6
*/
protected static function preloadComponents()
{
// Get the database connection object.
$db = JFactory::getDbo();
// Build the database query:
$query = $db->getQuery(true);
$query->select('element');
$query->from('#__extensions');
$query->where('type = ' . $db->quote('component'));
$query->where('enabled = ' . $db->quote(1));
// Set the query and get the list of active components:
$db->setQuery($query);
$components = $db->loadColumn();
// Get a fresh query object:
$query = $db->getQuery(true);
// Build the in clause for the queries:
$inClause = '';
$last = end($components);
foreach ($components as $component) {
if ($component === $last) {
$inClause .= $db->quote($component);
} else {
$inClause .= $db->quote($component) . ',';
}
}
// Build the database query:
$query->select('a.name, a.rules');
$query->from('#__assets AS a');
$query->where('(a.name IN (' . $inClause . ') OR a.name = ' . $db->quote('root.1') . ')');
// Get the Name Permission Map List
$db->setQuery($query);
$namePermissionMap = $db->loadAssocList('name');
$root = array();
$root['rules'] = '';
if (isset($namePermissionMap['root.1'])) {
$root = $namePermissionMap['root.1'];
unset($namePermissionMap['root.1']);
}
// Container for all of the JAccessRules for this $assetType
$rulesList = array();
// Collects permissions for each $assetName and adds
// into the $assetRules class variable.
foreach ($namePermissionMap as $assetName => &$permissions) {
// Instantiate and return the JAccessRules object for the asset rules.
$rules = new JAccessRules();
$rules->mergeCollection(array($root['rules'], $permissions['rules']));
$rulesList[$assetName] = $rules;
}
unset($assetName);
unset($permissions);
// Merge our rules list with self::$assetRules
self::$assetRules = self::$assetRules + $rulesList;
unset($rulesList);
return $components;
}
示例3: clearStatics
/**
* Method for clearing static caches.
*
* @return void
*
* @since 11.3
*/
public static function clearStatics()
{
self::$componentsPreloaded = false;
self::$viewLevels = array();
self::$assetPermissionsById = array();
self::$assetPermissionsByName = array();
self::$preloadedAssetTypes = array();
self::$identities = array();
self::$assetRules = array();
self::$userGroups = array();
self::$userGroupPaths = array();
self::$groupsByUser = array();
}