]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Tweak minor improvements to API code
authorMarcin Haba <marcin.haba@bacula.pl>
Thu, 15 Aug 2019 08:17:51 +0000 (10:17 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 14 Dec 2019 14:55:58 +0000 (15:55 +0100)
gui/baculum/protected/API/Class/BaculumAPIServer.php
gui/baculum/protected/API/Pages/API/BVFSLsDirs.php
gui/baculum/protected/API/Pages/API/BVFSLsFiles.php
gui/baculum/protected/API/Pages/API/JobCancel.php
gui/baculum/protected/API/Pages/API/PoolUpdate.php
gui/baculum/protected/API/Pages/API/PoolUpdateVolumes.php

index 90e7334cb602434fbb5c835256ecb85da656f78b..960f94bffc22c67eddf9584739d5b97945f34c12 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2018 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -238,7 +238,7 @@ abstract class BaculumAPIServer extends TPage {
         * @return none
         */
        private function put() {
-               $id = $this->Request->contains('id') ? $this->Request['id'] : null;
+               $id = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
 
                /**
                 * Check if it is possible to read PUT method data.
index 4daa09b05c8cb532c9ae27b0c0edc8f66f08b615..fcbd6998c5e80713d258a75d0c6c7c1d4ba31039 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2018 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -25,14 +25,6 @@ class BVFSLsDirs extends BaculumAPIServer {
        private $jobids;
        private $path;
 
-       public function set($id, $params) {
-               // TODO: Remove when finished support for old API
-               $misc = $this->getModule('misc');
-               $this->jobids = property_exists($params, 'jobids') && $misc->isValidIdsList($params->jobids) ? $params->jobids : null;
-               $this->path = property_exists($params, 'path') && $misc->isValidPath($params->path) ? $params->path : null;
-               $this->get();
-       }
-
        public function get() {
                $misc = $this->getModule('misc');
                $limit = $this->Request->contains('limit') ? intval($this->Request['limit']) : 0;
index e713372ab6066e4a666d418dda9907694d5634fc..e6af45b87a7b44b8dc90ec0d4e4b526fa56f997b 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2018 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -25,14 +25,6 @@ class BVFSLsFiles extends BaculumAPIServer {
        private $jobids;
        private $path;
 
-       public function set($id, $params) {
-               // TODO: Remove when finished support for old API
-               $misc = $this->getModule('misc');
-               $this->jobids = property_exists($params, 'jobids') && $misc->isValidIdsList($params->jobids) ? $params->jobids : null;
-               $this->path = property_exists($params, 'path') && $misc->isValidPath($params->path) ? $params->path : null;
-               $this->get();
-       }
-
        public function get() {
                $misc = $this->getModule('misc');
                $limit = $this->Request->contains('limit') ? intval($this->Request['limit']) : 0;
index 19cd69a2dcb808e388ac3af8fc6dcc163a601871..60be22d8e84e7282c81b23646ecd90c54320b624 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2018 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -23,8 +23,7 @@
 class JobCancel extends BaculumAPIServer {
 
        public function set($id, $params) {
-               $jobid = intval($id);
-               $job = $this->getModule('job')->getJobById($jobid);
+               $job = $this->getModule('job')->getJobById($id);
                if (is_object($job)) {
                        $cancel = $this->getModule('bconsole')->bconsoleCommand(
                                $this->director,
index 3667f09a46b44a92858693632d302b15bb3fc5be..5073212180e1badf79e7aa7e63ce4855b7c5f55b 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2018 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
 class PoolUpdate extends BaculumAPIServer {
 
        public function set($id, $params) {
-               $poolid = intval($id);
                $result = $this->getModule('bconsole')->bconsoleCommand(
                        $this->director,
                        array('.pool')
                );
                if ($result->exitcode === 0) {
                        array_shift($result->output);
-                       $pool = $this->getModule('pool')->getPoolById($poolid);
+                       $pool = $this->getModule('pool')->getPoolById($id);
                        if (is_object($pool) && in_array($pool->name, $result->output)) {
                                $result = $this->getModule('bconsole')->bconsoleCommand(
                                        $this->director,
index 8346830b887e3ff65195363ca50c39c01a38411c..27243f080eb4692dd3f6159b1f8c4a02f45c8ae2 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2018 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
 class PoolUpdateVolumes extends BaculumAPIServer {
 
        public function set($id, $params) {
-               $poolid = intval($id);
                $result = $this->getModule('bconsole')->bconsoleCommand(
                        $this->director,
                        array('.pool')
                );
                if ($result->exitcode === 0) {
                        array_shift($result->output);
-                       $pool = $this->getModule('pool')->getPoolById($poolid);
+                       $pool = $this->getModule('pool')->getPoolById($id);
                        if (is_object($pool) && in_array($pool->name, $result->output)) {
                                $voldata = $this->getModule('volume')->getVolumeByPoolId($pool->poolid);
                                if(is_object($voldata)) {