/** Get all users permissions * @return array Set of permissions (System\User\Perm) */ public function get_rights() { if (is_null($this->rights)) { if ($this->id) { $conds = array("public" => true); $ids = collect_ids($this->groups->fetch()); if (any($ids)) { $conds[] = "id_group IN (" . implode(',', $ids) . ")"; } $this->rights = \System\User\Perm::get_all()->where($conds, "t0", true)->reset_cols()->add_cols(array("trigger", "id_system_user_perm"), "t0")->assoc_with('')->fetch('trigger', 'id_system_user_perm'); } else { $this->rights = array(); } } return $this->rights; }
/** * Get all available modules * * @param bool $with_perms * @return array */ public static function get_all($with_perms = false) { $mods = array(); $path = ROOT . self::DIR; \System\Directory::find_all_files($path, $mods, '/\\.php$/'); sort($mods); foreach ($mods as &$mod) { $mod = array("path" => preg_replace('/\\.php$/', '', substr($mod, strlen($path) + 1))); if ($with_perms) { $mod['perms'] = \System\User\Perm::get_all()->where(array("type" => 'module', "trigger" => $mod['path']))->fetch(); } } return $mods; }