]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Pages/API/RestoreRun.php
baculum: Update copyright dates
[bacula/bacula] / gui / baculum / protected / Pages / API / RestoreRun.php
1 <?php
2 /**
3  * Bacula® - The Network Backup Solution
4  * Baculum - Bacula web interface
5  *
6  * Copyright (C) 2013-2015 Marcin Haba
7  *
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.
11  *
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.
16  *
17  * Bacula® is a registered trademark of Kern Sibbald.
18  */
19  
20 class RestoreRun extends BaculumAPI {
21
22         public function get() {}
23
24         public function create($params) {
25                 $rfile = property_exists($params, 'rpath') ? $params->rpath : null;
26                 $clientid = property_exists($params, 'clientid') ? intval($params->clientid) : null;
27                 $fileset = property_exists($params, 'fileset') ? $params->fileset : null;
28                 $priority = property_exists($params, 'priority') ? intval($params->priority) : null;
29                 $where = property_exists($params, 'where') ? $params->where : null;
30                 $replace = property_exists($params, 'replace') ? $params->replace : null;
31
32                 $client = $this->getModule('client')->getClientById($clientid);
33
34                 if(!is_null($fileset)) {
35                         if(!is_null($client)) {
36                                 if(preg_match('/^b2[\d]+$/', $rfile) === 1) {
37                                         if(!is_null($where)) {
38                                                 if(!is_null($replace)) {
39                                                         $restore = $this->getModule('bconsole')->bconsoleCommand($this->director, array('restore', 'file="?' . $rfile . '"', 'client="' . $client->name . '"', 'where="' . $where . '"', 'replace="' . $replace . '"', 'fileset="' . $fileset . '"', 'priority="' . $priority . '"', 'yes'), $this->user);
40                                                         $this->output = $restore->output;
41                                                         $this->error = (integer)$restore->exitcode;
42                                                 } else {
43                                                         $this->output = JobError::MSG_ERROR_INVALID_REPLACE_OPTION;
44                                                         $this->error = JobError::ERROR_INVALID_REPLACE_OPTION;
45                                                 }
46                                         } else {
47                                                 $this->output = JobError::MSG_ERROR_INVALID_WHERE_OPTION;
48                                                 $this->error = JobError::ERROR_INVALID_WHERE_OPTION;
49                                         }
50                                 } else {
51                                         $this->output = JobError::MSG_ERROR_INVALID_RPATH;
52                                         $this->error = JobError::ERROR_INVALID_RPATH;
53                                 }
54                         } else {
55                                 $this->output = JobError::MSG_ERROR_CLIENTID_DOES_NOT_EXISTS;
56                                 $this->error = JobError::ERROR_CLIENTID_DOES_NOT_EXISTS;
57                         }
58                 } else {
59                         $this->output = JobError::MSG_ERROR_FILESETID_DOES_NOT_EXISTS;
60                         $this->error = JobError::ERROR_FILESETID_DOES_NOT_EXISTS;
61                 }
62         }
63 }
64
65 ?>