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

@@ -28,7 +28,7 @@ class auth
$res .= "body { padding-top: 40px; padding-bottom: 40px; $res .= "body { padding-top: 40px; padding-bottom: 40px;
font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;
background-attachment: fixed; background-position: top; background-attachment: fixed; background-position: top;
background-image: radial-gradient(ellipse at center -60px, background-image: radial-gradient(ellipse at center -60px,
#9da1ac 0%,#1c202a 100%); #9da1ac 0%,#1c202a 100%);
background-color: #eee; }\n"; background-color: #eee; }\n";
$res .= ".form-signin { max-width: 430px;padding:15px;margin:0 auto;}\n"; $res .= ".form-signin { max-width: 430px;padding:15px;margin:0 auto;}\n";
@@ -87,25 +87,25 @@ class auth
$res .= "'>\n"; $res .= "'>\n";
if ($alreadyAuth === false) if ($alreadyAuth === false)
{ {
$res .= " <h2 class='form-signin-heading'>".dgettext("domframework", $res .= " <h2 class='form-signin-heading'>".dgettext("domframework",
"Please sign in"); "Please sign in");
$res .= "</h2>\n"; $res .= "</h2>\n";
$res .= " <input type='text' class='form-control' name='email' "; $res .= " <input type='text' class='form-control' name='email' ";
$res .= "placeholder='".dgettext("domframework", $res .= "placeholder='".dgettext("domframework",
"Email address")."' required autofocus/>\n"; "Email address")."' required autofocus/>\n";
$res .= " <input type='password' class='form-control' name='password' "; $res .= " <input type='password' class='form-control' name='password' ";
$res .= "placeholder='".dgettext("domframework", $res .= "placeholder='".dgettext("domframework",
"Password")."' required/>\n"; "Password")."' required/>\n";
// $res .= " <label class='checkbox'>"; // $res .= " <label class='checkbox'>";
// $res .= "<input type='checkbox' name='remember-me'/>".dgettext("domframework", // $res .= "<input type='checkbox' name='remember-me'/>".dgettext("domframework",
// "Remember me"); // "Remember me");
// $res .= "</label>\n"; // $res .= "</label>\n";
$res .= " <input type='submit' value='".dgettext("domframework", $res .= " <input type='submit' value='".dgettext("domframework",
"Sign in")."'/>\n"; "Sign in")."'/>\n";
} }
else else
{ {
$res .= " <h2 class='form-signin-heading'>".dgettext("domframework", $res .= " <h2 class='form-signin-heading'>".dgettext("domframework",
"Already sign in"); "Already sign in");
$res .= "</h2>\n"; $res .= "</h2>\n";
if (is_string ($alreadyAuth)) if (is_string ($alreadyAuth))
@@ -129,7 +129,7 @@ class auth
/** Establish the connection to authentication server */ /** Establish the connection to authentication server */
public function connect () public function connect ()
{ {
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"No connect to authentication available"), "No connect to authentication available"),
405); 405);
} }
@@ -141,14 +141,14 @@ class auth
@param string $password Password to authenticate */ @param string $password Password to authenticate */
public function authentication ($email, $password) public function authentication ($email, $password)
{ {
throw new exception (dgettext("domframework", throw new exception (dgettext("domframework",
"No authentication available"), 405); "No authentication available"), 405);
} }
/** Return all the parameters recorded for the authenticate user */ /** Return all the parameters recorded for the authenticate user */
public function getdetails () public function getdetails ()
{ {
throw new exception (dgettext("domframework", throw new exception (dgettext("domframework",
"No getdetails available"), 405); "No getdetails available"), 405);
} }
@@ -158,7 +158,7 @@ class auth
@param string $newpassword The new password to be recorded */ @param string $newpassword The new password to be recorded */
public function changepassword ($oldpassword, $newpassword) public function changepassword ($oldpassword, $newpassword)
{ {
throw new exception (dgettext("domframework", throw new exception (dgettext("domframework",
"No password change available"), 405); "No password change available"), 405);
} }
@@ -169,7 +169,7 @@ class auth
@param string $newpassword The new password to be recorded */ @param string $newpassword The new password to be recorded */
public function overwritepassword ($email, $newpassword) public function overwritepassword ($email, $newpassword)
{ {
throw new exception (dgettext("domframework", throw new exception (dgettext("domframework",
"No password overwrite available"), 405); "No password overwrite available"), 405);
} }
@@ -177,7 +177,7 @@ class auth
Return firstname, lastname, mail, with mail is an array */ Return firstname, lastname, mail, with mail is an array */
public function listusers () public function listusers ()
{ {
throw new exception (dgettext("domframework", throw new exception (dgettext("domframework",
"No List User available"), 405); "No List User available"), 405);
} }

View File

@@ -33,7 +33,7 @@ class authentication
public $htmlMethods = array ("session"); public $htmlMethods = array ("session");
/** The authentication methods. Can be ldap, sympa...*/ /** The authentication methods. Can be ldap, sympa...*/
public $authMethods = array (); public $authMethods = array ();
/** The authentication servers configuration /** The authentication servers configuration
array ("authXXXX"=>array ( array ("authXXXX"=>array (
array ("ldapserver"=>"ldaps://annuaire.grenoble.cnrs.fr", array ("ldapserver"=>"ldaps://annuaire.grenoble.cnrs.fr",
"ldapport"=>636, "ldapport"=>636,

View File

@@ -25,7 +25,7 @@ class authimap extends auth
throw new Exception ("IMAP support unavailable in PHP", 500); throw new Exception ("IMAP support unavailable in PHP", 500);
} }
/** Establish the connection to IMAP server. Don't do anything as the /** Establish the connection to IMAP server. Don't do anything as the
needed parameters are username and password */ needed parameters are username and password */
public function connect () public function connect ()
{ {

View File

@@ -101,7 +101,7 @@ class authldap extends auth
@param string $newpassword The new password to be recorded */ @param string $newpassword The new password to be recorded */
public function changepassword ($oldpassword, $newpassword) public function changepassword ($oldpassword, $newpassword)
{ {
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"The password can't be change for LDAP users"), 405); "The password can't be change for LDAP users"), 405);
} }

View File

@@ -44,7 +44,7 @@ class authorizationdb extends authorization
public function initialize () public function initialize ()
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
$tables = $this->db->listTables (); $tables = $this->db->listTables ();
if (!in_array ($this->db->tableprefix.$this->db->table, $tables)) if (!in_array ($this->db->tableprefix.$this->db->table, $tables))
@@ -63,16 +63,16 @@ class authorizationdb extends authorization
public function validate ($object) public function validate ($object)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (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 don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
try try
{ {
@@ -87,7 +87,7 @@ class authorizationdb extends authorization
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Object %s doesn't exists"), "Object %s doesn't exists"),
$object), $object),
404); 404);
@@ -140,24 +140,24 @@ class authorizationdb extends authorization
public function add ($object, $ownerid, $groupid, $modbits) public function add ($object, $ownerid, $groupid, $modbits)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
// The modbits are stored in octal to be more readable // The modbits are stored in octal to be more readable
$modbits = decoct ($modbits); $modbits = decoct ($modbits);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (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 don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
if ($this->authiduser !== 0 && $this->authiduser !== $ownerid) 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); "Can't create object not owned by myself"), 406);
if ($this->authiduser !== 0 && !in_array ($groupid, $this->authgroups)) 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); "Can't create object with not owned group"), 406);
try try
{ {
@@ -172,7 +172,7 @@ class authorizationdb extends authorization
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search)) if (count ($search))
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Object %s already defined"), $object), "Object %s already defined"), $object),
400); 400);
@@ -209,19 +209,19 @@ class authorizationdb extends authorization
public function drop ($object) public function drop ($object)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (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 don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
if ($object === "/") if ($object === "/")
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"The root can not be removed"), 406); "The root can not be removed"), 406);
try try
{ {
@@ -236,7 +236,7 @@ class authorizationdb extends authorization
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Object %s doesn't exists"), "Object %s doesn't exists"),
$object), 400); $object), 400);
@@ -246,10 +246,10 @@ class authorizationdb extends authorization
{ {
$rc = $this->db->delete ($object); $rc = $this->db->delete ($object);
if ($rc > 1) if ($rc > 1)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Removing more than one object"), 406); "Removing more than one object"), 406);
if ($rc == 0) if ($rc == 0)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"No object removed"), 406); "No object removed"), 406);
$rc = $this->db->delete ("$object$this->separator%"); $rc = $this->db->delete ("$object$this->separator%");
return TRUE; return TRUE;
@@ -266,10 +266,10 @@ class authorizationdb extends authorization
$rc = $this->db->delete ($object); $rc = $this->db->delete ($object);
if ($rc > 1) if ($rc > 1)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Removing more than one object"), 406); "Removing more than one object"), 406);
if ($rc == 0) if ($rc == 0)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"No object removed"), 406); "No object removed"), 406);
$rc = $this->db->delete ("$object$this->separator%"); $rc = $this->db->delete ("$object$this->separator%");
return TRUE; return TRUE;
@@ -283,19 +283,19 @@ class authorizationdb extends authorization
public function chown ($object, $ownerid) public function chown ($object, $ownerid)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (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 don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
if ($this->authiduser !== 0) if ($this->authiduser !== 0)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"The chown is reserved to root user"), 405); "The chown is reserved to root user"), 405);
try try
{ {
@@ -310,7 +310,7 @@ class authorizationdb extends authorization
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Object %s doesn't exists"), $object), "Object %s doesn't exists"), $object),
400); 400);
$search = reset ($search); $search = reset ($search);
@@ -326,22 +326,22 @@ class authorizationdb extends authorization
public function chgrp ($object, $groupid) public function chgrp ($object, $groupid)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (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 don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
if ($this->authiduser !== 0 && !in_array ($groupid, $this->authgroups)) 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); "The user must be in the wanted group"), 405);
if (!in_array ("WRITE", $this->validate ($object))) 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); "%s is write protected"), $object), 405);
try try
{ {
@@ -356,7 +356,7 @@ class authorizationdb extends authorization
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Object %s doesn't exists"), $object), "Object %s doesn't exists"), $object),
400); 400);
$search = reset ($search); $search = reset ($search);
@@ -372,19 +372,19 @@ class authorizationdb extends authorization
public function chmod ($object, $mod) public function chmod ($object, $mod)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (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 don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
if (!in_array ("WRITE", $this->validate ($object))) 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); "%s is write protected"), $object), 405);
try try
{ {
@@ -399,7 +399,7 @@ class authorizationdb extends authorization
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Object %s doesn't exists"), $object), "Object %s doesn't exists"), $object),
400); 400);
$search = reset ($search); $search = reset ($search);
@@ -415,16 +415,16 @@ class authorizationdb extends authorization
public function lsmod ($object) public function lsmod ($object)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (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 don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
try try
{ {
@@ -439,7 +439,7 @@ class authorizationdb extends authorization
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Object %s doesn't exists"), $object), "Object %s doesn't exists"), $object),
400); 400);
$search = reset ($search); $search = reset ($search);
@@ -453,16 +453,16 @@ class authorizationdb extends authorization
public function lsown ($object) public function lsown ($object)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (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 don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
try try
{ {
@@ -477,7 +477,7 @@ class authorizationdb extends authorization
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Object %s doesn't exists"), $object), "Object %s doesn't exists"), $object),
400); 400);
$search = reset ($search); $search = reset ($search);
@@ -491,16 +491,16 @@ class authorizationdb extends authorization
public function lsgrp ($object) public function lsgrp ($object)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (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 don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
try try
{ {
@@ -515,7 +515,7 @@ class authorizationdb extends authorization
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Object %s doesn't exists"), $object), "Object %s doesn't exists"), $object),
404); 404);
$search = reset ($search); $search = reset ($search);
@@ -531,7 +531,7 @@ class authorizationdb extends authorization
private function treecheckExecute ($object) private function treecheckExecute ($object)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
// Search all the parents in an array // Search all the parents in an array
$parents = array (); $parents = array ();
@@ -568,7 +568,7 @@ class authorizationdb extends authorization
} }
} }
if (!$found) if (!$found)
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"The path %s is not found in database"), "The path %s is not found in database"),
$p), 404); $p), 404);
else else
@@ -593,7 +593,7 @@ class authorizationdb extends authorization
if (($parentModbits & 0001) === 1) if (($parentModbits & 0001) === 1)
continue; continue;
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"No execute rights on %s"), $p), 405); "No execute rights on %s"), $p), 405);
} }
} }
@@ -624,7 +624,7 @@ class authorizationdb extends authorization
if (($parentModbits & 0002) === 2) if (($parentModbits & 0002) === 2)
return TRUE; return TRUE;
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"No write rights on %s"), $parent), 405); "No write rights on %s"), $parent), 405);
} }
} }

View File

@@ -10,7 +10,7 @@ class authparams
public $password = null; public $password = null;
/** Parse the different authentication processes to found the email/password /** Parse the different authentication processes to found the email/password
of the user. of the user.
If non is found, return "anonymous", "anonymous" */ If non is found, return "anonymous", "anonymous" */
public function __construct ($authprocesses=array("session","post")) public function __construct ($authprocesses=array("session","post"))
{ {
@@ -63,7 +63,7 @@ class authparams
/** Get information from a HTTP authentication */ /** Get information from a HTTP authentication */
public function http() public function http()
{ {
$realm = dgettext("domframework", $realm = dgettext("domframework",
"Restricted access"); "Restricted access");
if (!isset($_SERVER['PHP_AUTH_USER'])) if (!isset($_SERVER['PHP_AUTH_USER']))
{ {

View File

@@ -52,7 +52,7 @@ class authsession extends auth
@param string $newpassword The new password to be recorded */ @param string $newpassword The new password to be recorded */
public function changepassword ($oldpassword, $newpassword) public function changepassword ($oldpassword, $newpassword)
{ {
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"The password can't be change for SESSION users"), "The password can't be change for SESSION users"),
405); 405);
} }

View File

@@ -63,7 +63,7 @@ class authshibboleth extends auth
{ {
// Redirect to Shibboleth IDP // Redirect to Shibboleth IDP
if ($this->urlPasswdChange == "") if ($this->urlPasswdChange == "")
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"The password can't be change for Shibboleth users"), "The password can't be change for Shibboleth users"),
405); 405);
$route = new route (); $route = new route ();

View File

@@ -125,7 +125,7 @@ class authsql extends auth
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Can't change the password if the user is not authenticated"), "Can't change the password if the user is not authenticated"),
500); 500);
$data = $this->db->read (array (array ($this->fieldIdentifier, $data = $this->db->read (array (array ($this->fieldIdentifier,
$this->details[$this->fieldIdentifier])), $this->details[$this->fieldIdentifier])),
array ($this->fieldIdentifier, array ($this->fieldIdentifier,
$this->fieldPassword)); $this->fieldPassword));
@@ -143,7 +143,7 @@ class authsql extends auth
)); ));
//now do the actual hashing //now do the actual hashing
$cryptpassword = crypt ($newpassword, $param); $cryptpassword = crypt ($newpassword, $param);
$rc = $this->db->update ($this->details[$this->fieldIdentifier], $rc = $this->db->update ($this->details[$this->fieldIdentifier],
array ($this->fieldPassword => $cryptpassword)); array ($this->fieldPassword => $cryptpassword));
if ($rc !== 1) if ($rc !== 1)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
@@ -177,7 +177,7 @@ class authsql extends auth
)); ));
//now do the actual hashing //now do the actual hashing
$cryptpassword = crypt ($newpassword, $param); $cryptpassword = crypt ($newpassword, $param);
$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","Can't change the password"),

View File

@@ -41,7 +41,7 @@ class authsympa extends auth
public function __construct () public function __construct ()
{ {
if (! class_exists ("SoapClient")) if (! class_exists ("SoapClient"))
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"No SOAP PHP library available"), 500); "No SOAP PHP library available"), 500);
} }
@@ -49,7 +49,7 @@ class authsympa extends auth
public function connect () public function connect ()
{ {
if ($this->wsdl === null) if ($this->wsdl === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"No WSDL provided to Sympa auth"), 401); "No WSDL provided to Sympa auth"), 401);
$this->client = new SoapClient($this->wsdl); $this->client = new SoapClient($this->wsdl);
} }
@@ -60,14 +60,14 @@ class authsympa extends auth
public function authentication ($email, $password) public function authentication ($email, $password)
{ {
if ($this->client === null) if ($this->client === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"The SOAP connection is not opened"), 401); "The SOAP connection is not opened"), 401);
if ($this->list === null) if ($this->list === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"The list to check is not defined"), 401); "The list to check is not defined"), 401);
$this->authkey = $this->client->login ($email, $password); $this->authkey = $this->client->login ($email, $password);
if ($this->authkey === null) if ($this->authkey === null)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Can't connect with provided email/password to sympa"), "Can't connect with provided email/password to sympa"),
401); 401);
$this->email = $email; $this->email = $email;
@@ -81,7 +81,7 @@ class authsympa extends auth
/** Return all the parameters recorded for the authenticate user */ /** Return all the parameters recorded for the authenticate user */
public function getdetails () public function getdetails ()
{ {
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"The details can't be provided by Sympa"), 404); "The details can't be provided by Sympa"), 404);
} }
@@ -91,7 +91,7 @@ class authsympa extends auth
@param string $newpassword The new password to be recorded */ @param string $newpassword The new password to be recorded */
public function changepassword ($oldpassword, $newpassword) public function changepassword ($oldpassword, $newpassword)
{ {
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"The password can't be change for SYMPA users"), "The password can't be change for SYMPA users"),
405); 405);
} }

View File

@@ -48,7 +48,7 @@ class authzgroups
".$this->tableprefix."authzobject AS o, ".$this->tableprefix."authzobject AS o,
".$this->tableprefix."authzgroup AS g, ".$this->tableprefix."authzgroup AS g,
".$this->tableprefix."authzgroupmember AS gm ".$this->tableprefix."authzgroupmember AS gm
WHERE r.idgroup=g.idgroup AND r.idobject=o.idobject AND WHERE r.idgroup=g.idgroup AND r.idobject=o.idobject AND
gm.idgroup=g.idgroup gm.idgroup=g.idgroup
AND gm.user=:user AND g.module=:module AND gm.user=:user AND g.module=:module
GROUP BY o.object GROUP BY o.object
@@ -110,7 +110,7 @@ class authzgroups
// The complete tree should not be readable for the user : it can have // The complete tree should not be readable for the user : it can have
// access to a card, but not to all the cards (group -> reject, // access to a card, but not to all the cards (group -> reject,
// group/XXX->allow) // group/XXX->allow)
/*// Limit to allowed trees : if a member of the path is not recorded (is /*// Limit to allowed trees : if a member of the path is not recorded (is
// unreadable), return NO. // unreadable), return NO.
// Can be the last entry (the complete object) too // Can be the last entry (the complete object) too
$path = explode ("/", $object); $path = explode ("/", $object);
@@ -119,7 +119,7 @@ class authzgroups
{ {
if ($k>1) if ($k>1)
$completePath .= "/"; $completePath .= "/";
$completePath .= "$p"; $completePath .= "$p";
if (! isset ($ressource[$completePath])) if (! isset ($ressource[$completePath]))
{ {
if ($this->debug) if ($this->debug)
@@ -132,7 +132,7 @@ class authzgroups
return $ressource[$object]; return $ressource[$object];
} }
/** Return TRUE if the user right allow to see the object (RO or RW) /** Return TRUE if the user right allow to see the object (RO or RW)
Return a 403 Exception if the user don't have the right Return a 403 Exception if the user don't have the right
Return a 401 Exception if the user is not connected */ Return a 401 Exception if the user is not connected */
public function accessRight ($module, $user, $object) public function accessRight ($module, $user, $object)
@@ -246,7 +246,7 @@ class authzgroups
$this->dbObject->unique = array ("idobject", array ("object", "module")); $this->dbObject->unique = array ("idobject", array ("object", "module"));
$this->dbObject->titles = array ("idobject"=>dgettext("domframework", $this->dbObject->titles = array ("idobject"=>dgettext("domframework",
"idobject"), "idobject"),
"module"=>dgettext("domframework", "module"=>dgettext("domframework",
"Module"), "Module"),
"object"=>dgettext("domframework", "object"=>dgettext("domframework",
"Object"), "Object"),
@@ -354,7 +354,7 @@ class authzgroups
$tables = array ("Object", "Group", "GroupMember", "Right"); $tables = array ("Object", "Group", "GroupMember", "Right");
foreach ($tables as $table) foreach ($tables as $table)
{ {
try try
{ {
$class= "db$table"; $class= "db$table";
$this->$class->createTable (); $this->$class->createTable ();
@@ -988,9 +988,9 @@ class authzgroups
throw new Exception (dgettext ("domframework", throw new Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
$select[] = array ("idright", $idright); $select[] = array ("idright", $idright);
return $this->dbRight->read ($select); return $this->dbRight->read ($select);
} }
/** Return an array with all the available rights for a module and an object /** Return an array with all the available rights for a module and an object
*/ */
public function rightReadByObject ($module, $object) public function rightReadByObject ($module, $object)
@@ -1003,7 +1003,7 @@ class authzgroups
throw new Exception (dgettext ("domframework", throw new Exception (dgettext ("domframework",
"Wanted object not found"), 404); "Wanted object not found"), 404);
$select[] = array ("idobject", $objects[0]["idobject"]); $select[] = array ("idobject", $objects[0]["idobject"]);
return $this->dbRight->read ($select); return $this->dbRight->read ($select);
} }
/** Return an array with all the available rights for a module and an idobject /** Return an array with all the available rights for a module and an idobject

View File

@@ -74,29 +74,28 @@ class cachefile
public function cachedir () public function cachedir ()
{ {
if (! isset ($this->directory) || $this->directory === "") if (! isset ($this->directory) || $this->directory === "")
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"No cache directory defined"), 500); "No cache directory defined"), 500);
if (! file_exists ($this->directory)) if (! file_exists ($this->directory))
{ {
// Need to create the cache dir // Need to create the cache dir
$parent = realpath (dirname ($this->directory)); $parent = realpath (dirname ($this->directory));
if (! is_writeable (dirname ($this->directory))) if (! is_writeable (dirname ($this->directory)))
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Directory %s is not writable : can not create cache directory"), "Directory %s is not writable : can not create cache directory"),
$parent), 500); $parent), 500);
if (!mkdir ($this->directory)) if (!mkdir ($this->directory))
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Can not create cache directory %s"), "Can not create cache directory %s"),
$this->directory), 500); $this->directory), 500);
chmod ($this->directory, 0777); chmod ($this->directory, 0777);
} }
if (! is_writable ($this->directory)) if (! is_writable ($this->directory))
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Cache directory %s is not writable"), "Cache directory %s is not writable"),
$this->directory), 500); $this->directory), 500);
if (! is_readable ($this->directory)) if (! is_readable ($this->directory))
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Cache directory %s is not readable"), "Cache directory %s is not readable"),
$this->directory), 500); $this->directory), 500);
if (!file_exists ($this->directory."/.htaccess")) if (!file_exists ($this->directory."/.htaccess"))
@@ -115,7 +114,7 @@ class cachefile
if ($this->nocache !== false) if ($this->nocache !== false)
return false; return false;
if ($data === false) if ($data === false)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Can not store FALSE in cache"), 500); "Can not store FALSE in cache"), 500);
try try
{ {
@@ -159,11 +158,11 @@ class cachefile
if (!file_exists ($fileCache)) if (!file_exists ($fileCache))
return false; return false;
if (!is_readable ($fileCache)) if (!is_readable ($fileCache))
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"File cache %s is not readable"), "File cache %s is not readable"),
$fileCache), 500); $fileCache), 500);
if (!is_writable ($fileCache)) if (!is_writable ($fileCache))
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"File cache %s is not writable"), "File cache %s is not writable"),
$fileCache), 500); $fileCache), 500);
// Lock : waiting the reconstruction of the cache by another process // Lock : waiting the reconstruction of the cache by another process

View File

@@ -27,7 +27,7 @@ class cacheoutput
{ {
$res = @include ("domframework/cache$method.php"); $res = @include ("domframework/cache$method.php");
if ($res === false) if ($res === false)
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Unkwnown cache method : "), $method), "Unkwnown cache method : "), $method),
500); 500);
$this->id = $id; $this->id = $id;

View File

@@ -76,12 +76,12 @@ class config
if (@file_put_contents ($this->confFile, if (@file_put_contents ($this->confFile,
"<?php\r\n\$conf = array ();\r\n") "<?php\r\n\$conf = array ();\r\n")
=== FALSE) === FALSE)
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"No configuration file '%s' available and it can't be created"), "No configuration file '%s' available and it can't be created"),
$this->confFile), 500); $this->confFile), 500);
} }
elseif (! is_readable ($this->confFile)) elseif (! is_readable ($this->confFile))
throw new Exception (sprintf ( dgettext("domframework", throw new Exception (sprintf ( dgettext("domframework",
"The configuration file '%s' is not readable"), "The configuration file '%s' is not readable"),
$this->confFile)); $this->confFile));
$conf = array (); $conf = array ();
@@ -145,11 +145,11 @@ class config
} }
elseif (! is_readable ($this->confFile)) elseif (! is_readable ($this->confFile))
throw new Exception (sprintf ( throw new Exception (sprintf (
dgettext("domframework", dgettext("domframework",
"The configuration file '%s' is not readable"), "The configuration file '%s' is not readable"),
$this->confFile), 500); $this->confFile), 500);
if (!is_writeable ($this->confFile)) if (!is_writeable ($this->confFile))
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Configuration file '%s' is write protected"), "Configuration file '%s' is write protected"),
$this->confFile), 500); $this->confFile), 500);
$conf = array (); $conf = array ();
@@ -164,7 +164,7 @@ class config
$txt .= ");\r\n"; $txt .= ");\r\n";
if (@file_put_contents ($this->confFile, $txt, LOCK_EX) === FALSE) if (@file_put_contents ($this->confFile, $txt, LOCK_EX) === FALSE)
throw new Exception (sprintf (dgettext("domframework", throw new Exception (sprintf (dgettext("domframework",
"Can't save configuration file '%s'"), "Can't save configuration file '%s'"),
$this->confFile), 500); $this->confFile), 500);
return TRUE; return TRUE;
@@ -200,7 +200,7 @@ class config
$phpcode .= "),\r\n"; $phpcode .= "),\r\n";
} }
else else
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Config : missing type ").gettype ($val), 500); "Config : missing type ").gettype ($val), 500);
} }
@@ -221,7 +221,7 @@ class config
$val = trim ($val); $val = trim ($val);
if (strpos ($val, "=>") !== false) if (strpos ($val, "=>") !== false)
{ {
// Associated array // Associated array
unset ($values[$key]); unset ($values[$key]);
list ($key1, $val1) = explode ("=>", $val); list ($key1, $val1) = explode ("=>", $val);
$key1 = trim ($key1); $key1 = trim ($key1);

View File

@@ -42,18 +42,18 @@ class csrf
return TRUE; return TRUE;
if (! isset ($_SESSION["domframework"]["csrf"]["csrf"])) if (! isset ($_SESSION["domframework"]["csrf"]["csrf"]))
{ {
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"No previous CSRF token : abort"), 406); "No previous CSRF token : abort"), 406);
} }
if ($_SESSION["domframework"]["csrf"]["csrf"] !== $tokenFromUser) if ($_SESSION["domframework"]["csrf"]["csrf"] !== $tokenFromUser)
{ {
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Invalid CSRF token provided"), 406); "Invalid CSRF token provided"), 406);
} }
if (($_SESSION["domframework"]["csrf"]["csrfStart"] + $this->csrfTimeout) < if (($_SESSION["domframework"]["csrf"]["csrfStart"] + $this->csrfTimeout) <
microtime (TRUE)) microtime (TRUE))
{ {
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Obsolete CSRF token provided"), 406); "Obsolete CSRF token provided"), 406);
} }
return TRUE; return TRUE;

View File

@@ -10,7 +10,7 @@
* array ("key"=>"val", "key2"=>"val2") <== Look for two parameters * array ("key"=>"val", "key2"=>"val2") <== Look for two parameters
* - A document is an array containing the fields and the values to store * - A document is an array containing the fields and the values to store
* array ("key"=>"val) * array ("key"=>"val)
* *
* - The field named _id is the document key * - The field named _id is the document key
*/ */
@@ -279,12 +279,12 @@ class dbjson
* array () <== Look for all the documents (no * array () <== Look for all the documents (no
* filter) * filter)
* array ("key"=>"val") <== Look for the key equal val * array ("key"=>"val") <== Look for the key equal val
* array ("key=>array ("val", "<=")) <== Look for the key lighter or * array ("key=>array ("val", "<=")) <== Look for the key lighter or
* equal than val * equal than val
* array ("key"=>"val", "key2"=>"val2") <== Look for two parameters * array ("key"=>"val", "key2"=>"val2") <== Look for two parameters
* array ("key"=>array ("val", "=="), * array ("key"=>array ("val", "=="),
* "key2"=>array ("val2", "==")) <== Look for two complex parameters * "key2"=>array ("val2", "==")) <== Look for two complex parameters
* Here is the comparison types available : ==, * Here is the comparison types available : ==,
* @return array the keys matching the filter * @return array the keys matching the filter
*/ */
public function filter ($collection, $filter) public function filter ($collection, $filter)
@@ -362,7 +362,7 @@ class dbjson
} }
return $keys; return $keys;
} }
/** Generate a unique key /** Generate a unique key
* @return string the Unique key generated * @return string the Unique key generated
*/ */

View File

@@ -1429,7 +1429,7 @@ class dblayer
} }
/** Hook postread /** Hook postread
This hook is run after selecting the data. This hook is run after selecting the data.
@param array $data the data selected by the select @param array $data the data selected by the select
@return array The data modified by the hook */ @return array The data modified by the hook */

View File

@@ -66,7 +66,7 @@ class dblayerauthzgroups extends dblayer
} }
} }
/** Hook postread /** Hook postread
This hook is run after selecting the data. Return only the allowed data to This hook is run after selecting the data. Return only the allowed data to
the user. It must have at least the RO flag. the user. It must have at least the RO flag.
@param array $data the data selected by the select @param array $data the data selected by the select
@@ -98,13 +98,13 @@ class dblayerauthzgroups extends dblayer
} }
if ($this->primaryKeyAdded === true) if ($this->primaryKeyAdded === true)
unset ($data[$key][$this->primary]); unset ($data[$key][$this->primary]);
} }
return $data; return $data;
} }
/** Hook preinsert /** Hook preinsert
This hook is run before inserting a new data in the database, after the This hook is run before inserting a new data in the database, after the
verification verification
@param array the data to insert in the database @param array the data to insert in the database
@return the modified data */ @return the modified data */
public function hookpreinsert ($data) public function hookpreinsert ($data)
@@ -186,7 +186,7 @@ class dblayerauthzgroups extends dblayer
500); 500);
$this->allowPath (); $this->allowPath ();
$this->authzgroups->accessWrite ($this->module, $this->user, $this->path); $this->authzgroups->accessWrite ($this->module, $this->user, $this->path);
$this->authzgroups->accessWrite ($this->module, $this->user, $this->authzgroups->accessWrite ($this->module, $this->user,
$this->path."/$updatekey"); $this->path."/$updatekey");
return $data; return $data;
} }
@@ -208,7 +208,7 @@ class dblayerauthzgroups extends dblayer
500); 500);
$this->allowPath (); $this->allowPath ();
$this->authzgroups->accessWrite ($this->module, $this->user, $this->path); $this->authzgroups->accessWrite ($this->module, $this->user, $this->path);
$this->authzgroups->accessWrite ($this->module, $this->user, $this->authzgroups->accessWrite ($this->module, $this->user,
$this->path."/$deletekey"); $this->path."/$deletekey");
return $deletekey; return $deletekey;
} }
@@ -274,7 +274,7 @@ class dblayerauthzgroups extends dblayer
$this->module = $module; $this->module = $module;
return $this; return $this;
} }
/** Set the auth property */ /** Set the auth property */
public function authSet ($auth) public function authSet ($auth)
{ {
@@ -288,21 +288,21 @@ class dblayerauthzgroups extends dblayer
$this->user = $user; $this->user = $user;
return $this; return $this;
} }
/** Set the createGroup property */ /** Set the createGroup property */
public function createGroupSet ($createGroup) public function createGroupSet ($createGroup)
{ {
$this->createGroup = $createGroup; $this->createGroup = $createGroup;
return $this; return $this;
} }
/** Set the createRight property */ /** Set the createRight property */
public function createRightSet ($createRight) public function createRightSet ($createRight)
{ {
$this->createRight = $createRight; $this->createRight = $createRight;
return $this; return $this;
} }
/** Set the path property */ /** Set the path property */
public function pathSet ($path) public function pathSet ($path)
{ {

View File

@@ -79,7 +79,7 @@ class form
$this->fields = $fields; $this->fields = $fields;
} }
/** Add a field to the form. For the details of a field, see the description /** Add a field to the form. For the details of a field, see the description
* in fields method */ * in fields method */
public function addfield ($field) public function addfield ($field)
{ {
@@ -104,7 +104,7 @@ class form
} }
else else
{ {
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Unknown FORM method (GET or POST allowed)")); "Unknown FORM method (GET or POST allowed)"));
} }
@@ -213,7 +213,7 @@ class form
{ {
reset ($errors); reset ($errors);
$focusElement = key ($errors); $focusElement = key ($errors);
} }
$res .= "<script>document.getElementById('".$this->formName."_". $res .= "<script>document.getElementById('".$this->formName."_".
$focusElement."').focus();</script>\n"; $focusElement."').focus();</script>\n";
$res .= "</form>\n"; $res .= "</form>\n";
@@ -463,8 +463,8 @@ class formfield
$this->values[$key] !== "unset" && $this->values[$key] !== "unset" &&
$this->values[$key] !== "") $this->values[$key] !== "")
$res .= " checked='checked'"; $res .= " checked='checked'";
elseif (isset ($this->defaults[$key]) && elseif (isset ($this->defaults[$key]) &&
$this->defaults[$key] !== null && $this->defaults[$key] !== null &&
$this->defaults[$key] !== false && $this->defaults[$key] !== false &&
$this->defaults[$key] !== "unset" && $this->defaults[$key] !== "unset" &&
$this->defaults[$key] !== "") $this->defaults[$key] !== "")

View File

@@ -168,7 +168,7 @@ class imap
$res = array (); $res = array ();
foreach ($subs as $sub) foreach ($subs as $sub)
{ {
$res [] = str_replace ($sub->delimiter, "/", $res [] = str_replace ($sub->delimiter, "/",
substr ($sub->name, strlen ($this->mailbox))); substr ($sub->name, strlen ($this->mailbox)));
} }
$res = array_map (function ($folder) { $res = array_map (function ($folder) {
@@ -272,7 +272,7 @@ class imap
if ($from < 1) if ($from < 1)
$from = 1; $from = 1;
if ($from > $MC->Nmsgs) if ($from > $MC->Nmsgs)
throw new Exception ("Mail start is higher than the number of mails", throw new Exception ("Mail start is higher than the number of mails",
500); 500);
$from = $MC->Nmsgs - $from + 1; $from = $MC->Nmsgs - $from + 1;
$to = $from + $nbmails - 1; $to = $from + $nbmails - 1;
@@ -282,7 +282,7 @@ class imap
else else
{ {
if ($from > $MC->Nmsgs) if ($from > $MC->Nmsgs)
throw new Exception ("Mail start is higher than the number of mails", throw new Exception ("Mail start is higher than the number of mails",
500); 500);
if ($from < 1) if ($from < 1)
$from = 1; $from = 1;
@@ -535,7 +535,7 @@ class imap
strtolower ($struct2->subtype); strtolower ($struct2->subtype);
else else
throw new Exception (sprintf ( throw new Exception (sprintf (
dgettext("domframework", dgettext("domframework",
"Unknown type in imap_fetchstructure : %s"), "Unknown type in imap_fetchstructure : %s"),
$struct2->type), 500); $struct2->type), 500);
} }
@@ -581,7 +581,7 @@ class imap
strtolower ($struct1->subtype); strtolower ($struct1->subtype);
else else
throw new Exception (sprintf ( throw new Exception (sprintf (
dgettext("domframework", dgettext("domframework",
"Unknown type in imap_fetchstructure : %s"), "Unknown type in imap_fetchstructure : %s"),
$struct1->type), 500); $struct1->type), 500);
} }
@@ -665,7 +665,7 @@ class imap
imap_errors(); imap_errors();
if (! isset ($quota["STORAGE"])) if (! isset ($quota["STORAGE"]))
return array (); return array ();
return array_map (function ($n) {return intval ($n/1000);}, return array_map (function ($n) {return intval ($n/1000);},
$quota["STORAGE"]); $quota["STORAGE"]);
} }
@@ -688,7 +688,7 @@ class imap
$this->changeFolder ($this->curDir); $this->changeFolder ($this->curDir);
if (is_array ($msgno)) if (is_array ($msgno))
$msgno = implode (",", $msgno); $msgno = implode (",", $msgno);
$rc = @imap_setflag_full (self::$instance[$this->mailbox], $msgno, $rc = @imap_setflag_full (self::$instance[$this->mailbox], $msgno,
implode (" ", $flags)); implode (" ", $flags));
imap_errors(); imap_errors();
if ($rc === FALSE) if ($rc === FALSE)
@@ -712,7 +712,7 @@ class imap
$this->changeFolder ($this->curDir); $this->changeFolder ($this->curDir);
if (is_array ($msgno)) if (is_array ($msgno))
$msgno = implode (",", $msgno); $msgno = implode (",", $msgno);
$rc = @imap_clearflag_full (self::$instance[$this->mailbox], $msgno, $rc = @imap_clearflag_full (self::$instance[$this->mailbox], $msgno,
implode (" ", $flags)); implode (" ", $flags));
imap_errors(); imap_errors();
if ($rc === FALSE) if ($rc === FALSE)

View File

@@ -8,7 +8,7 @@
class inifile class inifile
{ {
/** Return an array with the .ini file content /** Return an array with the .ini file content
If the sections are true, the sections are analyzed too If the sections are true, the sections are analyzed too
This function is the same as parse_ini_file PHP internal */ This function is the same as parse_ini_file PHP internal */
public function getFile ($file, $sections=false) public function getFile ($file, $sections=false)
{ {
@@ -22,7 +22,7 @@ class inifile
} }
/** Return an array with the .ini string content /** Return an array with the .ini string content
If the sections are true, the sections are analyzed too If the sections are true, the sections are analyzed too
This function is the same as parse_ini_string PHP internal */ This function is the same as parse_ini_string PHP internal */
public function getString ($string, $sections=false) public function getString ($string, $sections=false)
{ {
@@ -48,11 +48,11 @@ class inifile
elseif ($v === "false") elseif ($v === "false")
$res[$key][$k] = false; $res[$key][$k] = false;
elseif (is_numeric ($v)) elseif (is_numeric ($v))
$res[$key][$k] = $v + 0; $res[$key][$k] = $v + 0;
} }
} }
elseif (is_numeric ($val)) elseif (is_numeric ($val))
$res[$key] = $val + 0; $res[$key] = $val + 0;
} }
return $res; return $res;
} }

View File

@@ -78,7 +78,7 @@ class ipaddresses
/* Get an IPv6 address with the format /* Get an IPv6 address with the format
x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x
and return it with format and return it with format
xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
Return false if the IP provided is not complete */ Return false if the IP provided is not complete */
public function groupIPv6 ($ipv6) public function groupIPv6 ($ipv6)

View File

@@ -23,7 +23,7 @@ class language
/** Language cache directory */ /** Language cache directory */
public $cacheDir = "data/locale"; public $cacheDir = "data/locale";
/** Choose the best language in the browser list and which is available in /** Choose the best language in the browser list and which is available in
locale path locale path
@param string|null $repLocale Directory where are stored the translations @param string|null $repLocale Directory where are stored the translations
@param string|null $languageCode The coding langugage of the soft @param string|null $languageCode The coding langugage of the soft
@@ -89,7 +89,7 @@ class language
foreach ($arrAccept as $value) foreach ($arrAccept as $value)
{ {
// Regarde si un repertoire existe avec la language proposee. // Regarde si un repertoire existe avec la language proposee.
// Recherche insensible à la casse, retourne le nom du fichier avec la // Recherche insensible à la casse, retourne le nom du fichier avec la
// casse // casse
$val2 = strtolower ($value); $val2 = strtolower ($value);
foreach ($arrLanguageAvailable as $val) foreach ($arrLanguageAvailable as $val)
@@ -141,7 +141,7 @@ class language
return $_COOKIE[$cookieName]; return $_COOKIE[$cookieName];
return FALSE; return FALSE;
} }
/** Set the cookie with a TTL of one month /** Set the cookie with a TTL of one month
@param string $cookieName The name of the cookie @param string $cookieName The name of the cookie
@param string $languageCode Language to store @param string $languageCode Language to store
@@ -275,7 +275,7 @@ class language
$codeset = "UTF8"; // SANS TIRET ET EN MAJSUCULES!!! $codeset = "UTF8"; // SANS TIRET ET EN MAJSUCULES!!!
// -> Le répertoire de données doit être fr_FR.UTF8 // -> Le répertoire de données doit être fr_FR.UTF8
putenv ('LANG='.$languageCode.'.'.$codeset); putenv ('LANG='.$languageCode.'.'.$codeset);
putenv ('LANGUAGE='.$languageCode.'.'.$codeset); putenv ('LANGUAGE='.$languageCode.'.'.$codeset);
$GLOBALS["domframework"]["lang"] = $languageCode; $GLOBALS["domframework"]["lang"] = $languageCode;
bind_textdomain_codeset ($package, "utf-8"); bind_textdomain_codeset ($package, "utf-8");
bindtextdomain ($package, $repLocale); bindtextdomain ($package, $repLocale);
@@ -338,7 +338,7 @@ class language
case "fr_FR": return dgettext("domframework", "French"); case "fr_FR": return dgettext("domframework", "French");
case "en_US": return dgettext("domframework", "English (US)"); case "en_US": return dgettext("domframework", "English (US)");
case "en_GB": return dgettext("domframework", "English (GB)"); case "en_GB": return dgettext("domframework", "English (GB)");
default: default:
throw new Exception ("No language available for '$languageCode'", 500); throw new Exception ("No language available for '$languageCode'", 500);
} }
} }

View File

@@ -174,7 +174,7 @@ class logger
// Add the filename which generate the error // Add the filename which generate the error
$msg .= " [".basename ($back["file"]).":".$back["line"]."]"; $msg .= " [".basename ($back["file"]).":".$back["line"]."]";
// Display the backtrace if it is needed // Display the backtrace if it is needed
if ($this->backtraceDisplay) if ($this->backtraceDisplay)
{ {
$e = new Exception(); $e = new Exception();

View File

@@ -99,7 +99,7 @@ class mail
*/ */
private function sectionDel ($sectionID) private function sectionDel ($sectionID)
{ {
// TODO ! // TODO !
} }
/** Add a newChild to an existing section at the end of the list /** Add a newChild to an existing section at the end of the list

View File

@@ -137,7 +137,7 @@ class markdown
$pos++; $pos++;
} }
// Insert Geshi on $content // Insert Geshi on $content
if ($this->debug) if ($this->debug)
echo "RETURN typeCode : <pre><code>$content</code></pre>\n"; echo "RETURN typeCode : <pre><code>$content</code></pre>\n";
return "<pre><code>$content</code></pre>\n"; return "<pre><code>$content</code></pre>\n";
} }
@@ -175,7 +175,7 @@ class markdown
$blockStart = $pos; $blockStart = $pos;
$blockContent = ""; $blockContent = "";
while (isset ($text[$pos]) && while (isset ($text[$pos]) &&
$this->depth($text[$pos]) >= $depth && $this->depth($text[$pos]) >= $depth &&
$this->lineType ($text[$pos]) === $type) $this->lineType ($text[$pos]) === $type)
{ {
if ($this->debug) if ($this->debug)
@@ -251,7 +251,7 @@ class markdown
// linetype changed // linetype changed
$Pinc = $pos; $Pinc = $pos;
while (isset ($text[$pos]) && while (isset ($text[$pos]) &&
$this->depth($text[$pos]) == $depth && $this->depth($text[$pos]) == $depth &&
$this->lineType ($text[$pos]) === "p") $this->lineType ($text[$pos]) === "p")
{ {
if (substr ($text[$pos], -2) === " ") if (substr ($text[$pos], -2) === " ")
@@ -312,7 +312,7 @@ class markdown
" < $depth)\n"; " < $depth)\n";
return $content; return $content;
} }
$type = $this->lineType ($text[$pos]); $type = $this->lineType ($text[$pos]);
$func = "type$type"; $func = "type$type";
if ($this->debug) if ($this->debug)

View File

@@ -8,8 +8,8 @@ class module
{ {
/** The modules are not allowed if $toplevel=0 /** The modules are not allowed if $toplevel=0
The modules can be in a module directory if $toplevel=1 The modules can be in a module directory if $toplevel=1
The modules can be in the parent directory if $toplevel=2 The modules can be in the parent directory if $toplevel=2
The modules can be in the local directory if $toplevel=4 The modules can be in the local directory if $toplevel=4
The values can be added to allow multiple possibilities */ The values can be added to allow multiple possibilities */
public $toplevel = 0; public $toplevel = 0;

View File

@@ -50,7 +50,7 @@ class outputhtml extends output
$title = $resView["title"]; $title = $resView["title"];
if (! isset ($resView["content"])) if (! isset ($resView["content"]))
throw new Exception (sprintf ( throw new Exception (sprintf (
dgettext("domframework", dgettext("domframework",
"No data provided from view %s::%s"), "No data provided from view %s::%s"),
$viewClass,$viewMethod), $viewClass,$viewMethod),
500); 500);
@@ -132,12 +132,12 @@ EOT;
/** Get the layout and provide it the variables. The variables will be push in /** Get the layout and provide it the variables. The variables will be push in
* global to the layout (they can be used like $XX) * global to the layout (they can be used like $XX)
* @param string the layout file to load * @param string the layout file to load
* @param array $variables The variables array to push to the layout * @param array $variables The variables array to push to the layout
* @return string the Layout with variables interpreted */ * @return string the Layout with variables interpreted */
private function layoutVariables ($layout, $variables) private function layoutVariables ($layout, $variables)
{ {
// The layout can be a external layout file or the HTML page itself. // The layout can be a external layout file or the HTML page itself.
// FIXME : Allow to manage variables in a layout provided in the variable, // FIXME : Allow to manage variables in a layout provided in the variable,
// without eval use // without eval use
if (! file_exists ($layout)) if (! file_exists ($layout))
return $layout; return $layout;

View File

@@ -11,7 +11,7 @@ class ratelimit
/** The unit time in seconds */ /** The unit time in seconds */
public $unittime = 60; public $unittime = 60;
/** The function set a rate-limit /** The function set a rate-limit
@return bool true if the rate-limit is not overloaded @return bool true if the rate-limit is not overloaded
false if the rate-limit is overloaded */ false if the rate-limit is overloaded */
public function set ($name) public function set ($name)

View File

@@ -14,7 +14,7 @@ class ratelimitfile extends ratelimit
/** Debug the ratelimiting process to screen */ /** Debug the ratelimiting process to screen */
public $debug = false; public $debug = false;
/** The function set a rate-limit /** The function set a rate-limit
@return bool true if the rate-limit is not overloaded @return bool true if the rate-limit is not overloaded
false if the rate-limit is overloaded */ false if the rate-limit is overloaded */
public function set ($name) public function set ($name)

View File

@@ -107,7 +107,7 @@ class renderer
require_once ("domframework/outputhtml.php"); require_once ("domframework/outputhtml.php");
if ($route === null) if ($route === null)
$route = new route (); $route = new route ();
// Return a $dataflash with the displayed flash in Bootstrap // Return a $dataflash with the displayed flash in Bootstrap
$dataflash = ""; $dataflash = "";
if (isset ($_SESSION["renderer"]["flash"])) if (isset ($_SESSION["renderer"]["flash"]))
{ {
@@ -145,7 +145,7 @@ class renderer
} }
$html = new outputhtml (); $html = new outputhtml ();
$replacement = array_merge ($replacement, $replacement = array_merge ($replacement,
array ("{baseurl}"=>$route->baseURL (), array ("{baseurl}"=>$route->baseURL (),
"{baseurlresource}"=>$route->baseURLresource (), "{baseurlresource}"=>$route->baseURLresource (),
"{flash}"=>$dataflash)); "{flash}"=>$dataflash));

View File

@@ -58,7 +58,7 @@ class route
/** Array to variable definition */ /** Array to variable definition */
public $variable = array (); public $variable = array ();
/** The route constructor : initialize the parameters */ /** The route constructor : initialize the parameters */
function __construct () function __construct ()
{ {
$this->ratelimiter = new ratelimitfile (); $this->ratelimiter = new ratelimitfile ();
@@ -99,7 +99,7 @@ class route
if (substr ($this->baseURL, -1) !== "/") if (substr ($this->baseURL, -1) !== "/")
$this->baseURL .= "/"; $this->baseURL .= "/";
} }
elseif (isset ($_SERVER["REQUEST_URI"]) && elseif (isset ($_SERVER["REQUEST_URI"]) &&
strpos ($_SERVER["REQUEST_URI"], "index.php?url=") !== false) strpos ($_SERVER["REQUEST_URI"], "index.php?url=") !== false)
{ {
$this->baseURL = ""; $this->baseURL = "";
@@ -139,7 +139,6 @@ class route
strpos ($_SERVER["REQUEST_URI"], "index.php?url=") !== false) strpos ($_SERVER["REQUEST_URI"], "index.php?url=") !== false)
return "index.php?url=".$this->baseURL; return "index.php?url=".$this->baseURL;
return $this->baseURL; return $this->baseURL;
} }
/** Return the baseURL of the module /** Return the baseURL of the module
@@ -187,7 +186,7 @@ class route
} }
if (isset ($_SERVER["REQUEST_URI"])) if (isset ($_SERVER["REQUEST_URI"]))
{ {
// If there is a directory before the index.php file, must remove the // If there is a directory before the index.php file, must remove the
// directory structure // directory structure
if (dirname ($_SERVER["SCRIPT_NAME"]) !== "/") if (dirname ($_SERVER["SCRIPT_NAME"]) !== "/")
$url .= substr ($_SERVER["REQUEST_URI"], $url .= substr ($_SERVER["REQUEST_URI"],

View File

@@ -9,7 +9,7 @@ require_once ("domframework/renderer.php");
error_reporting (E_ALL); error_reporting (E_ALL);
/** Automatic Routing for SQL database /** Automatic Routing for SQL database
Allow to do CRUD on data with only one line in index.php */ Allow to do CRUD on data with only one line in index.php */
class routeSQL class routeSQL
{ {
@@ -46,8 +46,8 @@ class routeSQL
public $authHTML = array ("email"=>"anonymous"); public $authHTML = array ("email"=>"anonymous");
/** Authentication for REST part */ /** Authentication for REST part */
public $authREST = array ("email"=>"anonymous"); public $authREST = array ("email"=>"anonymous");
/** Authorization object. Should allow a method named /** Authorization object. Should allow a method named
"allow ($module, $user, $object)" which return "allow ($module, $user, $object)" which return
- NO if the object is not defined - NO if the object is not defined
- RO if the object is in read-only mode - RO if the object is in read-only mode
- RW if the object is in read-write mode */ - RW if the object is in read-write mode */
@@ -75,8 +75,8 @@ class routeSQL
private $model_file = ""; private $model_file = "";
/** The model class included in the model file */ /** The model class included in the model file */
private $model_class = ""; private $model_class = "";
/** The prefix to be used in the URL. Should be the end of $model_file /** The prefix to be used in the URL. Should be the end of $model_file
Ex : if $model_file = models/model_zone.php, the url_prefix should be Ex : if $model_file = models/model_zone.php, the url_prefix should be
zone */ zone */
private $url_prefix = ""; private $url_prefix = "";
/** The SQL object created */ /** The SQL object created */
@@ -371,7 +371,7 @@ $content .= "</li>\n";
// Limiting access to data only to data with read access right // Limiting access to data only to data with read access right
foreach ($data as $key=>$vals) foreach ($data as $key=>$vals)
{ {
if ($this->accessright ($this->authHTML["email"], if ($this->accessright ($this->authHTML["email"],
$vals[$this->objectDB->primary]) !== TRUE) $vals[$this->objectDB->primary]) !== TRUE)
unset ($data[$key]); unset ($data[$key]);
} }
@@ -427,7 +427,7 @@ $content .= "</li>\n";
if ($this->chainedForeign !== null && if ($this->chainedForeign !== null &&
isset ($values[$this->chainedForeign]) && isset ($values[$this->chainedForeign]) &&
$values[$this->chainedForeign] !== $chain) $values[$this->chainedForeign] !== $chain)
$errorsChain[$this->chainedForeign] = $errorsChain[$this->chainedForeign] =
array ("error", dgettext("domframework", array ("error", dgettext("domframework",
"Can not change the external key")); "Can not change the external key"));
if ($this->chainedForeign !== null) if ($this->chainedForeign !== null)
@@ -495,7 +495,7 @@ $content .= "</li>\n";
if ($this->chainedForeign !== null && if ($this->chainedForeign !== null &&
isset ($values[$this->chainedForeign]) && isset ($values[$this->chainedForeign]) &&
$values[$this->chainedForeign] !== $chain) $values[$this->chainedForeign] !== $chain)
$errorsChain[$this->chainedForeign] = $errorsChain[$this->chainedForeign] =
array ("error", dgettext("domframework", array ("error", dgettext("domframework",
"Can not change the external key")); "Can not change the external key"));
$errors = $this->objectDB->verify ($values, $id); $errors = $this->objectDB->verify ($values, $id);
@@ -576,7 +576,7 @@ $content .= "</li>\n";
{ {
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 ("Chained can not have an already chained object",
500); 500);
$this->url_prefix = $this->chained->url_prefix."/{chain}/". $this->url_prefix = $this->chained->url_prefix."/{chain}/".
$this->url_prefix; $this->url_prefix;
} }
@@ -693,7 +693,7 @@ $content .= "</li>\n";
// Limiting access to data only to data with read access right // Limiting access to data only to data with read access right
foreach ($data as $key=>$vals) foreach ($data as $key=>$vals)
{ {
if ($this->accessright ($this->authHTML["email"], if ($this->accessright ($this->authHTML["email"],
$vals[$this->objectDB->primary]) !== TRUE) $vals[$this->objectDB->primary]) !== TRUE)
unset ($data[$key]); unset ($data[$key]);
} }
@@ -757,7 +757,7 @@ $content .= "</li>\n";
} }
$content = ""; $content = "";
// Internal CSS // Internal CSS
if ($this->enableInternalCSS === true) if ($this->enableInternalCSS === true)
{ {
@@ -984,7 +984,7 @@ $content .= "</li>\n";
}); });
$route->get ($this->url_prefix."/add", function ($chain=null) $route->get ($this->url_prefix."/add", function ($chain=null)
{ {
// Add a new entry : form to be filled by the user // Add a new entry : form to be filled by the user
if ($this->chained !== null) if ($this->chained !== null)
@@ -1143,7 +1143,7 @@ $content .= "</li>\n";
$this->rendererhtml ($content); $this->rendererhtml ($content);
}); });
$route->post ($this->url_prefix."/add", function ($chain=null) use ($route) $route->post ($this->url_prefix."/add", function ($chain=null) use ($route)
{ {
// Add a new entry : effective save of the data // Add a new entry : effective save of the data
if ($this->chained !== null) if ($this->chained !== null)
@@ -1188,7 +1188,7 @@ $content .= "</li>\n";
if ($this->chainedForeign !== null && if ($this->chainedForeign !== null &&
isset ($values[$this->chainedForeign]) && isset ($values[$this->chainedForeign]) &&
$values[$this->chainedForeign] !== $chain) $values[$this->chainedForeign] !== $chain)
$errorsChain[$this->chainedForeign] = $errorsChain[$this->chainedForeign] =
array ("error", dgettext("domframework", array ("error", dgettext("domframework",
"Can not change the external key")); "Can not change the external key"));
$errors = $this->objectDB->verify ($values); $errors = $this->objectDB->verify ($values);
@@ -1197,8 +1197,8 @@ $content .= "</li>\n";
try try
{ {
$this->objectDB->insert ($values); $this->objectDB->insert ($values);
$renderer = new renderer (); $renderer = new renderer ();
$renderer->flash ("SUCCESS", dgettext("domframework", $renderer->flash ("SUCCESS", dgettext("domframework",
"Creation done")); "Creation done"));
$route->redirect ("/". $route->redirect ("/".
str_replace ("{chain}", $chain, $this->url_prefix), str_replace ("{chain}", $chain, $this->url_prefix),
@@ -1257,7 +1257,7 @@ $content .= "</li>\n";
$this->chained->editright ($this->authHTML["email"], $chain) !== true) $this->chained->editright ($this->authHTML["email"], $chain) !== true)
$this->readwriteAllowed = false; $this->readwriteAllowed = false;
if ($this->readwriteAllowed === true) if ($this->readwriteAllowed === true)
$this->readwriteAllowed = $this->editright ($this->authHTML["email"], $this->readwriteAllowed = $this->editright ($this->authHTML["email"],
$id); $id);
$readonly = $this->readonly ($this->authHTML["email"], $id); $readonly = $this->readonly ($this->authHTML["email"], $id);
@@ -1429,8 +1429,8 @@ $content .= "</li>\n";
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);
@@ -1444,7 +1444,7 @@ $content .= "</li>\n";
if ($this->chainedForeign !== null && if ($this->chainedForeign !== null &&
isset ($values[$this->chainedForeign]) && isset ($values[$this->chainedForeign]) &&
$values[$this->chainedForeign] !== $chain) $values[$this->chainedForeign] !== $chain)
$errorsChain[$this->chainedForeign] = $errorsChain[$this->chainedForeign] =
array ("error", dgettext("domframework", array ("error", dgettext("domframework",
"Can not change the external key")); "Can not change the external key"));
if ($this->chainedForeign !== null) if ($this->chainedForeign !== null)
@@ -1455,7 +1455,7 @@ $content .= "</li>\n";
try try
{ {
$this->objectDB->update ($id, $values); $this->objectDB->update ($id, $values);
$renderer = new renderer (); $renderer = new renderer ();
$renderer->flash ("SUCCESS", dgettext("domframework","Update done")); $renderer->flash ("SUCCESS", dgettext("domframework","Update done"));
$route->redirect ("/". $route->redirect ("/".
str_replace ("{chain}", $chain, $this->url_prefix), str_replace ("{chain}", $chain, $this->url_prefix),
@@ -1500,7 +1500,7 @@ $content .= "</li>\n";
return TRUE; return TRUE;
} }
/** Authorization : Return TRUE if the user right allow to edit the data /** Authorization : Return TRUE if the user right allow to edit the data
Return FALSE else */ Return FALSE else */
public function editright ($auth, $id=null) public function editright ($auth, $id=null)
{ {
@@ -1508,7 +1508,7 @@ $content .= "</li>\n";
// var_export($this->model_class, TRUE)."\n"; // var_export($this->model_class, TRUE)."\n";
if ($this->authorization !== null) if ($this->authorization !== null)
{ {
$result = $this->authorization->allow ($this->module, $auth, $result = $this->authorization->allow ($this->module, $auth,
"/".$this->model_class."/$id"); "/".$this->model_class."/$id");
// echo "RESULT=$result\n"; // echo "RESULT=$result\n";
if ($result === "RW") return TRUE; if ($result === "RW") return TRUE;
@@ -1525,7 +1525,7 @@ $content .= "</li>\n";
// var_export($this->model_class, TRUE)."\n"; // var_export($this->model_class, TRUE)."\n";
if ($this->authorization !== null) if ($this->authorization !== null)
{ {
$result = $this->authorization->allow ($this->module, $auth, $result = $this->authorization->allow ($this->module, $auth,
"/".$this->model_class."/$id"); "/".$this->model_class."/$id");
// echo "RESULT=$result\n"; // echo "RESULT=$result\n";
if ($result === "RO") return TRUE; if ($result === "RO") return TRUE;

View File

@@ -1,5 +1,5 @@
<?php <?php
/** The abstraction class of the users /** The abstraction class of the users
Allow to manage the users in multiple storages (SQL, HTPasswd, passwd file). Allow to manage the users in multiple storages (SQL, HTPasswd, passwd file).
CRUD the users and allow to modify the password */ CRUD the users and allow to modify the password */
class users class users
@@ -9,7 +9,7 @@ class users
{ {
} }
/** Initialise the storage /** Initialise the storage
Create the structure of data needed to the class */ Create the structure of data needed to the class */
public function initStorage () public function initStorage ()
{ {
@@ -20,7 +20,7 @@ class users
password) */ password) */
public function adduser ($email, $firstname, $lastname, $password=null) public function adduser ($email, $firstname, $lastname, $password=null)
{ {
} }
/** Delete a user */ /** Delete a user */
public function deluser ($email) public function deluser ($email)
@@ -37,7 +37,7 @@ class users
{ {
} }
/** Change password /** Change password
@param string $email the user email to change the password @param string $email the user email to change the password
@param string $oldpassword The old password (to check if the user have the @param string $oldpassword The old password (to check if the user have the
rights to change the password) rights to change the password)
@@ -65,15 +65,15 @@ class users
public function checkEmail ($email) public function checkEmail ($email)
{ {
if (! is_string ($email)) if (! is_string ($email))
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Invalid email provided : not a string"), "Invalid email provided : not a string"),
500); 500);
if (strlen ($email) < 5) if (strlen ($email) < 5)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Invalid email provided : too short"), "Invalid email provided : too short"),
500); 500);
if (strpos ($email, ":") !== false) if (strpos ($email, ":") !== false)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Invalid email provided : colon forbidden"), "Invalid email provided : colon forbidden"),
500); 500);
return true; return true;
@@ -83,15 +83,15 @@ class users
public function checkFirstname ($firstname) public function checkFirstname ($firstname)
{ {
if (! is_string ($firstname)) if (! is_string ($firstname))
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Invalid firstname provided : not a string"), "Invalid firstname provided : not a string"),
500); 500);
if (strlen ($firstname) < 1) if (strlen ($firstname) < 1)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Invalid firstname provided : too short"), "Invalid firstname provided : too short"),
500); 500);
if (strpos ($firstname, ":") !== false) if (strpos ($firstname, ":") !== false)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Invalid firstname provided : colon forbidden"), "Invalid firstname provided : colon forbidden"),
500); 500);
return true; return true;
@@ -101,11 +101,11 @@ class users
public function checkLastname ($lastname) public function checkLastname ($lastname)
{ {
if (! is_string ($lastname)) if (! is_string ($lastname))
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Invalid lastname provided : not a string"), "Invalid lastname provided : not a string"),
500); 500);
if (strpos ($lastname, ":") !== false) if (strpos ($lastname, ":") !== false)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Invalid lastname provided : colon forbidden"), "Invalid lastname provided : colon forbidden"),
500); 500);
return true; return true;
@@ -115,15 +115,15 @@ class users
public function checkPassword ($password) public function checkPassword ($password)
{ {
if (! is_string ($password)) if (! is_string ($password))
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Invalid password provided : not a string"), "Invalid password provided : not a string"),
500); 500);
if (strlen ($password) < 5) if (strlen ($password) < 5)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Invalid password provided : too short"), "Invalid password provided : too short"),
500); 500);
if (strlen ($password) >= 128) if (strlen ($password) >= 128)
throw new Exception (dgettext("domframework", throw new Exception (dgettext("domframework",
"Invalid password provided : too long"), "Invalid password provided : too long"),
500); 500);
return true; return true;

View File

@@ -39,7 +39,7 @@ class userssql extends users
$this->password = $password; $this->password = $password;
$this->driver_options = $driver_options; $this->driver_options = $driver_options;
} }
/** Connect to the storage */ /** Connect to the storage */
public function connect () public function connect ()
{ {
@@ -75,7 +75,7 @@ class userssql extends users
$this->db->tableprefix = $this->tableprefix; $this->db->tableprefix = $this->tableprefix;
} }
/** Initialise the storage /** Initialise the storage
Create the structure of data needed to the class */ Create the structure of data needed to the class */
public function initStorage () public function initStorage ()
{ {
@@ -139,7 +139,7 @@ class userssql extends users
$this->fieldLastname)); $this->fieldLastname));
} }
/** Change password /** Change password
@param string $email the user email to change the password @param string $email the user email to change the password
@param string $oldpassword The old password (to check if the user have the @param string $oldpassword The old password (to check if the user have the
rights to change the password) rights to change the password)