authzgroups : if the provided object start by a slash, don't add it.
authzgroups : add a local cache in the object, for the userrightsget, to not access to the database each time git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2265 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -16,6 +16,8 @@ class authzgroups
|
|||||||
private $dbGroupMember = null;
|
private $dbGroupMember = null;
|
||||||
private $dbRight = null;
|
private $dbRight = null;
|
||||||
public $debug = 0;
|
public $debug = 0;
|
||||||
|
/** A local cache of the rights if multiple tests are needed */
|
||||||
|
private $rightCache = null;
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// USER RIGHTS //
|
// USER RIGHTS //
|
||||||
@@ -27,6 +29,8 @@ class authzgroups
|
|||||||
{
|
{
|
||||||
// if (isset ($_SESSION["domframework"]["authzgroups"][$module][$user]))
|
// if (isset ($_SESSION["domframework"]["authzgroups"][$module][$user]))
|
||||||
// return $_SESSION["domframework"]["authzgroups"][$module][$user];
|
// return $_SESSION["domframework"]["authzgroups"][$module][$user];
|
||||||
|
if ($this->rightCache !== null)
|
||||||
|
return $this->rightCache;
|
||||||
if ($this->dbObject == null)
|
if ($this->dbObject == null)
|
||||||
throw new Exception (dgettext ("domframework",
|
throw new Exception (dgettext ("domframework",
|
||||||
"DB for Object is not connected"), 500);
|
"DB for Object is not connected"), 500);
|
||||||
@@ -88,6 +92,7 @@ class authzgroups
|
|||||||
}
|
}
|
||||||
if (isset ($_SESSION))
|
if (isset ($_SESSION))
|
||||||
$_SESSION["domframework"]["authzgroups"][$module][$user] = $res;
|
$_SESSION["domframework"]["authzgroups"][$module][$user] = $res;
|
||||||
|
$this->rightCache = $res;
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,10 +142,11 @@ class authzgroups
|
|||||||
if ($object === null || ! is_string ($object))
|
if ($object === null || ! is_string ($object))
|
||||||
throw new Exception ("Object not provided to authzgroups\\accessRight",
|
throw new Exception ("Object not provided to authzgroups\\accessRight",
|
||||||
500);
|
500);
|
||||||
if ($object === "/") $object = "";
|
if ($object{0} !== "/")
|
||||||
$rc = $this->allow ($module, $user, "/$object");
|
$object = "/$object";
|
||||||
|
$rc = $this->allow ($module, $user, "$object");
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
trigger_error ("authzgroups : accessRight ('$module','$user','/$object')".
|
trigger_error ("authzgroups : accessRight ('$module','$user','$object')".
|
||||||
"=$rc", E_USER_NOTICE);
|
"=$rc", E_USER_NOTICE);
|
||||||
if ($rc !== "NO")
|
if ($rc !== "NO")
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -166,10 +172,11 @@ class authzgroups
|
|||||||
if ($object === null || ! is_string ($object))
|
if ($object === null || ! is_string ($object))
|
||||||
throw new Exception ("Object not provided to authzgroups\\accessWrite",
|
throw new Exception ("Object not provided to authzgroups\\accessWrite",
|
||||||
500);
|
500);
|
||||||
if ($object === "/") $object = "";
|
if ($object{0} !== "/")
|
||||||
$rc = $this->allow ($module, $user, "/$object");
|
$object = "/$object";
|
||||||
|
$rc = $this->allow ($module, $user, $object);
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
trigger_error ("authzgroups : accessWrite ('$module','$user','/$object')".
|
trigger_error ("authzgroups : accessWrite ('$module','$user','$object')".
|
||||||
"=$rc", E_USER_NOTICE);
|
"=$rc", E_USER_NOTICE);
|
||||||
if ($rc === "RW")
|
if ($rc === "RW")
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -196,11 +203,12 @@ class authzgroups
|
|||||||
if ($object === null || ! is_string ($object))
|
if ($object === null || ! is_string ($object))
|
||||||
throw new Exception ("Object not provided to authzgroups\\accessReadOnly",
|
throw new Exception ("Object not provided to authzgroups\\accessReadOnly",
|
||||||
500);
|
500);
|
||||||
if ($object === "/") $object = "";
|
if ($object{0} !== "/")
|
||||||
$rc = $this->allow ($module, $user, "/$object");
|
$object = "/$object";
|
||||||
|
$rc = $this->allow ($module, $user, $object);
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
trigger_error ("authzgroups : accessReadOnly ('$module','$user',".
|
trigger_error ("authzgroups : accessReadOnly ('$module','$user',".
|
||||||
"'/$object')" ."=$rc", E_USER_NOTICE);
|
"'$object')" ."=$rc", E_USER_NOTICE);
|
||||||
if ($rc === "RO")
|
if ($rc === "RO")
|
||||||
return TRUE;
|
return TRUE;
|
||||||
if ($user === "anonymous")
|
if ($user === "anonymous")
|
||||||
|
|||||||
Reference in New Issue
Block a user