Changeset 560

Show
Ignore:
Timestamp:
08/30/07 00:25:43 (1 year ago)
Author:
laurentj
Message:

added supports of drivers in jAcl

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/manifests/jelix-lib.mn

    r557 r560  
    2222  jAclUserGroup.class.php 
    2323  jAclManager.class.php 
     24  jAclDb.class.php 
    2425 
    2526cd lib/jelix/controllers 
     
    250251  CREDITS 
    251252cd lib/jelix-plugins/auth/ 
     253cd lib/jelix-plugins/acl/ 
    252254cd lib/jelix-plugins/coord/ 
    253255cd lib/jelix-plugins/db/ 
     
    256258cd lib/jelix-plugins/wr_rules/ 
    257259 
     260cd lib/jelix/plugins/acl/db 
     261  db.acl.php 
    258262cd lib/jelix/plugins/auth/db 
    259263  db.auth.php 
  • trunk/build/manifests/jelix-lib.mn

    r557 r560  
    2222  jAclUserGroup.class.php 
    2323  jAclManager.class.php 
     24  jAclDb.class.php 
    2425 
    2526cd lib/jelix/controllers 
     
    250251  CREDITS 
    251252cd lib/jelix-plugins/auth/ 
     253cd lib/jelix-plugins/acl/ 
    252254cd lib/jelix-plugins/coord/ 
    253255cd lib/jelix-plugins/db/ 
     
    256258cd lib/jelix-plugins/wr_rules/ 
    257259 
     260cd lib/jelix/plugins/acl/db 
     261  db.acl.php 
    258262cd lib/jelix/plugins/auth/db 
    259263  db.auth.php 
  • trunk/lib/jelix-scripts/commands/aclgroup.cmd.php

    r414 r560  
    8686    protected function cmd_list(){ 
    8787        $sql="SELECT id_aclgrp, name, grouptype FROM jacl_group WHERE grouptype <2 ORDER BY name"; 
    88         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     88        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    8989        $rs = $cnx->query($sql); 
    9090        echo "id\tlabel name\t\tdefault\n--------------------------------------------------------\n"; 
     
    103103            die("wrong parameter count\n"); 
    104104 
    105         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     105        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    106106 
    107107        $sql="INSERT into jacl_group (name, grouptype, ownerlogin) VALUES ("; 
     
    122122            die("wrong parameter count\n"); 
    123123 
    124         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     124        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    125125 
    126126        $sql="SELECT id_aclgrp,  grouptype FROM jacl_group WHERE id_aclgrp=".intval($params[0]); 
     
    155155            die("wrong parameter count\n"); 
    156156 
    157         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     157        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    158158 
    159159        $sql="SELECT id_aclgrp,  grouptype FROM jacl_group WHERE id_aclgrp=".intval($params[0]); 
     
    186186            die("wrong parameter count\n"); 
    187187 
    188         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     188        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    189189 
    190190        $sql="SELECT id_aclgrp,  grouptype FROM jacl_group WHERE id_aclgrp=".intval($params[0]); 
  • trunk/lib/jelix-scripts/commands/aclgroup.cmd.php

    r414 r560  
    8686    protected function cmd_list(){ 
    8787        $sql="SELECT id_aclgrp, name, grouptype FROM jacl_group WHERE grouptype <2 ORDER BY name"; 
    88         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     88        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    8989        $rs = $cnx->query($sql); 
    9090        echo "id\tlabel name\t\tdefault\n--------------------------------------------------------\n"; 
     
    103103            die("wrong parameter count\n"); 
    104104 
    105         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     105        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    106106 
    107107        $sql="INSERT into jacl_group (name, grouptype, ownerlogin) VALUES ("; 
     
    122122            die("wrong parameter count\n"); 
    123123 
    124         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     124        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    125125 
    126126        $sql="SELECT id_aclgrp,  grouptype FROM jacl_group WHERE id_aclgrp=".intval($params[0]); 
     
    155155            die("wrong parameter count\n"); 
    156156 
    157         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     157        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    158158 
    159159        $sql="SELECT id_aclgrp,  grouptype FROM jacl_group WHERE id_aclgrp=".intval($params[0]); 
     
    186186            die("wrong parameter count\n"); 
    187187 
    188         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     188        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    189189 
    190190        $sql="SELECT id_aclgrp,  grouptype FROM jacl_group WHERE id_aclgrp=".intval($params[0]); 
  • trunk/lib/jelix-scripts/commands/aclright.cmd.php

    r414 r560  
    8181                 AND r.id_aclsbj=s.id_aclsbj 
    8282                ORDER BY name, subject, value,id_aclres "; 
    83         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     83        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    8484        $rs = $cnx->query($sql); 
    8585        echo "group\tsubject\tvalue\t\tresource\n---------------------------------------------------------------\n"; 
     
    106106            die("wrong parameter count\n"); 
    107107 
    108         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     108        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    109109 
    110110        $group = intval($params[0]); 
     
    160160            die("wrong parameter count\n"); 
    161161 
    162          $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     162         $cnx = jDb::getConnection(jAclDb::getProfil()); 
    163163 
    164164        $group = intval($params[0]); 
     
    196196 
    197197        $sql="SELECT id_aclsbj, id_aclvalgrp, label_key FROM jacl_subject ORDER BY id_aclsbj"; 
    198         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     198        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    199199        $rs = $cnx->query($sql); 
    200200        echo "id\t\t\tlabel key\n--------------------------------------------------------\n"; 
     
    216216            die("wrong parameter count\n"); 
    217217 
    218         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     218        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    219219  
    220220        $sql="SELECT id_aclsbj FROM jacl_subject WHERE id_aclsbj=".$cnx->quote($params[0]); 
     
    244244            die("wrong parameter count\n"); 
    245245 
    246         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     246        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    247247 
    248248        $sql="SELECT id_aclsbj FROM jacl_subject WHERE id_aclsbj=".$cnx->quote($params[0]); 
  • trunk/lib/jelix-scripts/commands/aclright.cmd.php

    r414 r560  
    8181                 AND r.id_aclsbj=s.id_aclsbj 
    8282                ORDER BY name, subject, value,id_aclres "; 
    83         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     83        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    8484        $rs = $cnx->query($sql); 
    8585        echo "group\tsubject\tvalue\t\tresource\n---------------------------------------------------------------\n"; 
     
    106106            die("wrong parameter count\n"); 
    107107 
    108         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     108        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    109109 
    110110        $group = intval($params[0]); 
     
    160160            die("wrong parameter count\n"); 
    161161 
    162          $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     162         $cnx = jDb::getConnection(jAclDb::getProfil()); 
    163163 
    164164        $group = intval($params[0]); 
     
    196196 
    197197        $sql="SELECT id_aclsbj, id_aclvalgrp, label_key FROM jacl_subject ORDER BY id_aclsbj"; 
    198         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     198        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    199199        $rs = $cnx->query($sql); 
    200200        echo "id\t\t\tlabel key\n--------------------------------------------------------\n"; 
     
    216216            die("wrong parameter count\n"); 
    217217 
    218         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     218        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    219219  
    220220        $sql="SELECT id_aclsbj FROM jacl_subject WHERE id_aclsbj=".$cnx->quote($params[0]); 
     
    244244            die("wrong parameter count\n"); 
    245245 
    246         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     246        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    247247 
    248248        $sql="SELECT id_aclsbj FROM jacl_subject WHERE id_aclsbj=".$cnx->quote($params[0]); 
  • trunk/lib/jelix-scripts/commands/aclvalue.cmd.php

    r414 r560  
    9696    protected function cmd_group_list(){ 
    9797        $sql="SELECT id_aclvalgrp, label_key, type_aclvalgrp FROM jacl_right_values_group ORDER BY id_aclvalgrp"; 
    98         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     98        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    9999        $rs = $cnx->query($sql); 
    100100        echo "id\tlabel key\t\t\ttype\n--------------------------------------------------------\n"; 
     
    113113            die("wrong parameter count\n"); 
    114114 
    115         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     115        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    116116 
    117117        $sql="INSERT into jacl_right_values_group (id_aclvalgrp, label_key, type_aclvalgrp) VALUES ("; 
     
    129129            die("wrong parameter count\n"); 
    130130 
    131         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     131        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    132132 
    133133        $rs = $cnx->query('SELECT count(id_aclsbj) as n FROM jacl_subject WHERE id_aclvalgrp='.intval($params[0])); 
     
    168168        } 
    169169 
    170         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     170        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    171171        $rs = $cnx->query($sql); 
    172172 
     
    197197            die("wrong parameter count\n"); 
    198198 
    199         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     199        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    200200 
    201201        $rs = $cnx->query('SELECT count(id_aclvalgrp) as n FROM jacl_right_values_group WHERE id_aclvalgrp='.intval($params[2])); 
     
    226226            die("wrong parameter count\n"); 
    227227 
    228         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     228        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    229229 
    230230        $rs = $cnx->query('SELECT count(*) as n FROM jacl_right_values WHERE id_aclvalgrp='.intval($params[1]).' AND value='.$cnx->quote($params[0])); 
  • trunk/lib/jelix-scripts/commands/aclvalue.cmd.php

    r414 r560  
    9696    protected function cmd_group_list(){ 
    9797        $sql="SELECT id_aclvalgrp, label_key, type_aclvalgrp FROM jacl_right_values_group ORDER BY id_aclvalgrp"; 
    98         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     98        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    9999        $rs = $cnx->query($sql); 
    100100        echo "id\tlabel key\t\t\ttype\n--------------------------------------------------------\n"; 
     
    113113            die("wrong parameter count\n"); 
    114114 
    115         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     115        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    116116 
    117117        $sql="INSERT into jacl_right_values_group (id_aclvalgrp, label_key, type_aclvalgrp) VALUES ("; 
     
    129129            die("wrong parameter count\n"); 
    130130 
    131         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     131        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    132132 
    133133        $rs = $cnx->query('SELECT count(id_aclsbj) as n FROM jacl_subject WHERE id_aclvalgrp='.intval($params[0])); 
     
    168168        } 
    169169 
    170         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     170        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    171171        $rs = $cnx->query($sql); 
    172172 
     
    197197            die("wrong parameter count\n"); 
    198198 
    199         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     199        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    200200 
    201201        $rs = $cnx->query('SELECT count(id_aclvalgrp) as n FROM jacl_right_values_group WHERE id_aclvalgrp='.intval($params[2])); 
     
    226226            die("wrong parameter count\n"); 
    227227 
    228         $cnx = jDb::getConnection(jAcl::getDbProfil()); 
     228        $cnx = jDb::getConnection(jAclDb::getProfil()); 
    229229 
    230230        $rs = $cnx->query('SELECT count(*) as n FROM jacl_right_values WHERE id_aclvalgrp='.intval($params[1]).' AND value='.$cnx->quote($params[0])); 
  • trunk/lib/jelix-scripts/templates/var/config/defaultconfig.ini.php.tpl

    r559 r560  
    129129; SMTP server timeout in seconds 
    130130smtpTimeout = 10 
     131 
     132 
     133[acl] 
     134driver = db 
  • trunk/lib/jelix-scripts/templates/var/config/defaultconfig.ini.php.tpl

    r559 r560  
    129129; SMTP server timeout in seconds 
    130130smtpTimeout = 10 
     131 
     132 
     133[acl] 
     134driver = db 
  • trunk/lib/jelix/acl/jAcl.class.php

    r412 r560  
    44* @subpackage  acl 
    55* @author      Laurent Jouanneau 
    6 * @copyright   2006 Laurent Jouanneau 
     6* @copyright   2006-2007 Laurent Jouanneau 
    77* @link        http://www.jelix.org 
    88* @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 
     
    1111 
    1212/** 
     13 * interface for jAcl drivers 
     14 * @package jelix 
     15 * @subpackage acl 
     16 */ 
     17interface jIAclDriver { 
     18 
     19    /** 
     20     * return the possible values of the right on the given subject (and on the optional resource) 
     21     * @param string $subject the key of the subject 
     22     * @param string $resource the id of a resource 
     23     * @return array list of values corresponding to the right 
     24     */ 
     25    public function getRight($subject, $resource=null); 
     26 
     27    /** 
     28     * clear some cached datas, it a cache exists in the driver.. 
     29     */ 
     30    public function clearCache(); 
     31 
     32} 
     33 
     34/** 
    1335 * Main class to query the acl system, and to know value of a right 
    1436 * 
    1537 * you should call this class (all method are static) when you want to know if 
    16  * the current user have a right, or to know if he is a member of a group 
    17  * This class needs the acl module. 
     38 * the current user have a right 
    1839 * @package jelix 
    1940 * @subpackage acl 
     
    2849 
    2950    /** 
    30      * Says if the current user is a member of the given user group 
    31      * @param int $groupid The id of a group 
    32      * @return boolean true if it's ok 
     51     * load the acl driver 
     52     * @return jIAclDriver 
    3353     */ 
    34     public static function isMemberOfGroup ($groupid){ 
    35         $groups = self::getGroups(); 
    36         return in_array($groupid, $groups); 
     54    protected static function _getDriver(){ 
     55        static $driver = null; 
     56        if($driver == null){ 
     57            global $gJConfig; 
     58            $db = strtolower($gJConfig->acl['driver']); 
     59            if(!isset($gJConfig->_pluginsPathList_acl)  
     60                || !isset($gJConfig->_pluginsPathList_acl[$db]) 
     61                || !file_exists($gJConfig->_pluginsPathList_acl[$db]) ){ 
     62                 throw new jException('jelix~errors.acl.driver.notfound',$db); 
     63            } 
     64            require_once($gJConfig->_pluginsPathList_acl[$db].$db.'.acl.php'); 
     65            $dname = $gJConfig->acl['driver'].'AclDriver'; 
     66            $driver = new $dname($gJConfig->acl); 
     67        } 
     68        return $driver; 
    3769    } 
     70 
    3871 
    3972    /** 
     
    4477     * @return boolean true if yes 
    4578     */ 
    46     public static function check($subject, $value, $resource=null){ 
     79    public static function check($subject, $value=true, $resource=null){ 
    4780        $val = self::getRight($subject, $resource); 
    4881        return in_array($value,$val); 
    4982    } 
     83         
    5084 
    51  
    52     protected static $aclres = array(); 
    53     protected static $acl = array(); 
    5485 
    5586    /** 
     
    6091     */ 
    6192    public static function getRight($subject, $resource=null){ 
    62  
    63         if($resource === null && isset(self::$acl[$subject])){ 
    64             return self::$acl[$subject]; 
    65         }elseif(isset(self::$aclres[$subject][$resource])){ 
    66             return self::$aclres[$subject][$resource]; 
    67         } 
    68  
    69         if(!jAuth::isConnected()) // not authificated = no rights 
    70             return array(); 
    71  
    72         $groups = self::getGroups(); 
    73  
    74         // recupère toutes les valeurs correspondant aux groupes auquel appartient le user, 
    75         //   avec le sujet et ressource indiqué 
    76         $values= array(); 
    77         $dao = jDao::get('jelix~jaclrights', self::getDbProfil()); 
    78         $list = $dao->getAllGroupRights($subject, $groups); 
    79         foreach($list as $right){ 
    80             $values [] = $right->value; 
    81         } 
    82         self::$acl[$subject] = $values; 
    83  
    84         if($resource !== null){ 
    85             $list = $dao->getAllGroupRightsWithRes($subject, $groups, $resource); 
    86             foreach($list as $right){ 
    87                 $values [] = $right->value; 
    88             } 
    89             self::$aclres[$subject][$resource] = $values = array_unique($values); 
    90         } 
    91  
    92         return $values; 
     93        $dr = self::_getDriver(); 
     94        return $dr->getRight($subject, $resource); 
    9395    } 
    9496 
     
    98100     */ 
    99101    public static function clearCache(){ 
    100         self::$acl = array(); 
    101         self::$aclres = array(); 
    102     } 
    103  
    104  
    105     /** 
    106      * retrieve the list of group the current user is member of 
    107      * @return array list of group id 
    108      */ 
    109     protected static function getGroups(){ 
    110         static $groups = null; 
    111  
    112         if(!jAuth::isConnected()) 
    113             return array(); 
    114  
    115         // chargement des groupes 
    116         if($groups === null){ 
    117             $dao = jDao::get('jelix~jaclusergroup', self::getDbProfil()); 
    118             $gp = $dao->getGroupsUser($_SESSION['JELIX_USER']->login); 
    119             $groups = array(); 
    120             foreach($gp as $g){ 
    121                 $groups[]=intval($g->id_aclgrp); 
    122             } 
    123         } 
    124         return $groups; 
    125     } 
    126  
    127     /** 
    128      * return the profil name used for jacl connection 
    129      * @return string profil name 
    130      * @since 1.0b2 
    131      */ 
    132     public static function getDbProfil(){ 
    133         static $profil=''; 
    134         if($profil== ''){ 
    135             try{ 
    136                 $prof = jDb::getProfil ('jacl_profil', true); 
    137             }catch(Exception $e){ 
    138                 $prof = jDb::getProfil (); 
    139             } 
    140             $profil = $prof['name']; 
    141         } 
    142         return $profil; 
     102        $dr = self::_getDriver(); 
     103        $dr->clearCache(); 
    143104    } 
    144105} 
  • trunk/lib/jelix/acl/jAcl.class.php

    r412 r560  
    44* @subpackage  acl 
    55* @author      Laurent Jouanneau 
    6 * @copyright   2006 Laurent Jouanneau 
     6* @copyright   2006-2007 Laurent Jouanneau 
    77* @link        http://www.jelix.org 
    88* @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 
     
    1111 
    1212/** 
     13 * interface for jAcl drivers 
     14 * @package jelix 
     15 * @subpackage acl 
     16 */ 
     17interface jIAclDriver { 
     18 
     19    /** 
     20     * return the possible values of the right on the given subject (and on the optional resource) 
     21     * @param string $subject the key of the subject 
     22     * @param string $resource the id of a resource 
     23     * @return array list of values corresponding to the right 
     24     */ 
     25    public function getRight($subject, $resource=null); 
     26 
     27    /** 
     28     * clear some cached datas, it a cache exists in the driver.. 
     29     */ 
     30    public function clearCache(); 
     31 
     32} 
     33 
     34/** 
    1335 * Main class to query the acl system, and to know value of a right 
    1436 * 
    1537 * you should call this class (all method are static) when you want to know if 
    16  * the current user have a right, or to know if he is a member of a group 
    17  * This class needs the acl module. 
     38 * the current user have a right 
    1839 * @package jelix 
    1940 * @subpackage acl 
     
    2849 
    2950    /** 
    30      * Says if the current user is a member of the given user group 
    31      * @param int $groupid The id of a group 
    32      * @return boolean true if it's ok 
     51     * load the acl driver 
     52     * @return jIAclDriver 
    3353     */ 
    34     public static function isMemberOfGroup ($groupid){ 
    35         $groups = self::getGroups(); 
    36         return in_array($groupid, $groups); 
     54    protected static function _getDriver(){ 
     55        static $driver = null; 
     56        if($driver == null){ 
     57            global $gJConfig; 
     58            $db = strtolower($gJConfig->acl['driver']); 
     59            if(!isset($gJConfig->_pluginsPathList_acl)  
     60                || !isset($gJConfig->_pluginsPathList_acl[$db]) 
     61                || !file_exists($gJConfig->_pluginsPathList_acl[$db]) ){ 
     62                 throw new jException('jelix~errors.acl.driver.notfound',$db); 
     63            } 
     64            require_once($gJConfig->_pluginsPathList_acl[$db].$db.'.acl.php'); 
     65            $dname = $gJConfig->acl['driver'].'AclDriver'; 
     66            $driver = new $dname($gJConfig->acl); 
     67        } 
     68        return $driver; 
    3769    } 
     70 
    3871 
    3972    /** 
     
    4477     * @return boolean true if yes 
    4578     */ 
    46     public static function check($subject, $value, $resource=null){ 
     79    public static function check($subject, $value=true, $resource=null){ 
    4780        $val = self::getRight($subject, $resource); 
    4881        return in_array($value,$val); 
    4982    } 
     83         
    5084 
    51  
    52     protected static $aclres = array(); 
    53     protected static $acl = array(); 
    5485 
    5586    /** 
     
    6091     */ 
    6192    public static function getRight($subject, $resource=null){ 
    62  
    63         if($resource === null && isset(self::$acl[$subject])){ 
    64             return self::$acl[$subject]; 
    65         }elseif(isset(self::$aclres[$subject][$resource])){ 
    66             return self::$aclres[$subject][$resource]; 
    67         } 
    68  
    69         if(!jAuth::isConnected()) // not authificated = no rights 
    70             return array(); 
    71  
    72         $groups = self::getGroups(); 
    73  
    74         // recupère toutes les valeurs correspondant aux groupes auquel appartient le user, 
    75         //   avec le sujet et ressource indiqué 
    76         $values= array(); 
    77         $dao = jDao::get('jelix~jaclrights', self::getDbProfil()); 
    78         $list = $dao->getAllGroupRights($subject, $groups); 
    79         foreach($list as $right){ 
    80             $values [] = $right->value; 
    81         } 
    82         self::$acl[$subject] = $values; 
    83  
    84         if($resource !== null){ 
    85             $list = $dao->getAllGroupRightsWithRes($subject, $groups, $resource); 
    86             foreach($list as $right){ 
    87                 $values [] = $right->value; 
    88             } 
    89             self::$aclres[$subject][$resource] = $values = array_unique($values); 
    90         } 
    91  
    92         return $values; 
     93        $dr = self::_getDriver(); 
     94        return $dr->getRight($subject, $resource); 
    9395    } 
    9496 
     
    98100     */ 
    99101    public static function clearCache(){ 
    100         self::$acl = array(); 
    101         self::$aclres = array(); 
    102     } 
    103  
    104  
    105     /** 
    106      * retrieve the list of group the current user is member of 
    107      * @return array list of group id 
    108      */ 
    109     protected static function getGroups(){ 
    110         static $groups = null; 
    111  
    112         if(!jAuth::isConnected()) 
    113             return array(); 
    114  
    115         // chargement des groupes 
    116         if($groups === null){ 
    117             $dao = jDao::get('jelix~jaclusergroup', self::getDbProfil()); 
    118             $gp = $dao->getGroupsUser($_SESSION['JELIX_USER']->login); 
    119             $groups = array(); 
    120             foreach($gp as $g){ 
    121                 $groups[]=intval($g->id_aclgrp); 
    122             } 
    123         } 
    124         return $groups; 
    125     } 
    126  
    127     /** 
    128      * return the profil name used for jacl connection 
    129      * @return string profil name 
    130      * @since 1.0b2 
    131      */ 
    132     public static function getDbProfil(){ 
    133         static $profil=''; 
    134         if($profil== ''){ 
    135             try{ 
    136                 $prof = jDb::getProfil ('jacl_profil', true); 
    137             }catch(Exception $e){ 
    138                 $prof = jDb::getProfil (); 
    139             } 
    140             $profil = $prof['name']; 
    141         } 
    142         return $profil; 
     102        $dr = self::_getDriver(); 
     103        $dr->clearCache(); 
    143104    } 
    144105} 
  • trunk/lib/jelix/acl/jAclManager.class.php

    r412 r560  
    1313/** 
    1414 * This class is used to manage rights 
    15  * It needs the jxacl module. 
    1615 * @package     jelix 
    1716 * @subpackage  acl 
     
    3433     */ 
    3534    public static function addRight($group, $subject, $value , $resource=''){ 
    36         $profil = jAcl::getDbProfil(); 
     35        $profil = jAclDb::getProfil(); 
    3736        $daosbj = jDao::get('jelix~jaclsubject', $profil); 
    3837        $daorightval = jDao::get('jelix~jaclrightvalues', $profil); 
     
    7978     */ 
    8079    public static function removeRight($group, $subject, $value , $resource=''){ 
    81         $daoright = jDao::get('jelix~jaclrights', jAcl::getDbProfil()); 
     80        $daoright = jDao::get('jelix~jaclrights', jAclDb::getProfil()); 
    8281        if($resource === null) $resource=''; 
    8382        $daoright->delete($subject,$group,$resource,$value); 
     
    9392     */ 
    9493    public static function removeResourceRight($subject, $resource){ 
    95         $daoright = jDao::get('jelix~jaclrights', jAcl::getDbProfil()); 
     94        $daoright = jDao::get('jelix~jaclrights', jAclDb::getProfil()); 
    9695        $daoright->deleteBySubjRes($subject, $resource); 
    9796        jAcl::clearCache(); 
     
    106105    public static function addSubject($subject, $id_aclvalgrp, $label_key){ 
    107106        // ajoute un sujet dans la table jacl_subject 
    108         $p = jAcl::getDbProfil(); 
     107        $p = jAclDb::getProfil(); 
    109108        $daosbj = jDao::get('jelix~jaclsubject',$p); 
    110109        $subj = jDao::createRecord('jelix~jaclsubject',$p); 
     
    124123        // supprime dans jacl_rights 
    125124        // supprime dans jacl_subject 
    126         $p = jAcl::getDbProfil(); 
     125        $p = jAclDb::getProfil(); 
    127126        $daoright = jDao::get('jelix~jaclrights',$p); 
    128127        $daoright->deleteBySubject($subject); 
  • trunk/lib/jelix/acl/jAclManager.class.php

    r412 r560  
    1313/** 
    1414 * This class is used to manage rights 
    15  * It needs the jxacl module. 
    1615 * @package     jelix 
    1716 * @subpackage  acl 
     
    3433     */ 
    3534    public static function addRight($group, $subject, $value , $resource=''){ 
    36         $profil = jAcl::getDbProfil(); 
     35        $profil = jAclDb::getProfil(); 
    3736        $daosbj = jDao::get('jelix~jaclsubject', $profil); 
    3837        $daorightval = jDao::get('jelix~jaclrightvalues', $profil); 
     
    7978     */ 
    8079    public static function removeRight($group, $subject, $value , $resource=''){ 
    81         $daoright = jDao::get('jelix~jaclrights', jAcl::getDbProfil()); 
     80        $daoright = jDao::get('jelix~jaclrights', jAclDb::getProfil()); 
    8281        if($resource === null) $resource=''; 
    8382        $daoright->delete($subject,$group,$resource,$value); 
     
    9392     */ 
    9493    public static function removeResourceRight($subject, $resource){ 
    95         $daoright = jDao::get('jelix~jaclrights', jAcl::getDbProfil()); 
     94        $daoright = jDao::get('jelix~jaclrights', jAclDb::getProfil()); 
    9695        $daoright->deleteBySubjRes($subject, $resource); 
    9796        jAcl::clearCache(); 
     
    106105    public static function addSubject($subject, $id_aclvalgrp, $label_key){ 
    107106        // ajoute un sujet dans la table jacl_subject 
    108         $p = jAcl::getDbProfil(); 
     107        $p = jAclDb::getProfil(); 
    109108        $daosbj = jDao::get('jelix~jaclsubject',$p); 
    110109        $subj = jDao::createRecord('jelix~jaclsubject',$p); 
     
    124123        // supprime dans jacl_rights 
    125124        // supprime dans jacl_subject 
    126         $p = jAcl::getDbProfil(); 
     125        $p = jAclDb::getProfil(); 
    127126        $daoright = jDao::get('jelix~jaclrights',$p); 
    128127        $daoright->deleteBySubject($subject); 
  • trunk/lib/jelix/acl/jAclUserGroup.class.php

    r412 r560  
    1212/** 
    1313 * Use this class to register or unregister users in the acl system, and to manage user groups 
    14  * It needs the acl module. 
    1514 * @package     jelix 
    1615 * @subpackage  acl 
     
    2524 
    2625    /** 
     26     * Says if the current user is a member of the given user group 
     27     * @param int $groupid The id of a group 
     28     * @return boolean true if it's ok 
     29     */ 
     30    public static function isMemberOfGroup ($groupid){ 
     31        $groups = self::getGroups(); 
     32        return in_array($groupid, $groups); 
     33    } 
     34 
     35    /** 
     36     * retrieve the list of group the current user is member of 
     37     * @return array list of group id 
     38     */ 
     39    public static function getGroups(){ 
     40        static $groups = null; 
     41 
     42        if(!jAuth::isConnected()) 
     43            return array(); 
     44 
     45        // chargement des groupes 
     46        if($groups === null){ 
     47            $dao = jDao::get('jelix~jaclusergroup', jAclDb::getProfil()); 
     48            $gp = $dao->getGroupsUser($_SESSION['JELIX_USER']->login); 
     49            $groups = array(); 
     50            foreach($gp as $g){ 
     51                $groups[]=intval($g->id_aclgrp); 
     52            } 
     53        } 
     54        return $groups; 
     55    } 
     56 
     57 
     58    /** 
    2759     * get the list of the users of a group 
    2860     * @param int $groupid  id of the user group 
     
    3062     */ 
    3163    public static function getUsersList($groupid){ 
    32       $dao = jDao::get('jelix~jaclusergroup', jAcl::getDbProfil()); 
     64      $dao = jDao::get('jelix~jaclusergroup', jAclDb::getProfil()); 
    3365      return $dao->getUsersGroup($groupid); 
    3466    } 
     
    4476     */ 
    4577    public static function createUser($login, $defaultGroup=true){ 
    46         $p = jAcl::getDbProfil(); 
     78        $p = jAclDb::getProfil(); 
    4779        $daousergroup = jDao::get('jelix~jaclusergroup',$p); 
    4880        $daogroup = jDao::get('jelix~jaclgroup',$p); 
     
    78110     */ 
    79