]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/baculum/protected/API/Pages/API/VolumePrune.php
baculum: API endpoints code refactor
[bacula/bacula] / gui / baculum / protected / API / Pages / API / VolumePrune.php
index 283a996d2cdfa5128a649e6069c67d15bc8c8afe..fe22c65781cd379810a59b6036ec165f583a2f69 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 VolumePrune extends BaculumAPIServer {
        public function get() {
-               $mediaid = intval($this->Request['id']);
+               $mediaid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
                $volume = $this->getModule('volume')->getVolumeById($mediaid);
-               if(!is_null($volume)) {
-                       $prune = $this->getModule('bconsole')->bconsoleCommand($this->director, array('prune', 'volume="' . $volume->volumename . '"', 'yes'), $this->user);
-                       $this->output = $prune->output;
-                       $this->error = (integer)$prune->exitcode;
+               if(is_object($volume)) {
+                       $result = $this->getModule('bconsole')->bconsoleCommand(
+                               $this->director,
+                               array('prune', 'volume="' . $volume->volumename . '"', 'yes')
+                       );
+                       $this->output = $result->output;
+                       $this->error = $result->exitcode;
                } else {
                        $this->output = VolumeError::MSG_ERROR_VOLUME_DOES_NOT_EXISTS;
                        $this->error = VolumeError::ERROR_VOLUME_DOES_NOT_EXISTS;
@@ -35,4 +38,4 @@ class VolumePrune extends BaculumAPIServer {
        }
 }
 
-?>
\ No newline at end of file
+?>