]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/baculum/protected/API/Pages/API/StorageUmount.php
baculum: API endpoints code refactor
[bacula/bacula] / gui / baculum / protected / API / Pages / API / StorageUmount.php
index 82d383f3b40242c89ec0292e171ea50b718bc8e8..2a58bcd008ce716b2cbfe719e3de3ba548d2580a 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 StorageUmount extends BaculumAPIServer {
        public function get() {
-               $storageid = intval($this->Request['id']);
-               $drive = intval($this->Request['drive']);
+               $storageid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
+               $drive = $this->Request->contains('drive') ? intval($this->Request['drive']) : 0;
                $storage = $this->getModule('storage')->getStorageById($storageid);
-               if(!is_null($storage)) {
-                       $storageUmount = $this->getModule('bconsole')->bconsoleCommand($this->director, array('umount', 'storage="' . $storage->name . '"', 'drive=' . $drive), $this->user);
-                       $this->output = $storageUmount->output;
-                       $this->error = (integer)$storageUmount->exitcode;
+               if (is_object($storage)) {
+                       $result = $this->getModule('bconsole')->bconsoleCommand(
+                               $this->director,
+                               array('umount', 'storage="' . $storage->name . '"', 'drive=' . $drive)
+                       );
+                       $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;
@@ -36,4 +39,4 @@ class StorageUmount extends BaculumAPIServer {
        }
 }
 
-?>
\ No newline at end of file
+?>