modification de 'array()' vers '[]'
This commit is contained in:
parent
81d84d833f
commit
3e95721ca7
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
|
||||||
|
"local" : {
|
||||||
|
"host" : "http://stefproject",
|
||||||
|
"root" : "/"
|
||||||
|
},
|
||||||
|
|
||||||
|
"remote" : {
|
||||||
|
"host" : "https://stefproject.xdrm.io",
|
||||||
|
"root" : "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -56,7 +56,7 @@
|
||||||
$R->get('/?', function(){ header('Location: /dashboard/'); });
|
$R->get('/?', function(){ header('Location: /dashboard/'); });
|
||||||
|
|
||||||
/* (2) Liste des pages du site */
|
/* (2) Liste des pages du site */
|
||||||
$page_list = array(
|
$page_list = [
|
||||||
'dashboard',
|
'dashboard',
|
||||||
'profile',
|
'profile',
|
||||||
'machines',
|
'machines',
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
'groups',
|
'groups',
|
||||||
'analytics',
|
'analytics',
|
||||||
'settings'
|
'settings'
|
||||||
);
|
];
|
||||||
|
|
||||||
// nomPage/arg1/arg2 -> inclusion de la page
|
// nomPage/arg1/arg2 -> inclusion de la page
|
||||||
$R->get('(?:'.implode('|', $page_list).')(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
$R->get('(?:'.implode('|', $page_list).')(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
public static function init(){
|
public static function init(){
|
||||||
/* (1) Initialisation
|
/* (1) Initialisation
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
if( !isset($_SESSION['AUTH']) ) $_SESSION['AUTH'] = array();
|
if( !isset($_SESSION['AUTH']) ) $_SESSION['AUTH'] = [];
|
||||||
if( !isset($_SESSION['PERM']) ) $_SESSION['PERM'] = array();
|
if( !isset($_SESSION['PERM']) ) $_SESSION['PERM'] = [];
|
||||||
|
|
||||||
|
|
||||||
/* (2) Gestion de AUTH (authentification)
|
/* (2) Gestion de AUTH (authentification)
|
||||||
|
@ -43,20 +43,21 @@
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
/* (1) Double authentification */
|
/* (1) Double authentification */
|
||||||
if( preg_match('/^([a-f0-9]{40})([a-f0-9]{40})$/', $AUTH, $match) )
|
if( preg_match('/^([a-f0-9]{40})([a-f0-9]{40})$/', $AUTH, $match) )
|
||||||
$_SESSION['AUTH'] = array( $match[1], $match[2] );
|
$_SESSION['AUTH'] = [ $match[1], $match[2] ];
|
||||||
|
|
||||||
/* (2) Authentification unique */
|
/* (2) Authentification unique */
|
||||||
else if( preg_match('/^[a-f0-9]{40}$/', $AUTH, $match) )
|
else if( preg_match('/^[a-f0-9]{40}$/', $AUTH, $match) )
|
||||||
$_SESSION['AUTH'] = array( $match[0] );
|
$_SESSION['AUTH'] = [ $match[0] ];
|
||||||
|
|
||||||
/* (3) Aucune authentification */
|
/* (3) Aucune authentification */
|
||||||
else
|
else
|
||||||
$_SESSION['AUTH'] = array();
|
$_SESSION['AUTH'] = [];
|
||||||
|
|
||||||
|
|
||||||
/* (4) On vérifie l'authentification par BDD
|
/* (4) On vérifie l'authentification par BDD
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
return self::check();
|
if( !self::check() )
|
||||||
|
$_SESSION['AUTH'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,25 +71,25 @@
|
||||||
/* [1] Si aucune authentification
|
/* [1] Si aucune authentification
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
if( authLevel() == 0 )
|
if( authLevel() == 0 )
|
||||||
return true;
|
return false;
|
||||||
|
|
||||||
/* [2] Si authentification unique
|
/* [2] Si authentification unique
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
if( authLevel() >= 1 ){
|
if( authLevel() >= 1 ){
|
||||||
$checkRoot = new Repo('warehouse/getByToken', array($_SESSION['AUTH'][0]));
|
$checkRoot = new Repo('warehouse/getByToken', [ $_SESSION['AUTH'][0] ]);
|
||||||
|
|
||||||
// Si le token n'existe pas
|
// Si le token n'existe pas
|
||||||
if( $checkRoot->answer() === false )
|
if( count($checkRoot->answer()) < 1 )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* [3] Si authentification double
|
/* [3] Si authentification double
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
if( authLevel() >= 2 ){
|
if( authLevel() >= 2 ){
|
||||||
$checkBranch = new Repo('admin/getByToken', array($_SESSION['AUTH'][1]));
|
$checkBranch = new Repo('admin/getByToken', [ $_SESSION['AUTH'][1] ]);
|
||||||
|
|
||||||
// Si le token n'existe pas
|
// Si le token n'existe pas
|
||||||
if( $checkBranch->answer() === false )
|
if( count($checkBranch->answer()) < 1 )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
class DataBase{
|
class DataBase{
|
||||||
|
|
||||||
/* ATTRIBUTS STATIQUES */
|
/* ATTRIBUTS STATIQUES */
|
||||||
public static $config_path = array(
|
public static $config_path = [
|
||||||
'local' => 'f/json/database-local/conf',
|
'local' => 'f/json/database-local/conf',
|
||||||
'remote' => 'f/json/database/conf'
|
'remote' => 'f/json/database/conf'
|
||||||
);
|
];
|
||||||
|
|
||||||
private static $pdo;
|
private static $pdo;
|
||||||
private static $instance;
|
private static $instance;
|
||||||
|
@ -77,10 +77,10 @@
|
||||||
|
|
||||||
|
|
||||||
public function getConfig(){
|
public function getConfig(){
|
||||||
return array(
|
return [
|
||||||
'host' => $this->host,
|
'host' => $this->host,
|
||||||
'username' => $this->username
|
'username' => $this->username
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
public static function delNumeric($fetchData, $oneDimension=false){
|
public static function delNumeric($fetchData, $oneDimension=false){
|
||||||
// On quitte si ce n'est pas un tableau
|
// On quitte si ce n'est pas un tableau
|
||||||
if( !is_array($fetchData) )
|
if( !is_array($fetchData) )
|
||||||
return array();
|
return [];
|
||||||
|
|
||||||
$nextEquivalent = false; // Vaut VRAI si le prochain est peut-etre un equivalent numerique
|
$nextEquivalent = false; // Vaut VRAI si le prochain est peut-etre un equivalent numerique
|
||||||
|
|
||||||
|
@ -365,9 +365,9 @@
|
||||||
/* [1] On definit les traductions
|
/* [1] On definit les traductions
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
// Jours de la semaine
|
// Jours de la semaine
|
||||||
$days = array("Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche");
|
$days = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"];
|
||||||
// Mois de l'annee
|
// Mois de l'annee
|
||||||
$months = array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
|
$months = ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"];
|
||||||
|
|
||||||
/* [2] On recupere le timestamp et les indices
|
/* [2] On recupere le timestamp et les indices
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -378,12 +378,12 @@
|
||||||
|
|
||||||
/* [3] On recupere les infos independemment
|
/* [3] On recupere les infos independemment
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$result = array(
|
$result = [
|
||||||
$days[$daynum], // nom de jour
|
$days[$daynum], // nom de jour
|
||||||
date('j', $time), // jour du mois
|
date('j', $time), // jour du mois
|
||||||
$months[$monthnum], // nom du mois
|
$months[$monthnum], // nom du mois
|
||||||
date('Y', $time), // annee
|
date('Y', $time), // annee
|
||||||
);
|
];
|
||||||
|
|
||||||
|
|
||||||
return implode(" ", $result);
|
return implode(" ", $result);
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
|
|
||||||
// Constantes
|
// Constantes
|
||||||
public static $config_path = 'f/json/modules/conf';
|
public static $config_path = 'f/json/modules/conf';
|
||||||
public static $default_options = array(
|
public static $default_options = [
|
||||||
'download' => false
|
'download' => false
|
||||||
);
|
];
|
||||||
|
|
||||||
// Attributs prives utiles (initialisation)
|
// Attributs prives utiles (initialisation)
|
||||||
private $path;
|
private $path;
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type de @data (optionnel)
|
// Type de @data (optionnel)
|
||||||
$params = (is_array($params)) ? $params : array();
|
$params = (is_array($params)) ? $params : [];
|
||||||
|
|
||||||
|
|
||||||
/* [2] Verification du chemin (existence module+methode)
|
/* [2] Verification du chemin (existence module+methode)
|
||||||
|
@ -190,7 +190,7 @@
|
||||||
|
|
||||||
/* (3) Si @headers n'est pas défini on met par défaut */
|
/* (3) Si @headers n'est pas défini on met par défaut */
|
||||||
if( !isset($returned['headers']) || !is_array($returned['headers']) )
|
if( !isset($returned['headers']) || !is_array($returned['headers']) )
|
||||||
$returned['headers'] = array();
|
$returned['headers'] = [];
|
||||||
|
|
||||||
|
|
||||||
$fromAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
|
$fromAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
|
||||||
|
@ -348,10 +348,10 @@
|
||||||
|
|
||||||
/* [4] Enregistrement du chemin et renvoi de SUCCESS
|
/* [4] Enregistrement du chemin et renvoi de SUCCESS
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$this->path = array(
|
$this->path = [
|
||||||
'module' => $module,
|
'module' => $module,
|
||||||
'method' => $method
|
'method' => $method
|
||||||
);
|
];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* (1) On verifie que le token est valide */
|
/* (1) On verifie que le token est valide */
|
||||||
$checkToken = new Repo('token/check', array($token) );
|
$checkToken = new Repo('token/check', [$token] );
|
||||||
$token_permissions = $checkToken->answer();
|
$token_permissions = $checkToken->answer();
|
||||||
|
|
||||||
// Si le token est invalide, on retourne une erreur -> FAUX
|
// Si le token est invalide, on retourne une erreur -> FAUX
|
||||||
|
@ -540,7 +540,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private function getFunctionCaller(){
|
private function getFunctionCaller(){
|
||||||
return array( '\\manager\\module\\'.$this->path['module'], $this->path['method'] );
|
return [ '\\manager\\module\\'.$this->path['module'], $this->path['method'] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct($error=ManagerError::Success){
|
public function __construct($error=ManagerError::Success){
|
||||||
$this->data = array();
|
$this->data = [];
|
||||||
$this->error = $error;
|
$this->error = $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,11 +143,10 @@
|
||||||
// header('Content-Type: application/json');
|
// header('Content-Type: application/json');
|
||||||
|
|
||||||
// On rajoute l'erreur au message
|
// On rajoute l'erreur au message
|
||||||
$returnData = array_merge(
|
$returnData = array_merge([
|
||||||
array(
|
|
||||||
'ModuleError' => $this->error,
|
'ModuleError' => $this->error,
|
||||||
'ErrorDescription' => ManagerError::explicit($this->error)
|
'ErrorDescription' => ManagerError::explicit($this->error)
|
||||||
),
|
],
|
||||||
$this->data
|
$this->data
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type de @params (optionnel)
|
// Type de @params (optionnel)
|
||||||
$params = (is_array($params)) ? $params : array();
|
$params = (is_array($params)) ? $params : [];
|
||||||
|
|
||||||
|
|
||||||
/* [2] Verification du chemin (existence repo+methode)
|
/* [2] Verification du chemin (existence repo+methode)
|
||||||
|
@ -170,10 +170,10 @@
|
||||||
|
|
||||||
/* [4] Enregistrement du chemin et renvoi de SUCCESS
|
/* [4] Enregistrement du chemin et renvoi de SUCCESS
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$this->path = array(
|
$this->path = [
|
||||||
'repo' => $repository,
|
'repo' => $repository,
|
||||||
'method' => $method
|
'method' => $method
|
||||||
);
|
];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private function getFunctionCaller(){
|
private function getFunctionCaller(){
|
||||||
return array( '\\manager\\repo\\'.$this->path['repo'], $this->path['method'] );
|
return [ '\\manager\\repo\\'.$this->path['repo'], $this->path['method'] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -144,11 +144,11 @@
|
||||||
/* [2] Creation (non serialisee) des flags
|
/* [2] Creation (non serialisee) des flags
|
||||||
======================================================*/
|
======================================================*/
|
||||||
// Si tout se deroule bien, on cree les flags
|
// Si tout se deroule bien, on cree les flags
|
||||||
$this->flags = array(
|
$this->flags = [
|
||||||
'extension' => $serialFlags[0],
|
'extension' => $serialFlags[0],
|
||||||
'filename' => $serialFlags[1],
|
'filename' => $serialFlags[1],
|
||||||
'parent' => $serialFlags[2]
|
'parent' => $serialFlags[2]
|
||||||
);
|
];
|
||||||
|
|
||||||
// Ajout du sous-parent optionnel
|
// Ajout du sous-parent optionnel
|
||||||
if( $opt_subParent )
|
if( $opt_subParent )
|
||||||
|
|
|
@ -23,46 +23,46 @@
|
||||||
|
|
||||||
/* [1] Creation de la machine
|
/* [1] Creation de la machine
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create_machine = new Repo('machine/create', array($code, $name) );
|
$create_machine = new Repo('machine/create', [$code, $name];
|
||||||
$id_machine = $create_machine->answer();
|
$id_machine = $create_machine->answer();
|
||||||
|
|
||||||
// Si une erreur est retournee, on retourne une erreur
|
// Si une erreur est retournee, on retourne une erreur
|
||||||
if( $id_machine === false )
|
if( $id_machine === false )
|
||||||
return array('ModuleError' => ManagerError::ModuleError);
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [2] Creation du groupe de meme nom que la machine
|
/* [2] Creation du groupe de meme nom que la machine
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create_group = new Repo('cluster/create', array($name) );
|
$create_group = new Repo('cluster/create', [$name] );
|
||||||
$id_group = $create_group->answer();
|
$id_group = $create_group->answer();
|
||||||
|
|
||||||
// Si une erreur est retournee, on retourne une erreur
|
// Si une erreur est retournee, on retourne une erreur
|
||||||
if( $id_group === false )
|
if( $id_group === false )
|
||||||
return array('ModuleError' => ManagerError::ModuleError);
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] Association au groupe
|
/* [3] Association au groupe
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$assoc_goup = new Repo('cluster/link', array($id_group, $id_machine, clusterRepo::MACHINE_CLASS));
|
$assoc_goup = new Repo('cluster/link', [$id_group, $id_machine, clusterRepo::MACHINE_CLASS]);
|
||||||
$id_assoc = $assoc_goup->answer();
|
$id_assoc = $assoc_goup->answer();
|
||||||
|
|
||||||
// Si une erreur est retournee, on retourne une erreur
|
// Si une erreur est retournee, on retourne une erreur
|
||||||
if( $id_assoc === false )
|
if( $id_assoc === false )
|
||||||
return array('ModuleError' => ManagerError::ModuleError);
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [4] Gestion du retour
|
/* [4] Gestion du retour
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return array(
|
return [
|
||||||
'ModuleError' => ManagerError::Success,
|
'ModuleError' => ManagerError::Success,
|
||||||
'id_machine' => $id_machine,
|
'id_machine' => $id_machine,
|
||||||
'id_cluster' => $id_group
|
'id_cluster' => $id_group
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,9 +82,9 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
/* Creation de l'association */
|
/* Creation de l'association */
|
||||||
$link_machine = new Repo('cluster/link', array($id_cluster, $id_machine, clusterRepo::MACHINE_CLASS));
|
$link_machine = new Repo('cluster/link', [$id_cluster, $id_machine, clusterRepo::MACHINE_CLASS]);
|
||||||
|
|
||||||
return array();
|
return [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,9 +105,9 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
/* Suppression de l'association */
|
/* Suppression de l'association */
|
||||||
$link_machine = new Repo('cluster/unlink', array($id_cluster, $id_machine, clusterRepo::MACHINE_CLASS));
|
$link_machine = new Repo('cluster/unlink', [$id_cluster, $id_machine, clusterRepo::MACHINE_CLASS]);
|
||||||
|
|
||||||
return array();
|
return [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,11 +126,9 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$machine = new Repo('machine/search', array($keywords));
|
$machine = new Repo('machine/search', [$keywords]);
|
||||||
|
|
||||||
return array(
|
return [ 'machines' => $machine->answer() ];
|
||||||
'machines' => $machine->answer()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,9 +144,7 @@
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$machines = new Repo('machine/getAll');
|
$machines = new Repo('machine/getAll');
|
||||||
|
|
||||||
return array(
|
return [ 'machines' => $machines->answer() ];
|
||||||
'machines' => $machines->answer()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,17 +162,15 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/getById', array($id_machine));
|
$request = new Repo('machine/getById', [$id_machine]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
if( $answer === false )
|
if( $answer === false )
|
||||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return [ 'machine' => $answer ];
|
||||||
'machine' => $answer
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -194,17 +188,15 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/getByCode', array($code));
|
$request = new Repo('machine/getByCode', [$code]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
if( $answer === false )
|
if( $answer === false )
|
||||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return [ 'machine' => $answer ];
|
||||||
'machine' => $answer
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -223,17 +215,15 @@
|
||||||
|
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/getByName', array($name));
|
$request = new Repo('machine/getByName', [$name]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
if( $answer === false )
|
if( $answer === false )
|
||||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return [ 'machine' => $answer ];
|
||||||
'machine' => $answer
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -251,17 +241,15 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/getClusters', array($id_machine));
|
$request = new Repo('machine/getClusters', [$id_machine]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
if( $answer === false )
|
if( $answer === false )
|
||||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return [ 'clusters' => $answer ];
|
||||||
'clusters' => $answer
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -283,12 +271,12 @@
|
||||||
|
|
||||||
/* [1] On verifie l'existence de la machine
|
/* [1] On verifie l'existence de la machine
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$machine_exists = new Repo('machine/getById', array($id_machine));
|
$machine_exists = new Repo('machine/getById', [$id_machine]);
|
||||||
$machine_data = $machine_exists->answer();
|
$machine_data = $machine_exists->answer();
|
||||||
|
|
||||||
// Si on a recupere aucune machine, on retourne une erreur
|
// Si on a recupere aucune machine, on retourne une erreur
|
||||||
if( !is_array($machine_data) )
|
if( !is_array($machine_data) )
|
||||||
return array('ModuleError' => ManagerError::NoMatchFound);
|
return ['ModuleError' => ManagerError::NoMatchFound];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -297,30 +285,28 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
|
||||||
/* (1) Verification des parametres (si correct et different)*/
|
/* (1) Verification des parametres (si correct et different)*/
|
||||||
$correct_param = array(
|
$correct_param = [
|
||||||
'code' => !is_null($code) && $machine_data['code'] != $code,
|
'code' => !is_null($code) && $machine_data['code'] != $code,
|
||||||
'name' => !is_null($name) && $machine_data['name'] != $name
|
'name' => !is_null($name) && $machine_data['name'] != $name
|
||||||
);
|
];
|
||||||
|
|
||||||
/* (2) Gestion des parametres optionnels */
|
/* (2) Gestion des parametres optionnels */
|
||||||
$opt_data = array(
|
$opt_data = [
|
||||||
'code' => ($correct_param['code']) ? $code : $machine_data['code'],
|
'code' => ($correct_param['code']) ? $code : $machine_data['code'],
|
||||||
'name' => ($correct_param['name']) ? $name : $machine_data['name']
|
'name' => ($correct_param['name']) ? $name : $machine_data['name']
|
||||||
);
|
];
|
||||||
|
|
||||||
|
|
||||||
/* [3] Modification de la machine
|
/* [3] Modification de la machine
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$request = new Repo('machine/edit', array(
|
$request = new Repo('machine/edit', [
|
||||||
$id_machine,
|
$id_machine,
|
||||||
$opt_data['code'],
|
$opt_data['code'],
|
||||||
$opt_data['name']
|
$opt_data['name']
|
||||||
));
|
]);
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return [ 'status' => $request->answer() ];
|
||||||
'status' => $request->answer()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -338,12 +324,10 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/delete', array($id_machine));
|
$request = new Repo('machine/delete', [$id_machine]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
return array(
|
return [ 'status' => $answer ];
|
||||||
'status' => $answer
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
*/
|
*/
|
||||||
public static function method(){
|
public static function method(){
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
'ModuleError' => ManagerError::Success,
|
'ModuleError' => ManagerError::Success,
|
||||||
'ReceivedArguments' => func_get_args()
|
'ReceivedArguments' => func_get_args()
|
||||||
);
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
// Gestion de l'erreur de parsage
|
// Gestion de l'erreur de parsage
|
||||||
if( $modules == null )
|
if( $modules == null )
|
||||||
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||||
|
|
||||||
/* [2] Mise en forme de la liste des modules
|
/* [2] Mise en forme de la liste des modules
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -60,17 +60,17 @@
|
||||||
|
|
||||||
/* [n] Gestion du retour
|
/* [n] Gestion du retour
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return array(
|
return [
|
||||||
'ModuleError' => ManagerError::Success,
|
'ModuleError' => ManagerError::Success,
|
||||||
'headers' => array(
|
'headers' => [
|
||||||
'Content-Type' => 'text/markdown; charset=utf-8',
|
'Content-Type' => 'text/markdown; charset=utf-8',
|
||||||
'Content-Transfer-Encoding' => 'binary',
|
'Content-Transfer-Encoding' => 'binary',
|
||||||
'Content-Disposition' => 'attachment; filename=NxTIC.apib',
|
'Content-Disposition' => 'attachment; filename=NxTIC.apib',
|
||||||
'Pragma' => 'no-cache',
|
'Pragma' => 'no-cache',
|
||||||
'Expires' => '0'
|
'Expires' => '0'
|
||||||
),
|
],
|
||||||
'body' => $markdown
|
'body' => $markdown
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
|
|
||||||
// Gestion de l'erreur de parsage
|
// Gestion de l'erreur de parsage
|
||||||
if( $modules == null )
|
if( $modules == null )
|
||||||
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||||
|
|
||||||
|
|
||||||
/* [1] Début du fichier custom
|
/* [1] Début du fichier custom
|
||||||
|
@ -258,17 +258,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
'ModuleError' => ManagerError::Success,
|
'ModuleError' => ManagerError::Success,
|
||||||
'headers' => array(
|
'headers' => [
|
||||||
'Content-Type' => 'application/octet-stream; charset=utf-8',
|
'Content-Type' => 'application/octet-stream; charset=utf-8',
|
||||||
'Content-Transfer-Encoding' => 'binary',
|
'Content-Transfer-Encoding' => 'binary',
|
||||||
'Content-Disposition' => 'attachment; filename=NxTIC.apib',
|
'Content-Disposition' => 'attachment; filename=NxTIC.apib',
|
||||||
'Pragma' => 'no-cache',
|
'Pragma' => 'no-cache',
|
||||||
'Expires' => '0'
|
'Expires' => '0'
|
||||||
),
|
],
|
||||||
'body' => $content
|
'body' => $content
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,46 +32,46 @@
|
||||||
|
|
||||||
/* [2] Creation de l'utilisateur
|
/* [2] Creation de l'utilisateur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create_user = new Repo('user/create', array($code, $username, $firstname, $lastname, $mail, $password_hash, $status) );
|
$create_user = new Repo('user/create', [$code, $username, $firstname, $lastname, $mail, $password_hash, $status] );
|
||||||
$id_user = $create_user->answer();
|
$id_user = $create_user->answer();
|
||||||
|
|
||||||
var_dump($create_user);
|
var_dump($create_user);
|
||||||
|
|
||||||
// Si une erreur est retournee, on retourne une erreur
|
// Si une erreur est retournee, on retourne une erreur
|
||||||
if( $id_user === false )
|
if( $id_user === false )
|
||||||
return array('ModuleError' => ManagerError::ModuleError);
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] Creation du groupe de meme nom que l'username
|
/* [3] Creation du groupe de meme nom que l'username
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create_group = new Repo('cluster/create', array($username) );
|
$create_group = new Repo('cluster/create', [$username] );
|
||||||
$id_group = $create_group->answer();
|
$id_group = $create_group->answer();
|
||||||
|
|
||||||
// Si une erreur est retournee, on retourne une erreur
|
// Si une erreur est retournee, on retourne une erreur
|
||||||
if( $id_group === false )
|
if( $id_group === false )
|
||||||
return array('ModuleError' => ManagerError::ModuleError);
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [4] Association au groupe
|
/* [4] Association au groupe
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$assoc_goup = new Repo('cluster/link', array($id_group, $id_user, clusterRepo::USER_CLASS));
|
$assoc_goup = new Repo('cluster/link', [$id_group, $id_user, clusterRepo::USER_CLASS]);
|
||||||
$id_assoc = $assoc_goup->answer();
|
$id_assoc = $assoc_goup->answer();
|
||||||
|
|
||||||
// Si une erreur est retournee, on retourne une erreur
|
// Si une erreur est retournee, on retourne une erreur
|
||||||
if( $id_assoc === false )
|
if( $id_assoc === false )
|
||||||
return array('ModuleError' => ManagerError::ModuleError);
|
return ['ModuleError' => ManagerError::ModuleError];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [5] Gestion du retour
|
/* [5] Gestion du retour
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return array(
|
return [
|
||||||
'id_user' => $id_user,
|
'id_user' => $id_user,
|
||||||
'id_cluster' => $id_group
|
'id_cluster' => $id_group
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,9 +92,9 @@
|
||||||
|
|
||||||
/* [1] Creation de l'association
|
/* [1] Creation de l'association
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$link_user = new Repo('cluster/link', array($id_cluster, $id_user, clusterRepo::USER_CLASS));
|
$link_user = new Repo('cluster/link', [$id_cluster, $id_user, clusterRepo::USER_CLASS]);
|
||||||
|
|
||||||
return array();
|
return [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,9 +116,9 @@
|
||||||
|
|
||||||
/* [1] Suppression de l'association
|
/* [1] Suppression de l'association
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$link_user = new Repo('cluster/unlink', array($id_cluster, $id_user, clusterRepo::USER_CLASS));
|
$link_user = new Repo('cluster/unlink', [$id_cluster, $id_user, clusterRepo::USER_CLASS]);
|
||||||
|
|
||||||
return array();
|
return [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,11 +137,9 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$user = new Repo('user/search', array($keywords));
|
$user = new Repo('user/search', [$keywords]);
|
||||||
|
|
||||||
return array(
|
return [ 'users' => $user->answer() ];
|
||||||
'users' => $user->answer()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,9 +155,7 @@
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$users = new Repo('user/getAll');
|
$users = new Repo('user/getAll');
|
||||||
|
|
||||||
return array(
|
return [ 'users' => $users->answer() ];
|
||||||
'users' => $users->answer()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,17 +173,15 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('user/getById', array($id_user));
|
$request = new Repo('user/getById', [$id_user]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
if( $answer === false )
|
if( $answer === false )
|
||||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return [ 'user' => $answer ];
|
||||||
'user' => $answer
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,17 +199,15 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('user/getByCode', array($code));
|
$request = new Repo('user/getByCode', [$code]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
if( $answer === false )
|
if( $answer === false )
|
||||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return [ 'user' => $answer ];
|
||||||
'user' => $answer
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -234,17 +226,15 @@
|
||||||
|
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('user/getByUsername', array($username));
|
$request = new Repo('user/getByUsername', [$username]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
if( $answer === false )
|
if( $answer === false )
|
||||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return [ 'user' => $answer ];
|
||||||
'user' => $answer
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -263,17 +253,15 @@
|
||||||
|
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('user/getClusters', array($id_user));
|
$request = new Repo('user/getClusters', [$id_user]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
if( $answer === false )
|
if( $answer === false )
|
||||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return [ 'clusters' => $answer ];
|
||||||
'clusters' => $answer
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,12 +287,12 @@
|
||||||
|
|
||||||
/* [1] On verifie l'existence de l'utilisateur
|
/* [1] On verifie l'existence de l'utilisateur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$user_exists = new Repo('user/getById', array($id_user));
|
$user_exists = new Repo('user/getById', [$id_user]);
|
||||||
$user_data = $user_exists->answer();
|
$user_data = $user_exists->answer();
|
||||||
|
|
||||||
// Si on a recupere aucun utilisateur, on retourne une erreur
|
// Si on a recupere aucun utilisateur, on retourne une erreur
|
||||||
if( !is_array($user_data) )
|
if( !is_array($user_data) )
|
||||||
return array('ModuleError' => ManagerError::NoMatchFound);
|
return ['ModuleError' => ManagerError::NoMatchFound];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -313,7 +301,7 @@
|
||||||
$password_hash = sessionManager::secure_sha1($password);
|
$password_hash = sessionManager::secure_sha1($password);
|
||||||
|
|
||||||
/* (1) Verification des parametres (si non nul + differents)*/
|
/* (1) Verification des parametres (si non nul + differents)*/
|
||||||
$diff_param = array(
|
$diff_param = [
|
||||||
'code' => !is_null($code) && $user_data['code'] != $code,
|
'code' => !is_null($code) && $user_data['code'] != $code,
|
||||||
'username' => !is_null($username) && $user_data['username'] != $username,
|
'username' => !is_null($username) && $user_data['username'] != $username,
|
||||||
'firstname' => !is_null($firstname) && $user_data['firstname'] != $firstname,
|
'firstname' => !is_null($firstname) && $user_data['firstname'] != $firstname,
|
||||||
|
@ -321,10 +309,10 @@
|
||||||
'mail' => !is_null($mail) && $user_data['mail'] != $mail,
|
'mail' => !is_null($mail) && $user_data['mail'] != $mail,
|
||||||
'password' => !is_null($password) && $user_data['password'] != $password_hash,
|
'password' => !is_null($password) && $user_data['password'] != $password_hash,
|
||||||
'status' => !is_null($status) && $user_data['status'] != $status
|
'status' => !is_null($status) && $user_data['status'] != $status
|
||||||
);
|
];
|
||||||
|
|
||||||
/* (2) Gestion des parametres optionnels */
|
/* (2) Gestion des parametres optionnels */
|
||||||
$opt_data = array(
|
$opt_data = [
|
||||||
'code' => ($diff_param['code']) ? $code : $user_data['code'],
|
'code' => ($diff_param['code']) ? $code : $user_data['code'],
|
||||||
'username' => ($diff_param['username']) ? $username : $user_data['username'],
|
'username' => ($diff_param['username']) ? $username : $user_data['username'],
|
||||||
'firstname' => ($diff_param['firstname']) ? $firstname : $user_data['firstname'],
|
'firstname' => ($diff_param['firstname']) ? $firstname : $user_data['firstname'],
|
||||||
|
@ -332,14 +320,14 @@
|
||||||
'mail' => ($diff_param['mail']) ? $mail : $user_data['mail'],
|
'mail' => ($diff_param['mail']) ? $mail : $user_data['mail'],
|
||||||
'password' => ($diff_param['password']) ? $password : $user_data['password'],
|
'password' => ($diff_param['password']) ? $password : $user_data['password'],
|
||||||
'status' => ($diff_param['status']) ? $status : $user_data['status'],
|
'status' => ($diff_param['status']) ? $status : $user_data['status'],
|
||||||
);
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] Modification de l'utilisateur
|
/* [3] Modification de l'utilisateur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$request = new Repo('user/edit', array(
|
$request = new Repo('user/edit', [
|
||||||
$id_user,
|
$id_user,
|
||||||
$opt_data['code'],
|
$opt_data['code'],
|
||||||
$opt_data['username'],
|
$opt_data['username'],
|
||||||
|
@ -348,12 +336,10 @@
|
||||||
$opt_data['mail'],
|
$opt_data['mail'],
|
||||||
$opt_data['password'],
|
$opt_data['password'],
|
||||||
$opt_data['status'])
|
$opt_data['status'])
|
||||||
);
|
];
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return [ 'status' => $request->answer() ];
|
||||||
'status' => $request->answer()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -372,12 +358,10 @@
|
||||||
|
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('user/delete', array($id_user));
|
$request = new Repo('user/delete', [$id_user]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
return array(
|
return [ 'status' => $answer ];
|
||||||
'status' => $answer
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,206 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace manager\repo;
|
||||||
|
use \manager\Database;
|
||||||
|
use \manager\sessionManager;
|
||||||
|
use \manager\repo\cluster as clusterRepo;
|
||||||
|
|
||||||
|
class admin extends parentRepo{
|
||||||
|
|
||||||
|
protected static function table_name(){ static $table_name = 'admin'; return $table_name; }
|
||||||
|
|
||||||
|
/* CREATION D'UN ADMINISTRATEUR
|
||||||
|
*
|
||||||
|
* @username<String> Identifiant de l'administrateur
|
||||||
|
* @mail<String> Adresse mail de l'administrateur
|
||||||
|
* @password<String> Mot de passe de l'administrateur
|
||||||
|
*
|
||||||
|
* @return id_admin<int> Renvoie l'UID de l'administrateur cree
|
||||||
|
* Renvoie FALSE si une erreur occure
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function create($username, $mail, $password){
|
||||||
|
/* [1] Verification de l'identifiant du nom+mail (username, mail)
|
||||||
|
=========================================================*/
|
||||||
|
$check_unique = count(self::getByUsername($username)) == 0;
|
||||||
|
$check_unique = $check_unique && count(self::getByMail($mail)) == 0;
|
||||||
|
|
||||||
|
// Si un administrateur a deja cet identifiant ou mail, on renvoie une erreur
|
||||||
|
if( !$check_unique )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* [2] Creation de l'administrateur
|
||||||
|
=========================================================*/
|
||||||
|
$insert_admin = Database::getPDO()->prepare("INSERT INTO admin(id_admin, username, mail, password, token)
|
||||||
|
VALUES(DEFAULT, :username, :mail, :password, :token)");
|
||||||
|
$insert_admin->execute([
|
||||||
|
':username' => $username,
|
||||||
|
':mail' => $mail,
|
||||||
|
':password' => sessionManager::secure_sha1( $password ),
|
||||||
|
':token' => sessionManager::secure_sha1( uniqid() )
|
||||||
|
]);
|
||||||
|
|
||||||
|
/* [3] On retourne l'id_admin ou FALSE si erreur
|
||||||
|
=========================================================*/
|
||||||
|
$check_admin = self::getByUsername($username);
|
||||||
|
|
||||||
|
// Si n'existe pas on retourne FALSE
|
||||||
|
if( !isset($check_admin[0]) || !is_array($check_admin[0]) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Sinon, on retourne son id
|
||||||
|
return intval( $check_admin[0]['id_admin'] );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* MISE A JOUR DU TOKEN D'UN ADMINISTRATEUR
|
||||||
|
*
|
||||||
|
* @id_admin<int> UID de l'administrateur
|
||||||
|
*
|
||||||
|
* @return new_token<String> Renvoie le nouveau token
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function updateToken($id_admin=null){
|
||||||
|
|
||||||
|
/* [1] On vérifie que l'administrateur existe
|
||||||
|
=========================================================*/
|
||||||
|
if( self::getById($id_admin) === false )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
/* [2] On met à jour le token
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) On crée un nouveau token */
|
||||||
|
$new_token = sessionManager::secure_sha1( uniqid() );
|
||||||
|
|
||||||
|
/* (2) On applique le nouveau token */
|
||||||
|
$update_token = Database::getPDO()->prepare("UPDATE admin
|
||||||
|
SET token = :token
|
||||||
|
WHERE id_admin = :id_admin");
|
||||||
|
|
||||||
|
$update_token->execute([
|
||||||
|
':token' => $new_token,
|
||||||
|
':id_admin' => $id_admin
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
/* [3] On renvoie le token
|
||||||
|
=========================================================*/
|
||||||
|
return $new_token;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* MODIFICATION D'UN ADMINISTRATEUR
|
||||||
|
*
|
||||||
|
* @id_admin<int> UID de l'administrateur
|
||||||
|
* @username<String> Identifiant de l'administrateur
|
||||||
|
* @mail<String> Adresse mail de l'administrateur
|
||||||
|
* @password<String> Mot de passe de l'administrateur
|
||||||
|
*
|
||||||
|
* @return status<Boolean> Renvoie si oui ou non tout s'est bien passe
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function edit($id_admin=null, $username=null, $mail=null, $password=null){
|
||||||
|
/* [1] Verification de l'unicite du nom (name) (si different)
|
||||||
|
=========================================================*/
|
||||||
|
// On recupere les administrateurs ayant le meme nom (si existent)
|
||||||
|
// pour éviter les collisions (car le nom doit être unique)
|
||||||
|
$getbyuname = self::getByUsername($username);
|
||||||
|
$getbymail = self::getByMail($mail);
|
||||||
|
|
||||||
|
$check_unique = is_array($getbyuname) && $getbyuname['id_user'] == $id_user || !is_array($getbyuname);
|
||||||
|
|
||||||
|
// Si un utilisateur a deja ce code ou cet username (sauf lui), on renvoie une erreur
|
||||||
|
if( !$check_unique )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* [2] Modification de l'utilisateur
|
||||||
|
=========================================================*/
|
||||||
|
$edit_admin = Database::getPDO()->prepare("UPDATE admin
|
||||||
|
SET name = :name,
|
||||||
|
password = :password
|
||||||
|
WHERE id_admin = :id_admin");
|
||||||
|
$edit_admin->execute([
|
||||||
|
':name' => $name,
|
||||||
|
':password' => $password,
|
||||||
|
':id_admin' => $id_admin
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* [3] On retourne si tout a ete modifie, si erreur
|
||||||
|
=========================================================*/
|
||||||
|
$check_admin = self::getById($id_admin);
|
||||||
|
|
||||||
|
$checker = $check_admin['id_admin'] == $id_admin;
|
||||||
|
$checker = $checker && $check_admin['name'] == $name;
|
||||||
|
$checker = $checker && $check_admin['password'] == $password;
|
||||||
|
|
||||||
|
// On retourne l'etat de la modification
|
||||||
|
return $checker;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SUPPRIME UN ENTREPOT DONNE
|
||||||
|
*
|
||||||
|
* @id_admin<int> UID de l'administrateur en question
|
||||||
|
*
|
||||||
|
* @return status<Boolean> Retourne si oui ou non l'administrateur a bien ete supprime
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function delete($id_admin){
|
||||||
|
/* [1] On redige/execute la requete
|
||||||
|
=========================================================*/
|
||||||
|
$delete_admin = Database::getPDO()->prepare("DELETE FROM admin WHERE id_admin = :id_admin");
|
||||||
|
$delete_admin->execute([ ':id_admin' => $id_admin ]);
|
||||||
|
|
||||||
|
|
||||||
|
/* [2] On verifie que l'utilisateur n'existe plus
|
||||||
|
=========================================================*/
|
||||||
|
return ( self::getById($id_admin) === false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
|
@ -34,9 +34,7 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$insert_user = Database::getPDO()->prepare("INSERT INTO cluster(id_cluster, name)
|
$insert_user = Database::getPDO()->prepare("INSERT INTO cluster(id_cluster, name)
|
||||||
VALUES(DEFAULT, :name)");
|
VALUES(DEFAULT, :name)");
|
||||||
$insert_user->execute(array(
|
$insert_user->execute([ ':name' => $name ]);
|
||||||
':name' => $name
|
|
||||||
));
|
|
||||||
|
|
||||||
/* [3] On retourne l'id_group ou FALSE si erreur
|
/* [3] On retourne l'id_group ou FALSE si erreur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -113,11 +111,11 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$link_entity = Database::getPDO()->prepare("INSERT INTO cluster_merge(id_cluster_merge, id_cluster, id_entity, class)
|
$link_entity = Database::getPDO()->prepare("INSERT INTO cluster_merge(id_cluster_merge, id_cluster, id_entity, class)
|
||||||
VALUES(DEFAULT, :id_cluster, :id_entity, :class)");
|
VALUES(DEFAULT, :id_cluster, :id_entity, :class)");
|
||||||
$link_entity->execute(array(
|
$link_entity->execute([
|
||||||
':id_cluster' => $id_cluster,
|
':id_cluster' => $id_cluster,
|
||||||
':id_entity' => $id_entity,
|
':id_entity' => $id_entity,
|
||||||
':class' => $class
|
':class' => $class
|
||||||
));
|
]);
|
||||||
|
|
||||||
/* [5] On retourne l'id_cluster_merge ou FALSE si erreur
|
/* [5] On retourne l'id_cluster_merge ou FALSE si erreur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -154,11 +152,11 @@
|
||||||
WHERE id_cluster = :id_cluster
|
WHERE id_cluster = :id_cluster
|
||||||
AND id_entity = :id_entity
|
AND id_entity = :id_entity
|
||||||
AND class = :class");
|
AND class = :class");
|
||||||
$delete_cluster_merge->execute(array(
|
$delete_cluster_merge->execute([
|
||||||
':id_cluster' => $id_cluster,
|
':id_cluster' => $id_cluster,
|
||||||
':id_entity' => $id_entity,
|
':id_entity' => $id_entity,
|
||||||
':class' => $class
|
':class' => $class
|
||||||
));
|
]);
|
||||||
|
|
||||||
|
|
||||||
/* [2] On verifie que l'association n'existe plus
|
/* [2] On verifie que l'association n'existe plus
|
||||||
|
@ -190,11 +188,11 @@
|
||||||
AND class = :class");
|
AND class = :class");
|
||||||
|
|
||||||
// On execute la requete
|
// On execute la requete
|
||||||
$request->execute(array(
|
$request->execute([
|
||||||
':id_cluster' => $id_cluster,
|
':id_cluster' => $id_cluster,
|
||||||
':id_entity' => $id_entity,
|
':id_entity' => $id_entity,
|
||||||
':class' => $class
|
':class' => $class
|
||||||
));
|
]);
|
||||||
|
|
||||||
// On recupere 1 seule relation
|
// On recupere 1 seule relation
|
||||||
$answer = $request->fetch();
|
$answer = $request->fetch();
|
||||||
|
@ -227,9 +225,7 @@
|
||||||
$get_members = Database::getPDO()->prepare("SELECT * FROM cluster_merge
|
$get_members = Database::getPDO()->prepare("SELECT * FROM cluster_merge
|
||||||
WHERE id_cluster = :id_cluster
|
WHERE id_cluster = :id_cluster
|
||||||
ORDER BY id_cluster_merge");
|
ORDER BY id_cluster_merge");
|
||||||
$get_members->execute(array(
|
$get_members->execute([ ':id_cluster' => $id_cluster ]);
|
||||||
':id_cluster' => $id_cluster
|
|
||||||
));
|
|
||||||
|
|
||||||
$members = Database::delNumeric( $get_members->fetchAll() );
|
$members = Database::delNumeric( $get_members->fetchAll() );
|
||||||
|
|
||||||
|
@ -280,9 +276,7 @@
|
||||||
/* [1] On redige/execute la requete
|
/* [1] On redige/execute la requete
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$delete_group = Database::getPDO()->prepare("DELETE FROM cluster WHERE id_cluster = :id_cluster");
|
$delete_group = Database::getPDO()->prepare("DELETE FROM cluster WHERE id_cluster = :id_cluster");
|
||||||
$delete_group->execute(array(
|
$delete_group->execute([ ':id_cluster' => $id_cluster ]);
|
||||||
':id_cluster' => $id_cluster
|
|
||||||
));
|
|
||||||
|
|
||||||
|
|
||||||
/* [2] On verifie que le groupe n'existe plus
|
/* [2] On verifie que le groupe n'existe plus
|
||||||
|
|
|
@ -32,10 +32,10 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$insert_machine = Database::getPDO()->prepare("INSERT INTO machine(id_machine, code, name)
|
$insert_machine = Database::getPDO()->prepare("INSERT INTO machine(id_machine, code, name)
|
||||||
VALUES(DEFAULT, :code, :name)");
|
VALUES(DEFAULT, :code, :name)");
|
||||||
$insert_machine->execute(array(
|
$insert_machine->execute([
|
||||||
':code' => $code,
|
':code' => $code,
|
||||||
':name' => $name
|
':name' => $name
|
||||||
));
|
]);
|
||||||
|
|
||||||
/* [3] On retourne l'id_machine ou FALSE si erreur
|
/* [3] On retourne l'id_machine ou FALSE si erreur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -91,10 +91,10 @@
|
||||||
AND cm.id_entity = :id_machine
|
AND cm.id_entity = :id_machine
|
||||||
AND cm.class = :class
|
AND cm.class = :class
|
||||||
ORDER BY c.id_cluster");
|
ORDER BY c.id_cluster");
|
||||||
$get_clusters->execute(array(
|
$get_clusters->execute([
|
||||||
':id_machine' => $id_machine,
|
':id_machine' => $id_machine,
|
||||||
':class' => clusterRepo::MACHINE_CLASS
|
':class' => clusterRepo::MACHINE_CLASS
|
||||||
));
|
]);
|
||||||
|
|
||||||
/* [2] On retourne la liste des groupes
|
/* [2] On retourne la liste des groupes
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -137,11 +137,11 @@
|
||||||
SET code = :code,
|
SET code = :code,
|
||||||
name = :name
|
name = :name
|
||||||
WHERE id_machine = :id_machine");
|
WHERE id_machine = :id_machine");
|
||||||
$edit_machine->execute(array(
|
$edit_machine->execute([
|
||||||
':code' => $code,
|
':code' => $code,
|
||||||
':name' => $name,
|
':name' => $name,
|
||||||
':id_machine' => $id_machine
|
':id_machine' => $id_machine
|
||||||
));
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,9 +175,7 @@
|
||||||
/* [1] On redige/execute la requete
|
/* [1] On redige/execute la requete
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$delete_machine = Database::getPDO()->prepare("DELETE FROM machine WHERE id_machine = :id_machine");
|
$delete_machine = Database::getPDO()->prepare("DELETE FROM machine WHERE id_machine = :id_machine");
|
||||||
$delete_machine->execute(array(
|
$delete_machine->execute([ ':id_machine' => $id_machine ]);
|
||||||
':id_machine' => $id_machine
|
|
||||||
));
|
|
||||||
|
|
||||||
|
|
||||||
/* [2] On verifie que la machine n'existe plus
|
/* [2] On verifie que la machine n'existe plus
|
||||||
|
|
|
@ -33,9 +33,9 @@
|
||||||
$getColumns = Database::getPDO()->query('SHOW COLUMNS FROM '.static::table_name());
|
$getColumns = Database::getPDO()->query('SHOW COLUMNS FROM '.static::table_name());
|
||||||
$cols = Database::delNumeric( $getColumns->fetchAll() );
|
$cols = Database::delNumeric( $getColumns->fetchAll() );
|
||||||
|
|
||||||
$table_columns = array(
|
$table_columns = [
|
||||||
'_PRIMARY_' => array() // Contiendra les champs de la clé primaire
|
'_PRIMARY_' => [] // Contiendra les champs de la clé primaire
|
||||||
);
|
];
|
||||||
|
|
||||||
// On ajoute la liste des colonnes
|
// On ajoute la liste des colonnes
|
||||||
foreach($cols as $column){
|
foreach($cols as $column){
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
// Si 'getById', on compose la clé primaire
|
// Si 'getById', on compose la clé primaire
|
||||||
if( $getById ){
|
if( $getById ){
|
||||||
|
|
||||||
$pdo_vars = array();
|
$pdo_vars = [];
|
||||||
|
|
||||||
foreach($table_columns['_PRIMARY_'] as $i=>$primary_column)
|
foreach($table_columns['_PRIMARY_'] as $i=>$primary_column)
|
||||||
$pdo_vars[':primary'.$i] = $args[$i];
|
$pdo_vars[':primary'.$i] = $args[$i];
|
||||||
|
@ -101,9 +101,9 @@
|
||||||
|
|
||||||
// Si 'getSomething', on ajoute le champ
|
// Si 'getSomething', on ajoute le champ
|
||||||
}else
|
}else
|
||||||
$getRequest->execute(array(
|
$getRequest->execute([
|
||||||
':value' => ($getSomething||$getById) ? $args[0] : null
|
':value' => ($getSomething||$getById) ? $args[0] : null
|
||||||
));
|
]);
|
||||||
|
|
||||||
/* [6] On récupère le résultat
|
/* [6] On récupère le résultat
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$insert_user = Database::getPDO()->prepare("INSERT INTO user(id_user, code, username, firstname, lastname, mail, password, status)
|
$insert_user = Database::getPDO()->prepare("INSERT INTO user(id_user, code, username, firstname, lastname, mail, password, status)
|
||||||
VALUES(DEFAULT, :code, :username, :firstname, :lastname, :mail, :password, :status)");
|
VALUES(DEFAULT, :code, :username, :firstname, :lastname, :mail, :password, :status)");
|
||||||
$insert_user->execute(array(
|
$insert_user->execute([
|
||||||
':code' => $code,
|
':code' => $code,
|
||||||
':username' => $username,
|
':username' => $username,
|
||||||
':firstname' => $firstname,
|
':firstname' => $firstname,
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
':mail' => $mail,
|
':mail' => $mail,
|
||||||
':password' => $password,
|
':password' => $password,
|
||||||
':status' => $status
|
':status' => $status
|
||||||
));
|
]);
|
||||||
|
|
||||||
/* [3] On retourne l'id_user ou FALSE si erreur
|
/* [3] On retourne l'id_user ou FALSE si erreur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -105,10 +105,10 @@
|
||||||
AND cm.id_entity = :id_user
|
AND cm.id_entity = :id_user
|
||||||
AND cm.class = :class
|
AND cm.class = :class
|
||||||
ORDER BY c.id_cluster");
|
ORDER BY c.id_cluster");
|
||||||
$get_clusters->execute(array(
|
$get_clusters->execute([
|
||||||
':id_user' => $id_user,
|
':id_user' => $id_user,
|
||||||
':class' => clusterRepo::USER_CLASS
|
':class' => clusterRepo::USER_CLASS
|
||||||
));
|
]);
|
||||||
|
|
||||||
/* [2] On retourne la liste des groupes
|
/* [2] On retourne la liste des groupes
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -162,7 +162,7 @@
|
||||||
password = :password,
|
password = :password,
|
||||||
status = :status
|
status = :status
|
||||||
WHERE id_user = :id_user");
|
WHERE id_user = :id_user");
|
||||||
$edit_user->execute(array(
|
$edit_user->execute([
|
||||||
':code' => $code,
|
':code' => $code,
|
||||||
':username' => $username,
|
':username' => $username,
|
||||||
':firstname' => $firstname,
|
':firstname' => $firstname,
|
||||||
|
@ -171,7 +171,7 @@
|
||||||
':password' => $password,
|
':password' => $password,
|
||||||
':status' => $status,
|
':status' => $status,
|
||||||
':id_user' => $id_user
|
':id_user' => $id_user
|
||||||
));
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,9 +210,7 @@
|
||||||
/* [1] On redige/execute la requete
|
/* [1] On redige/execute la requete
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$delete_user = Database::getPDO()->prepare("DELETE FROM user WHERE id_user = :id_user");
|
$delete_user = Database::getPDO()->prepare("DELETE FROM user WHERE id_user = :id_user");
|
||||||
$delete_user->execute(array(
|
$delete_user->execute([ ':id_user' => $id_user ]);
|
||||||
':id_user' => $id_user
|
|
||||||
));
|
|
||||||
|
|
||||||
|
|
||||||
/* [2] On verifie que l'utilisateur n'existe plus
|
/* [2] On verifie que l'utilisateur n'existe plus
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
protected static function table_name(){ static $table_name = 'warehouse'; return $table_name; }
|
protected static function table_name(){ static $table_name = 'warehouse'; return $table_name; }
|
||||||
|
|
||||||
/* CREATION D'UN UTILISATEUR ET DE SON GROUPE INDIVIDUEL
|
/* CREATION D'UN ENTREPOT
|
||||||
*
|
*
|
||||||
* @name<String> Identifiant de l'entrepot
|
* @name<String> Identifiant de l'entrepot
|
||||||
* @password<String> Mot de passe de l'entrepot
|
* @password<String> Mot de passe de l'entrepot
|
||||||
|
@ -31,11 +31,11 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$insert_warehouse = Database::getPDO()->prepare("INSERT INTO warehouse(id_warehouse, name, password, token)
|
$insert_warehouse = Database::getPDO()->prepare("INSERT INTO warehouse(id_warehouse, name, password, token)
|
||||||
VALUES(DEFAULT, :name, :password, :token)");
|
VALUES(DEFAULT, :name, :password, :token)");
|
||||||
$insert_warehouse->execute(array(
|
$insert_warehouse->execute([
|
||||||
':name' => $name,
|
':name' => $name,
|
||||||
':password' => sessionManager::secure_sha1( $password ),
|
':password' => sessionManager::secure_sha1( $password ),
|
||||||
':token' => sessionManager::secure_sha1( uniqid() )
|
':token' => sessionManager::secure_sha1( uniqid() )
|
||||||
));
|
]);
|
||||||
|
|
||||||
/* [3] On retourne l'id_warehouse ou FALSE si erreur
|
/* [3] On retourne l'id_warehouse ou FALSE si erreur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -81,10 +81,10 @@
|
||||||
SET token = :token
|
SET token = :token
|
||||||
WHERE id_warehouse = :id_warehouse");
|
WHERE id_warehouse = :id_warehouse");
|
||||||
|
|
||||||
$update_token->execute(array(
|
$update_token->execute([
|
||||||
':token' => $new_token,
|
':token' => $new_token,
|
||||||
':id_warehouse' => $id_warehouse
|
':id_warehouse' => $id_warehouse
|
||||||
));
|
]);
|
||||||
|
|
||||||
|
|
||||||
/* [3] On renvoie le token
|
/* [3] On renvoie le token
|
||||||
|
@ -114,11 +114,11 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
// On recupere les entrepots ayant le meme nom (si existent)
|
// On recupere les entrepots ayant le meme nom (si existent)
|
||||||
// pour éviter les collisions (car le nom doit être unique)
|
// pour éviter les collisions (car le nom doit être unique)
|
||||||
$getbyname = self::getByName($code);
|
$getbyname = self::getByName($name);
|
||||||
|
|
||||||
$check_unique = is_array($getbyname) && $getbyname['id_user'] == $id_user || !is_array($getbyname);
|
$check_unique = is_array($getbyname) && $getbyname['id_user'] == $id_user || !is_array($getbyname);
|
||||||
|
|
||||||
// Si un utilisateur a deja ce code ou cet username (sauf lui), on renvoie une erreur
|
// Si un utilisateur a deja ce name ou cet username (sauf lui), on renvoie une erreur
|
||||||
if( !$check_unique )
|
if( !$check_unique )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -128,11 +128,11 @@
|
||||||
SET name = :name,
|
SET name = :name,
|
||||||
password = :password
|
password = :password
|
||||||
WHERE id_warehouse = :id_warehouse");
|
WHERE id_warehouse = :id_warehouse");
|
||||||
$edit_warehouse->execute(array(
|
$edit_warehouse->execute([
|
||||||
':name' => $name,
|
':name' => $name,
|
||||||
':password' => $password,
|
':password' => $password,
|
||||||
':id_warehouse' => $id_warehouse
|
':id_warehouse' => $id_warehouse
|
||||||
));
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,9 +166,9 @@
|
||||||
/* [1] On redige/execute la requete
|
/* [1] On redige/execute la requete
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$delete_warehouse = Database::getPDO()->prepare("DELETE FROM warehouse WHERE id_warehouse = :id_warehouse");
|
$delete_warehouse = Database::getPDO()->prepare("DELETE FROM warehouse WHERE id_warehouse = :id_warehouse");
|
||||||
$delete_warehouse->execute(array(
|
$delete_warehouse->execute([
|
||||||
':id_warehouse' => $id_warehouse
|
':id_warehouse' => $id_warehouse
|
||||||
));
|
]);
|
||||||
|
|
||||||
|
|
||||||
/* [2] On verifie que l'utilisateur n'existe plus
|
/* [2] On verifie que l'utilisateur n'existe plus
|
||||||
|
|
|
@ -305,7 +305,7 @@
|
||||||
<tr><td><div align="right"><a name="110"></a><a href="#110">110</a></div></td><td class="codeLine"> public static function delNumeric($fetchData, $oneDimension=false){</td></tr>
|
<tr><td><div align="right"><a name="110"></a><a href="#110">110</a></div></td><td class="codeLine"> public static function delNumeric($fetchData, $oneDimension=false){</td></tr>
|
||||||
<tr><td><div align="right"><a name="111"></a><a href="#111">111</a></div></td><td class="codeLine"> // On quitte si ce n'est pas un tableau</td></tr>
|
<tr><td><div align="right"><a name="111"></a><a href="#111">111</a></div></td><td class="codeLine"> // On quitte si ce n'est pas un tableau</td></tr>
|
||||||
<tr class="success popin" data-title="6 tests cover line 112" data-content="<ul><li class="success">phpunit\Database_delNumeric::testTypeInt</li><li class="success">phpunit\Database_delNumeric::testTypeString</li><li class="success">phpunit\Database_delNumeric::testGlobal2Dim</li><li class="success">phpunit\Database_delNumeric::testGlobal2DimWithNumericIndexes</li><li class="success">phpunit\Database_delNumeric::testGlobal1Dim</li><li class="success">phpunit\Database_delNumeric::testGlobal1DimWithNumericIndexes</li></ul>" data-placement="bottom" data-html="true"><td><div align="right"><a name="112"></a><a href="#112">112</a></div></td><td class="codeLine"> if( !is_array($fetchData) )</td></tr>
|
<tr class="success popin" data-title="6 tests cover line 112" data-content="<ul><li class="success">phpunit\Database_delNumeric::testTypeInt</li><li class="success">phpunit\Database_delNumeric::testTypeString</li><li class="success">phpunit\Database_delNumeric::testGlobal2Dim</li><li class="success">phpunit\Database_delNumeric::testGlobal2DimWithNumericIndexes</li><li class="success">phpunit\Database_delNumeric::testGlobal1Dim</li><li class="success">phpunit\Database_delNumeric::testGlobal1DimWithNumericIndexes</li></ul>" data-placement="bottom" data-html="true"><td><div align="right"><a name="112"></a><a href="#112">112</a></div></td><td class="codeLine"> if( !is_array($fetchData) )</td></tr>
|
||||||
<tr class="success popin" data-title="6 tests cover line 113" data-content="<ul><li class="success">phpunit\Database_delNumeric::testTypeInt</li><li class="success">phpunit\Database_delNumeric::testTypeString</li><li class="success">phpunit\Database_delNumeric::testGlobal2Dim</li><li class="success">phpunit\Database_delNumeric::testGlobal2DimWithNumericIndexes</li><li class="success">phpunit\Database_delNumeric::testGlobal1Dim</li><li class="success">phpunit\Database_delNumeric::testGlobal1DimWithNumericIndexes</li></ul>" data-placement="bottom" data-html="true"><td><div align="right"><a name="113"></a><a href="#113">113</a></div></td><td class="codeLine"> return array();</td></tr>
|
<tr class="success popin" data-title="6 tests cover line 113" data-content="<ul><li class="success">phpunit\Database_delNumeric::testTypeInt</li><li class="success">phpunit\Database_delNumeric::testTypeString</li><li class="success">phpunit\Database_delNumeric::testGlobal2Dim</li><li class="success">phpunit\Database_delNumeric::testGlobal2DimWithNumericIndexes</li><li class="success">phpunit\Database_delNumeric::testGlobal1Dim</li><li class="success">phpunit\Database_delNumeric::testGlobal1DimWithNumericIndexes</li></ul>" data-placement="bottom" data-html="true"><td><div align="right"><a name="113"></a><a href="#113">113</a></div></td><td class="codeLine"> return [];</td></tr>
|
||||||
<tr><td><div align="right"><a name="114"></a><a href="#114">114</a></div></td><td class="codeLine"></td></tr>
|
<tr><td><div align="right"><a name="114"></a><a href="#114">114</a></div></td><td class="codeLine"></td></tr>
|
||||||
<tr class="success popin" data-title="4 tests cover line 115" data-content="<ul><li class="success">phpunit\Database_delNumeric::testGlobal2Dim</li><li class="success">phpunit\Database_delNumeric::testGlobal2DimWithNumericIndexes</li><li class="success">phpunit\Database_delNumeric::testGlobal1Dim</li><li class="success">phpunit\Database_delNumeric::testGlobal1DimWithNumericIndexes</li></ul>" data-placement="bottom" data-html="true"><td><div align="right"><a name="115"></a><a href="#115">115</a></div></td><td class="codeLine"> $nextEquivalent = false; // Vaut VRAI si le prochain est peut-etre un equivalent numerique</td></tr>
|
<tr class="success popin" data-title="4 tests cover line 115" data-content="<ul><li class="success">phpunit\Database_delNumeric::testGlobal2Dim</li><li class="success">phpunit\Database_delNumeric::testGlobal2DimWithNumericIndexes</li><li class="success">phpunit\Database_delNumeric::testGlobal1Dim</li><li class="success">phpunit\Database_delNumeric::testGlobal1DimWithNumericIndexes</li></ul>" data-placement="bottom" data-html="true"><td><div align="right"><a name="115"></a><a href="#115">115</a></div></td><td class="codeLine"> $nextEquivalent = false; // Vaut VRAI si le prochain est peut-etre un equivalent numerique</td></tr>
|
||||||
<tr><td><div align="right"><a name="116"></a><a href="#116">116</a></div></td><td class="codeLine"></td></tr>
|
<tr><td><div align="right"><a name="116"></a><a href="#116">116</a></div></td><td class="codeLine"></td></tr>
|
||||||
|
|
|
@ -230,7 +230,7 @@ jQuery.fn = jQuery.prototype = {
|
||||||
return num == null ?
|
return num == null ?
|
||||||
|
|
||||||
// Return a 'clean' array
|
// Return a 'clean' array
|
||||||
this.toArray() :
|
this.to[] :
|
||||||
|
|
||||||
// Return just the object
|
// Return just the object
|
||||||
( num < 0 ? this[ this.length + num ] : this[ num ] );
|
( num < 0 ? this[ this.length + num ] : this[ num ] );
|
||||||
|
@ -5864,7 +5864,7 @@ jQuery.fn.extend({
|
||||||
});
|
});
|
||||||
} else if ( arguments.length ) {
|
} else if ( arguments.length ) {
|
||||||
var set = jQuery.clean( arguments );
|
var set = jQuery.clean( arguments );
|
||||||
set.push.apply( set, this.toArray() );
|
set.push.apply( set, this.to[] );
|
||||||
return this.pushStack( set, "before", arguments );
|
return this.pushStack( set, "before", arguments );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -7200,7 +7200,7 @@ jQuery.fn.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
serialize: function() {
|
serialize: function() {
|
||||||
return jQuery.param( this.serializeArray() );
|
return jQuery.param( this.serialize[] );
|
||||||
},
|
},
|
||||||
|
|
||||||
serializeArray: function() {
|
serializeArray: function() {
|
||||||
|
|
|
@ -5,23 +5,23 @@
|
||||||
/* [0] Verification du type
|
/* [0] Verification du type
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
public function testTypeInt(){
|
public function testTypeInt(){
|
||||||
$this->assertEquals( array(), \manager\Database::delNumeric(10) );
|
$this->assertEquals( [], \manager\Database::delNumeric(10) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTypeString(){
|
public function testTypeString(){
|
||||||
$this->assertEquals( array(), \manager\Database::delNumeric('notarray') );
|
$this->assertEquals( [], \manager\Database::delNumeric('notarray') );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* [1] Verification pour 2 dimensions
|
/* [1] Verification pour 2 dimensions
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) Global */
|
/* (1) Global */
|
||||||
public function testGlobal2Dim(){
|
public function testGlobal2Dim(){
|
||||||
$fetchData = array(array(
|
$fetchData = [[
|
||||||
'id' => '000001',
|
'id' => '000001',
|
||||||
0 => '000001',
|
0 => '000001',
|
||||||
'nom' => 'Jean Dupont',
|
'nom' => 'Jean Dupont',
|
||||||
1 => 'Jean Dupont',
|
1 => 'Jean Dupont',
|
||||||
));
|
]];
|
||||||
|
|
||||||
$computed_array = \manager\Database::delNumeric( $fetchData );
|
$computed_array = \manager\Database::delNumeric( $fetchData );
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
/* (2) Verification d'indices numeriques dans les donnees */
|
/* (2) Verification d'indices numeriques dans les donnees */
|
||||||
public function testGlobal2DimWithNumericIndexes(){
|
public function testGlobal2DimWithNumericIndexes(){
|
||||||
$fetchData = array(array(
|
$fetchData = [[
|
||||||
'id' => '000001',
|
'id' => '000001',
|
||||||
0 => '000001',
|
0 => '000001',
|
||||||
'nom' => 'Jean Dupont',
|
'nom' => 'Jean Dupont',
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
5 => 'Bla',
|
5 => 'Bla',
|
||||||
6 => 'Bla',
|
6 => 'Bla',
|
||||||
7 => 'Bla'
|
7 => 'Bla'
|
||||||
));
|
]];
|
||||||
|
|
||||||
$computed_array = \manager\Database::delNumeric( $fetchData );
|
$computed_array = \manager\Database::delNumeric( $fetchData );
|
||||||
|
|
||||||
|
@ -66,12 +66,12 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) Global */
|
/* (1) Global */
|
||||||
public function testGlobal1Dim(){
|
public function testGlobal1Dim(){
|
||||||
$fetchData = array(
|
$fetchData = [
|
||||||
'id' => '000001',
|
'id' => '000001',
|
||||||
0 => '000001',
|
0 => '000001',
|
||||||
'nom' => 'Jean Dupont',
|
'nom' => 'Jean Dupont',
|
||||||
1 => 'Jean Dupont'
|
1 => 'Jean Dupont'
|
||||||
);
|
];
|
||||||
|
|
||||||
$computed_array = \manager\Database::delNumeric( $fetchData );
|
$computed_array = \manager\Database::delNumeric( $fetchData );
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
|
|
||||||
/* (2) Verification d'indices numeriques dans les donnees */
|
/* (2) Verification d'indices numeriques dans les donnees */
|
||||||
public function testGlobal1DimWithNumericIndexes(){
|
public function testGlobal1DimWithNumericIndexes(){
|
||||||
$fetchData = array(
|
$fetchData = [
|
||||||
'id' => '000001',
|
'id' => '000001',
|
||||||
0 => '000001',
|
0 => '000001',
|
||||||
'nom' => 'Jean Dupont',
|
'nom' => 'Jean Dupont',
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
5 => 'Bla',
|
5 => 'Bla',
|
||||||
6 => 'Bla',
|
6 => 'Bla',
|
||||||
7 => 'Bla'
|
7 => 'Bla'
|
||||||
);
|
];
|
||||||
|
|
||||||
$computed_array = \manager\Database::delNumeric( $fetchData );
|
$computed_array = \manager\Database::delNumeric( $fetchData );
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Route{
|
||||||
// ATTRIBUTS
|
// ATTRIBUTS
|
||||||
private $pattern;
|
private $pattern;
|
||||||
private $callback;
|
private $callback;
|
||||||
private $matches = array();
|
private $matches = [];
|
||||||
|
|
||||||
/* Initialise la route
|
/* Initialise la route
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,10 +21,10 @@ class Router{
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
|
||||||
// On initialise les routes
|
// On initialise les routes
|
||||||
$this->routes = array(
|
$this->routes = [
|
||||||
'GET' => array(),
|
'GET' => [],
|
||||||
'POST' => array()
|
'POST' => []
|
||||||
);
|
];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
foreach( $json as $user ){
|
foreach( $json as $user ){
|
||||||
|
|
||||||
// Creation de la requete
|
// Creation de la requete
|
||||||
$request = new ModuleRequest('userDefault/create', array(
|
$request = new ModuleRequest('userDefault/create', [
|
||||||
$user['code'],
|
$user['code'],
|
||||||
$user['username'],
|
$user['username'],
|
||||||
$user['firstname'],
|
$user['firstname'],
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
$user['email'],
|
$user['email'],
|
||||||
$user['password'],
|
$user['password'],
|
||||||
$user['status']
|
$user['status']
|
||||||
));
|
]);
|
||||||
$answer = $request->dispatch();
|
$answer = $request->dispatch();
|
||||||
// Debug error
|
// Debug error
|
||||||
var_dump( $answer->error == ManagerError::Success );
|
var_dump( $answer->error == ManagerError::Success );
|
||||||
|
@ -62,10 +62,10 @@
|
||||||
foreach( $json as $machine ){
|
foreach( $json as $machine ){
|
||||||
|
|
||||||
// Creation de la requete
|
// Creation de la requete
|
||||||
$request = new ModuleRequest('machineDefault/create', array(
|
$request = new ModuleRequest('machineDefault/create', [
|
||||||
$machine['code'],
|
$machine['code'],
|
||||||
$machine['name']
|
$machine['name']
|
||||||
));
|
]);
|
||||||
$answer = $request->dispatch();
|
$answer = $request->dispatch();
|
||||||
// Debug error
|
// Debug error
|
||||||
var_dump( $answer->error == ManagerError::Success );
|
var_dump( $answer->error == ManagerError::Success );
|
||||||
|
@ -173,7 +173,7 @@
|
||||||
function testModuleDispatcher(){
|
function testModuleDispatcher(){
|
||||||
|
|
||||||
// Creation d'une requete en objet
|
// Creation d'une requete en objet
|
||||||
$req1 = new ModuleRequest('firstModule/returnvar', array('id_user' => 10, 'code' => '11-22-33-44') );
|
$req1 = new ModuleRequest('firstModule/returnvar', ['id_user' => 10, 'code' => '11-22-33-44'] );
|
||||||
// Creation d'une requete a partir d'un json en <String>
|
// Creation d'une requete a partir d'un json en <String>
|
||||||
$req2 = ModuleRequest::fromString('{"path": "firstModule/returnvar", "data": {"id_user":10, "code":"11-22-33-44"}}');
|
$req2 = ModuleRequest::fromString('{"path": "firstModule/returnvar", "data": {"id_user":10, "code":"11-22-33-44"}}');
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@
|
||||||
function testRepoDispatcher(){
|
function testRepoDispatcher(){
|
||||||
|
|
||||||
// Creation d'une requete en objet
|
// Creation d'une requete en objet
|
||||||
$req1 = new Repo('user/getById', array('19'));
|
$req1 = new Repo('user/getById', ['19']);
|
||||||
// $req1 = new Repo('user/getByCode', array('92-55-B9-B3'));
|
// $req1 = new Repo('user/getByCode', array('92-55-B9-B3'));
|
||||||
var_dump( $req1->answer() );
|
var_dump( $req1->answer() );
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@
|
||||||
function insertUsersComposite(){
|
function insertUsersComposite(){
|
||||||
|
|
||||||
// Creation de la requete
|
// Creation de la requete
|
||||||
$request = new ModuleRequest('userDefault/create', array('92-55-B9-B1', 'b', 'bla', 'bla', 'bla@test.com', 'sadas', '1') );
|
$request = new ModuleRequest('userDefault/create', ['92-55-B9-B1', 'b', 'bla', 'bla', 'bla@test.com', 'sadas', '1'] );
|
||||||
$answer = $request->dispatch();
|
$answer = $request->dispatch();
|
||||||
// Debug error
|
// Debug error
|
||||||
if( $answer->error != ManagerError::Success )
|
if( $answer->error != ManagerError::Success )
|
||||||
|
@ -248,7 +248,7 @@
|
||||||
$id_user = 115;
|
$id_user = 115;
|
||||||
|
|
||||||
// Groupes de l'utilisateur 'a'
|
// Groupes de l'utilisateur 'a'
|
||||||
$getUser1Clusters = new Repo('user/getClusters', array($id_user));
|
$getUser1Clusters = new Repo('user/getClusters', [$id_user]);
|
||||||
$user1Clusters = $getUser1Clusters->answer();
|
$user1Clusters = $getUser1Clusters->answer();
|
||||||
var_dump( $user1Clusters );
|
var_dump( $user1Clusters );
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php define('__ROOT__', dirname(dirname(__FILE__)) );
|
||||||
|
require_once __ROOT__.'/manager/autoloader.php';
|
||||||
|
debug();
|
||||||
|
|
||||||
|
use \manager\sessionManager;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$hash = 'mySecretKey';
|
||||||
|
$hashes = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for( $i = 0 ; $i < 1000 ; $i++ ){
|
||||||
|
$hash = sessionManager::secure_sha1($hash);
|
||||||
|
|
||||||
|
if( in_array($hash, $hashes) )
|
||||||
|
var_dump('already');
|
||||||
|
|
||||||
|
$hashes[] = $hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var_dump( count($hashes) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$post = array();
|
$post = [];
|
||||||
foreach($_POST as $k=>$v)
|
foreach($_POST as $k=>$v)
|
||||||
array_push($post, $k);
|
array_push($post, $k);
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$post = array();
|
$post = [];
|
||||||
foreach($_POST as $k=>$v)
|
foreach($_POST as $k=>$v)
|
||||||
array_push($post, $k);
|
array_push($post, $k);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$post = array();
|
$post = [];
|
||||||
foreach($_POST as $k=>$v)
|
foreach($_POST as $k=>$v)
|
||||||
array_push($post, $k);
|
array_push($post, $k);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$post = array();
|
$post = [];
|
||||||
foreach($_POST as $k=>$v)
|
foreach($_POST as $k=>$v)
|
||||||
array_push($post, $k);
|
array_push($post, $k);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$post = array();
|
$post = [];
|
||||||
foreach($_POST as $k=>$v)
|
foreach($_POST as $k=>$v)
|
||||||
array_push($post, $k);
|
array_push($post, $k);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$post = array();
|
$post = [];
|
||||||
foreach($_POST as $k=>$v)
|
foreach($_POST as $k=>$v)
|
||||||
array_push($post, $k);
|
array_push($post, $k);
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
|
|
||||||
// Liste des utilisateurs
|
// Liste des utilisateurs
|
||||||
foreach( $answer->get('users') as $user){
|
foreach( $answer->get('users') as $user){
|
||||||
$clusters = new Repo('user/getClusters', array($user['id_user']));
|
$clusters = new Repo('user/getClusters', [$user['id_user']]);
|
||||||
$clusters = $clusters->answer();
|
$clusters = $clusters->answer();
|
||||||
|
|
||||||
echo "<article class='inline-box' id='".$user['id_user']."'>";
|
echo "<article class='inline-box' id='".$user['id_user']."'>";
|
||||||
|
|
Loading…
Reference in New Issue