public static function checkAuth() { if (preg_match('/(builder\\/(.*)|^builder$)/', current_path())) { if (User::hasLoggedUser() && !User::logged()->isAdmin) { \Meta\Core\Flash::error(t('You need to login with user that have the "Admin user" flag to access the builder interface.')); User::logout(); } if (!User::hasLoggedUser()) { redirect(url('user-login', array('back_to' => urlencode(current_path())))); } } }
public function buildItems($pages = array()) { $items = array(); // gera uma lista mais "simples" de itens para depois gerar o menu foreach ($pages as $path => $page) { // checks the user permissions if (isset($page['checkperms'])) { $hasPerms = !$page['checkperms'] || $page['checkperms'] && User::hasLoggedUser() && User::logged()->isInGroups((array) $page['groupsAllowed']); } else { $hasPerms = true; } if ($hasPerms) { // adiciona o path $items[$path] = array('path' => $path, 'label' => $page['label'], 'parentmenu' => isset($page['parentmenu']) ? $page['parentmenu'] : NULL, 'icon' => isset($page['menuIcon']) ? $page['menuIcon'] : NULL, 'pageType' => isset($page['pageType']) ? $page['pageType'] : NULL, 'showonmenu' => isset($page['showonmenu']) ? $page['showonmenu'] : NULL, 'hasPermission' => $hasPerms); } } asort($items); return $items; }
public function userIsAdmin() { return User::hasLoggedUser() && User::logged()->isAdmin; }
/** * @return boolean */ public function isUserAllowed() { if ($this->checkperms) { if (!User::hasLoggedUser()) { return false; } return User::logged()->isInGroups($this->groupsAllowed); } return true; }