Cosmetics changes : remove ending lines spaces

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3012 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2016-08-31 07:20:24 +00:00
parent 94099866f6
commit a04d3a4f4a
35 changed files with 208 additions and 210 deletions

View File

@@ -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
{
@@ -87,7 +87,7 @@ class authorizationdb extends authorization
// 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
{
@@ -172,7 +172,7 @@ class authorizationdb extends authorization
// 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);
@@ -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
{
@@ -236,7 +236,7 @@ class authorizationdb extends authorization
// 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;
@@ -266,10 +266,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;
@@ -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
{
@@ -310,7 +310,7 @@ class authorizationdb extends authorization
// 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
{
@@ -356,7 +356,7 @@ class authorizationdb extends authorization
// 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
{
@@ -399,7 +399,7 @@ class authorizationdb extends authorization
// 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
{
@@ -439,7 +439,7 @@ class authorizationdb extends authorization
// 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
{
@@ -477,7 +477,7 @@ class authorizationdb extends authorization
// 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
{
@@ -515,7 +515,7 @@ class authorizationdb extends authorization
// 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);
}
}