Change all the "new class" by "new Class"
This commit is contained in:
@@ -28,7 +28,7 @@ class Authorizationdb extends Authorization
|
||||
$driver_options=null)
|
||||
{
|
||||
// Define the structure of the table in the database
|
||||
$this->db = new dblayer ($dsn, $username, $password, $driver_options);
|
||||
$this->db = new Dblayer ($dsn, $username, $password, $driver_options);
|
||||
$this->db->table = "domframework_authorization";
|
||||
$this->db->tableprefix = $this->tableprefix;
|
||||
$this->db->fields = array (
|
||||
@@ -44,7 +44,7 @@ class Authorizationdb extends Authorization
|
||||
public function initialize ()
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Database to authorize is not connected"), 500);
|
||||
$tables = $this->db->listTables ();
|
||||
if (!in_array ($this->db->tableprefix.$this->db->table, $tables))
|
||||
@@ -63,16 +63,16 @@ class Authorizationdb extends Authorization
|
||||
public function validate ($object)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Database to authorize is not connected"), 500);
|
||||
if (substr ($object, -1) === "/")
|
||||
$object = substr ($object, 0, -1);
|
||||
if (substr ($object, 0, 1) !== "/")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Object don't start by slash"), 406);
|
||||
$object = preg_replace ("#//+#", "/", $object);
|
||||
if ($this->authiduser === "")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Not authenticated"), 401);
|
||||
try
|
||||
{
|
||||
@@ -80,14 +80,14 @@ class Authorizationdb extends Authorization
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception ($e->getMessage(), 405);
|
||||
throw new \Exception ($e->getMessage(), 405);
|
||||
}
|
||||
|
||||
// All the folder structure is accessible. Check if the object already
|
||||
// exists
|
||||
$search = $this->db->read (array (array ("object", $object)));
|
||||
if (count ($search) === 0)
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"Object %s doesn't exists"),
|
||||
$object),
|
||||
404);
|
||||
@@ -140,24 +140,24 @@ class Authorizationdb extends Authorization
|
||||
public function add ($object, $ownerid, $groupid, $modbits)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Database to authorize is not connected"), 500);
|
||||
// The modbits are stored in octal to be more readable
|
||||
$modbits = decoct ($modbits);
|
||||
if (substr ($object, -1) === "/")
|
||||
$object = substr ($object, 0, -1);
|
||||
if (substr ($object, 0, 1) !== "/")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Object don't start by slash"), 406);
|
||||
$object = preg_replace ("#//+#", "/", $object);
|
||||
if ($this->authiduser === "")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Not authenticated"), 401);
|
||||
if ($this->authiduser !== 0 && $this->authiduser !== $ownerid)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Can't create object not owned by myself"), 406);
|
||||
if ($this->authiduser !== 0 && !in_array ($groupid, $this->authgroups))
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Can't create object with not owned group"), 406);
|
||||
try
|
||||
{
|
||||
@@ -165,14 +165,14 @@ class Authorizationdb extends Authorization
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception ($e->getMessage(), 405);
|
||||
throw new \Exception ($e->getMessage(), 405);
|
||||
}
|
||||
|
||||
// All the folder structure is accessible. Check if the object already
|
||||
// exists
|
||||
$search = $this->db->read (array (array ("object", $object)));
|
||||
if (count ($search))
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"Object %s already defined"), $object),
|
||||
400);
|
||||
|
||||
@@ -193,7 +193,7 @@ class Authorizationdb extends Authorization
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception ($e->getMessage(), 405);
|
||||
throw new \Exception ($e->getMessage(), 405);
|
||||
}
|
||||
|
||||
$this->db->create (array ("object"=>$object,
|
||||
@@ -209,19 +209,19 @@ class Authorizationdb extends Authorization
|
||||
public function drop ($object)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Database to authorize is not connected"), 500);
|
||||
if (substr ($object, -1) === "/")
|
||||
$object = substr ($object, 0, -1);
|
||||
if (substr ($object, 0, 1) !== "/")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Object don't start by slash"), 406);
|
||||
$object = preg_replace ("#//+#", "/", $object);
|
||||
if ($this->authiduser === "")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Not authenticated"), 401);
|
||||
if ($object === "/")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"The root can not be removed"), 406);
|
||||
try
|
||||
{
|
||||
@@ -229,14 +229,14 @@ class Authorizationdb extends Authorization
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception ($e->getMessage(), 405);
|
||||
throw new \Exception ($e->getMessage(), 405);
|
||||
}
|
||||
|
||||
// All the folder structure is accessible. Check if the object already
|
||||
// exists
|
||||
$search = $this->db->read (array (array ("object", $object)));
|
||||
if (count ($search) === 0)
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"Object %s doesn't exists"),
|
||||
$object), 400);
|
||||
|
||||
@@ -246,10 +246,10 @@ class Authorizationdb extends Authorization
|
||||
{
|
||||
$rc = $this->db->delete ($object);
|
||||
if ($rc > 1)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Removing more than one object"), 406);
|
||||
if ($rc == 0)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"No object removed"), 406);
|
||||
$rc = $this->db->delete ("$object$this->separator%");
|
||||
return TRUE;
|
||||
@@ -261,15 +261,15 @@ class Authorizationdb extends Authorization
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception ($e->getMessage(), 405);
|
||||
throw new \Exception ($e->getMessage(), 405);
|
||||
}
|
||||
|
||||
$rc = $this->db->delete ($object);
|
||||
if ($rc > 1)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Removing more than one object"), 406);
|
||||
if ($rc == 0)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"No object removed"), 406);
|
||||
$rc = $this->db->delete ("$object$this->separator%");
|
||||
return TRUE;
|
||||
@@ -283,19 +283,19 @@ class Authorizationdb extends Authorization
|
||||
public function chown ($object, $ownerid)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Database to authorize is not connected"), 500);
|
||||
if (substr ($object, -1) === "/")
|
||||
$object = substr ($object, 0, -1);
|
||||
if (substr ($object, 0, 1) !== "/")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Object don't start by slash"), 406);
|
||||
$object = preg_replace ("#//+#", "/", $object);
|
||||
if ($this->authiduser === "")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Not authenticated"), 401);
|
||||
if ($this->authiduser !== 0)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"The chown is reserved to root user"), 405);
|
||||
try
|
||||
{
|
||||
@@ -303,14 +303,14 @@ class Authorizationdb extends Authorization
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception ($e->getMessage(), 405);
|
||||
throw new \Exception ($e->getMessage(), 405);
|
||||
}
|
||||
|
||||
// All the folder structure is accessible. Check if the object already
|
||||
// exists
|
||||
$search = $this->db->read (array (array ("object", $object)));
|
||||
if (count ($search) === 0)
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"Object %s doesn't exists"), $object),
|
||||
400);
|
||||
$search = reset ($search);
|
||||
@@ -326,22 +326,22 @@ class Authorizationdb extends Authorization
|
||||
public function chgrp ($object, $groupid)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Database to authorize is not connected"), 500);
|
||||
if (substr ($object, -1) === "/")
|
||||
$object = substr ($object, 0, -1);
|
||||
if (substr ($object, 0, 1) !== "/")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Object don't start by slash"), 406);
|
||||
$object = preg_replace ("#//+#", "/", $object);
|
||||
if ($this->authiduser === "")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Not authenticated"), 401);
|
||||
if ($this->authiduser !== 0 && !in_array ($groupid, $this->authgroups))
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"The user must be in the wanted group"), 405);
|
||||
if (!in_array ("WRITE", $this->validate ($object)))
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"%s is write protected"), $object), 405);
|
||||
try
|
||||
{
|
||||
@@ -349,14 +349,14 @@ class Authorizationdb extends Authorization
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception ($e->getMessage(), 405);
|
||||
throw new \Exception ($e->getMessage(), 405);
|
||||
}
|
||||
|
||||
// All the folder structure is accessible. Check if the object already
|
||||
// exists
|
||||
$search = $this->db->read (array (array ("object", $object)));
|
||||
if (count ($search) === 0)
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"Object %s doesn't exists"), $object),
|
||||
400);
|
||||
$search = reset ($search);
|
||||
@@ -372,19 +372,19 @@ class Authorizationdb extends Authorization
|
||||
public function chmod ($object, $mod)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Database to authorize is not connected"), 500);
|
||||
if (substr ($object, -1) === "/")
|
||||
$object = substr ($object, 0, -1);
|
||||
if (substr ($object, 0, 1) !== "/")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Object don't start by slash"), 406);
|
||||
$object = preg_replace ("#//+#", "/", $object);
|
||||
if ($this->authiduser === "")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Not authenticated"), 401);
|
||||
if (!in_array ("WRITE", $this->validate ($object)))
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"%s is write protected"), $object), 405);
|
||||
try
|
||||
{
|
||||
@@ -392,14 +392,14 @@ class Authorizationdb extends Authorization
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception ($e->getMessage(), 405);
|
||||
throw new \Exception ($e->getMessage(), 405);
|
||||
}
|
||||
|
||||
// All the folder structure is accessible. Check if the object already
|
||||
// exists
|
||||
$search = $this->db->read (array (array ("object", $object)));
|
||||
if (count ($search) === 0)
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"Object %s doesn't exists"), $object),
|
||||
400);
|
||||
$search = reset ($search);
|
||||
@@ -415,16 +415,16 @@ class Authorizationdb extends Authorization
|
||||
public function lsmod ($object)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Database to authorize is not connected"), 500);
|
||||
if (substr ($object, -1) === "/")
|
||||
$object = substr ($object, 0, -1);
|
||||
if (substr ($object, 0, 1) !== "/")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Object don't start by slash"), 406);
|
||||
$object = preg_replace ("#//+#", "/", $object);
|
||||
if ($this->authiduser === "")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Not authenticated"), 401);
|
||||
try
|
||||
{
|
||||
@@ -432,14 +432,14 @@ class Authorizationdb extends Authorization
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception ($e->getMessage(), 405);
|
||||
throw new \Exception ($e->getMessage(), 405);
|
||||
}
|
||||
|
||||
// All the folder structure is accessible. Check if the object already
|
||||
// exists
|
||||
$search = $this->db->read (array (array ("object", $object)));
|
||||
if (count ($search) === 0)
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"Object %s doesn't exists"), $object),
|
||||
400);
|
||||
$search = reset ($search);
|
||||
@@ -453,16 +453,16 @@ class Authorizationdb extends Authorization
|
||||
public function lsown ($object)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Database to authorize is not connected"), 500);
|
||||
if (substr ($object, -1) === "/")
|
||||
$object = substr ($object, 0, -1);
|
||||
if (substr ($object, 0, 1) !== "/")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Object don't start by slash"), 406);
|
||||
$object = preg_replace ("#//+#", "/", $object);
|
||||
if ($this->authiduser === "")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Not authenticated"), 401);
|
||||
try
|
||||
{
|
||||
@@ -470,14 +470,14 @@ class Authorizationdb extends Authorization
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception ($e->getMessage(), 405);
|
||||
throw new \Exception ($e->getMessage(), 405);
|
||||
}
|
||||
|
||||
// All the folder structure is accessible. Check if the object already
|
||||
// exists
|
||||
$search = $this->db->read (array (array ("object", $object)));
|
||||
if (count ($search) === 0)
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"Object %s doesn't exists"), $object),
|
||||
400);
|
||||
$search = reset ($search);
|
||||
@@ -491,16 +491,16 @@ class Authorizationdb extends Authorization
|
||||
public function lsgrp ($object)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Database to authorize is not connected"), 500);
|
||||
if (substr ($object, -1) === "/")
|
||||
$object = substr ($object, 0, -1);
|
||||
if (substr ($object, 0, 1) !== "/")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Object don't start by slash"), 406);
|
||||
$object = preg_replace ("#//+#", "/", $object);
|
||||
if ($this->authiduser === "")
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Not authenticated"), 401);
|
||||
try
|
||||
{
|
||||
@@ -508,14 +508,14 @@ class Authorizationdb extends Authorization
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception ($e->getMessage(), 405);
|
||||
throw new \Exception ($e->getMessage(), 405);
|
||||
}
|
||||
|
||||
// All the folder structure is accessible. Check if the object already
|
||||
// exists
|
||||
$search = $this->db->read (array (array ("object", $object)));
|
||||
if (count ($search) === 0)
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"Object %s doesn't exists"), $object),
|
||||
404);
|
||||
$search = reset ($search);
|
||||
@@ -531,7 +531,7 @@ class Authorizationdb extends Authorization
|
||||
private function treecheckExecute ($object)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext ("domframework",
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Database to authorize is not connected"), 500);
|
||||
// Search all the parents in an array
|
||||
$parents = array ();
|
||||
@@ -568,7 +568,7 @@ class Authorizationdb extends Authorization
|
||||
}
|
||||
}
|
||||
if (!$found)
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"The path %s is not found in database"),
|
||||
$p), 404);
|
||||
else
|
||||
@@ -593,7 +593,7 @@ class Authorizationdb extends Authorization
|
||||
if (($parentModbits & 0001) === 1)
|
||||
continue;
|
||||
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"No execute rights on %s"), $p), 405);
|
||||
}
|
||||
}
|
||||
@@ -624,7 +624,7 @@ class Authorizationdb extends Authorization
|
||||
if (($parentModbits & 0002) === 2)
|
||||
return TRUE;
|
||||
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
throw new \Exception (sprintf (dgettext ("domframework",
|
||||
"No write rights on %s"), $parent), 405);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user