modification de 'array()' vers '[]'
This commit is contained in:
parent
e8c8ca9452
commit
30f0ba8e82
|
@ -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/'); });
|
||||
|
||||
/* (2) Liste des pages du site */
|
||||
$page_list = array(
|
||||
$page_list = [
|
||||
'dashboard',
|
||||
'profile',
|
||||
'machines',
|
||||
|
@ -64,7 +64,7 @@
|
|||
'groups',
|
||||
'analytics',
|
||||
'settings'
|
||||
);
|
||||
];
|
||||
|
||||
// nomPage/arg1/arg2 -> inclusion de la page
|
||||
$R->get('(?:'.implode('|', $page_list).')(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
public static function init(){
|
||||
/* (1) Initialisation
|
||||
---------------------------------------------------------*/
|
||||
if( !isset($_SESSION['AUTH']) ) $_SESSION['AUTH'] = array();
|
||||
if( !isset($_SESSION['PERM']) ) $_SESSION['PERM'] = array();
|
||||
if( !isset($_SESSION['AUTH']) ) $_SESSION['AUTH'] = [];
|
||||
if( !isset($_SESSION['PERM']) ) $_SESSION['PERM'] = [];
|
||||
|
||||
|
||||
/* (2) Gestion de AUTH (authentification)
|
||||
|
@ -43,20 +43,21 @@
|
|||
---------------------------------------------------------*/
|
||||
/* (1) Double authentification */
|
||||
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 */
|
||||
else if( preg_match('/^[a-f0-9]{40}$/', $AUTH, $match) )
|
||||
$_SESSION['AUTH'] = array( $match[0] );
|
||||
$_SESSION['AUTH'] = [ $match[0] ];
|
||||
|
||||
/* (3) Aucune authentification */
|
||||
else
|
||||
$_SESSION['AUTH'] = array();
|
||||
$_SESSION['AUTH'] = [];
|
||||
|
||||
|
||||
/* (4) On vérifie l'authentification par BDD
|
||||
---------------------------------------------------------*/
|
||||
return self::check();
|
||||
if( !self::check() )
|
||||
$_SESSION['AUTH'] = [];
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,25 +71,25 @@
|
|||
/* [1] Si aucune authentification
|
||||
=========================================================*/
|
||||
if( authLevel() == 0 )
|
||||
return true;
|
||||
return false;
|
||||
|
||||
/* [2] Si authentification unique
|
||||
=========================================================*/
|
||||
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
|
||||
if( $checkRoot->answer() === false )
|
||||
if( count($checkRoot->answer()) < 1 )
|
||||
return false;
|
||||
}
|
||||
|
||||
/* [3] Si authentification double
|
||||
=========================================================*/
|
||||
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
|
||||
if( $checkBranch->answer() === false )
|
||||
if( count($checkBranch->answer()) < 1 )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
class DataBase{
|
||||
|
||||
/* ATTRIBUTS STATIQUES */
|
||||
public static $config_path = array(
|
||||
public static $config_path = [
|
||||
'local' => 'f/json/database-local/conf',
|
||||
'remote' => 'f/json/database/conf'
|
||||
);
|
||||
];
|
||||
|
||||
private static $pdo;
|
||||
private static $instance;
|
||||
|
@ -77,10 +77,10 @@
|
|||
|
||||
|
||||
public function getConfig(){
|
||||
return array(
|
||||
return [
|
||||
'host' => $this->host,
|
||||
'username' => $this->username
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +110,7 @@
|
|||
public static function delNumeric($fetchData, $oneDimension=false){
|
||||
// On quitte si ce n'est pas un tableau
|
||||
if( !is_array($fetchData) )
|
||||
return array();
|
||||
return [];
|
||||
|
||||
$nextEquivalent = false; // Vaut VRAI si le prochain est peut-etre un equivalent numerique
|
||||
|
||||
|
@ -365,9 +365,9 @@
|
|||
/* [1] On definit les traductions
|
||||
=========================================================*/
|
||||
// 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
|
||||
$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
|
||||
=========================================================*/
|
||||
|
@ -378,12 +378,12 @@
|
|||
|
||||
/* [3] On recupere les infos independemment
|
||||
=========================================================*/
|
||||
$result = array(
|
||||
$result = [
|
||||
$days[$daynum], // nom de jour
|
||||
date('j', $time), // jour du mois
|
||||
$months[$monthnum], // nom du mois
|
||||
date('Y', $time), // annee
|
||||
);
|
||||
];
|
||||
|
||||
|
||||
return implode(" ", $result);
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
// Constantes
|
||||
public static $config_path = 'f/json/modules/conf';
|
||||
public static $default_options = array(
|
||||
public static $default_options = [
|
||||
'download' => false
|
||||
);
|
||||
];
|
||||
|
||||
// Attributs prives utiles (initialisation)
|
||||
private $path;
|
||||
|
@ -66,7 +66,7 @@
|
|||
}
|
||||
|
||||
// Type de @data (optionnel)
|
||||
$params = (is_array($params)) ? $params : array();
|
||||
$params = (is_array($params)) ? $params : [];
|
||||
|
||||
|
||||
/* [2] Verification du chemin (existence module+methode)
|
||||
|
@ -190,7 +190,7 @@
|
|||
|
||||
/* (3) Si @headers n'est pas défini on met par défaut */
|
||||
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';
|
||||
|
@ -348,10 +348,10 @@
|
|||
|
||||
/* [4] Enregistrement du chemin et renvoi de SUCCESS
|
||||
=========================================================*/
|
||||
$this->path = array(
|
||||
$this->path = [
|
||||
'module' => $module,
|
||||
'method' => $method
|
||||
);
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -383,7 +383,7 @@
|
|||
|
||||
|
||||
/* (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();
|
||||
|
||||
// Si le token est invalide, on retourne une erreur -> FAUX
|
||||
|
@ -540,7 +540,7 @@
|
|||
*
|
||||
*/
|
||||
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){
|
||||
$this->data = array();
|
||||
$this->data = [];
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
|
@ -143,11 +143,10 @@
|
|||
// header('Content-Type: application/json');
|
||||
|
||||
// On rajoute l'erreur au message
|
||||
$returnData = array_merge(
|
||||
array(
|
||||
$returnData = array_merge([
|
||||
'ModuleError' => $this->error,
|
||||
'ErrorDescription' => ManagerError::explicit($this->error)
|
||||
),
|
||||
],
|
||||
$this->data
|
||||
);
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
}
|
||||
|
||||
// Type de @params (optionnel)
|
||||
$params = (is_array($params)) ? $params : array();
|
||||
$params = (is_array($params)) ? $params : [];
|
||||
|
||||
|
||||
/* [2] Verification du chemin (existence repo+methode)
|
||||
|
@ -170,10 +170,10 @@
|
|||
|
||||
/* [4] Enregistrement du chemin et renvoi de SUCCESS
|
||||
=========================================================*/
|
||||
$this->path = array(
|
||||
$this->path = [
|
||||
'repo' => $repository,
|
||||
'method' => $method
|
||||
);
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@
|
|||
*
|
||||
*/
|
||||
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
|
||||
======================================================*/
|
||||
// Si tout se deroule bien, on cree les flags
|
||||
$this->flags = array(
|
||||
$this->flags = [
|
||||
'extension' => $serialFlags[0],
|
||||
'filename' => $serialFlags[1],
|
||||
'parent' => $serialFlags[2]
|
||||
);
|
||||
];
|
||||
|
||||
// Ajout du sous-parent optionnel
|
||||
if( $opt_subParent )
|
||||
|
|
|
@ -84,9 +84,9 @@
|
|||
function authLevel(){ return !is_array($_SESSION['AUTH']) ? 0 : count($_SESSION['AUTH']); }
|
||||
|
||||
/* (1) Retourne si l'utilisateur est connecte ou non */
|
||||
function connected(){ return isset($_SESSION['PERM']) && count($_SESSION['PERM']) > 0; }
|
||||
function connected(){ return isset($_SESSION['PERM']) && count($_SESSION['PERM']) > 0; }
|
||||
|
||||
/* (2) Retourne si l'utilisateur a le status en question */
|
||||
function permission($type){ return connected() && in_array($type, $_SESSION['PERM']); }
|
||||
function permission($type){ return connected() && in_array($type, $_SESSION['PERM']); }
|
||||
|
||||
?>
|
||||
|
|
|
@ -23,46 +23,46 @@
|
|||
|
||||
/* [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();
|
||||
|
||||
// Si une erreur est retournee, on retourne une erreur
|
||||
if( $id_machine === false )
|
||||
return array('ModuleError' => ManagerError::ModuleError);
|
||||
return ['ModuleError' => ManagerError::ModuleError];
|
||||
|
||||
|
||||
|
||||
|
||||
/* [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();
|
||||
|
||||
// Si une erreur est retournee, on retourne une erreur
|
||||
if( $id_group === false )
|
||||
return array('ModuleError' => ManagerError::ModuleError);
|
||||
return ['ModuleError' => ManagerError::ModuleError];
|
||||
|
||||
|
||||
|
||||
|
||||
/* [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();
|
||||
|
||||
// Si une erreur est retournee, on retourne une erreur
|
||||
if( $id_assoc === false )
|
||||
return array('ModuleError' => ManagerError::ModuleError);
|
||||
return ['ModuleError' => ManagerError::ModuleError];
|
||||
|
||||
|
||||
|
||||
/* [4] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'id_machine' => $id_machine,
|
||||
'id_cluster' => $id_group
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,9 +82,9 @@
|
|||
extract($params);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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);
|
||||
|
||||
// On recupere les donnees
|
||||
$machine = new Repo('machine/search', array($keywords));
|
||||
$machine = new Repo('machine/search', [$keywords]);
|
||||
|
||||
return array(
|
||||
'machines' => $machine->answer()
|
||||
);
|
||||
return [ 'machines' => $machine->answer() ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,9 +144,7 @@
|
|||
// On recupere les donnees
|
||||
$machines = new Repo('machine/getAll');
|
||||
|
||||
return array(
|
||||
'machines' => $machines->answer()
|
||||
);
|
||||
return [ 'machines' => $machines->answer() ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,17 +162,15 @@
|
|||
extract($params);
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('machine/getById', array($id_machine));
|
||||
$request = new Repo('machine/getById', [$id_machine]);
|
||||
$answer = $request->answer();
|
||||
|
||||
// Si aucun resultat, on retourne une erreur
|
||||
if( $answer === false )
|
||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
||||
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||
|
||||
|
||||
return array(
|
||||
'machine' => $answer
|
||||
);
|
||||
return [ 'machine' => $answer ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,17 +188,15 @@
|
|||
extract($params);
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('machine/getByCode', array($code));
|
||||
$request = new Repo('machine/getByCode', [$code]);
|
||||
$answer = $request->answer();
|
||||
|
||||
// Si aucun resultat, on retourne une erreur
|
||||
if( $answer === false )
|
||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
||||
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||
|
||||
|
||||
return array(
|
||||
'machine' => $answer
|
||||
);
|
||||
return [ 'machine' => $answer ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -223,17 +215,15 @@
|
|||
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('machine/getByName', array($name));
|
||||
$request = new Repo('machine/getByName', [$name]);
|
||||
$answer = $request->answer();
|
||||
|
||||
// Si aucun resultat, on retourne une erreur
|
||||
if( $answer === false )
|
||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
||||
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||
|
||||
|
||||
return array(
|
||||
'machine' => $answer
|
||||
);
|
||||
return [ 'machine' => $answer ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -251,17 +241,15 @@
|
|||
extract($params);
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('machine/getClusters', array($id_machine));
|
||||
$request = new Repo('machine/getClusters', [$id_machine]);
|
||||
$answer = $request->answer();
|
||||
|
||||
// Si aucun resultat, on retourne une erreur
|
||||
if( $answer === false )
|
||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
||||
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||
|
||||
|
||||
return array(
|
||||
'clusters' => $answer
|
||||
);
|
||||
return [ 'clusters' => $answer ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -283,12 +271,12 @@
|
|||
|
||||
/* [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();
|
||||
|
||||
// Si on a recupere aucune machine, on retourne une erreur
|
||||
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)*/
|
||||
$correct_param = array(
|
||||
$correct_param = [
|
||||
'code' => !is_null($code) && $machine_data['code'] != $code,
|
||||
'name' => !is_null($name) && $machine_data['name'] != $name
|
||||
);
|
||||
];
|
||||
|
||||
/* (2) Gestion des parametres optionnels */
|
||||
$opt_data = array(
|
||||
$opt_data = [
|
||||
'code' => ($correct_param['code']) ? $code : $machine_data['code'],
|
||||
'name' => ($correct_param['name']) ? $name : $machine_data['name']
|
||||
);
|
||||
];
|
||||
|
||||
|
||||
/* [3] Modification de la machine
|
||||
=========================================================*/
|
||||
$request = new Repo('machine/edit', array(
|
||||
$request = new Repo('machine/edit', [
|
||||
$id_machine,
|
||||
$opt_data['code'],
|
||||
$opt_data['name']
|
||||
));
|
||||
]);
|
||||
|
||||
|
||||
return array(
|
||||
'status' => $request->answer()
|
||||
);
|
||||
return [ 'status' => $request->answer() ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -338,12 +324,10 @@
|
|||
extract($params);
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('machine/delete', array($id_machine));
|
||||
$request = new Repo('machine/delete', [$id_machine]);
|
||||
$answer = $request->answer();
|
||||
|
||||
return array(
|
||||
'status' => $answer
|
||||
);
|
||||
return [ 'status' => $answer ];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
*/
|
||||
public static function method(){
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'ReceivedArguments' => func_get_args()
|
||||
);
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
// Gestion de l'erreur de parsage
|
||||
if( $modules == null )
|
||||
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
||||
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||
|
||||
/* [2] Mise en forme de la liste des modules
|
||||
=========================================================*/
|
||||
|
@ -60,17 +60,17 @@
|
|||
|
||||
/* [n] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'headers' => array(
|
||||
'headers' => [
|
||||
'Content-Type' => 'text/markdown; charset=utf-8',
|
||||
'Content-Transfer-Encoding' => 'binary',
|
||||
'Content-Disposition' => 'attachment; filename=NxTIC.apib',
|
||||
'Pragma' => 'no-cache',
|
||||
'Expires' => '0'
|
||||
),
|
||||
],
|
||||
'body' => $markdown
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,7 +87,7 @@
|
|||
|
||||
// Gestion de l'erreur de parsage
|
||||
if( $modules == null )
|
||||
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
||||
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||
|
||||
|
||||
/* [1] Début du fichier custom
|
||||
|
@ -258,17 +258,17 @@
|
|||
}
|
||||
|
||||
|
||||
return array(
|
||||
return [
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'headers' => array(
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/octet-stream; charset=utf-8',
|
||||
'Content-Transfer-Encoding' => 'binary',
|
||||
'Content-Disposition' => 'attachment; filename=NxTIC.apib',
|
||||
'Pragma' => 'no-cache',
|
||||
'Expires' => '0'
|
||||
),
|
||||
],
|
||||
'body' => $content
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,46 +32,46 @@
|
|||
|
||||
/* [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();
|
||||
|
||||
var_dump($create_user);
|
||||
|
||||
// Si une erreur est retournee, on retourne une erreur
|
||||
if( $id_user === false )
|
||||
return array('ModuleError' => ManagerError::ModuleError);
|
||||
return ['ModuleError' => ManagerError::ModuleError];
|
||||
|
||||
|
||||
|
||||
/* [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();
|
||||
|
||||
// Si une erreur est retournee, on retourne une erreur
|
||||
if( $id_group === false )
|
||||
return array('ModuleError' => ManagerError::ModuleError);
|
||||
return ['ModuleError' => ManagerError::ModuleError];
|
||||
|
||||
|
||||
|
||||
|
||||
/* [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();
|
||||
|
||||
// Si une erreur est retournee, on retourne une erreur
|
||||
if( $id_assoc === false )
|
||||
return array('ModuleError' => ManagerError::ModuleError);
|
||||
return ['ModuleError' => ManagerError::ModuleError];
|
||||
|
||||
|
||||
|
||||
/* [5] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
return [
|
||||
'id_user' => $id_user,
|
||||
'id_cluster' => $id_group
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,9 +92,9 @@
|
|||
|
||||
/* [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
|
||||
=========================================================*/
|
||||
$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);
|
||||
|
||||
// On recupere les donnees
|
||||
$user = new Repo('user/search', array($keywords));
|
||||
$user = new Repo('user/search', [$keywords]);
|
||||
|
||||
return array(
|
||||
'users' => $user->answer()
|
||||
);
|
||||
return [ 'users' => $user->answer() ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,9 +155,7 @@
|
|||
// On recupere les donnees
|
||||
$users = new Repo('user/getAll');
|
||||
|
||||
return array(
|
||||
'users' => $users->answer()
|
||||
);
|
||||
return [ 'users' => $users->answer() ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -177,17 +173,15 @@
|
|||
extract($params);
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('user/getById', array($id_user));
|
||||
$request = new Repo('user/getById', [$id_user]);
|
||||
$answer = $request->answer();
|
||||
|
||||
// Si aucun resultat, on retourne une erreur
|
||||
if( $answer === false )
|
||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
||||
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||
|
||||
|
||||
return array(
|
||||
'user' => $answer
|
||||
);
|
||||
return [ 'user' => $answer ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -205,17 +199,15 @@
|
|||
extract($params);
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('user/getByCode', array($code));
|
||||
$request = new Repo('user/getByCode', [$code]);
|
||||
$answer = $request->answer();
|
||||
|
||||
// Si aucun resultat, on retourne une erreur
|
||||
if( $answer === false )
|
||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
||||
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||
|
||||
|
||||
return array(
|
||||
'user' => $answer
|
||||
);
|
||||
return [ 'user' => $answer ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -234,17 +226,15 @@
|
|||
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('user/getByUsername', array($username));
|
||||
$request = new Repo('user/getByUsername', [$username]);
|
||||
$answer = $request->answer();
|
||||
|
||||
// Si aucun resultat, on retourne une erreur
|
||||
if( $answer === false )
|
||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
||||
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||
|
||||
|
||||
return array(
|
||||
'user' => $answer
|
||||
);
|
||||
return [ 'user' => $answer ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -263,17 +253,15 @@
|
|||
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('user/getClusters', array($id_user));
|
||||
$request = new Repo('user/getClusters', [$id_user]);
|
||||
$answer = $request->answer();
|
||||
|
||||
// Si aucun resultat, on retourne une erreur
|
||||
if( $answer === false )
|
||||
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
||||
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||
|
||||
|
||||
return array(
|
||||
'clusters' => $answer
|
||||
);
|
||||
return [ 'clusters' => $answer ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,12 +287,12 @@
|
|||
|
||||
/* [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();
|
||||
|
||||
// Si on a recupere aucun utilisateur, on retourne une erreur
|
||||
if( !is_array($user_data) )
|
||||
return array('ModuleError' => ManagerError::NoMatchFound);
|
||||
return ['ModuleError' => ManagerError::NoMatchFound];
|
||||
|
||||
|
||||
|
||||
|
@ -313,7 +301,7 @@
|
|||
$password_hash = sessionManager::secure_sha1($password);
|
||||
|
||||
/* (1) Verification des parametres (si non nul + differents)*/
|
||||
$diff_param = array(
|
||||
$diff_param = [
|
||||
'code' => !is_null($code) && $user_data['code'] != $code,
|
||||
'username' => !is_null($username) && $user_data['username'] != $username,
|
||||
'firstname' => !is_null($firstname) && $user_data['firstname'] != $firstname,
|
||||
|
@ -321,10 +309,10 @@
|
|||
'mail' => !is_null($mail) && $user_data['mail'] != $mail,
|
||||
'password' => !is_null($password) && $user_data['password'] != $password_hash,
|
||||
'status' => !is_null($status) && $user_data['status'] != $status
|
||||
);
|
||||
];
|
||||
|
||||
/* (2) Gestion des parametres optionnels */
|
||||
$opt_data = array(
|
||||
$opt_data = [
|
||||
'code' => ($diff_param['code']) ? $code : $user_data['code'],
|
||||
'username' => ($diff_param['username']) ? $username : $user_data['username'],
|
||||
'firstname' => ($diff_param['firstname']) ? $firstname : $user_data['firstname'],
|
||||
|
@ -332,14 +320,14 @@
|
|||
'mail' => ($diff_param['mail']) ? $mail : $user_data['mail'],
|
||||
'password' => ($diff_param['password']) ? $password : $user_data['password'],
|
||||
'status' => ($diff_param['status']) ? $status : $user_data['status'],
|
||||
);
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
/* [3] Modification de l'utilisateur
|
||||
=========================================================*/
|
||||
$request = new Repo('user/edit', array(
|
||||
$request = new Repo('user/edit', [
|
||||
$id_user,
|
||||
$opt_data['code'],
|
||||
$opt_data['username'],
|
||||
|
@ -348,12 +336,10 @@
|
|||
$opt_data['mail'],
|
||||
$opt_data['password'],
|
||||
$opt_data['status'])
|
||||
);
|
||||
];
|
||||
|
||||
|
||||
return array(
|
||||
'status' => $request->answer()
|
||||
);
|
||||
return [ 'status' => $request->answer() ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -372,12 +358,10 @@
|
|||
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('user/delete', array($id_user));
|
||||
$request = new Repo('user/delete', [$id_user]);
|
||||
$answer = $request->answer();
|
||||
|
||||
return array(
|
||||
'status' => $answer
|
||||
);
|
||||
return [ '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)
|
||||
VALUES(DEFAULT, :name)");
|
||||
$insert_user->execute(array(
|
||||
':name' => $name
|
||||
));
|
||||
$insert_user->execute([ ':name' => $name ]);
|
||||
|
||||
/* [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)
|
||||
VALUES(DEFAULT, :id_cluster, :id_entity, :class)");
|
||||
$link_entity->execute(array(
|
||||
$link_entity->execute([
|
||||
':id_cluster' => $id_cluster,
|
||||
':id_entity' => $id_entity,
|
||||
':class' => $class
|
||||
));
|
||||
]);
|
||||
|
||||
/* [5] On retourne l'id_cluster_merge ou FALSE si erreur
|
||||
=========================================================*/
|
||||
|
@ -154,11 +152,11 @@
|
|||
WHERE id_cluster = :id_cluster
|
||||
AND id_entity = :id_entity
|
||||
AND class = :class");
|
||||
$delete_cluster_merge->execute(array(
|
||||
$delete_cluster_merge->execute([
|
||||
':id_cluster' => $id_cluster,
|
||||
':id_entity' => $id_entity,
|
||||
':class' => $class
|
||||
));
|
||||
]);
|
||||
|
||||
|
||||
/* [2] On verifie que l'association n'existe plus
|
||||
|
@ -190,11 +188,11 @@
|
|||
AND class = :class");
|
||||
|
||||
// On execute la requete
|
||||
$request->execute(array(
|
||||
$request->execute([
|
||||
':id_cluster' => $id_cluster,
|
||||
':id_entity' => $id_entity,
|
||||
':class' => $class
|
||||
));
|
||||
]);
|
||||
|
||||
// On recupere 1 seule relation
|
||||
$answer = $request->fetch();
|
||||
|
@ -227,9 +225,7 @@
|
|||
$get_members = Database::getPDO()->prepare("SELECT * FROM cluster_merge
|
||||
WHERE id_cluster = :id_cluster
|
||||
ORDER BY id_cluster_merge");
|
||||
$get_members->execute(array(
|
||||
':id_cluster' => $id_cluster
|
||||
));
|
||||
$get_members->execute([ ':id_cluster' => $id_cluster ]);
|
||||
|
||||
$members = Database::delNumeric( $get_members->fetchAll() );
|
||||
|
||||
|
@ -280,9 +276,7 @@
|
|||
/* [1] On redige/execute la requete
|
||||
=========================================================*/
|
||||
$delete_group = Database::getPDO()->prepare("DELETE FROM cluster WHERE id_cluster = :id_cluster");
|
||||
$delete_group->execute(array(
|
||||
':id_cluster' => $id_cluster
|
||||
));
|
||||
$delete_group->execute([ ':id_cluster' => $id_cluster ]);
|
||||
|
||||
|
||||
/* [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)
|
||||
VALUES(DEFAULT, :code, :name)");
|
||||
$insert_machine->execute(array(
|
||||
$insert_machine->execute([
|
||||
':code' => $code,
|
||||
':name' => $name
|
||||
));
|
||||
]);
|
||||
|
||||
/* [3] On retourne l'id_machine ou FALSE si erreur
|
||||
=========================================================*/
|
||||
|
@ -91,10 +91,10 @@
|
|||
AND cm.id_entity = :id_machine
|
||||
AND cm.class = :class
|
||||
ORDER BY c.id_cluster");
|
||||
$get_clusters->execute(array(
|
||||
$get_clusters->execute([
|
||||
':id_machine' => $id_machine,
|
||||
':class' => clusterRepo::MACHINE_CLASS
|
||||
));
|
||||
]);
|
||||
|
||||
/* [2] On retourne la liste des groupes
|
||||
=========================================================*/
|
||||
|
@ -137,11 +137,11 @@
|
|||
SET code = :code,
|
||||
name = :name
|
||||
WHERE id_machine = :id_machine");
|
||||
$edit_machine->execute(array(
|
||||
$edit_machine->execute([
|
||||
':code' => $code,
|
||||
':name' => $name,
|
||||
':id_machine' => $id_machine
|
||||
));
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
@ -175,9 +175,7 @@
|
|||
/* [1] On redige/execute la requete
|
||||
=========================================================*/
|
||||
$delete_machine = Database::getPDO()->prepare("DELETE FROM machine WHERE id_machine = :id_machine");
|
||||
$delete_machine->execute(array(
|
||||
':id_machine' => $id_machine
|
||||
));
|
||||
$delete_machine->execute([ ':id_machine' => $id_machine ]);
|
||||
|
||||
|
||||
/* [2] On verifie que la machine n'existe plus
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
$getColumns = Database::getPDO()->query('SHOW COLUMNS FROM '.static::table_name());
|
||||
$cols = Database::delNumeric( $getColumns->fetchAll() );
|
||||
|
||||
$table_columns = array(
|
||||
'_PRIMARY_' => array() // Contiendra les champs de la clé primaire
|
||||
);
|
||||
$table_columns = [
|
||||
'_PRIMARY_' => [] // Contiendra les champs de la clé primaire
|
||||
];
|
||||
|
||||
// On ajoute la liste des colonnes
|
||||
foreach($cols as $column){
|
||||
|
@ -92,7 +92,7 @@
|
|||
// Si 'getById', on compose la clé primaire
|
||||
if( $getById ){
|
||||
|
||||
$pdo_vars = array();
|
||||
$pdo_vars = [];
|
||||
|
||||
foreach($table_columns['_PRIMARY_'] as $i=>$primary_column)
|
||||
$pdo_vars[':primary'.$i] = $args[$i];
|
||||
|
@ -101,9 +101,9 @@
|
|||
|
||||
// Si 'getSomething', on ajoute le champ
|
||||
}else
|
||||
$getRequest->execute(array(
|
||||
$getRequest->execute([
|
||||
':value' => ($getSomething||$getById) ? $args[0] : null
|
||||
));
|
||||
]);
|
||||
|
||||
/* [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)
|
||||
VALUES(DEFAULT, :code, :username, :firstname, :lastname, :mail, :password, :status)");
|
||||
$insert_user->execute(array(
|
||||
$insert_user->execute([
|
||||
':code' => $code,
|
||||
':username' => $username,
|
||||
':firstname' => $firstname,
|
||||
|
@ -44,7 +44,7 @@
|
|||
':mail' => $mail,
|
||||
':password' => $password,
|
||||
':status' => $status
|
||||
));
|
||||
]);
|
||||
|
||||
/* [3] On retourne l'id_user ou FALSE si erreur
|
||||
=========================================================*/
|
||||
|
@ -105,10 +105,10 @@
|
|||
AND cm.id_entity = :id_user
|
||||
AND cm.class = :class
|
||||
ORDER BY c.id_cluster");
|
||||
$get_clusters->execute(array(
|
||||
$get_clusters->execute([
|
||||
':id_user' => $id_user,
|
||||
':class' => clusterRepo::USER_CLASS
|
||||
));
|
||||
]);
|
||||
|
||||
/* [2] On retourne la liste des groupes
|
||||
=========================================================*/
|
||||
|
@ -162,7 +162,7 @@
|
|||
password = :password,
|
||||
status = :status
|
||||
WHERE id_user = :id_user");
|
||||
$edit_user->execute(array(
|
||||
$edit_user->execute([
|
||||
':code' => $code,
|
||||
':username' => $username,
|
||||
':firstname' => $firstname,
|
||||
|
@ -171,7 +171,7 @@
|
|||
':password' => $password,
|
||||
':status' => $status,
|
||||
':id_user' => $id_user
|
||||
));
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
@ -210,9 +210,7 @@
|
|||
/* [1] On redige/execute la requete
|
||||
=========================================================*/
|
||||
$delete_user = Database::getPDO()->prepare("DELETE FROM user WHERE id_user = :id_user");
|
||||
$delete_user->execute(array(
|
||||
':id_user' => $id_user
|
||||
));
|
||||
$delete_user->execute([ ':id_user' => $id_user ]);
|
||||
|
||||
|
||||
/* [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; }
|
||||
|
||||
/* CREATION D'UN UTILISATEUR ET DE SON GROUPE INDIVIDUEL
|
||||
/* CREATION D'UN ENTREPOT
|
||||
*
|
||||
* @name<String> Identifiant 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)
|
||||
VALUES(DEFAULT, :name, :password, :token)");
|
||||
$insert_warehouse->execute(array(
|
||||
$insert_warehouse->execute([
|
||||
':name' => $name,
|
||||
':password' => sessionManager::secure_sha1( $password ),
|
||||
':token' => sessionManager::secure_sha1( uniqid() )
|
||||
));
|
||||
]);
|
||||
|
||||
/* [3] On retourne l'id_warehouse ou FALSE si erreur
|
||||
=========================================================*/
|
||||
|
@ -78,13 +78,13 @@
|
|||
|
||||
/* (2) On applique le nouveau token */
|
||||
$update_token = Database::getPDO()->prepare("UPDATE warehouse
|
||||
SET token = :token
|
||||
SET token = :token
|
||||
WHERE id_warehouse = :id_warehouse");
|
||||
|
||||
$update_token->execute(array(
|
||||
$update_token->execute([
|
||||
':token' => $new_token,
|
||||
':id_warehouse' => $id_warehouse
|
||||
));
|
||||
]);
|
||||
|
||||
|
||||
/* [3] On renvoie le token
|
||||
|
@ -114,25 +114,25 @@
|
|||
=========================================================*/
|
||||
// On recupere les entrepots ayant le meme nom (si existent)
|
||||
// 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);
|
||||
|
||||
// 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 )
|
||||
return false;
|
||||
|
||||
/* [2] Modification de l'utilisateur
|
||||
=========================================================*/
|
||||
$edit_warehouse = Database::getPDO()->prepare("UPDATE warehouse
|
||||
SET name = :name,
|
||||
password = :password
|
||||
SET name = :name,
|
||||
password = :password
|
||||
WHERE id_warehouse = :id_warehouse");
|
||||
$edit_warehouse->execute(array(
|
||||
$edit_warehouse->execute([
|
||||
':name' => $name,
|
||||
':password' => $password,
|
||||
':id_warehouse' => $id_warehouse
|
||||
));
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
@ -166,9 +166,9 @@
|
|||
/* [1] On redige/execute la requete
|
||||
=========================================================*/
|
||||
$delete_warehouse = Database::getPDO()->prepare("DELETE FROM warehouse WHERE id_warehouse = :id_warehouse");
|
||||
$delete_warehouse->execute(array(
|
||||
$delete_warehouse->execute([
|
||||
':id_warehouse' => $id_warehouse
|
||||
));
|
||||
]);
|
||||
|
||||
|
||||
/* [2] On verifie que l'utilisateur n'existe plus
|
||||
|
|
|
@ -5,23 +5,23 @@
|
|||
/* [0] Verification du type
|
||||
=========================================================*/
|
||||
public function testTypeInt(){
|
||||
$this->assertEquals( array(), \manager\Database::delNumeric(10) );
|
||||
$this->assertEquals( [], \manager\Database::delNumeric(10) );
|
||||
}
|
||||
|
||||
public function testTypeString(){
|
||||
$this->assertEquals( array(), \manager\Database::delNumeric('notarray') );
|
||||
$this->assertEquals( [], \manager\Database::delNumeric('notarray') );
|
||||
}
|
||||
|
||||
/* [1] Verification pour 2 dimensions
|
||||
=========================================================*/
|
||||
/* (1) Global */
|
||||
public function testGlobal2Dim(){
|
||||
$fetchData = array(array(
|
||||
$fetchData = [[
|
||||
'id' => '000001',
|
||||
0 => '000001',
|
||||
'nom' => 'Jean Dupont',
|
||||
1 => 'Jean Dupont',
|
||||
));
|
||||
]];
|
||||
|
||||
$computed_array = \manager\Database::delNumeric( $fetchData );
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
|||
|
||||
/* (2) Verification d'indices numeriques dans les donnees */
|
||||
public function testGlobal2DimWithNumericIndexes(){
|
||||
$fetchData = array(array(
|
||||
$fetchData = [[
|
||||
'id' => '000001',
|
||||
0 => '000001',
|
||||
'nom' => 'Jean Dupont',
|
||||
|
@ -44,7 +44,7 @@
|
|||
5 => 'Bla',
|
||||
6 => 'Bla',
|
||||
7 => 'Bla'
|
||||
));
|
||||
]];
|
||||
|
||||
$computed_array = \manager\Database::delNumeric( $fetchData );
|
||||
|
||||
|
@ -66,12 +66,12 @@
|
|||
=========================================================*/
|
||||
/* (1) Global */
|
||||
public function testGlobal1Dim(){
|
||||
$fetchData = array(
|
||||
$fetchData = [
|
||||
'id' => '000001',
|
||||
0 => '000001',
|
||||
'nom' => 'Jean Dupont',
|
||||
1 => 'Jean Dupont'
|
||||
);
|
||||
];
|
||||
|
||||
$computed_array = \manager\Database::delNumeric( $fetchData );
|
||||
|
||||
|
@ -83,7 +83,7 @@
|
|||
|
||||
/* (2) Verification d'indices numeriques dans les donnees */
|
||||
public function testGlobal1DimWithNumericIndexes(){
|
||||
$fetchData = array(
|
||||
$fetchData = [
|
||||
'id' => '000001',
|
||||
0 => '000001',
|
||||
'nom' => 'Jean Dupont',
|
||||
|
@ -94,7 +94,7 @@
|
|||
5 => 'Bla',
|
||||
6 => 'Bla',
|
||||
7 => 'Bla'
|
||||
);
|
||||
];
|
||||
|
||||
$computed_array = \manager\Database::delNumeric( $fetchData );
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class Route{
|
|||
// ATTRIBUTS
|
||||
private $pattern;
|
||||
private $callback;
|
||||
private $matches = array();
|
||||
private $matches = [];
|
||||
|
||||
/* Initialise la route
|
||||
*
|
||||
|
|
|
@ -21,10 +21,10 @@ class Router{
|
|||
$this->url = $url;
|
||||
|
||||
// On initialise les routes
|
||||
$this->routes = array(
|
||||
'GET' => array(),
|
||||
'POST' => array()
|
||||
);
|
||||
$this->routes = [
|
||||
'GET' => [],
|
||||
'POST' => []
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
foreach( $json as $user ){
|
||||
|
||||
// Creation de la requete
|
||||
$request = new ModuleRequest('userDefault/create', array(
|
||||
$request = new ModuleRequest('userDefault/create', [
|
||||
$user['code'],
|
||||
$user['username'],
|
||||
$user['firstname'],
|
||||
|
@ -35,7 +35,7 @@
|
|||
$user['email'],
|
||||
$user['password'],
|
||||
$user['status']
|
||||
));
|
||||
]);
|
||||
$answer = $request->dispatch();
|
||||
// Debug error
|
||||
var_dump( $answer->error == ManagerError::Success );
|
||||
|
@ -62,10 +62,10 @@
|
|||
foreach( $json as $machine ){
|
||||
|
||||
// Creation de la requete
|
||||
$request = new ModuleRequest('machineDefault/create', array(
|
||||
$request = new ModuleRequest('machineDefault/create', [
|
||||
$machine['code'],
|
||||
$machine['name']
|
||||
));
|
||||
]);
|
||||
$answer = $request->dispatch();
|
||||
// Debug error
|
||||
var_dump( $answer->error == ManagerError::Success );
|
||||
|
@ -173,7 +173,7 @@
|
|||
function testModuleDispatcher(){
|
||||
|
||||
// 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>
|
||||
$req2 = ModuleRequest::fromString('{"path": "firstModule/returnvar", "data": {"id_user":10, "code":"11-22-33-44"}}');
|
||||
|
||||
|
@ -195,7 +195,7 @@
|
|||
function testRepoDispatcher(){
|
||||
|
||||
// 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'));
|
||||
var_dump( $req1->answer() );
|
||||
|
||||
|
@ -221,7 +221,7 @@
|
|||
function insertUsersComposite(){
|
||||
|
||||
// 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();
|
||||
// Debug error
|
||||
if( $answer->error != ManagerError::Success )
|
||||
|
@ -248,7 +248,7 @@
|
|||
$id_user = 115;
|
||||
|
||||
// Groupes de l'utilisateur 'a'
|
||||
$getUser1Clusters = new Repo('user/getClusters', array($id_user));
|
||||
$getUser1Clusters = new Repo('user/getClusters', [$id_user]);
|
||||
$user1Clusters = $getUser1Clusters->answer();
|
||||
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
|
||||
|
||||
$post = array();
|
||||
$post = [];
|
||||
foreach($_POST as $k=>$v)
|
||||
array_push($post, $k);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
<?php
|
||||
|
||||
$post = array();
|
||||
$post = [];
|
||||
foreach($_POST as $k=>$v)
|
||||
array_push($post, $k);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
<?php
|
||||
|
||||
$post = array();
|
||||
$post = [];
|
||||
foreach($_POST as $k=>$v)
|
||||
array_push($post, $k);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
<?php
|
||||
|
||||
$post = array();
|
||||
$post = [];
|
||||
foreach($_POST as $k=>$v)
|
||||
array_push($post, $k);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<?php
|
||||
|
||||
$post = array();
|
||||
$post = [];
|
||||
foreach($_POST as $k=>$v)
|
||||
array_push($post, $k);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
<?php
|
||||
|
||||
$post = array();
|
||||
$post = [];
|
||||
foreach($_POST as $k=>$v)
|
||||
array_push($post, $k);
|
||||
|
||||
|
@ -72,7 +72,7 @@
|
|||
|
||||
// Liste des utilisateurs
|
||||
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();
|
||||
|
||||
echo "<article class='inline-box' id='".$user['id_user']."'>";
|
||||
|
|
Loading…
Reference in New Issue