From: Marcin Haba Date: Thu, 15 Aug 2019 08:17:51 +0000 (+0200) Subject: baculum: Tweak minor improvements to API code X-Git-Tag: Release-9.6.0~140 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3a65f8d3af9f89638ac508d8f149b075ee0a4c5;p=thirdparty%2Fbacula.git baculum: Tweak minor improvements to API code --- diff --git a/gui/baculum/protected/API/Class/BaculumAPIServer.php b/gui/baculum/protected/API/Class/BaculumAPIServer.php index 90e7334cb..960f94bff 100644 --- a/gui/baculum/protected/API/Class/BaculumAPIServer.php +++ b/gui/baculum/protected/API/Class/BaculumAPIServer.php @@ -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. diff --git a/gui/baculum/protected/API/Pages/API/BVFSLsDirs.php b/gui/baculum/protected/API/Pages/API/BVFSLsDirs.php index 4daa09b05..fcbd6998c 100644 --- a/gui/baculum/protected/API/Pages/API/BVFSLsDirs.php +++ b/gui/baculum/protected/API/Pages/API/BVFSLsDirs.php @@ -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; diff --git a/gui/baculum/protected/API/Pages/API/BVFSLsFiles.php b/gui/baculum/protected/API/Pages/API/BVFSLsFiles.php index e713372ab..e6af45b87 100644 --- a/gui/baculum/protected/API/Pages/API/BVFSLsFiles.php +++ b/gui/baculum/protected/API/Pages/API/BVFSLsFiles.php @@ -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; diff --git a/gui/baculum/protected/API/Pages/API/JobCancel.php b/gui/baculum/protected/API/Pages/API/JobCancel.php index 19cd69a2d..60be22d8e 100644 --- a/gui/baculum/protected/API/Pages/API/JobCancel.php +++ b/gui/baculum/protected/API/Pages/API/JobCancel.php @@ -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, diff --git a/gui/baculum/protected/API/Pages/API/PoolUpdate.php b/gui/baculum/protected/API/Pages/API/PoolUpdate.php index 3667f09a4..507321218 100644 --- a/gui/baculum/protected/API/Pages/API/PoolUpdate.php +++ b/gui/baculum/protected/API/Pages/API/PoolUpdate.php @@ -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,14 +23,13 @@ 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, diff --git a/gui/baculum/protected/API/Pages/API/PoolUpdateVolumes.php b/gui/baculum/protected/API/Pages/API/PoolUpdateVolumes.php index 8346830b8..27243f080 100644 --- a/gui/baculum/protected/API/Pages/API/PoolUpdateVolumes.php +++ b/gui/baculum/protected/API/Pages/API/PoolUpdateVolumes.php @@ -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,14 +23,13 @@ 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)) {