nyroFwk  0.2
security/abstract.class.php
Go to the documentation of this file.
1 <?php
10 abstract class security_abstract extends object {
11 
12  protected function afterInit() {
13  foreach($this->cfg->defaultRoles as $role)
14  $this->addRole($role);
15  }
16 
22  abstract public function isLogged();
23 
31  abstract public function login($prm = null, $page=null);
32 
39  abstract public function logout($prm = null);
40 
47  abstract public function addRole($role);
48 
55  abstract public function hasRole($role=null);
56 
63  abstract public function delRole($role=null);
64 
73  abstract public function check(array $url = null, $redirect=true);
74 
80  abstract public function getLoginForm(array $prm = array());
81 
88  public function protect($page = null) {
89  if (!$this->isLogged())
90  response::getInstance()->redirect(request::uri($page? $page : $this->getPage('forbidden')));
91  return true;
92  }
93 
101  public function getPage($type='login', $uri=false) {
102  $page = $this->cfg->getInArray('pages', $type);
103  return $uri? request::uri($page) : $page;
104  }
105 
117  protected function hook($name) {}
118 
126  protected function isContained(array $url, array $checks) {
127  return utils::isContained($url, $checks);
128  }
129 
130 }
delRole($role=null)
isContained(array $url, array $checks)
logout($prm=null)
static isContained(array $url, array $checks)
static getInstance()
login($prm=null, $page=null)
getPage($type='login', $uri=false)
hasRole($role=null)
static uri($prm=array())
check(array $url=null, $redirect=true)
getLoginForm(array $prm=array())
Generated on Sun Oct 15 2017 22:25:20 for nyroFwk by doxygen 1.8.13