Пример #1
0
 /**
  * return the value of the right on the given subject (and on the optional resource)
  * @param string $subject the key of the subject
  * @param string $resource the id of a resource
  * @return array list of values corresponding to the right
  */
 public function getRight($subject, $resource = null)
 {
     if ($resource === null && isset(self::$acl[$subject])) {
         return self::$acl[$subject];
     } elseif (isset(self::$aclres[$subject][$resource])) {
         return self::$aclres[$subject][$resource];
     }
     if (!jAuth::isConnected()) {
         // not authificated = no rights
         return array();
     }
     $groups = jAclDbUserGroup::getGroups();
     if (count($groups) == 0) {
         self::$acl[$subject] = array();
         self::$aclres[$subject][$resource] = array();
         return array();
     }
     // recupère toutes les valeurs correspondant aux groupes auquel appartient le user,
     //   avec le sujet et ressource indiqué
     $values = array();
     $dao = jDao::get('jelix~jaclrights', jAclDb::getProfile());
     $list = $dao->getAllGroupRights($subject, $groups);
     foreach ($list as $right) {
         $values[] = $right->value;
     }
     self::$acl[$subject] = $values;
     if ($resource !== null) {
         $list = $dao->getAllGroupRightsWithRes($subject, $groups, $resource);
         foreach ($list as $right) {
             $values[] = $right->value;
         }
         self::$aclres[$subject][$resource] = $values = array_unique($values);
     }
     return $values;
 }
Пример #2
0
 /**
  * return the value of the right on the given subject (and on the optional resource)
  * @param string $subject the key of the subject
  * @param string $resource the id of a resource
  * @return array list of values corresponding to the right
  */
 public function getRight($subject, $resource = null)
 {
     if ($resource === null && isset(self::$acl[$subject])) {
         return self::$acl[$subject];
     } elseif (isset(self::$aclres[$subject][$resource])) {
         return self::$aclres[$subject][$resource];
     }
     if (!jAuth::isConnected()) {
         // not authificated = no rights
         return array();
     }
     $groups = jAclDbUserGroup::getGroups();
     if (count($groups) == 0) {
         self::$acl[$subject] = array();
         self::$aclres[$subject][$resource] = array();
         return array();
     }
     // get all the values corresponding to the groups which the user has access to,
     //  with the subject and resource indicated
     $values = array();
     $dao = jDao::get('jacldb~jaclrights', 'jacl_profile');
     $list = $dao->getAllGroupRights($subject, $groups);
     foreach ($list as $right) {
         $values[] = $right->value;
     }
     self::$acl[$subject] = $values;
     if ($resource !== null) {
         $list = $dao->getAllGroupRightsWithRes($subject, $groups, $resource);
         foreach ($list as $right) {
             $values[] = $right->value;
         }
         self::$aclres[$subject][$resource] = $values = array_unique($values);
     }
     return $values;
 }
Пример #3
0
 /**
  * Called when a user has been removed : delete rights about this user
  *
  * @param jEvent $event   the event
  */
 function onAuthRemoveUser($event)
 {
     if (jApp::config()->acl['driver'] == 'db') {
         $login = $event->getParam('login');
         jAclDbUserGroup::removeUser($login);
     }
 }
Пример #4
0
 /**
  * Called when a user has been removed : delete rights about this user
  *
  * @param jEvent $event   the event
  */
 function onAuthRemoveUser($event)
 {
     if ($GLOBALS['gJConfig']->acl['driver'] == 'db') {
         $login = $event->getParam('login');
         jAclDbUserGroup::removeUser($login);
     }
 }
 public function testRemoveUsedGroup()
 {
     // on detruit un groupe qui a des users
     // on ajoute d'abord un user dans un groupe
     jAclDbUserGroup::addUserToGroup('max', $this->grpId3);
     $this->usergroups = array(array('login' => 'laurent', 'id_aclgrp' => $this->grpId5), array('login' => 'max', 'id_aclgrp' => $this->grpId6), array('login' => 'max', 'id_aclgrp' => $this->defaultGroupId), array('login' => 'max', 'id_aclgrp' => $this->grpId3));
     $this->assertTableContainsRecords('jacl_user_group', $this->usergroups);
     // ok maintenant on supprime le groupe
     jAclDbUserGroup::removeGroup($this->grpId3);
     $this->usergroups = array(array('login' => 'laurent', 'id_aclgrp' => $this->grpId5), array('login' => 'max', 'id_aclgrp' => $this->grpId6), array('login' => 'max', 'id_aclgrp' => $this->defaultGroupId));
     $this->assertTableContainsRecords('jacl_user_group', $this->usergroups);
     unset($this->groups[2]);
     $this->assertTableContainsRecords('jacl_group', $this->groups);
 }
Пример #6
0
 public function testIsMemberOfGroup()
 {
     $this->assertTrue(jAclDbUserGroup::isMemberOfGroup(1));
     $this->assertFalse(jAclDbUserGroup::isMemberOfGroup(2));
 }