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:
48
routeSQL.php
48
routeSQL.php
@@ -9,7 +9,7 @@ require_once ("domframework/renderer.php");
|
||||
|
||||
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 */
|
||||
class routeSQL
|
||||
{
|
||||
@@ -46,8 +46,8 @@ class routeSQL
|
||||
public $authHTML = array ("email"=>"anonymous");
|
||||
/** Authentication for REST part */
|
||||
public $authREST = array ("email"=>"anonymous");
|
||||
/** Authorization object. Should allow a method named
|
||||
"allow ($module, $user, $object)" which return
|
||||
/** Authorization object. Should allow a method named
|
||||
"allow ($module, $user, $object)" which return
|
||||
- NO if the object is not defined
|
||||
- RO if the object is in read-only mode
|
||||
- RW if the object is in read-write mode */
|
||||
@@ -75,8 +75,8 @@ class routeSQL
|
||||
private $model_file = "";
|
||||
/** The model class included in the model file */
|
||||
private $model_class = "";
|
||||
/** 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
|
||||
/** 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
|
||||
zone */
|
||||
private $url_prefix = "";
|
||||
/** The SQL object created */
|
||||
@@ -371,7 +371,7 @@ $content .= "</li>\n";
|
||||
// Limiting access to data only to data with read access right
|
||||
foreach ($data as $key=>$vals)
|
||||
{
|
||||
if ($this->accessright ($this->authHTML["email"],
|
||||
if ($this->accessright ($this->authHTML["email"],
|
||||
$vals[$this->objectDB->primary]) !== TRUE)
|
||||
unset ($data[$key]);
|
||||
}
|
||||
@@ -427,7 +427,7 @@ $content .= "</li>\n";
|
||||
if ($this->chainedForeign !== null &&
|
||||
isset ($values[$this->chainedForeign]) &&
|
||||
$values[$this->chainedForeign] !== $chain)
|
||||
$errorsChain[$this->chainedForeign] =
|
||||
$errorsChain[$this->chainedForeign] =
|
||||
array ("error", dgettext("domframework",
|
||||
"Can not change the external key"));
|
||||
if ($this->chainedForeign !== null)
|
||||
@@ -495,7 +495,7 @@ $content .= "</li>\n";
|
||||
if ($this->chainedForeign !== null &&
|
||||
isset ($values[$this->chainedForeign]) &&
|
||||
$values[$this->chainedForeign] !== $chain)
|
||||
$errorsChain[$this->chainedForeign] =
|
||||
$errorsChain[$this->chainedForeign] =
|
||||
array ("error", dgettext("domframework",
|
||||
"Can not change the external key"));
|
||||
$errors = $this->objectDB->verify ($values, $id);
|
||||
@@ -576,7 +576,7 @@ $content .= "</li>\n";
|
||||
{
|
||||
if (strpos ($this->chained->url_prefix, "/{chain}/") !== false)
|
||||
throw new Exception ("Chained can not have an already chained object",
|
||||
500);
|
||||
500);
|
||||
$this->url_prefix = $this->chained->url_prefix."/{chain}/".
|
||||
$this->url_prefix;
|
||||
}
|
||||
@@ -693,7 +693,7 @@ $content .= "</li>\n";
|
||||
// Limiting access to data only to data with read access right
|
||||
foreach ($data as $key=>$vals)
|
||||
{
|
||||
if ($this->accessright ($this->authHTML["email"],
|
||||
if ($this->accessright ($this->authHTML["email"],
|
||||
$vals[$this->objectDB->primary]) !== TRUE)
|
||||
unset ($data[$key]);
|
||||
}
|
||||
@@ -757,7 +757,7 @@ $content .= "</li>\n";
|
||||
}
|
||||
|
||||
|
||||
$content = "";
|
||||
$content = "";
|
||||
// Internal CSS
|
||||
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
|
||||
if ($this->chained !== null)
|
||||
@@ -1143,7 +1143,7 @@ $content .= "</li>\n";
|
||||
$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
|
||||
if ($this->chained !== null)
|
||||
@@ -1188,7 +1188,7 @@ $content .= "</li>\n";
|
||||
if ($this->chainedForeign !== null &&
|
||||
isset ($values[$this->chainedForeign]) &&
|
||||
$values[$this->chainedForeign] !== $chain)
|
||||
$errorsChain[$this->chainedForeign] =
|
||||
$errorsChain[$this->chainedForeign] =
|
||||
array ("error", dgettext("domframework",
|
||||
"Can not change the external key"));
|
||||
$errors = $this->objectDB->verify ($values);
|
||||
@@ -1197,8 +1197,8 @@ $content .= "</li>\n";
|
||||
try
|
||||
{
|
||||
$this->objectDB->insert ($values);
|
||||
$renderer = new renderer ();
|
||||
$renderer->flash ("SUCCESS", dgettext("domframework",
|
||||
$renderer = new renderer ();
|
||||
$renderer->flash ("SUCCESS", dgettext("domframework",
|
||||
"Creation done"));
|
||||
$route->redirect ("/".
|
||||
str_replace ("{chain}", $chain, $this->url_prefix),
|
||||
@@ -1257,7 +1257,7 @@ $content .= "</li>\n";
|
||||
$this->chained->editright ($this->authHTML["email"], $chain) !== true)
|
||||
$this->readwriteAllowed = false;
|
||||
if ($this->readwriteAllowed === true)
|
||||
$this->readwriteAllowed = $this->editright ($this->authHTML["email"],
|
||||
$this->readwriteAllowed = $this->editright ($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)
|
||||
throw new Exception (dgettext("domframework","Access forbidden"), 403);
|
||||
|
||||
$this->connect();
|
||||
$oldvalues = $this->objectDB->read (array (array
|
||||
$this->connect();
|
||||
$oldvalues = $this->objectDB->read (array (array
|
||||
($this->objectDB->primary, $id)));
|
||||
if (count ($oldvalues) === 0)
|
||||
throw new Exception (dgettext("domframework", "Object not found"), 404);
|
||||
@@ -1444,7 +1444,7 @@ $content .= "</li>\n";
|
||||
if ($this->chainedForeign !== null &&
|
||||
isset ($values[$this->chainedForeign]) &&
|
||||
$values[$this->chainedForeign] !== $chain)
|
||||
$errorsChain[$this->chainedForeign] =
|
||||
$errorsChain[$this->chainedForeign] =
|
||||
array ("error", dgettext("domframework",
|
||||
"Can not change the external key"));
|
||||
if ($this->chainedForeign !== null)
|
||||
@@ -1455,7 +1455,7 @@ $content .= "</li>\n";
|
||||
try
|
||||
{
|
||||
$this->objectDB->update ($id, $values);
|
||||
$renderer = new renderer ();
|
||||
$renderer = new renderer ();
|
||||
$renderer->flash ("SUCCESS", dgettext("domframework","Update done"));
|
||||
$route->redirect ("/".
|
||||
str_replace ("{chain}", $chain, $this->url_prefix),
|
||||
@@ -1500,7 +1500,7 @@ $content .= "</li>\n";
|
||||
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 */
|
||||
public function editright ($auth, $id=null)
|
||||
{
|
||||
@@ -1508,7 +1508,7 @@ $content .= "</li>\n";
|
||||
// var_export($this->model_class, TRUE)."\n";
|
||||
if ($this->authorization !== null)
|
||||
{
|
||||
$result = $this->authorization->allow ($this->module, $auth,
|
||||
$result = $this->authorization->allow ($this->module, $auth,
|
||||
"/".$this->model_class."/$id");
|
||||
// echo "RESULT=$result\n";
|
||||
if ($result === "RW") return TRUE;
|
||||
@@ -1525,7 +1525,7 @@ $content .= "</li>\n";
|
||||
// var_export($this->model_class, TRUE)."\n";
|
||||
if ($this->authorization !== null)
|
||||
{
|
||||
$result = $this->authorization->allow ($this->module, $auth,
|
||||
$result = $this->authorization->allow ($this->module, $auth,
|
||||
"/".$this->model_class."/$id");
|
||||
// echo "RESULT=$result\n";
|
||||
if ($result === "RO") return TRUE;
|
||||
|
||||
Reference in New Issue
Block a user