. */ /** * plugin_gestionuser classe de gestion user * @author Mika * @link http://mkf.mkdevs.com/ */ class plugin_gestionuser{ protected $tabAllowDeny=array(); public function __construct(){ if(isset($_SESSION['gestionuser_tabAllowDeny'])){ $this->tabAllowDeny=$_SESSION['gestionuser_tabAllowDeny']; } } private function register(){ $_SESSION['gestionuser_tabAllowDeny']=$this->tabAllowDeny; } /** purge les permissions en session * (appeler avant de reassigner de nouvelles permissions pour eviter la concatenation) * @access public * @return void */ public function purge(){ $_SESSION['gestionuser_tabAllowDeny']=array(); $this->tabAllowDeny=array(); } /** * @access public * @return void * @param string $action action qu'on autorise sur $ressource * @param string $ressource ressource l'action est autorise sur $ressource */ public function allow($action,$ressource){ if(isset($this->tabAllowDeny[$ressource][$action])){ return false; } $this->tabAllowDeny[$ressource][$action]=1; $this->register(); } /** * @access public * @return void * @param string $action action qu'on n'autorise pas sur $ressource * @param string $ressource ressource l'action est n'autorise pas sur $ressource */ public function deny($action,$ressource){ if(isset($this->tabAllowDeny[$ressource][$action])){ return false; } $this->tabAllowDeny[$ressource][$action]=0; $this->register(); } /** * @access public * @return bool retourne true/false selon qu'on est autorise ou non a faire $action sur $ressource * @param string $action action qu'on autorise sur $ressource * @param string $ressource ressource l'action est autorise sur $ressource */ public function can($action,$ressource){ $ok=true; if(!isset($this->tabAllowDeny[$ressource]) ){ $ok=false; } if(!isset($this->tabAllowDeny[$ressource][$action]) ){ $ok=false; } if(_root::getConfigVar('site.mode')== 'dev'){ $tAskCan=_root::getConfigVar('tAskCan'); $tAskCan[]=array($action,$ressource,$ok); _root::setConfigVar('tAskCan',$tAskCan); } if($ok){ $sOk ='oui'; }else{ $sOk='non'; } _root::getLog()->info('ACL can "'.$action.'" on "'.$ressource.'" ? : '.$sOk); return $ok; } }