- [x] [userDefault][userRepo] Gestion des parametres optionnels pour la modification
This commit is contained in:
parent
5d4025323a
commit
11991afd0c
|
@ -310,37 +310,64 @@
|
|||
*
|
||||
*/
|
||||
public static function edit($id_user=null, $code=null, $username=null, $firstname=null, $lastname=null, $mail=null, $password=null, $status=null){
|
||||
/* [1] Normalisation + verification des donnees
|
||||
// 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);
|
||||
|
||||
|
||||
/* [1] On verifie l'existence de l'utilisateur
|
||||
=========================================================*/
|
||||
$user_exists = new Repo('user/getById', array($id_user));
|
||||
$user_data = $user_data->answer();
|
||||
|
||||
// Si on a recupere aucun utilisateur, on retourne une erreur
|
||||
if( !is_array($user_data) )
|
||||
return array('ModuleError' => ManagerError::ModuleError);
|
||||
|
||||
|
||||
|
||||
/* [2] Normalisation + verification des donnees
|
||||
=========================================================*/
|
||||
$password_hash = sessionManager::secure_sha1($password);
|
||||
|
||||
$correct_param = Database::check('auto_increment_id', $id_user);
|
||||
$correct_param = $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);
|
||||
/* (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,
|
||||
'status' => Database::check('user.status', $status ) && $user_data['status'] != $status
|
||||
);
|
||||
|
||||
// Si les parametres ne sont pas corrects, on retourne une erreur
|
||||
if( !$correct_param )
|
||||
return array('ModuleError' => ManagerError::ParamError);
|
||||
/* (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'],
|
||||
);
|
||||
|
||||
|
||||
/* [2] On verifie l'existence de l'utilisateur
|
||||
=========================================================*/
|
||||
$user_exists = new Repo('user/getById', array($id_user));
|
||||
$user_exists = $user_exists->answer();
|
||||
|
||||
// Si on a recupere aucun utilisateur, on retourne une erreur
|
||||
if( !is_array($user_exists) )
|
||||
return array('ModuleError' => ManagerError::ModuleError);
|
||||
|
||||
|
||||
/* [3] Modification de l'utilisateur
|
||||
=========================================================*/
|
||||
$request = new Repo('user/edit', array($id_user, $code, $username, $firstname, $lastname, $mail, $password_hash, $status));
|
||||
$request = new Repo('user/edit', array(
|
||||
$id_user,
|
||||
$opt_data['code'],
|
||||
$opt_data['username'],
|
||||
$opt_data['firstname'],
|
||||
$opt_data['lastname'],
|
||||
$opt_data['mail'],
|
||||
$opt_data['password_hash'],
|
||||
$opt_data['status'])
|
||||
);
|
||||
|
||||
$answer = $request->answer();
|
||||
|
||||
return array(
|
||||
|
|
|
@ -295,7 +295,7 @@
|
|||
* @return status<Boolean> Renvoie si oui ou non tout s'est bien passe
|
||||
*
|
||||
*/
|
||||
public static function edit($id_user, $code, $username, $firstname, $lastname, $mail, $password, $status){
|
||||
public static function edit($id_user=null, $code=null, $username=null, $firstname=null, $lastname=null, $mail=null, $password=null, $status=null){
|
||||
/* [1] Verification de l'unicite de code+username (si differents)
|
||||
=========================================================*/
|
||||
// On recupere les utilisateurs ayant le meme code ou username (si existent)
|
||||
|
|
3
todo.md
3
todo.md
|
@ -7,6 +7,8 @@
|
|||
############
|
||||
# EN COURS #
|
||||
############
|
||||
- [ ] [machineDefaut][machineRepo] Gestion des parametres optionnels pour la modification
|
||||
|
||||
|
||||
- [ ] [view/js/machines] Recherche instantanee
|
||||
- [ ] [view/js/users] Recherche instantanee
|
||||
|
@ -16,6 +18,7 @@
|
|||
########
|
||||
# FAIT #
|
||||
########
|
||||
- [x] [userDefault][userRepo] Gestion des parametres optionnels pour la modification
|
||||
- [x] [machines.js][machineDefault][machineRepo] Gestion de la nouvelle modification (avec recherche)
|
||||
- [x] [machineDefault] Implementer la modification
|
||||
- [x] [users.js][userDefault][userRepo] Gestion de la nouvelle modification (avec recherche)
|
||||
|
|
Loading…
Reference in New Issue