Gestion complète config du module
This commit is contained in:
parent
d0e89d349d
commit
dd6290bf48
|
@ -19,143 +19,8 @@
|
|||
"edit",
|
||||
|
||||
"delete"
|
||||
]
|
||||
],
|
||||
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
|
||||
"userDefault": {
|
||||
"create": {
|
||||
"description": "blablabla",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
"code": { "description": "Code RFID de l'utilisateur.", "type": "rfid" },
|
||||
"username": { "description": "Identifiant de l'utilisateur.", "type": "varchar(1,30)" },
|
||||
"firstname": { "description": "Prénom de l'utilisateur.", "type": "varchar(3,30)" },
|
||||
"lastname": { "description": "Nom de l'utilisateur.", "type": "varchar(3,30)" },
|
||||
"mail": { "description": "Adresse mail de l'utilisateur.", "type": "mail" },
|
||||
"password": { "description": "Mot de passe de l'utilisateur.", "type": "text" },
|
||||
"status": { "description": "Status de l'utilisateur.", "type": "status" }
|
||||
},
|
||||
"output": {
|
||||
"id_user": { "description": "UID de l'utilisateur créé.", "type": "id" },
|
||||
"id_group": { "description": "UID du groupe de l'utilisateur.", "type": "id" }
|
||||
}
|
||||
},
|
||||
|
||||
"link": {
|
||||
"description": "blablabla",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
|
||||
},
|
||||
"output": {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
"unlink": {
|
||||
"description": "blablabla",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
|
||||
},
|
||||
"output": {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
"search": {
|
||||
"description": "blablabla",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
|
||||
},
|
||||
"output": {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
"getAll": {
|
||||
"description": "blablabla",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
|
||||
},
|
||||
"output": {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
"getById": {
|
||||
"description": "blablabla",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
|
||||
},
|
||||
"output": {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
"getByCode": {
|
||||
"description": "blablabla",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
|
||||
},
|
||||
"output": {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
"getByUsername": {
|
||||
"description": "blablabla",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
|
||||
},
|
||||
"output": {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
"getClusters": {
|
||||
"description": "blablabla",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
|
||||
},
|
||||
"output": {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
"edit": {
|
||||
"description": "blablabla",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
|
||||
},
|
||||
"output": {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
"delete": {
|
||||
"description": "blablabla",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
|
||||
},
|
||||
"output": {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"module": {
|
||||
"method": {
|
||||
|
@ -242,5 +107,155 @@
|
|||
"all": { "description": "Si vaut TRUE, renvoie tous les sujets enregistrés.", "type": "boolean", "optional": true }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"userDefault": {
|
||||
|
||||
"create": {
|
||||
"description": "Création d'un nouvel utilisateur.",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
"code": { "description": "Code RFID de l'utilisateur.", "type": "rfid" },
|
||||
"username": { "description": "Identifiant de l'utilisateur.", "type": "varchar(1,30,alphanumeric)" },
|
||||
"firstname": { "description": "Prénom de l'utilisateur.", "type": "varchar(3,30,letters)" },
|
||||
"lastname": { "description": "Nom de l'utilisateur.", "type": "varchar(3,30,letters)" },
|
||||
"mail": { "description": "Adresse mail de l'utilisateur.", "type": "mail" },
|
||||
"password": { "description": "Mot de passe de l'utilisateur.", "type": "text" },
|
||||
"status": { "description": "Status de l'utilisateur.", "type": "status" }
|
||||
},
|
||||
"output": {
|
||||
"id_user": { "description": "UID de l'utilisateur créé.", "type": "id" },
|
||||
"id_group": { "description": "UID du groupe de l'utilisateur.", "type": "id" }
|
||||
}
|
||||
},
|
||||
|
||||
"link": {
|
||||
"description": "Ajout d'un utilisateur à un groupe.",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
"id_cluster": { "description": "UID du groupe auquel rattacher.", "type": "id" },
|
||||
"id_user": { "description": "UID de l'utilisateur à rattacher.", "type": "id" }
|
||||
},
|
||||
"output": {}
|
||||
},
|
||||
|
||||
|
||||
"unlink": {
|
||||
"description": "Retrait d'un utilisateur d'un groupe",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
"id_cluster": { "description": "UID du groupe auquel détacher.", "type": "id" },
|
||||
"id_user": { "description": "UID de l'utilisateur à détacher.", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
"search": {
|
||||
"description": "Recherche d'un utilisateur par mots-clés.",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
"keywords": { "description": "Mots-clés de la recherche.", "type": "text" }
|
||||
},
|
||||
"output": {
|
||||
"users": { "description": "Liste des utilisateurs correspondants aux mots-clés.", "type": "array<mixed>" }
|
||||
}
|
||||
},
|
||||
|
||||
"getAll": {
|
||||
"description": "Liste de tous les utilisateurs",
|
||||
"permissions": [],
|
||||
"parameters": {},
|
||||
"output": {
|
||||
"users": { "description": "Liste de tous les utilisateurs.", "type": "array<array<mixed>>" }
|
||||
}
|
||||
},
|
||||
|
||||
"getById": {
|
||||
"description": "Retourne un utilisateur spécifique.",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
"id_user": { "description": "UID de l'utilisateur.", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
"user": { "description": "Données de l'utilisateur.", "type": "array<mixed>" }
|
||||
}
|
||||
},
|
||||
|
||||
"getByCode": {
|
||||
"description": "Retourne un utilisateur de Code RFID donné.",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
"code": { "description": "Code RFID de l'utilisateur.", "type": "rfid" }
|
||||
},
|
||||
"output": {
|
||||
"user": { "description": "Données de l'utilisateur.", "type": "array<mixed>" }
|
||||
}
|
||||
},
|
||||
|
||||
"getByUsername": {
|
||||
"description": "Retourne un utilisateur d'identifiant donné.",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
"username": { "description": "Identifiant de l'utilisateur.", "type": "varchar(1,30,alphanumeric)" }
|
||||
},
|
||||
"output": {
|
||||
"user": { "description": "Données de l'utilisateur.", "type": "array<mixed>" }
|
||||
}
|
||||
},
|
||||
|
||||
"getClusters": {
|
||||
"description": "Retourne les groupes d'un utilisateur.",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
"id_user": { "description": "UID de l'utilisateur.", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
"clusters": { "description": "Liste des groupes de l'utilisateur.", "type": "array<array<mixed>>" }
|
||||
}
|
||||
},
|
||||
|
||||
"edit": {
|
||||
"description": "Modifie les attributs d'un utilisateur.",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
"id_user": { "description": "UID de l'utilisateur.", "type": "id" },
|
||||
"code": { "description": "Code RFID de l'utilisateur.", "type": "rfid", "optional": true },
|
||||
"username": { "description": "Identifiant de l'utilisateur.", "type": "varchar(1,30,alphanumeric)", "optional": true },
|
||||
"firstname": { "description": "Prénom de l'utilisateur.", "type": "varchar(3,30,letters)", "optional": true },
|
||||
"lastname": { "description": "Nom de l'utilisateur.", "type": "varchar(3,30,letters)", "optional": true },
|
||||
"mail": { "description": "Adresse mail de l'utilisateur.", "type": "mail", "optional": true },
|
||||
"password": { "description": "Mot de passe de l'utilisateur.", "type": "text", "optional": true },
|
||||
"status": { "description": "Status de l'utilisateur.", "type": "status", "optional": true }
|
||||
|
||||
},
|
||||
"output": {
|
||||
"status": { "description": "Status de la modification.", "type": "boolean" }
|
||||
}
|
||||
},
|
||||
|
||||
"delete": {
|
||||
"description": "Suppression d'un utilisateur.",
|
||||
"permissions": [],
|
||||
"parameters": {
|
||||
"id_user": { "description": "UID de l'utilisateur.", "type": "id" }
|
||||
},
|
||||
"output": {
|
||||
"status": { "description": "Status de la suppression.", "type": "boolean" }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
use \manager\ModuleResponse;
|
||||
use \manager\ManagerError;
|
||||
|
||||
|
||||
/*******************************************/
|
||||
/* DEBUGGER */
|
||||
/*******************************************/
|
||||
|
|
|
@ -23,26 +23,13 @@
|
|||
* @return status<Boolean> Retourne si oui ou non, tout s'est bien passe
|
||||
*
|
||||
*/
|
||||
public static function create($code=null, $username=null, $firstname=null, $lastname=null, $mail=null, $password=null, $status=null){
|
||||
public static function create($params){
|
||||
extract($params);
|
||||
|
||||
/* [1] Normalisation + verification des donnees
|
||||
=========================================================*/
|
||||
$password_hash = sessionManager::secure_sha1($password);
|
||||
|
||||
$correct_param = Database::check('user.code', $code);
|
||||
$correct_param = $correct_param && Database::check('user.username', $username);
|
||||
$correct_param = $correct_param && Database::check('user.firstname', $firstname);
|
||||
$correct_param = $correct_param && Database::check('user.lastname', $lastname);
|
||||
$correct_param = $correct_param && Database::check('user.mail', $mail);
|
||||
$correct_param = $correct_param && Database::check('user.password', $password_hash);
|
||||
$correct_param = $correct_param && Database::check('user.status', $status);
|
||||
|
||||
// Si les parametres ne sont pas corrects, on retourne une erreur
|
||||
if( !$correct_param )
|
||||
return array('ModuleError' => ManagerError::ParamError);
|
||||
|
||||
|
||||
|
||||
|
||||
/* [2] Creation de l'utilisateur
|
||||
=========================================================*/
|
||||
$create_user = new Repo('user/create', array($code, $username, $firstname, $lastname, $mail, $password_hash, $status) );
|
||||
|
@ -81,7 +68,6 @@
|
|||
/* [5] Gestion du retour
|
||||
=========================================================*/
|
||||
return array(
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'id_user' => $id_user,
|
||||
'id_cluster' => $id_group
|
||||
);
|
||||
|
@ -100,21 +86,14 @@
|
|||
* Renvoie FALSE si une erreur occure
|
||||
*
|
||||
*/
|
||||
public static function link($id_cluster, $id_user){
|
||||
/* [1] Normalisation + verification des donnees
|
||||
=========================================================*/
|
||||
$correct_param = Database::check('auto_increment_id', $id_cluster);
|
||||
$correct_param = $correct_param && Database::check('auto_increment_id', $id_user);
|
||||
public static function link($params){
|
||||
extract($parmas);
|
||||
|
||||
// Si les parametres ne sont pas corrects, on retourne une erreur
|
||||
if( !$correct_param )
|
||||
return array('ModuleError' => ManagerError::ParamError);
|
||||
|
||||
/* [2] Creation de l'association
|
||||
/* [1] Creation de l'association
|
||||
=========================================================*/
|
||||
$link_user = new Repo('cluster/link', array($id_cluster, $id_user, clusterRepo::USER_CLASS));
|
||||
|
||||
return $link_user;
|
||||
return array();
|
||||
|
||||
}
|
||||
|
||||
|
@ -131,21 +110,14 @@
|
|||
* Renvoie FALSE si une erreur occure
|
||||
*
|
||||
*/
|
||||
public static function unlink($id_cluster, $id_user){
|
||||
/* [1] Normalisation + verification des donnees
|
||||
=========================================================*/
|
||||
$correct_param = Database::check('auto_increment_id', $id_cluster);
|
||||
$correct_param = $correct_param && Database::check('auto_increment_id', $id_user);
|
||||
public static function unlink($params){
|
||||
extract($params);
|
||||
|
||||
// Si les parametres ne sont pas corrects, on retourne une erreur
|
||||
if( !$correct_param )
|
||||
return array('ModuleError' => ManagerError::ParamError);
|
||||
|
||||
/* [2] Suppression de l'association
|
||||
/* [1] Suppression de l'association
|
||||
=========================================================*/
|
||||
$link_user = new Repo('cluster/unlink', array($id_cluster, $id_user, clusterRepo::USER_CLASS));
|
||||
|
||||
return $link_user;
|
||||
return array();
|
||||
|
||||
}
|
||||
|
||||
|
@ -160,7 +132,9 @@
|
|||
* @return users<Array> Retourne la liste des utilisateurs trouves
|
||||
*
|
||||
*/
|
||||
public static function search($keyword){
|
||||
public static function search($params){
|
||||
extract($params);
|
||||
|
||||
// On recupere les donnees
|
||||
$user = new Repo('user/search', array($keyword));
|
||||
|
||||
|
@ -198,7 +172,9 @@
|
|||
* @return utilisateur<Array> Utilisateur d'UID donne
|
||||
*
|
||||
*/
|
||||
public static function getById($id_user){
|
||||
public static function getById($params){
|
||||
extract($params);
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('user/getById', array($id_user));
|
||||
$answer = $request->answer();
|
||||
|
@ -224,7 +200,9 @@
|
|||
* @return utilisateur<Array> Utilisateur de code donne
|
||||
*
|
||||
*/
|
||||
public static function getByCode($code){
|
||||
public static function getByCode($params){
|
||||
extract($params);
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('user/getByCode', array($code));
|
||||
$answer = $request->answer();
|
||||
|
@ -250,7 +228,10 @@
|
|||
* @return utilisateur<Array> Utilisateur d'username donne
|
||||
*
|
||||
*/
|
||||
public static function getByUsername($username){
|
||||
public static function getByUsername($params){
|
||||
extract($params);
|
||||
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('user/getByUsername', array($username));
|
||||
$answer = $request->answer();
|
||||
|
@ -276,7 +257,10 @@
|
|||
* @return clusters<Array> Groupes de l'utilisateur donne
|
||||
*
|
||||
*/
|
||||
public static function getClusters($id_user){
|
||||
public static function getClusters($params){
|
||||
extract($params);
|
||||
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('user/getClusters', array($id_user));
|
||||
$answer = $request->answer();
|
||||
|
@ -309,10 +293,8 @@
|
|||
* @return status<Boolean> Retourne si oui ou non tout s'est bien deroule
|
||||
*
|
||||
*/
|
||||
public static function edit($id_user=null, $code=null, $username=null, $firstname=null, $lastname=null, $mail=null, $password=null, $status=null){
|
||||
// Si @id_user n'est pas au bon format, on retourne une erreur
|
||||
if( !Database::check('auto_increment_id', $id_user) )
|
||||
return array('ModuleError' => ManagerError::ModuleError);
|
||||
public static function edit($params){
|
||||
extract($params);
|
||||
|
||||
|
||||
/* [1] On verifie l'existence de l'utilisateur
|
||||
|
@ -330,26 +312,26 @@
|
|||
=========================================================*/
|
||||
$password_hash = sessionManager::secure_sha1($password);
|
||||
|
||||
/* (1) Verification des parametres (si correct et different)*/
|
||||
$correct_param = array(
|
||||
'code' => Database::check('user.code', $code ) && $user_data['code'] != $code,
|
||||
'username' => Database::check('user.username', $username ) && $user_data['username'] != $username,
|
||||
'firstname' => Database::check('user.firstname', $firstname ) && $user_data['firstname'] != $firstname,
|
||||
'lastname' => Database::check('user.lastname', $lastname ) && $user_data['lastname'] != $lastname,
|
||||
'mail' => Database::check('user.mail', $mail ) && $user_data['mail'] != $mail,
|
||||
'password' => Database::check('user.password', $password_hash ) && $user_data['password'] != $password_hash,
|
||||
'status' => Database::check('user.status', $status ) && $user_data['status'] != $status
|
||||
/* (1) Verification des parametres (si non nul + differents)*/
|
||||
$diff_param = array(
|
||||
'code' => !is_null($user_data['code']) && $user_data['code'] != $code,
|
||||
'username' => !is_null($user_data['username']) && $user_data['username'] != $username,
|
||||
'firstname' => !is_null($user_data['firstname']) && $user_data['firstname'] != $firstname,
|
||||
'lastname' => !is_null($user_data['lastname']) && $user_data['lastname'] != $lastname,
|
||||
'mail' => !is_null($user_data['mail']) && $user_data['mail'] != $mail,
|
||||
'password' => !is_null($user_data['password']) && $user_data['password'] != $password_hash,
|
||||
'status' => !is_null($user_data['status']) && $user_data['status'] != $status
|
||||
);
|
||||
|
||||
/* (2) Gestion des parametres optionnels */
|
||||
$opt_data = array(
|
||||
'code' => ($correct_param['code']) ? $code : $user_data['code'],
|
||||
'username' => ($correct_param['username']) ? $username : $user_data['username'],
|
||||
'firstname' => ($correct_param['firstname']) ? $firstname : $user_data['firstname'],
|
||||
'lastname' => ($correct_param['lastname']) ? $lastname : $user_data['lastname'],
|
||||
'mail' => ($correct_param['mail']) ? $mail : $user_data['mail'],
|
||||
'password' => ($correct_param['password']) ? $password : $user_data['password'],
|
||||
'status' => ($correct_param['status']) ? $status : $user_data['status'],
|
||||
'code' => ($diff_param['code']) ? $code : $user_data['code'],
|
||||
'username' => ($diff_param['username']) ? $username : $user_data['username'],
|
||||
'firstname' => ($diff_param['firstname']) ? $firstname : $user_data['firstname'],
|
||||
'lastname' => ($diff_param['lastname']) ? $lastname : $user_data['lastname'],
|
||||
'mail' => ($diff_param['mail']) ? $mail : $user_data['mail'],
|
||||
'password' => ($diff_param['password']) ? $password : $user_data['password'],
|
||||
'status' => ($diff_param['status']) ? $status : $user_data['status'],
|
||||
);
|
||||
|
||||
|
||||
|
@ -385,7 +367,10 @@
|
|||
* @return status<Boolean> Retourne si oui ou non tout s'est bien deroule
|
||||
*
|
||||
*/
|
||||
public static function delete($id_user){
|
||||
public static function delete($params){
|
||||
extract($params);
|
||||
|
||||
|
||||
// On recupere les donnees
|
||||
$request = new Repo('user/delete', array($id_user));
|
||||
$answer = $request->answer();
|
||||
|
|
|
@ -80,13 +80,13 @@
|
|||
=========================================================*/
|
||||
$entity_exists = false;
|
||||
/* (1) Utilisateur */
|
||||
if( $class == 0 ){
|
||||
if( $class == self::USER_CLASS ){
|
||||
// On verifie si c'est un utilisateur
|
||||
$user_check = userRepo::getById($id_entity);
|
||||
$entity_exists = ( $user_check !== FALSE );
|
||||
$entity_exists = ( $user_check !== FALSE );
|
||||
|
||||
/* (2) Machine */
|
||||
}elseif( $class == 1 ){
|
||||
/* (2) Machine */
|
||||
}elseif( $class == self::MACHINE_CLASS ){
|
||||
// On verifie si c'est une machine
|
||||
$machine_check = machineRepo::getById($id_entity);
|
||||
$entity_exists = ( $machine_check !== FALSE );
|
||||
|
|
|
@ -59,8 +59,8 @@
|
|||
/************/
|
||||
public static function session_start(){
|
||||
|
||||
// \session_start();
|
||||
// return;
|
||||
\session_start();
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
// si erreur, on affiche l'explicitation
|
||||
if( $answer->error != ManagerError::Success ){
|
||||
// var_dump( ManagerError::explicit($answer->error) );
|
||||
var_dump( ManagerError::explicit($answer->error) );
|
||||
|
||||
echo "<span class='error'>Une erreur est survenue, veuilez contacter le webmaster si cette erreur persiste.</span>";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue