]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Pages/Home.php
5fe09c78ed8fe70c3c3bb606f2be0b1387ff7905
[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-2014 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 function onInit($param) {
31                 parent::onInit($param);
32                 $isConfigExists = $this->getModule('configuration')->isApplicationConfig();
33                 if($isConfigExists === false) {
34                         $this->goToPage('ConfigurationWizard');
35                 }
36
37                 $appConfig = $this->getModule('configuration')->getApplicationConfig();
38
39                 $this->SettingsWizardBtn->Visible = $this->User->getIsAdmin();
40                 $this->MediaBtn->Visible = $this->User->getIsAdmin();
41                 $this->ClearBvfsCache->Visible = $this->User->getIsAdmin();
42                 $this->Logging->Visible = $this->User->getIsAdmin();
43
44                 if(!$this->IsPostBack && !$this->IsCallBack) {
45                         $this->Logging->Checked = $this->getModule('logging')->isDebugOn();
46                 }
47
48                 $directors = $this->getModule('api')->get(array('directors'))->output;
49
50                 if(!$this->IsPostBack && !$this->IsCallBack) {
51                         if(!array_key_exists('director', $_SESSION)) {
52                                 $_SESSION['director'] = $directors[0];
53                         }
54                         $this->Director->dataSource = array_combine($directors, $directors);
55                         $this->Director->SelectedValue = $_SESSION['director'];
56                         $this->Director->dataBind();
57                         $this->setJobs();
58                         $this->setClients();
59                 }
60         }
61
62         public function restore($sender, $param) {
63                 $this->goToPage('RestoreWizard');
64         }
65
66         public function configuration($sender, $param) {
67                 $this->goToPage('ConfigurationWizard');
68         }
69
70         public function director($sender, $param) {
71                 $_SESSION['director'] = $this->Director->SelectedValue;
72         }
73
74         public function setDebug($sender, $param) {
75                 if($this->User->getIsAdmin() === true) {
76                         $this->getModule('logging')->enableDebug($this->Logging->Checked);
77                 }
78         }
79
80         public function clearBvfsCache($sender, $param) {
81                 if($this->User->getIsAdmin() === true) {
82                         $this->getModule('api')->set(array('bvfs', 'clear'), array());
83                 }
84         }
85
86         public function getJobs() {
87                 return json_encode($this->jobs);
88         }
89
90         public function setJobs() {
91                 $this->jobs = $this->getModule('api')->get(array('jobs'));
92                 $jobs = array('@' => Prado::localize('select job'));
93                 foreach($this->jobs->output as $key => $job) {
94                         $jobs[$job->name] = $job->name;
95                 }
96                 $this->Jobs->dataSource = $jobs;
97                 $this->Jobs->dataBind();
98         }
99
100         public function setClients() {
101                 $clients_obj = $this->getModule('api')->get(array('clients'));
102                 $clients = array('@' => Prado::localize('select client'));
103                 foreach($clients_obj->output as $key => $client) {
104                         $clients[$client->clientid] = $client->name;
105                 }
106                 $this->Clients->dataSource = $clients;
107                 $this->Clients->dataBind();
108
109         }
110 }
111 ?>