MkFramework
 All Data Structures Functions
plugin_gestionuser.php
1 <?php
2 /*
3 This file is part of Mkframework.
4 
5 Mkframework is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License.
8 
9 Mkframework is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13 
14 You should have received a copy of the GNU Lesser General Public License
15 along with Mkframework. If not, see <http://www.gnu.org/licenses/>.
16 
17 */
24 
25  protected $tabAllowDeny=array();
26 
27  public function __construct(){
28  if(isset($_SESSION['gestionuser_tabAllowDeny'])){
29  $this->tabAllowDeny=$_SESSION['gestionuser_tabAllowDeny'];
30  }
31  }
32 
33  private function register(){
34  $_SESSION['gestionuser_tabAllowDeny']=$this->tabAllowDeny;
35  }
36 
42  public function purge(){
43  $_SESSION['gestionuser_tabAllowDeny']=array();
44  $this->tabAllowDeny=array();
45  }
46 
53  public function allow($action,$ressource){
54  if(isset($this->tabAllowDeny[$ressource][$action])){
55  return false;
56  }
57  $this->tabAllowDeny[$ressource][$action]=1;
58  $this->register();
59  }
66  public function deny($action,$ressource){
67  if(isset($this->tabAllowDeny[$ressource][$action])){
68  return false;
69  }
70  $this->tabAllowDeny[$ressource][$action]=0;
71  $this->register();
72  }
79  public function can($action,$ressource){
80 
81  $ok=true;
82 
83  if(!isset($this->tabAllowDeny[$ressource]) ){
84  $ok=false;
85  }
86  if(!isset($this->tabAllowDeny[$ressource][$action]) ){
87  $ok=false;
88  }
89 
90 
91  if(_root::getConfigVar('site.mode')== 'dev'){
92  $tAskCan=_root::getConfigVar('tAskCan');
93  $tAskCan[]=array($action,$ressource,$ok);
94  _root::setConfigVar('tAskCan',$tAskCan);
95  }
96 
97  if($ok){
98  $sOk ='oui';
99  }else{
100  $sOk='non';
101  }
102  _root::getLog()->info('ACL can "'.$action.'" on "'.$ressource.'" ? : '.$sOk);
103 
104  return $ok;
105 
106  }
107 
108 
109 }
can($action, $ressource)
allow($action, $ressource)
static getConfigVar($sCatAndVar, $uDefaut=null)
Definition: class_root.php:654
static setConfigVar($sCatAndVar, $uValue)
Definition: class_root.php:637
deny($action, $ressource)
static getLog()
Definition: class_root.php:610