From e2dacb129e75111559a6f16252009b031c2baeb4 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 19:57:05 +0100 Subject: [PATCH] Modification of options for update_image --- server/core/Image.php | 26 +++++++++++++++++++------- server/test.php | 6 +----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/server/core/Image.php b/server/core/Image.php index 37efa9d..cfd190d 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -101,13 +101,25 @@ class Image { public function update_image($id, array $opt){ $service = $this->oidentity; $image = $service->getImage($id); - $image->update([ - 'minDisk' => $opt['minDisk'], - 'minRam' => $opt['minRam'], - 'name' => $opt['name'], - 'protected' => $opt['protected'], - 'visibility' => $opt['visibility'], - ]); + $options = Array(); + + // Voir vérification des types + if(array_key_exists('name', $opt)){ //string + $options['name'] = $opt['name']; + } + if(array_key_exists('minDisk', $opt)){ //int + $options['minDisk'] = $opt['minDisk']; + } + if(array_key_exists('minRam', $opt)){ // int + $options['minRam'] = $opt['minRam']; + } + if(array_key_exists('protected', $opt)){ // boolean + $options['protected'] = $opt['protected']; + } + if(array_key_exists('visibility', $opt)){ // public, private + $options['visibility'] = $opt['visibility']; + } + $image->update($options); return $image; } diff --git a/server/test.php b/server/test.php index 47d780b..d7ee6f6 100644 --- a/server/test.php +++ b/server/test.php @@ -85,11 +85,7 @@ foreach ($list as $l) { /* $opt_update = Array(); -$opt_update['name'] = "TestUpdate"; -$opt_update['visibility'] = 'public'; -$opt_update['minDisk'] = 1; -$opt_update['protected'] = false; -$opt_update['minRam'] = 15; +$opt_update['name'] = "Test"; $update = $image->update_image($id_image, $opt_update); echo $update->name;