From 6011199fc77857740897a60d1360017dc418a7c0 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 19 Jul 2016 19:04:17 +0200 Subject: [PATCH] =?UTF-8?q?Client=20Virtuel:=20Gestion=20des=20permissions?= =?UTF-8?q?=20op=C3=A9rationnel,=20mais=20=C3=A0=20tester=20en=20profondeu?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/module/machineDefault.php | 8 ++++---- test/client/interface.php | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/manager/module/machineDefault.php b/manager/module/machineDefault.php index 5a7396e..52bb351 100755 --- a/manager/module/machineDefault.php +++ b/manager/module/machineDefault.php @@ -453,10 +453,10 @@ /* [N] Retourne les données =========================================================*/ return [ - 'actions' => Database::autotype( $sorted_actions ), - 'states' => Database::autotype( $globalStates ), - 'chips' => Database::autotype( $chips ), - 'permissions' => Database::autotype( $indexed_permissions ) + 'actions' => $sorted_actions, + 'states' => $globalStates, + 'chips' => $chips, + 'permissions' => $indexed_permissions ]; } diff --git a/test/client/interface.php b/test/client/interface.php index efb81a9..7b0ad13 100644 --- a/test/client/interface.php +++ b/test/client/interface.php @@ -363,13 +363,23 @@ for( var a in Object.keys(ACTIONS[COUNT]) ){ /* (3) On vérifie que l'utilisateur a la permissions d'effectuer l'action */ - var hasPermission = PERMISSIONS.hasOwnProperty(CARD) && PERMISSIONS[CARD].indexOf(ACTIONS[COUNT][a].id_action) > -1; - console.log( CARD, PERMISSIONS[CARD], ACTIONS[COUNT][a].id_action, hasPermission); + var hasPermission = false; - // Si pas la permission, on fait rien + // On vérifie parmis toutes les permissions de cette CARTE + if( PERMISSIONS.hasOwnProperty(CARD) ) + for( var i = 0 ; i < PERMISSIONS[CARD].length ; i++ ) + if( PERMISSIONS[CARD][i] == ACTIONS[COUNT][a].id_action ){ + hasPermission = true; + break; + } + + // Si on a pas la permission, on quitte if( !hasPermission ) continue; + // Si pas la permission, on fait rien + if( !hasPermission ) break; + /* (4) Si la condition est correcte, On applique la modification de l'état */ if( previous(ACTIONS[COUNT][a].previous, STATE) ){ action(ACTIONS[COUNT][a].action, STATE);