Exemplo n.º 1
0
 /**
  * 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();
 }
Exemplo n.º 2
0
 /**
  * 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;
 }
Exemplo n.º 3
0
 /**
  * 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();
 }