From c26128a85a393421cc20c242f6e8ce6d3a35c4f0 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 10 Jul 2016 12:06:41 +0200 Subject: [PATCH] Gestion des groupes 'personnels' --- manager/module/machineDefault.php | 25 +++++++++++++------------ manager/module/userDefault.php | 25 +++++++++++++------------ manager/repo/cluster.php | 13 +++++++++---- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/manager/module/machineDefault.php b/manager/module/machineDefault.php index 90713c0..edf162c 100755 --- a/manager/module/machineDefault.php +++ b/manager/module/machineDefault.php @@ -39,7 +39,8 @@ $create_group = new Repo('cluster/create', [ $_SESSION['WAREHOUSE']['id'], $name, - clusterRepo::MACHINE_CLASS + clusterRepo::MACHINE_CLASS, + $id_machine ]); $id_group = $create_group->answer(); @@ -49,17 +50,17 @@ /* [3] Association au groupe =========================================================*/ - $assoc_goup = new Repo('cluster/link', [ - $_SESSION['WAREHOUSE']['id'], - $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 ['ModuleError' => ManagerError::ModuleError]; + // $assoc_goup = new Repo('cluster/link', [ + // $_SESSION['WAREHOUSE']['id'], + // $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 ['ModuleError' => ManagerError::ModuleError]; /* [4] Gestion du retour diff --git a/manager/module/userDefault.php b/manager/module/userDefault.php index 04f3a08..b70d03e 100755 --- a/manager/module/userDefault.php +++ b/manager/module/userDefault.php @@ -55,7 +55,8 @@ $create_cluster = new Repo('cluster/create', [ $_SESSION['WAREHOUSE']['id'], $username, - clusterRepo::USER_CLASS + clusterRepo::USER_CLASS, + $id_user ]); $id_cluster = $create_cluster->answer(); @@ -68,17 +69,17 @@ /* [4] Association au groupe =========================================================*/ - $assoc_goup = new Repo('cluster/link', [ - $_SESSION['WAREHOUSE']['id'], - $id_cluster, - $id_user, - clusterRepo::USER_CLASS - ]); - $assoc_err = $assoc_goup->answer(); - - // Si une erreur est retournee, on retourne une erreur - if( $assoc_err != ManagerError::Success ) - return ['ModuleError' => $assoc_err]; + // $assoc_goup = new Repo('cluster/link', [ + // $_SESSION['WAREHOUSE']['id'], + // $id_cluster, + // $id_user, + // clusterRepo::USER_CLASS + // ]); + // $assoc_err = $assoc_goup->answer(); + // + // // Si une erreur est retournee, on retourne une erreur + // if( $assoc_err != ManagerError::Success ) + // return ['ModuleError' => $assoc_err]; diff --git a/manager/repo/cluster.php b/manager/repo/cluster.php index 3bd81c2..dda429b 100755 --- a/manager/repo/cluster.php +++ b/manager/repo/cluster.php @@ -17,12 +17,14 @@ * * @id_warehouse UID de l'entrepot * @name Nom du groupe + * @class Type d'entités du groupe + * @owner Si défini -> UID de l'entité qui a ce groupe comme groupe PERSONNEL * * @return id_user Renvoie l'UID du groupe cree * Renvoie FALSE si une erreur occure * */ - public static function create($id_warehouse, $name, $class){ + public static function create($id_warehouse, $name, $class, $owner=null){ /* [1] Verification de l'unicite de name =========================================================*/ $check_unique = ( self::getByName($id_warehouse, $name) === false ); @@ -34,12 +36,13 @@ /* [2] Creation du groupe =========================================================*/ - $insert_user = Database::getPDO()->prepare("INSERT INTO cluster(id_cluster, id_warehouse, name, class) - VALUES(DEFAULT, :id_warehouse, :name, :class)"); + $insert_user = Database::getPDO()->prepare("INSERT INTO cluster(id_cluster, id_warehouse, name, class, personal) + VALUES(DEFAULT, :id_warehouse, :name, :class, :personal)"); $insert_user->execute([ ':id_warehouse' => $id_warehouse, ':name' => $name, - ':class' => $class + ':class' => $class, + ':personal' => $owner ]); /* [3] On retourne l'id_group ou FALSE si erreur @@ -247,6 +250,7 @@ $request = Database::getPDO()->prepare("SELECT * FROM cluster as c WHERE c.id_warehouse = :id_warehouse + AND c.personal is null ORDER BY c.name ASC"); // On execute la requete @@ -357,6 +361,7 @@ WHERE cm.id_cluster = c.id_cluster AND c.id_cluster = :id_cluster AND c.id_warehouse = :id_warehouse + AND c.personal is null ORDER BY id_cluster_merge"); $get_members->execute([ ':id_warehouse' => $id_warehouse,