From 8744cf95772a43af5cb2b3ac1362a966f04a43f8 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 20 Jul 2016 20:05:32 +0200 Subject: [PATCH] =?UTF-8?q?Page=20'users/view',=20'users/remove',=20'users?= =?UTF-8?q?/edit'=20DONE=20+=20les=20repos/modules=20utiles=20=C3=A0=20leu?= =?UTF-8?q?r=20fonctionnement=20DONE=20+=20les=20liens=20entre=20les=20pag?= =?UTF-8?q?es=20(except=C3=A9=20la=20page=20'users/groups'=20vers=20les=20?= =?UTF-8?q?pages=20'groups/...')=20DONE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/module/userDefault.php | 82 ++++------------------------------ manager/repo/user.php | 24 +++------- view/js/users-min.js | 22 ++++----- view/js/users.js | 21 ++++----- view/users.php | 2 - 5 files changed, 34 insertions(+), 117 deletions(-) diff --git a/manager/module/userDefault.php b/manager/module/userDefault.php index 95af76b..085bb9b 100755 --- a/manager/module/userDefault.php +++ b/manager/module/userDefault.php @@ -17,8 +17,6 @@ * @firstname Prenom de l'utilisateur * @lastcode Nom de l'utilisateur * @mail Adresse email de l'utilisateur - * @password Mot de passe de l'utilisateur - * @status Status de l'utilisateur * * @return status Retourne si oui ou non, tout s'est bien passe * @@ -26,11 +24,7 @@ public static function create($params){ extract($params); - /* [1] Normalisation + verification des donnees - =========================================================*/ - $password_hash = sessionManager::secure_hash($password); - - /* [2] Creation de l'utilisateur + /* [1] Creation de l'utilisateur =========================================================*/ $create_user = new Repo('user/create', [ $_SESSION['WAREHOUSE']['id'], @@ -38,9 +32,7 @@ $username, $firstname, $lastname, - $mail, - $password_hash, - $status + $mail ]); $id_user = $create_user->answer(); @@ -49,28 +41,10 @@ return ['ModuleError' => ManagerError::ModuleError]; - - /* [3] Creation du groupe de meme nom que l'username - =========================================================*/ - $create_cluster = new Repo('user_cluster/create', [ - $_SESSION['WAREHOUSE']['id'], - $username, - clusterRepo::USER_CLASS, - $id_user - ]); - $id_cluster = $create_cluster->answer(); - - // Si une erreur est retournee, on retourne une erreur - if( $id_cluster === false ) - return ['ModuleError' => ManagerError::ModuleError]; - - - - /* [4] Gestion du retour + /* [2] Gestion du retour =========================================================*/ return [ - 'id_user' => $id_user, - 'id_cluster' => $id_cluster + 'id_user' => $id_user, ]; } @@ -299,8 +273,6 @@ * @firstname Prenom de l'utilisateur * @lastcode Nom de l'utilisateur * @mail Adresse email de l'utilisateur - * @password Mot de passe de l'utilisateur - * @status Status de l'utilisateur * * @return status Retourne si oui ou non tout s'est bien deroule * @@ -314,7 +286,7 @@ $_SESSION['WAREHOUSE']['id'], $id_user ]); - $user_data = $user_exists->answer(); + $user_data = $user_exists->answer(); // Si on a recupere aucun utilisateur, on retourne une erreur if( !is_array($user_data) ) @@ -324,17 +296,13 @@ /* [2] Normalisation + verification des donnees =========================================================*/ - $password_hash = sessionManager::secure_hash($password); - /* (1) Verification des parametres (si non nul + differents)*/ $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, 'lastname' => !is_null($lastname) && $user_data['lastname'] != $lastname, - '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 + 'mail' => !is_null($mail) && $user_data['mail'] != $mail ]; /* (2) Gestion des parametres optionnels */ @@ -343,9 +311,7 @@ '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'], + 'mail' => ($diff_param['mail']) ? $mail : $user_data['mail'] ]; @@ -360,9 +326,7 @@ $opt_data['username'], $opt_data['firstname'], $opt_data['lastname'], - $opt_data['mail'], - $opt_data['password'], - $opt_data['status'] + $opt_data['mail'] ]); @@ -391,36 +355,8 @@ ]); $deleted_user = $del_user->answer(); - if( !$deleted_user ) - return [ 'status' => false ]; - - /* [2] On récupère le groupe personnel - =========================================================*/ - $get_personal_cluster = new Repo('user_cluster/getPersonal', [ - $id_warehouse, - $id_user, - clusterRepo::USER_CLASS - ]); - - $personal_cluster = $get_personal_cluster->answer(); - - // si erreur - if( $personal_cluster === false ) - return [ 'status' => false ]; - - - /* [3] On supprime le groupe personnel - =========================================================*/ - $del_cluster = new Repo('user_cluster/delete', [ - $id_warehouse, - $personal_cluster['id_cluster'] - ]); - - $deleted = $del_cluster->answer(); - - - return [ 'status' => $deleted ]; + return [ 'status' => $deleted_user ]; } diff --git a/manager/repo/user.php b/manager/repo/user.php index 436adf8..ac7b3f9 100755 --- a/manager/repo/user.php +++ b/manager/repo/user.php @@ -16,14 +16,12 @@ * @firstname Prenom de l'utilisateur * @lastcode Nom de l'utilisateur * @mail Adresse email de l'utilisateur - * @password Mot de passe de l'utilisateur - * @status Status de l'utilisateur * * @return id_user Renvoie l'UID de l'utilisateur cree * Renvoie FALSE si une erreur occure * */ - public static function create($id_warehouse, $code, $username, $firstname, $lastname, $mail, $password, $status){ + public static function create($id_warehouse, $code, $username, $firstname, $lastname, $mail){ /* [1] Verification de l'unicite de code+username =========================================================*/ $check_unique = !is_array(self::getByCode($id_warehouse, $code)); @@ -35,17 +33,15 @@ /* [2] Creation de l'utilisateur =========================================================*/ - $insert_user = Database::getPDO()->prepare("INSERT INTO user(id_user, id_warehouse, code, username, firstname, lastname, mail, password, status) - VALUES(DEFAULT, :id_warehouse, :code, :username, :firstname, :lastname, :mail, :password, :status)"); + $insert_user = Database::getPDO()->prepare("INSERT INTO user(id_user, id_warehouse, code, username, firstname, lastname, mail) + VALUES(DEFAULT, :id_warehouse, :code, :username, :firstname, :lastname, :mail)"); $insert_user->execute([ ':id_warehouse' => $id_warehouse, ':code' => $code, ':username' => $username, ':firstname' => $firstname, ':lastname' => $lastname, - ':mail' => $mail, - ':password' => $password, - ':status' => $status + ':mail' => $mail ]); /* [3] On retourne l'id_user ou FALSE si erreur @@ -144,13 +140,11 @@ * @firstname Prenom de l'utilisateur * @lastcode Nom de l'utilisateur * @mail Adresse email de l'utilisateur - * @password Mot de passe de l'utilisateur - * @status Status de l'utilisateur * * @return status Renvoie si oui ou non tout s'est bien passe * */ - public static function edit($id_warehouse, $id_user=null, $code=null, $username=null, $firstname=null, $lastname=null, $mail=null, $password=null, $status=null){ + public static function edit($id_warehouse, $id_user=null, $code=null, $username=null, $firstname=null, $lastname=null, $mail=null){ /* [1] Verification de l'unicite de code+username (si differents) =========================================================*/ // On recupere les utilisateurs ayant le meme code ou username (si existent) @@ -172,9 +166,7 @@ username = :username, firstname = :firstname, lastname = :lastname, - mail = :mail, - password = :password, - status = :status + mail = :mail WHERE id_user = :id_user AND id_warehouse = :id_warehouse"); $edit_user->execute([ @@ -183,8 +175,6 @@ ':firstname' => $firstname, ':lastname' => $lastname, ':mail' => $mail, - ':password' => $password, - ':status' => $status, ':id_user' => $id_user, ':id_warehouse' => $id_warehouse ]); @@ -201,8 +191,6 @@ $checker = $checker && $check_user['firstname'] == $firstname; $checker = $checker && $check_user['lastname'] == $lastname; $checker = $checker && $check_user['mail'] == $mail; - $checker = $checker && $check_user['password'] == $password; - $checker = $checker && $check_user['status'] == $status; // On retourne l'etat de la modification return $checker; diff --git a/view/js/users-min.js b/view/js/users-min.js index c03a464..c9cb4da 100644 --- a/view/js/users-min.js +++ b/view/js/users-min.js @@ -2,20 +2,20 @@ var section={view:{text:'#CONTAINER > section[data-sublink="view"] ',element:doc edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySelector('#CONTAINER > section[data-sublink="edit"]')}}; if(null!=section.view.element){1 article.inline-box[id]");for(c=0;c
"; echo "
"; echo "
"; - echo "
"; echo ""; echo ""; @@ -147,7 +146,6 @@ echo "
"; echo "
"; echo "
"; - echo "
"; echo ""; echo "";