3 * Bacula® - The Network Backup Solution
4 * Baculum - Bacula web interface
6 * Copyright (C) 2013-2014 Marcin Haba
8 * The main author of Baculum is Marcin Haba.
9 * The main author of Bacula is Kern Sibbald, with contributions from many
10 * others, a complete list can be found in the file AUTHORS.
12 * You may use this file and others of this release according to the
13 * license defined in the LICENSE file, which includes the Affero General
14 * Public License, v3.0 ("AGPLv3") and some additional permissions and
15 * terms pursuant to its AGPLv3 Section 7.
17 * Bacula® is a registered trademark of Kern Sibbald.
20 class JobEstimate extends BaculumAPI {
22 public function get() {}
24 public function create($params) {
25 $jobid = property_exists($params, 'id') ? intval($params->id) : 0;
26 $job = $jobid > 0 ? $this->getModule('job')->getJobById($jobid)->name : $params->name;
27 $level = $params->level;
28 $fileset = $params->fileset;
29 $clientid = intval($params->clientid);
30 $client = $this->getModule('client')->getClientById($clientid);
31 $accurateJob = intval($params->accurate);
32 $accurate = $accurateJob === 1 ? 'yes' : 'no';
35 $isValidLevel = $this->getModule('misc')->isValidJobLevel($params->level);
36 if($isValidLevel === true) {
37 if(!is_null($fileset)) {
38 if(!is_null($client)) {
39 $joblevels = $this->getModule('misc')->getJobLevels();
40 $estimation = $this->getModule('bconsole')->bconsoleCommand($this->director, array('estimate', 'job="' . $job . '"', 'level="' . $joblevels[$level] . '"', 'fileset="' . $fileset. '"', 'client="' . $client->name . '"', 'accurate="' . $accurate . '"'), $this->user);
41 $this->output = $estimation->output;
42 $this->error = (integer)$estimation->exitcode;
44 $this->output = JobError::MSG_ERROR_CLIENTID_DOES_NOT_EXISTS;
45 $this->error = JobError::ERROR_CLIENTID_DOES_NOT_EXISTS;
48 $this->output = JobError::MSG_ERROR_FILESETID_DOES_NOT_EXISTS;
49 $this->error = JobError::ERROR_FILESETID_DOES_NOT_EXISTS;
52 $this->output = JobError::MSG_ERROR_INVALID_JOBLEVEL;
53 $this->error = JobError::ERROR_INVALID_JOBLEVEL;
56 $this->output = JobError::MSG_ERROR_JOB_DOES_NOT_EXISTS;
57 $this->error = JobError::ERROR_JOB_DOES_NOT_EXISTS;