]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/baculum/protected/API/Pages/API/StorageShow.php
baculum: API endpoints code refactor
[bacula/bacula] / gui / baculum / protected / API / Pages / API / StorageShow.php
index 0d4997170964e0be5c806234c02f05f258cf27e9..cc7c81b6eb90f75f78fb8d67c3ead01153be56bc 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2016 Kern Sibbald
+ * Copyright (C) 2013-2017 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
  
 class StorageShow extends BaculumAPIServer {
        public function get() {
-               $storageid = intval($this->Request['id']);
+               $storageid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
                $storage = $this->getModule('storage')->getStorageById($storageid);
-               if(!is_null($storage)) {
-                       $storageShow = $this->getModule('bconsole')->bconsoleCommand($this->director, array('show', 'storage="' . $storage->name . '"'), $this->user);
-                       $this->output = $storageShow->output;
-                       $this->error = (integer)$storageShow->exitcode;
+               if(is_object($storage)) {
+                       $result = $this->getModule('bconsole')->bconsoleCommand(
+                               $this->director,
+                               array('show', 'storage="' . $storage->name . '"')
+                       );
+                       $this->output = $result->output;
+                       $this->error = $result->exitcode;
                } else {
                        $this->output = StorageError::MSG_ERROR_STORAGE_DOES_NOT_EXISTS;
                        $this->error = StorageError::ERROR_STORAGE_DOES_NOT_EXISTS;
@@ -35,4 +38,4 @@ class StorageShow extends BaculumAPIServer {
        }
 }
 
-?>
\ No newline at end of file
+?>