]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/baculum/protected/API/Pages/API/BVFSUpdate.php
baculum: API endpoints code refactor
[bacula/bacula] / gui / baculum / protected / API / Pages / API / BVFSUpdate.php
index 760bbb66ff2eae495029d8f7640311eb0f6ecbca..7e4fc99aab2e07619b741ff5ab7ddf14e3f384cf 100644 (file)
 
 class BVFSUpdate extends BaculumAPIServer {
 
-       public function set($param, $ids) {
-               $isValid = true;
-               if (property_exists($ids, 'jobids')) {
-                       $jobids = explode(',', $ids->jobids);
-                       for($i = 0; $i < count($jobids); $i++) {
-                               $job = $this->getModule('job')->getJobById($jobids[$i]);
-                               if(is_null($job)) {
-                                       $isValid = false;
-                                       break;
-                               }
-                       }
-               } else {
-                       $isValid = false;
+       public function set($id, $params) {
+               $jobids = null;
+               if (property_exists($params, 'jobids') && $this->getModule('misc')->isValidIdsList($params->jobids)) {
+                       $jobids = $params->jobids;
                }
                
-               if($isValid === true) {
-                       $result = $this->getModule('bconsole')->bconsoleCommand(
-                               $this->director,
-                               array('.bvfs_update', 'jobid="' . $ids->jobids . '"'),
-                               $this->user
-                       );
-                       $this->output = $result->output;
-                       $this->error = $result->exitcode;
-               } else {
-                       $this->output = BVFSError::MSG_ERROR_JOB_DOES_NOT_EXISTS;
-                       $this->error = BVFSError::ERROR_JOB_DOES_NOT_EXISTS;
+               if (is_null($jobids)) {
+                       $this->output = BVFSError::MSG_ERROR_INVALID_JOBID_LIST;
+                       $this->error = BVFSError::ERROR_INVALID_JOBID_LIST;
+                       return;
                }
+
+               $result = $this->getModule('bconsole')->bconsoleCommand(
+                       $this->director,
+                       array('.bvfs_update', 'jobid="' . $jobids . '"')
+               );
+               $this->output = $result->output;
+               $this->error = $result->exitcode;
        }
 }
 ?>