Esempio n. 1
0
 public function checkAccess($module, $action, $deny = false, $group = false)
 {
     if ($this->auth->isLogged()) {
         $login = $this->auth->getLogin();
         // MLogin object
         $isAdmin = $login->isAdmin();
         // Is administrator?
         $rights = $login->rights[$module];
         // user rights
         if (!$rights) {
             $login->setRights($this->getRights($login->id));
         }
         $ok = @in_array($action, $login->rights[$module]);
         if (!$ok && $group) {
             $groups = $this->getGroupsAllowed($module, $action);
             $ok = sizeof(array_intersect($groups, $login->groups)) > 0;
         }
     }
     if (!$ok && $deny) {
         $msg = _M('Access Denied') . "<br><br>\n" . '<center><big><i><font color=red>' . _M('Transaction: ') . "{$transaction}</font></i></big></center><br><br>\n" . _M('Please inform a valid login/password to access this content.') . "<br>";
         $users = $this->getUsersAllowed($module, $action);
         if ($users) {
             $msg .= "<br><br>\n" . _M('Users with access rights') . ":<ul><li>" . implode('<li>', $users) . '</ul>';
         }
         $go = $this->manager->history->back('action');
         $error = Prompt::error($msg, $go, $caption, '');
         $error->addButton(_M('   Login   '), $this->manager->getActionURL($this->manager->getConf('login.module'), 'login', null, array('return_to' => urlencode($this->manager->history->top()))), '');
         $this->manager->prompt($error, $deny);
         //$this->manager->error($msg, $go);
     }
     return $ok;
 }