Update gettext : add spaces

DomCi : remove line too longs on all the files


git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5280 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2019-05-23 14:19:30 +00:00
parent a79b59685f
commit 17168aaaef
39 changed files with 588 additions and 565 deletions

View File

@@ -185,8 +185,8 @@ class authsql extends auth
$rc = $this->db->update ($email, $rc = $this->db->update ($email,
array ($this->fieldPassword => $cryptpassword)); array ($this->fieldPassword => $cryptpassword));
if ($rc !== 1) if ($rc !== 1)
throw new Exception (dgettext("domframework","Can't change the password"), throw new Exception (dgettext ("domframework",
500); "Can't change the password"), 500);
} }
/** List all the users available in the database /** List all the users available in the database
Return firstname, lastname, mail, with mail is an array */ Return firstname, lastname, mail, with mail is an array */

View File

@@ -321,15 +321,11 @@ class authzgroups
$this->dbGroupMember->foreign = array ( $this->dbGroupMember->foreign = array (
"idgroup"=>array ("authzgroup", "idgroup", "idgroup"=>array ("authzgroup", "idgroup",
"ON UPDATE CASCADE ON DELETE CASCADE")); "ON UPDATE CASCADE ON DELETE CASCADE"));
$this->dbGroupMember->titles = array ("idgroupmember"=> $this->dbGroupMember->titles = array (
dgettext("domframework", "idgroupmember"=> dgettext ("domframework", "idgroupmember"),
"idgroupmember"), "user"=>dgettext ("domframework", "User"),
"user"=>dgettext("domframework", "idgroup"=>dgettext ("domframework", "idgroup"),
"User"), "comment"=>dgettext ("domframework", "Comment"));
"idgroup"=>dgettext("domframework",
"idgroup"),
"comment"=>dgettext("domframework",
"Comment"));
$this->dbRight = new dblayer ($dsn, $username, $password, $driver_options); $this->dbRight = new dblayer ($dsn, $username, $password, $driver_options);
$this->dbRight->debug = $this->debug; $this->dbRight->debug = $this->debug;
@@ -349,15 +345,12 @@ class authzgroups
"idobject"=>array ("authzobject", "idobject", "idobject"=>array ("authzobject", "idobject",
"ON UPDATE CASCADE ON DELETE CASCADE"), "ON UPDATE CASCADE ON DELETE CASCADE"),
); );
$this->dbRight->titles = array ("idright"=>dgettext("domframework", $this->dbRight->titles = array (
"idright"), "idright"=>dgettext ("domframework", "idright"),
"idgroup"=>dgettext("domframework", "idgroup"=>dgettext ("domframework", "idgroup"),
"idgroup"), "idobject"=>dgettext ("domframework", "idobject"),
"idobject"=>dgettext("domframework",
"idobject"),
"right"=>dgettext ("domframework", "Right"), "right"=>dgettext ("domframework", "Right"),
"comment"=>dgettext("domframework", "comment"=>dgettext ("domframework", "Comment"));
"Comment"));
return TRUE; return TRUE;
} }

View File

@@ -133,7 +133,7 @@ class dblayer
$driver = @explode (":", $dsn); $driver = @explode (":", $dsn);
if (! isset ($driver[0])) if (! isset ($driver[0]))
throw new Exception (dgettext("domframework", "No valid DSN provided"), throw new \Exception (dgettext ("domframework", "No valid DSN provided"),
500); 500);
if (! in_array ($driver[0], pdo_drivers ())) if (! in_array ($driver[0], pdo_drivers ()))
throw new \Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
@@ -147,11 +147,11 @@ class dblayer
// Look at the right to write in database and in the directory // Look at the right to write in database and in the directory
$file = substr ($dsn, 7); $file = substr ($dsn, 7);
if (! is_writeable (dirname ($file))) if (! is_writeable (dirname ($file)))
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"The directory for SQLite database is write protected"), "The directory for SQLite database is write protected"),
500); 500);
if (file_exists ($file) && ! is_writeable ($file)) if (file_exists ($file) && ! is_writeable ($file))
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"The SQLite database file is write protected"), "The SQLite database file is write protected"),
500); 500);
if (function_exists ("posix_getuid") && if (function_exists ("posix_getuid") &&
@@ -170,9 +170,9 @@ class dblayer
self::$instance[$this->dsn]->setAttribute (PDO::ATTR_ERRMODE, self::$instance[$this->dsn]->setAttribute (PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION); PDO::ERRMODE_EXCEPTION);
} }
catch (Exception $e) catch (\Exception $e)
{ {
throw new Exception ("PDO error : ".$e->getMessage(), 500); throw new \Exception ("PDO error : ".$e->getMessage(), 500);
} }
} }
@@ -192,9 +192,9 @@ class dblayer
self::$instance[$this->dsn]->setAttribute (PDO::ATTR_ERRMODE, self::$instance[$this->dsn]->setAttribute (PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION); PDO::ERRMODE_EXCEPTION);
} }
catch (Exception $e) catch (\Exception $e)
{ {
throw new Exception ("PDO error : ".$e->getMessage(), 500); throw new \Exception ("PDO error : ".$e->getMessage(), 500);
} }
} }
@@ -213,9 +213,9 @@ class dblayer
self::$instance[$this->dsn]->setAttribute (PDO::ATTR_ERRMODE, self::$instance[$this->dsn]->setAttribute (PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION); PDO::ERRMODE_EXCEPTION);
} }
catch (Exception $e) catch (\Exception $e)
{ {
throw new Exception ("PDO error : ".$e->getMessage(), 500); throw new \Exception ("PDO error : ".$e->getMessage(), 500);
} }
} }
@@ -224,7 +224,7 @@ class dblayer
$this->sep = "\""; $this->sep = "\"";
break; break;
default: default:
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Unknown PDO driver provided"), 500); "Unknown PDO driver provided"), 500);
} }
return self::$instance[$this->dsn]; return self::$instance[$this->dsn];
@@ -235,7 +235,7 @@ class dblayer
public function databasename () public function databasename ()
{ {
if ($this->sep === "") if ($this->sep === "")
throw new Exception (dgettext("domframework", "Database not connected"), throw new \Exception (dgettext ("domframework", "Database not connected"),
500); 500);
$vals = explode (";", substr (strstr ($this->dsn, ":"), 1)); $vals = explode (";", substr (strstr ($this->dsn, ":"), 1));
$dsnExplode = array (); $dsnExplode = array ();
@@ -254,7 +254,7 @@ class dblayer
public function listTables () public function listTables ()
{ {
if ($this->sep === "") if ($this->sep === "")
throw new Exception (dgettext("domframework", "Database not connected"), throw new \Exception (dgettext ("domframework", "Database not connected"),
500); 500);
switch (self::$instance[$this->dsn]->getAttribute(PDO::ATTR_DRIVER_NAME)) switch (self::$instance[$this->dsn]->getAttribute(PDO::ATTR_DRIVER_NAME))
{ {
@@ -287,7 +287,7 @@ class dblayer
$res[] = $d["tablename"]; $res[] = $d["tablename"];
break; break;
default: default:
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Unknown database driver in listTables"), 500); "Unknown database driver in listTables"), 500);
} }
return $res; return $res;
@@ -573,7 +573,7 @@ class dblayer
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR); $st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR);
else else
{ {
throw new Exception ("TO BE DEVELOPPED : ".$this->fields[$foreign][0], throw new \Exception ("TO BE DEVELOPPED : ".$this->fields[$foreign][0],
500); 500);
} }
$st->execute (); $st->execute ();
@@ -598,20 +598,20 @@ class dblayer
{ {
if ($this->debug) echo "== Entering insert\n"; if ($this->debug) echo "== Entering insert\n";
if ($this->sep === "") if ($this->sep === "")
throw new Exception (dgettext("domframework", "Database not connected"), throw new \Exception (dgettext ("domframework", "Database not connected"),
500); 500);
if ($this->table === null) if ($this->table === null)
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No table name defined to insert in the table"), "No table name defined to insert in the table"),
500); 500);
if ($this->unique === null) if ($this->unique === null)
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Unique fields of table are not defined"), 500); "Unique fields of table are not defined"), 500);
if (! is_array ($this->unique)) if (! is_array ($this->unique))
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"The unique configuration is not an array"), 500); "The unique configuration is not an array"), 500);
if (!is_array ($data)) if (!is_array ($data))
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"The data provided to create are not array"), "The data provided to create are not array"),
405); 405);
foreach ($this->fields as $key=>$params) foreach ($this->fields as $key=>$params)
@@ -628,7 +628,7 @@ class dblayer
$errors = reset ($errors); $errors = reset ($errors);
if (! is_array ($errors)) if (! is_array ($errors))
$errors = array (0=>"error", 1=>$errors); $errors = array (0=>"error", 1=>$errors);
throw new Exception ($errors[1], 405); throw new \Exception ($errors[1], 405);
} }
foreach ($this->fields as $field=>$desc) foreach ($this->fields as $field=>$desc)
{ {
@@ -663,14 +663,15 @@ class dblayer
elseif ($this->fields[$key][0] === "date") elseif ($this->fields[$key][0] === "date")
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR); $st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR);
else else
throw new Exception ("TO BE DEVELOPPED : ".$this->fields[$key][0], 500); throw new \Exception ("TO BE DEVELOPPED : ".$this->fields[$key][0],
500);
} }
try try
{ {
$st->execute (); $st->execute ();
} }
catch (Exception $e) catch (\Exception $e)
{ {
echo "dblayer execute exception : ".$e->getMessage()."\n"; echo "dblayer execute exception : ".$e->getMessage()."\n";
exit; exit;
@@ -709,21 +710,21 @@ class dblayer
{ {
if ($this->debug) echo "== Entering read\n"; if ($this->debug) echo "== Entering read\n";
if ($this->sep === "") if ($this->sep === "")
throw new Exception (dgettext("domframework", "Database not connected"), throw new \Exception (dgettext ("domframework", "Database not connected"),
500); 500);
if ($this->table === null) if ($this->table === null)
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No table name defined to read the table"), 500); "No table name defined to read the table"), 500);
if ($select !== null && !is_array ($select)) if ($select !== null && !is_array ($select))
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Select information provided is not an array"), "Select information provided is not an array"),
405); 405);
if ($display !== null && !is_array ($display)) if ($display !== null && !is_array ($display))
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Display information provided is not an array"), "Display information provided is not an array"),
405); 405);
if ($order !== null && !is_array ($order)) if ($order !== null && !is_array ($order))
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Order information provided is not an array"), "Order information provided is not an array"),
405); 405);
if ($display !== null) if ($display !== null)
@@ -731,7 +732,7 @@ class dblayer
foreach ($display as $f) foreach ($display as $f)
{ {
if (!in_array ($f, array_keys ($this->fields))) if (!in_array ($f, array_keys ($this->fields)))
throw new Exception (sprintf (dgettext("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Field '%s' not allowed"), $f), 500); "Field '%s' not allowed"), $f), 500);
} }
} }
@@ -763,14 +764,14 @@ class dblayer
foreach ($select as $n=>$s) foreach ($select as $n=>$s)
{ {
if (! is_array ($s)) if (! is_array ($s))
throw new Exception ("Select not an array for element $n", 500); throw new \Exception ("Select not an array for element $n", 500);
// The foreign keys can not be in the select too (conflict) // The foreign keys can not be in the select too (conflict)
if (in_array ($s[0],$foreignSelectCols)) if (in_array ($s[0],$foreignSelectCols))
continue; continue;
if (! array_key_exists (0, $s)) if (! array_key_exists (0, $s))
throw new Exception ("Select field for key $n not provided", 406); throw new \Exception ("Select field for key $n not provided", 406);
if (! array_key_exists (1, $s)) if (! array_key_exists (1, $s))
throw new Exception ("Select value for key $n not provided", 406); throw new \Exception ("Select value for key $n not provided", 406);
if ($n > 0) if ($n > 0)
{ {
if ($whereOr === false) if ($whereOr === false)
@@ -781,7 +782,7 @@ class dblayer
if (!isset ($s[2])) if (!isset ($s[2]))
$s[2] = "="; $s[2] = "=";
if (!isset ($s[0])) if (!isset ($s[0]))
throw new Exception (sprintf (dgettext("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Select not found for id=%d"), $n), 500); "Select not found for id=%d"), $n), 500);
// The double-quotes are added for sqlite to escape the column if its // The double-quotes are added for sqlite to escape the column if its
// name is 'group' // name is 'group'
@@ -803,9 +804,9 @@ class dblayer
foreach ($foreignSelect as $n=>$s) foreach ($foreignSelect as $n=>$s)
{ {
if (! array_key_exists (0, $s)) if (! array_key_exists (0, $s))
throw new Exception ("Foreign field for key $n not provided", 406); throw new \Exception ("Foreign field for key $n not provided", 406);
if (! array_key_exists (1, $s)) if (! array_key_exists (1, $s))
throw new Exception ("Foreign value for key $n not provided", 406); throw new \Exception ("Foreign value for key $n not provided", 406);
if ($n > 0) if ($n > 0)
{ {
$req .= " AND"; $req .= " AND";
@@ -837,11 +838,11 @@ class dblayer
{ {
$st = self::$instance[$this->dsn]->prepare ($req); $st = self::$instance[$this->dsn]->prepare ($req);
} }
catch (Exception $e) catch (\Exception $e)
{ {
if ($this->debug) echo "DEBUG : PREPARE ERROR ! Return FALSE". if ($this->debug) echo "DEBUG : PREPARE ERROR ! Return FALSE".
$e->getMessage()."\n"; $e->getMessage()."\n";
throw new Exception ($e->getMessage(), 500); throw new \Exception ($e->getMessage(), 500);
} }
if ($select !== NULL) if ($select !== NULL)
@@ -890,18 +891,19 @@ class dblayer
{ {
if ($this->debug) echo "== Entering update\n"; if ($this->debug) echo "== Entering update\n";
if ($this->sep === "") if ($this->sep === "")
throw new Exception (dgettext("domframework", "Database not connected"), throw new \Exception (dgettext ("domframework", "Database not connected"),
500); 500);
if ($this->table === null) if ($this->table === null)
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No table name defined to update in the table"), "No table name defined to update in the table"),
500); 500);
if (count ($this->fields) === 0) if (count ($this->fields) === 0)
throw new Exception (dgettext("domframework", "No Field defined"), 500); throw new \Exception (dgettext ("domframework", "No Field defined"), 500);
if ($this->primary === null) if ($this->primary === null)
throw new Exception (dgettext("domframework", "No Primary defined"), 500); throw new \Exception (dgettext ("domframework", "No Primary defined"),
500);
if (count ($data) === 0) if (count ($data) === 0)
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"No data to update provided"), 500); "No data to update provided"), 500);
$dataOK = array (); $dataOK = array ();
$errors = $this->verify ($data, $updatekey); $errors = $this->verify ($data, $updatekey);
@@ -910,11 +912,11 @@ class dblayer
if (is_array ($errors)) if (is_array ($errors))
{ {
if (isset ($errors[0][1])) if (isset ($errors[0][1]))
throw new Exception ($errors[0][1], 405); throw new \Exception ($errors[0][1], 405);
$err = reset ($errors); $err = reset ($errors);
throw new Exception ($err[1], 405); throw new \Exception ($err[1], 405);
} }
throw new Exception ($errors[1], 405); throw new \Exception ($errors[1], 405);
} }
foreach ($this->fields as $field=>$desc) foreach ($this->fields as $field=>$desc)
{ {
@@ -973,7 +975,7 @@ class dblayer
else else
{ {
if ($this->debug) echo "(UNKNOWN)\n"; if ($this->debug) echo "(UNKNOWN)\n";
throw new Exception ("TO BE DEVELOPPED : ".$fields[$key][0], 500); throw new \Exception ("TO BE DEVELOPPED : ".$fields[$key][0], 500);
} }
} }
@@ -992,7 +994,8 @@ class dblayer
{ {
if ($this->debug) echo "== Entering delete\n"; if ($this->debug) echo "== Entering delete\n";
if ($this->sep === "") if ($this->sep === "")
throw new Exception (dgettext("domframework", "Database not connected")); throw new \Exception (dgettext ("domframework", "Database not connected"),
500);
if ($this->table === null) if ($this->table === null)
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No table name defined to delete in the table"), "No table name defined to delete in the table"),
@@ -1009,7 +1012,7 @@ class dblayer
{ {
$st->execute (); $st->execute ();
} }
catch (Exception $e) catch (\Exception $e)
{ {
throw new \Exception ($e->getMessage (), 500); throw new \Exception ($e->getMessage (), 500);
} }
@@ -1025,7 +1028,7 @@ class dblayer
{ {
if ($this->debug) echo "== Entering titles\n"; if ($this->debug) echo "== Entering titles\n";
if (count ($this->fields) === 0) if (count ($this->fields) === 0)
throw new Exception (dgettext("domframework", "No Field defined"), 500); throw new \Exception (dgettext ("domframework", "No Field defined"), 500);
$arr = array (); $arr = array ();
if (count ($this->titles) !== 0) if (count ($this->titles) !== 0)
{ {
@@ -1046,7 +1049,8 @@ class dblayer
{ {
if ($this->debug) echo "== Entering dropTables\n"; if ($this->debug) echo "== Entering dropTables\n";
if ($this->sep === "") if ($this->sep === "")
throw new Exception (dgettext("domframework", "Database not connected")); throw new \Exception (dgettext ("domframework", "Database not connected"),
500);
if ($this->table === null) if ($this->table === null)
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No table name defined to drop the table"), 500); "No table name defined to drop the table"), 500);
@@ -1076,10 +1080,10 @@ class dblayer
{ {
if ($this->debug) echo "== Entering createTable\n"; if ($this->debug) echo "== Entering createTable\n";
if ($this->sep === "") if ($this->sep === "")
throw new Exception (dgettext("domframework", "Database not connected"), throw new \Exception (dgettext ("domframework", "Database not connected"),
500); 500);
if (count ($this->fields) === 0) if (count ($this->fields) === 0)
throw new Exception (dgettext("domframework", "No Field defined"), 500); throw new \Exception (dgettext ("domframework", "No Field defined"), 500);
if ($this->table === null) if ($this->table === null)
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No table name defined to create the table"), 500); "No table name defined to create the table"), 500);
@@ -1098,7 +1102,7 @@ class dblayer
$sql .= "$this->sep$field$this->sep "; $sql .= "$this->sep$field$this->sep ";
// Type of field : in $params[0] // Type of field : in $params[0]
if (!isset ($params[0])) if (!isset ($params[0]))
throw new Exception (sprintf ( throw new \Exception (sprintf (
dgettext ("domframework", dgettext ("domframework",
"No database type defined for field '%s'"), "No database type defined for field '%s'"),
$field), 500); $field), 500);
@@ -1111,7 +1115,7 @@ class dblayer
break; break;
case "varchar": case "varchar":
if (!isset ($params[1])) if (!isset ($params[1]))
throw new Exception (sprintf (dgettext("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"No Size provided for varchar field '%s'"), "No Size provided for varchar field '%s'"),
$field), 500); $field), 500);
$sql .= "VARCHAR(".$params[1].")"; $sql .= "VARCHAR(".$params[1].")";
@@ -1126,7 +1130,7 @@ class dblayer
$params = array_slice ($params, 1); $params = array_slice ($params, 1);
break; break;
default: default:
throw new Exception (sprintf ( throw new \Exception (sprintf (
dgettext ("domframework", dgettext ("domframework",
"Unknown type '%s' provided for field '%s'"), "Unknown type '%s' provided for field '%s'"),
$params[0], $field), 500); $params[0], $field), 500);
@@ -1145,7 +1149,7 @@ class dblayer
case "not null": $sql .= " NOT NULL"; break; case "not null": $sql .= " NOT NULL"; break;
case "autoincrement": $sql .= " AUTOINCREMENT";break; case "autoincrement": $sql .= " AUTOINCREMENT";break;
default: default:
throw new Exception (sprintf (dgettext("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Unknown additionnal parameter for field '%s'"), "Unknown additionnal parameter for field '%s'"),
$field), 500); $field), 500);
} }
@@ -1156,7 +1160,7 @@ class dblayer
if ($this->unique !== null) if ($this->unique !== null)
{ {
if (!is_array ($this->unique)) if (!is_array ($this->unique))
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"The Unique field definition is not an array"), "The Unique field definition is not an array"),
500); 500);
foreach ($this->unique as $u) foreach ($this->unique as $u)
@@ -1195,7 +1199,7 @@ class dblayer
$sql .= "$this->sep$field$this->sep "; $sql .= "$this->sep$field$this->sep ";
// Type of field : in $params[0] // Type of field : in $params[0]
if (!isset ($params[0])) if (!isset ($params[0]))
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"No database type defined for field"), 500); "No database type defined for field"), 500);
switch ($params[0]) switch ($params[0])
{ {
@@ -1205,7 +1209,7 @@ class dblayer
break; break;
case "varchar": case "varchar":
if (!isset ($params[1])) if (!isset ($params[1]))
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"No Size provided for varchar field"), 500); "No Size provided for varchar field"), 500);
$sql .= "VARCHAR(".$params[1].")"; $sql .= "VARCHAR(".$params[1].")";
$params = array_slice ($params, 2); $params = array_slice ($params, 2);
@@ -1219,7 +1223,7 @@ class dblayer
$params = array_slice ($params, 1); $params = array_slice ($params, 1);
break; break;
default: default:
throw new Exception (sprintf ( throw new \Exception (sprintf (
dgettext ("domframework", dgettext ("domframework",
"Unknown type provided for field '%s'"), "Unknown type provided for field '%s'"),
$field), 500); $field), 500);
@@ -1238,7 +1242,7 @@ class dblayer
case "not null": $sql .= " NOT NULL"; break; case "not null": $sql .= " NOT NULL"; break;
case "autoincrement": $sql .= " AUTO_INCREMENT";break; case "autoincrement": $sql .= " AUTO_INCREMENT";break;
default: default:
throw new Exception (sprintf ( throw new \Exception (sprintf (
dgettext ("domframework", dgettext ("domframework",
"Unknown additionnal parameter for field '%s'"), "Unknown additionnal parameter for field '%s'"),
$field), 500); $field), 500);
@@ -1290,7 +1294,7 @@ class dblayer
{ {
// Type of field : in $params[0] // Type of field : in $params[0]
if (!isset ($params[0])) if (!isset ($params[0]))
throw new Exception (sprintf ( throw new \Exception (sprintf (
dgettext ("domframework", dgettext ("domframework",
"No database type defined for field '%s'"), "No database type defined for field '%s'"),
$field), 500); $field), 500);
@@ -1302,7 +1306,7 @@ class dblayer
break; break;
case "varchar": case "varchar":
if (!isset ($params[1])) if (!isset ($params[1]))
throw new Exception (sprintf ( throw new \Exception (sprintf (
dgettext ("domframework", dgettext ("domframework",
"No Size provided for varchar field '%s'"), "No Size provided for varchar field '%s'"),
$field), 500); $field), 500);
@@ -1318,7 +1322,7 @@ class dblayer
$params = array_slice ($params, 1); $params = array_slice ($params, 1);
break; break;
default: default:
throw new Exception (sprintf ( throw new \Exception (sprintf (
dgettext ("domframework", dgettext ("domframework",
"Unknown type provided for field '%s'"), "Unknown type provided for field '%s'"),
$field), 500); $field), 500);
@@ -1336,7 +1340,7 @@ class dblayer
{ {
case "not null": $sql .= " NOT NULL"; break; case "not null": $sql .= " NOT NULL"; break;
default: default:
throw new Exception (sprintf ( throw new \Exception (sprintf (
dgettext ("domframework", dgettext ("domframework",
"Unknown additionnal parameter for field '%s'"), "Unknown additionnal parameter for field '%s'"),
$field), 500); $field), 500);
@@ -1373,7 +1377,7 @@ class dblayer
$sql .=")"; $sql .=")";
break; break;
default: default:
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"PDO Engine not supported in dbLayer"), 500); "PDO Engine not supported in dbLayer"), 500);
} }

View File

@@ -97,9 +97,8 @@ class fts
foreach ($fields as $field) foreach ($fields as $field)
{ {
if (! array_key_exists ($field, $dbl->fields ())) if (! array_key_exists ($field, $dbl->fields ()))
throw new \Exception (sprintf ( throw new \Exception (sprintf (dgettext ("domframework",
dgettext("domframework", "The field '%s' doesn't exists in database"), "The field '%s' doesn't exists in database"), $field), 500);
$field), 500);
if ($i > 0) if ($i > 0)
$dbl->whereAddOR (); $dbl->whereAddOR ();
$dbl->whereAddParenthesisOpen (); $dbl->whereAddParenthesisOpen ();

View File

@@ -474,11 +474,11 @@ class ipaddresses
public function ipInNetwork ($ip, $network, $cidr) public function ipInNetwork ($ip, $network, $cidr)
{ {
if ($this->validIPAddress ($ip) === false) if ($this->validIPAddress ($ip) === false)
throw new \Excpetion (dgettext("domframework", "Invalid IP address"), throw new \Exception (dgettext ("domframework", "Invalid IP address"),
500); 500);
if ($this->validIPAddress ($network) === false) if ($this->validIPAddress ($network) === false)
throw new \Excpetion (dgettext("domframework", "Invalid Network address"), throw new \Exception (dgettext ("domframework",
500); "Invalid Network address"), 500);
$ipv4 = $this->validIPv4Address ($ip); $ipv4 = $this->validIPv4Address ($ip);
$networkv4 = $this->validIPv4Address ($network); $networkv4 = $this->validIPv4Address ($network);
if ($ipv4 !== $networkv4) if ($ipv4 !== $networkv4)

View File

@@ -148,7 +148,8 @@ class mail
private function sectionUpdate ($sectionID, $param) private function sectionUpdate ($sectionID, $param)
{ {
if (! array_key_exists ($sectionID, $this->sections)) if (! array_key_exists ($sectionID, $this->sections))
throw new \Exception (dgettext("domframework", "Section not found"), 404); throw new \Exception (dgettext ("domframework", "Section not found"),
404);
if (! is_array ($param)) if (! is_array ($param))
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Param provided to sectionUpdate is not array"), 406); "Param provided to sectionUpdate is not array"), 406);

View File

@@ -344,24 +344,24 @@ $content .= "</li>\n";
TRUE) TRUE)
{ {
if ($this->authREST["email"] === "anonymous") if ($this->authREST["email"] === "anonymous")
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Anonymous not allowed"), 401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Access forbidden"), 403); "Access forbidden"), 403);
} }
$this->chained->connect(); $this->chained->connect();
// $chainedValues are the information associated to the $chain // $chainedValues are the information associated to the $chain
$chainedValues = $this->chained->keyexists ($chain); $chainedValues = $this->chained->keyexists ($chain);
if ($chainedValues === false) if ($chainedValues === false)
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Object not found"), 404); "Object not found"), 404);
} }
if ($this->accessright ($this->authREST["email"]) !== TRUE) if ($this->accessright ($this->authREST["email"]) !== TRUE)
{ {
if ($this->authREST["email"] === "anonymous") if ($this->authREST["email"] === "anonymous")
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Anonymous not allowed"), 401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Access forbidden"), 403); "Access forbidden"), 403);
} }
@@ -372,7 +372,7 @@ $content .= "</li>\n";
if (!isset ($extension) || $extension === null || $extension === "") if (!isset ($extension) || $extension === null || $extension === "")
$extension = reset ($this->extensionsAllowed); $extension = reset ($this->extensionsAllowed);
if (!in_array ($extension, $this->extensionsAllowed)) if (!in_array ($extension, $this->extensionsAllowed))
throw new Exception (dgettext("domframework","Extension not allowed"), throw new \Exception (dgettext ("domframework","Extension not allowed"),
403); 403);
$search = rawurldecode ($search); $search = rawurldecode ($search);
$this->connect(); $this->connect();
@@ -423,9 +423,9 @@ $content .= "</li>\n";
TRUE) TRUE)
{ {
if ($this->authREST["email"] === "anonymous") if ($this->authREST["email"] === "anonymous")
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Anonymous not allowed"), 401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), throw new \Exception (dgettext ("domframework","Access forbidden"),
403); 403);
} }
$this->chained->connect(); $this->chained->connect();
@@ -438,24 +438,27 @@ $content .= "</li>\n";
if ($this->accessright ($this->authREST["email"]) !== TRUE) if ($this->accessright ($this->authREST["email"]) !== TRUE)
{ {
if ($this->authREST["email"] === "anonymous") if ($this->authREST["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->editright ($this->authREST["email"]) !== TRUE) if ($this->editright ($this->authREST["email"]) !== TRUE)
{ {
if ($this->authREST["email"] === "anonymous") if ($this->authREST["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->readonly ($this->authREST["email"]) === TRUE) if ($this->readonly ($this->authREST["email"]) === TRUE)
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
if (!isset ($extension) || $extension === null || $extension === "") if (!isset ($extension) || $extension === null || $extension === "")
$extension = reset ($this->extensionsAllowed); $extension = reset ($this->extensionsAllowed);
if (!in_array ($extension, $this->extensionsAllowed)) if (!in_array ($extension, $this->extensionsAllowed))
throw new Exception (dgettext("domframework","Extension not allowed"), throw new \Exception (dgettext ("domframework",
403); "Extension not allowed"), 403);
$this->connect(); $this->connect();
$values = $_POST; $values = $_POST;
$errorsChain = array (); $errorsChain = array ();
@@ -476,7 +479,7 @@ $content .= "</li>\n";
$this->objectDB->insert ($values); $this->objectDB->insert ($values);
$this->renderrest ($extension, "OK", 200); $this->renderrest ($extension, "OK", 200);
} }
catch (Exception $e) catch (\Exception $e)
{ {
$this->renderrest ($extension, $e->getMessage(), 400); $this->renderrest ($extension, $e->getMessage(), 400);
} }
@@ -491,9 +494,9 @@ $content .= "</li>\n";
TRUE) TRUE)
{ {
if ($this->authREST["email"] === "anonymous") if ($this->authREST["email"] === "anonymous")
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Anonymous not allowed"), 401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), throw new \Exception (dgettext ("domframework", "Access forbidden"),
403); 403);
} }
$this->chained->connect(); $this->chained->connect();
@@ -506,24 +509,27 @@ $content .= "</li>\n";
if ($this->accessright ($this->authREST["email"]) !== TRUE) if ($this->accessright ($this->authREST["email"]) !== TRUE)
{ {
if ($this->authREST["email"] === "anonymous") if ($this->authREST["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->editright ($this->authREST["email"]) !== TRUE) if ($this->editright ($this->authREST["email"]) !== TRUE)
{ {
if ($this->authREST["email"] === "anonymous") if ($this->authREST["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->readonly ($this->authREST["email"]) === TRUE) if ($this->readonly ($this->authREST["email"]) === TRUE)
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
if (!isset ($extension) || $extension === null || $extension === "") if (!isset ($extension) || $extension === null || $extension === "")
$extension = reset ($this->extensionsAllowed); $extension = reset ($this->extensionsAllowed);
if (!in_array ($extension, $this->extensionsAllowed)) if (!in_array ($extension, $this->extensionsAllowed))
throw new Exception (dgettext("domframework","Extension not allowed"), throw new \Exception (dgettext ("domframework",
403); "Extension not allowed"), 403);
$this->connect(); $this->connect();
parse_str (file_get_contents ("php://input"), $values); parse_str (file_get_contents ("php://input"), $values);
$errorsChain = array (); $errorsChain = array ();
@@ -542,7 +548,7 @@ $content .= "</li>\n";
$this->objectDB->update ($id, $values); $this->objectDB->update ($id, $values);
$this->renderrest ($extension, "OK", 200); $this->renderrest ($extension, "OK", 200);
} }
catch (Exception $e) catch (\Exception $e)
{ {
$this->renderrest ($extension, $e->getMessage(), 400); $this->renderrest ($extension, $e->getMessage(), 400);
} }
@@ -557,46 +563,49 @@ $content .= "</li>\n";
TRUE) TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Anonymous not allowed"), 401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), throw new \Exception (dgettext ("domframework", "Access forbidden"),
403); 403);
} }
$this->chained->connect(); $this->chained->connect();
// $chainedValues are the information associated to the $chain // $chainedValues are the information associated to the $chain
$chainedValues = $this->chained->keyexists ($chain); $chainedValues = $this->chained->keyexists ($chain);
if ($chainedValues === false) if ($chainedValues === false)
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Object not found"), 404); "Object not found"), 404);
} }
if ($this->accessright ($this->authREST["email"]) !== TRUE) if ($this->accessright ($this->authREST["email"]) !== TRUE)
{ {
if ($this->authREST["email"] === "anonymous") if ($this->authREST["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->editright ($this->authREST["email"]) !== TRUE) if ($this->editright ($this->authREST["email"]) !== TRUE)
{ {
if ($this->authREST["email"] === "anonymous") if ($this->authREST["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->readonly ($this->authREST["email"]) === TRUE) if ($this->readonly ($this->authREST["email"]) === TRUE)
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
if (!isset ($extension) || $extension === null || $extension === "") if (!isset ($extension) || $extension === null || $extension === "")
$extension = reset ($this->extensionsAllowed); $extension = reset ($this->extensionsAllowed);
if (!in_array ($extension, $this->extensionsAllowed)) if (!in_array ($extension, $this->extensionsAllowed))
throw new Exception (dgettext("domframework","Extension not allowed"), throw new \Exception (dgettext ("domframework",
403); "Extension not allowed"), 403);
$this->connect(); $this->connect();
try try
{ {
$this->objectDB->delete ($id); $this->objectDB->delete ($id);
$this->renderrest ($extension, "OK", 200); $this->renderrest ($extension, "OK", 200);
} }
catch (Exception $e) catch (\Exception $e)
{ {
$this->renderrest ($extension, $e->getMessage(), 400); $this->renderrest ($extension, $e->getMessage(), 400);
} }
@@ -610,8 +619,8 @@ $content .= "</li>\n";
if ($this->chained !== null) if ($this->chained !== null)
{ {
if (strpos ($this->chained->url_prefix, "/{chain}/") !== false) if (strpos ($this->chained->url_prefix, "/{chain}/") !== false)
throw new Exception ("Chained can not have an already chained object", throw new \Exception (dgettext ("domframework",
500); "Chained can not have an already chained object"), 500);
$this->url_prefix = $this->chained->url_prefix."/{chain}/". $this->url_prefix = $this->chained->url_prefix."/{chain}/".
$this->url_prefix; $this->url_prefix;
} }
@@ -636,24 +645,24 @@ $content .= "</li>\n";
TRUE) TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Anonymous not allowed"), 401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Access forbidden"), 403); "Access forbidden"), 403);
} }
$this->chained->connect(); $this->chained->connect();
// $chainedValues are the information associated to the $chain // $chainedValues are the information associated to the $chain
$chainedValues = $this->chained->keyexists ($chain); $chainedValues = $this->chained->keyexists ($chain);
if ($chainedValues === false) if ($chainedValues === false)
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Object not found"), 404); "Object not found"), 404);
} }
if ($this->accessright ($this->authHTML["email"]) !== TRUE) if ($this->accessright ($this->authHTML["email"]) !== TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Anonymous not allowed"), 401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Access forbidden"), 403); "Access forbidden"), 403);
} }
@@ -741,9 +750,9 @@ $content .= "</li>\n";
foreach ($this->objectDB->foreign as $foreign=>$params) foreach ($this->objectDB->foreign as $foreign=>$params)
{ {
if (! isset ($params[0])) if (! isset ($params[0]))
throw new Exception ("Undefined foreign key", 500); throw new \Exception ("Undefined foreign key", 500);
if (! isset ($params[1])) if (! isset ($params[1]))
throw new Exception ("Undefined foreign key column", 500); throw new \Exception ("Undefined foreign key column", 500);
$class = $params[0]; $class = $params[0];
$column = $params[1]; $column = $params[1];
require_once ("models/model_$class.php"); require_once ("models/model_$class.php");
@@ -990,12 +999,14 @@ $content .= "</li>\n";
$content .= " <tr>\n"; $content .= " <tr>\n";
if ($this->readwriteAllowed && $this->displayActions && if ($this->readwriteAllowed && $this->displayActions &&
$this->actionsAtEnd === false) $this->actionsAtEnd === false)
$content .= " <th>".dgettext("domframework","Actions")."</th>\n"; $content .= " <th>".dgettext ("domframework", "Actions").
"</th>\n";
foreach ($titles as $title) foreach ($titles as $title)
$content .= " <th>".htmlentities ($title)."</th>\n"; $content .= " <th>".htmlentities ($title)."</th>\n";
if ($this->readwriteAllowed && $this->displayActions && if ($this->readwriteAllowed && $this->displayActions &&
$this->actionsAtEnd !== false) $this->actionsAtEnd !== false)
$content .= " <th>".dgettext("domframework","Actions")."</th>\n"; $content .= " <th>".dgettext ("domframework", "Actions").
"</th>\n";
$content .= " </tr>\n"; $content .= " </tr>\n";
$content .= " </thead>\n"; $content .= " </thead>\n";
$content .= " <tbody>\n"; $content .= " <tbody>\n";
@@ -1044,7 +1055,7 @@ $content .= "</li>\n";
foreach ($this->internalLinks as $linkData) foreach ($this->internalLinks as $linkData)
{ {
if (! isset ($linkData["linkname"])) if (! isset ($linkData["linkname"]))
throw new Exception ("No linkname defined !", 500); throw new \Exception ("No linkname defined !", 500);
$content .= " <a href='".$route->baseURL().$this->url_prefix."/". $content .= " <a href='".$route->baseURL().$this->url_prefix."/".
$line[$this->objectDB->primary]."/". $line[$this->objectDB->primary]."/".
$linkData["linkname"]."'>"; $linkData["linkname"]."'>";
@@ -1097,34 +1108,37 @@ $content .= "</li>\n";
TRUE) TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Anonymous not allowed"), 401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), throw new \Exception (dgettext ("domframework","Access forbidden"),
403); 403);
} }
$this->chained->connect(); $this->chained->connect();
// $chainedValues are the information associated to the $chain // $chainedValues are the information associated to the $chain
$chainedValues = $this->chained->keyexists ($chain); $chainedValues = $this->chained->keyexists ($chain);
if ($chainedValues === false) if ($chainedValues === false)
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Object not found"), 404); "Object not found"), 404);
} }
if ($this->accessright ($this->authHTML["email"], $id) !== TRUE) if ($this->accessright ($this->authHTML["email"], $id) !== TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->editright ($this->authHTML["email"], $id) !== TRUE) if ($this->editright ($this->authHTML["email"], $id) !== TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->readonly ($this->authHTML["email"], $id) === TRUE) if ($this->readonly ($this->authHTML["email"], $id) === TRUE)
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
$this->connect(); $this->connect();
$csrf = new csrf (); $csrf = new csrf ();
@@ -1138,7 +1152,7 @@ $content .= "</li>\n";
str_replace ("{chain}", $chain, $this->url_prefix), str_replace ("{chain}", $chain, $this->url_prefix),
""); "");
} }
catch (Exception $e) catch (\Exception $e)
{ {
$renderer->flash ("ERROR", $e->getMessage()); $renderer->flash ("ERROR", $e->getMessage());
$route->redirect ("/". $route->redirect ("/".
@@ -1158,34 +1172,37 @@ $content .= "</li>\n";
TRUE) TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Anonymous not allowed"), 401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), throw new \Exception (dgettext ("domframework","Access forbidden"),
403); 403);
} }
$this->chained->connect(); $this->chained->connect();
// $chainedValues are the information associated to the $chain // $chainedValues are the information associated to the $chain
$chainedValues = $this->chained->keyexists ($chain); $chainedValues = $this->chained->keyexists ($chain);
if ($chainedValues === false) if ($chainedValues === false)
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Object not found"), 404); "Object not found"), 404);
} }
if ($this->accessright ($this->authHTML["email"]) !== TRUE) if ($this->accessright ($this->authHTML["email"]) !== TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->editright ($this->authHTML["email"]) !== TRUE) if ($this->editright ($this->authHTML["email"]) !== TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->readonly ($this->authHTML["email"]) === TRUE) if ($this->readonly ($this->authHTML["email"]) === TRUE)
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
$this->connect(); $this->connect();
@@ -1197,9 +1214,9 @@ $content .= "</li>\n";
foreach ($this->objectDB->foreign as $foreign=>$params) foreach ($this->objectDB->foreign as $foreign=>$params)
{ {
if (! isset ($params[0])) if (! isset ($params[0]))
throw new Exception ("Undefined foreign key", 500); throw new \Exception ("Undefined foreign key", 500);
if (! isset ($params[1])) if (! isset ($params[1]))
throw new Exception ("Undefined foreign key column", 500); throw new \Exception ("Undefined foreign key column", 500);
$class = $params[0]; $class = $params[0];
$column = $params[1]; $column = $params[1];
require_once ("models/model_$class.php"); require_once ("models/model_$class.php");
@@ -1346,7 +1363,7 @@ $content .= "</li>\n";
{ {
$field = new formfield ($key, $val); $field = new formfield ($key, $val);
if (! isset ($this->objectDB->fields[$key])) if (! isset ($this->objectDB->fields[$key]))
throw new Exception (sprintf (dgettext("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Field '%s' (defined in titles) not found in fields"), "Field '%s' (defined in titles) not found in fields"),
$key), 500); $key), 500);
if (in_array ("not null", $this->objectDB->fields[$key])) if (in_array ("not null", $this->objectDB->fields[$key]))
@@ -1389,9 +1406,9 @@ $content .= "</li>\n";
TRUE) TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Anonymous not allowed"), 401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), throw new \Exception (dgettext ("domframework","Access forbidden"),
403); 403);
} }
$this->chained->connect(); $this->chained->connect();
@@ -1404,19 +1421,22 @@ $content .= "</li>\n";
if ($this->accessright ($this->authHTML["email"]) !== TRUE) if ($this->accessright ($this->authHTML["email"]) !== TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->editright ($this->authHTML["email"]) !== TRUE) if ($this->editright ($this->authHTML["email"]) !== TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->readonly ($this->authHTML["email"]) === TRUE) if ($this->readonly ($this->authHTML["email"]) === TRUE)
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
$this->connect(); $this->connect();
$f = new form (); $f = new form ();
@@ -1441,7 +1461,7 @@ $content .= "</li>\n";
str_replace ("{chain}", $chain, $this->url_prefix), str_replace ("{chain}", $chain, $this->url_prefix),
""); "");
} }
catch (Exception $e) catch (\Exception $e)
{ {
$renderer = new renderer (); $renderer = new renderer ();
$renderer->flash ("ERROR", $e->getMessage ()); $renderer->flash ("ERROR", $e->getMessage ());
@@ -1471,9 +1491,9 @@ $content .= "</li>\n";
TRUE) TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Anonymous not allowed"), 401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), throw new \Exception (dgettext ("domframework","Access forbidden"),
403); 403);
} }
$this->chained->connect(); $this->chained->connect();
@@ -1486,9 +1506,10 @@ $content .= "</li>\n";
if ($this->accessright ($this->authHTML["email"], $id) !== TRUE) if ($this->accessright ($this->authHTML["email"], $id) !== TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->chained !== null && if ($this->chained !== null &&
$this->chained->editright ($this->authHTML["email"], $chain) !== true) $this->chained->editright ($this->authHTML["email"], $chain) !== true)
@@ -1507,9 +1528,9 @@ $content .= "</li>\n";
foreach ($this->objectDB->foreign as $foreign=>$params) foreach ($this->objectDB->foreign as $foreign=>$params)
{ {
if (! isset ($params[0])) if (! isset ($params[0]))
throw new Exception ("Undefined foreign key", 500); throw new \Exception ("Undefined foreign key", 500);
if (! isset ($params[1])) if (! isset ($params[1]))
throw new Exception ("Undefined foreign key column", 500); throw new \Exception ("Undefined foreign key column", 500);
$class = $params[0]; $class = $params[0];
$column = $params[1]; $column = $params[1];
require_once ("models/model_$class.php"); require_once ("models/model_$class.php");
@@ -1538,7 +1559,8 @@ $content .= "</li>\n";
$values = $this->objectDB->read (array (array ($this->objectDB->primary, $values = $this->objectDB->read (array (array ($this->objectDB->primary,
$id))); $id)));
if (count ($values) === 0) if (count ($values) === 0)
throw new Exception (dgettext("domframework", "Object not found"), 404); throw new \Exception (dgettext ("domframework", "Object not found"),
404);
$values = $values[0]; $values = $values[0];
if (isset ($_SESSION["domframework"]["routeSQL"]["errors"])) if (isset ($_SESSION["domframework"]["routeSQL"]["errors"]))
{ {
@@ -1660,7 +1682,7 @@ $content .= "</li>\n";
{ {
$field = new formfield ($key, $val); $field = new formfield ($key, $val);
if (! isset ($this->objectDB->fields[$key])) if (! isset ($this->objectDB->fields[$key]))
throw new Exception (sprintf (dgettext("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Field '%s' (defined in titles) not found in fields"), "Field '%s' (defined in titles) not found in fields"),
$key), 500); $key), 500);
if (in_array ("not null", $this->objectDB->fields[$key])) if (in_array ("not null", $this->objectDB->fields[$key]))
@@ -1709,9 +1731,9 @@ $content .= "</li>\n";
TRUE) TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Anonymous not allowed"), 401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), throw new \Exception (dgettext ("domframework","Access forbidden"),
403); 403);
} }
$this->chained->connect(); $this->chained->connect();
@@ -1724,30 +1746,34 @@ $content .= "</li>\n";
if ($this->accessright ($this->authHTML["email"], $id) !== TRUE) if ($this->accessright ($this->authHTML["email"], $id) !== TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->editright ($this->authHTML["email"], $id) !== TRUE) if ($this->editright ($this->authHTML["email"], $id) !== TRUE)
{ {
if ($this->authHTML["email"] === "anonymous") if ($this->authHTML["email"] === "anonymous")
throw new Exception (dgettext("domframework","Anonymous not allowed"), throw new \Exception (dgettext ("domframework",
401); "Anonymous not allowed"), 401);
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
} }
if ($this->readonly ($this->authHTML["email"], $id) === TRUE) if ($this->readonly ($this->authHTML["email"], $id) === TRUE)
throw new Exception (dgettext("domframework","Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"),
403);
$this->connect(); $this->connect();
$oldvalues = $this->objectDB->read (array (array $oldvalues = $this->objectDB->read (array (array
($this->objectDB->primary, $id))); ($this->objectDB->primary, $id)));
if (count ($oldvalues) === 0) if (count ($oldvalues) === 0)
throw new Exception (dgettext("domframework", "Object not found"), 404); throw new \Exception (dgettext ("domframework", "Object not found"),
404);
$oldvalues = $oldvalues[0]; $oldvalues = $oldvalues[0];
$f = new form (); $f = new form ();
$values = $f->values (); $values = $f->values ();
if ($values[$this->objectDB->primary] !== $id) if ($values[$this->objectDB->primary] !== $id)
throw new Exception (dgettext("domframework", throw new \Exception (dgettext ("domframework",
"Can not change the primary key"), 403); "Can not change the primary key"), 403);
$errorsChain = array (); $errorsChain = array ();
if ($this->chainedForeign !== null && if ($this->chainedForeign !== null &&
@@ -1770,7 +1796,7 @@ $content .= "</li>\n";
str_replace ("{chain}", $chain, $this->url_prefix), str_replace ("{chain}", $chain, $this->url_prefix),
""); "");
} }
catch (Exception $e) catch (\Exception $e)
{ {
$renderer = new renderer (); $renderer = new renderer ();
$renderer->flash ("ERROR", $e->getMessage ()); $renderer->flash ("ERROR", $e->getMessage ());