From 1fef8186a0c858854f2a1e059afba83ecc5e3171 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 21 Jul 2017 16:08:09 +0200 Subject: [PATCH] Added network identity management at machineDefault/update --- build/api/module/machineDefault.php | 24 +++++++++++++++---- build/database/repo/machine.php | 37 ++++++++++++++++++++++++++++- config/repositories.json | 3 ++- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/build/api/module/machineDefault.php b/build/api/module/machineDefault.php index f91e47f..5255f69 100755 --- a/build/api/module/machineDefault.php +++ b/build/api/module/machineDefault.php @@ -636,12 +636,16 @@ public function update($params){ extract($params); + /* [1] Initialisation des variables =========================================================*/ $fetched = [ - 'history' => 0, // count of registered logs - 'feature' => [] // count of registered logs for each feature - + 'history' => 0, // count of registered logs + 'feature' => [], // count of registered logs for each feature + 'identity' => [ // network identity + 'ap' => isset($data['identity']) && is_array($data['identity']) && isset($data['identity']['ap']) ? $data['identity']['ap'] : null, + 'ip' => isset($data['identity']) && is_array($data['identity']) && isset($data['identity']['ip']) ? $data['identity']['ip'] : null + ] ]; @@ -674,8 +678,20 @@ } + /* (2) For each feature's entry */ + // TODO: Manage feature's entries + /* (3) Mise à jour de l'identité de la machine (ap-ip) */ + $updateNetId = new Repo('machine/updateNetworkIdentity', [ + $_SESSION['WAREHOUSE']['id'], + $id_machine, + $fetched['identity']['ap'], + $fetched['identity']['ip'] + ]); + /* (2) On gère l'erreur */ + if( $updateNetId->error->get() != Err::Success || !$updateNetId->answer() ) + return [ 'error' => new Error(Err::RepoError) ]; /* [3] Gestion des données à envoyer @@ -686,8 +702,6 @@ - - /* [4] Envoi des données =========================================================*/ return array_merge($basis_update, ['saved' => $fetched]); diff --git a/build/database/repo/machine.php b/build/database/repo/machine.php index 16cf016..6665ef3 100755 --- a/build/database/repo/machine.php +++ b/build/database/repo/machine.php @@ -114,7 +114,7 @@ * * @id_warehouse UID de l'entrepot * @id_machine UID de la machine - * @name Identifiant l'utilisateur + * @name Nouveau nom de machine * * @return status Renvoie si oui ou non tout s'est bien passe * @@ -421,6 +421,41 @@ + + + + + + + /* MODIFICATION DE L'IDENTITE RESEAU D'UNE MACHINE DONNEE + * + * @id_warehouse UID de l'entrepot + * @id_machine UID de la machine + * @ap Identifiant de l'AP (Access Point) + * @ip Ip + * + * @return status Renvoie si oui ou non tout s'est bien passe + * + */ + public static function updateNetworkIdentity($id_warehouse=null, $id_machine=null, $ap=null, $ip=null){ + + /* [1] Mise à jour des identifiants + =========================================================*/ + $edited = Table::get('machine') + ->whereId($id_machine) + ->whereIdWarehouse($id_warehouse) + ->edit([ 'ap' => $ap, 'ip' => $ip ]); + + // On retourne l'etat de la modification + return $edited; + } + + + + + + + } diff --git a/config/repositories.json b/config/repositories.json index 172e4ad..96ab073 100755 --- a/config/repositories.json +++ b/config/repositories.json @@ -42,6 +42,7 @@ "search", "getClusters", + "updateNetworkIdentity", "unlock" @@ -109,7 +110,7 @@ "action_merge": [ "addPermission", "removePermission", - + "getPermissions", "getAccess", "getAuthenticatedClusters",