/** * 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; }
/** * 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; }