示例#1
0
 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()))));
         }
     }
 }
示例#2
0
文件: Menu.php 项目: moiseh/metapages
 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;
 }
示例#3
0
 public function userIsAdmin()
 {
     return User::hasLoggedUser() && User::logged()->isAdmin;
 }
示例#4
0
文件: Page.php 项目: moiseh/metapages
 /**
  * @return boolean
  */
 public function isUserAllowed()
 {
     if ($this->checkperms) {
         if (!User::hasLoggedUser()) {
             return false;
         }
         return User::logged()->isInGroups($this->groupsAllowed);
     }
     return true;
 }