]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Pages/Home.php
baculum: Open jobs window just after restore start
[bacula/bacula] / gui / baculum / protected / Pages / Home.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 Prado::using('System.Web.UI.ActiveControls.TActiveButton');
21 Prado::using('System.Web.UI.ActiveControls.TActivePanel');
22 Prado::using('System.Web.UI.ActiveControls.TActiveDropDownList');
23 Prado::using('System.Web.UI.ActiveControls.TActiveCheckBox');
24 Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
25
26 class Home extends BaculumPage
27 {
28         public $jobs;
29
30         public $openWindow = null;
31
32         public $windowIds = array('Storage', 'Client', 'Media', 'Pool', 'Job', 'JobRun');
33
34         public function onInit($param) {
35                 parent::onInit($param);
36                 $isConfigExists = $this->getModule('configuration')->isApplicationConfig();
37                 if($isConfigExists === false) {
38                         $this->goToPage('ConfigurationWizard');
39                 }
40
41                 $appConfig = $this->getModule('configuration')->getApplicationConfig();
42
43                 $this->SettingsWizardBtn->Visible = $this->User->getIsAdmin();
44                 $this->MediaBtn->Visible = $this->User->getIsAdmin();
45                 $this->ClearBvfsCache->Visible = $this->User->getIsAdmin();
46                 $this->Logging->Visible = $this->User->getIsAdmin();
47
48                 if(!$this->IsPostBack && !$this->IsCallBack) {
49                         $this->Logging->Checked = $this->getModule('logging')->isDebugOn();
50                 }
51
52                 if(!$this->IsPostBack && !$this->IsCallBack) {
53                         $directors = $this->getModule('api')->get(array('directors'))->output;
54                         if(!array_key_exists('director', $_SESSION)) {
55                                 $_SESSION['director'] = $directors[0];
56                         }
57                         $this->Director->dataSource = array_combine($directors, $directors);
58                         $this->Director->SelectedValue = $_SESSION['director'];
59                         $this->Director->dataBind();
60                         $this->setJobs();
61                         $this->setClients();
62                         $this->setWindowOpen();
63                 }
64         }
65
66         public function restore($sender, $param) {
67                 $this->goToPage('RestoreWizard');
68         }
69
70         public function configuration($sender, $param) {
71                 $this->goToPage('ConfigurationWizard');
72         }
73
74         public function director($sender, $param) {
75                 $_SESSION['director'] = $this->Director->SelectedValue;
76         }
77
78         public function setDebug($sender, $param) {
79                 if($this->User->getIsAdmin() === true) {
80                         $this->getModule('logging')->enableDebug($this->Logging->Checked);
81                 }
82         }
83
84         public function clearBvfsCache($sender, $param) {
85                 if($this->User->getIsAdmin() === true) {
86                         $this->getModule('api')->set(array('bvfs', 'clear'), array());
87                 }
88         }
89
90         public function getJobs() {
91                 return json_encode($this->jobs);
92         }
93
94         public function setJobs() {
95                 $this->jobs = $this->getModule('api')->get(array('jobs'));
96                 $jobs = array('@' => Prado::localize('select job'));
97                 foreach($this->jobs->output as $key => $job) {
98                         $jobs[$job->name] = $job->name;
99                 }
100                 $this->Jobs->dataSource = $jobs;
101                 $this->Jobs->dataBind();
102         }
103
104         public function setClients() {
105                 $clients_obj = $this->getModule('api')->get(array('clients'));
106                 $clients = array('@' => Prado::localize('select client'));
107                 foreach($clients_obj->output as $key => $client) {
108                         $clients[$client->clientid] = $client->name;
109                 }
110                 $this->Clients->dataSource = $clients;
111                 $this->Clients->dataBind();
112
113         }
114
115         public function setWindowOpen() {
116                 if (isset($this->Request['open']) && in_array($this->Request['open'], $this->windowIds)) {
117                         $btn = $this->Request['open'] . 'Btn';
118                         $this->openWindow = $this->{$btn}->ClientID;
119                 }
120         }
121 }
122 ?>