/** * Set the list of active collections * * @param array $collections names * @param bool $setDefault * * @return string Key to be used in restoreColections(...) */ public static function setCollections($collections = array(), $setDefault = true) { if ($setDefault) { if (self::$_collections && SlExtensions::loaded('Auth')) { $user = SlAuth::user(); if (isset($user['id'])) { $groups = SlSession::read('Auth.groups'); $collections["users"] = 200; if ($groups) { foreach ($groups as $i => $group) { $collections["Group{$group['id']}"] = 201 + $i; $collections[$group['name']] = 201 + $i; } } $collections["User{$user['id']}"] = 299; } else { $collections["guest"] = 299; } } $controller = Sl::getInstance()->controller; if ($controller) { $collections["{$controller->name}Controller"] = 50; if (!empty($controller->params['home'])) { $collections['home'] = 70; } if (!empty($controller->params['plugin'])) { $plugin = Inflector::camelize($controller->params['plugin']); $collections["{$plugin}Plugin"] = 60; // $collections["{$plugin}{$controller->name}"] = 61; } } $collections = am(array('important' => 1000, 'cookie' => 10, 'session' => 20, 'global' => 0), $collections); } $collections = Set::normalize($collections); arsort($collections); self::$_collectionsNoLocale = $collections; $localizedCollections = array(); foreach ($collections as $collection => $priority) { if (self::$_locale) { $localizedCollections[] = $collection . "." . self::$_locale; } $localizedCollections[] = $collection; } $key = self::rememberCollections(); self::$_collections = $localizedCollections; self::_refresh(); return $key; }