]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Web/Portlets/BaculaHosts.php
baculum: Revert back volume pool name in volume list window
[bacula/bacula] / gui / baculum / protected / Web / Portlets / BaculaHosts.php
1 <?php
2 /*
3  * Bacula(R) - The Network Backup Solution
4  * Baculum   - Bacula web interface
5  *
6  * Copyright (C) 2013-2016 Kern Sibbald
7  *
8  * The main author of Baculum is Marcin Haba.
9  * The original author of Bacula is Kern Sibbald, with contributions
10  * from many 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  * This notice must be preserved when any source code is
18  * conveyed and/or propagated.
19  *
20  * Bacula(R) is a registered trademark of Kern Sibbald.
21  */
22
23 Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
24 Prado::using('System.Web.UI.ActiveControls.TActiveRepeater');
25 Prado::using('Application.Web.Class.HostConfig');
26 Prado::using('Application.Web.Portlets.HostListTemplate');
27
28 class BaculaHosts extends HostListTemplate {
29
30         const CHILD_CONTROL = 'BaculaConfigComponents';
31
32         public $config;
33
34         public function loadConfig($sender, $param) {
35                 if(!$_SESSION['admin']) {
36                         return;
37                 }
38                 $this->config = $this->getModule('host_config')->getConfig();
39                 $hosts = array_keys($this->config);
40                 $this->RepeaterHosts->DataSource = $hosts;
41                 $this->RepeaterHosts->dataBind();
42         }
43
44         public function createHostListElement($sender, $param) {
45                 $control = $this->getChildControl($param->Item, self::CHILD_CONTROL);
46                 if (is_object($control)) {
47                         $control->setHost($param->Item->DataItem);
48                 }
49                 $param->Item->RemoveHost->setCommandParameter($param->Item->DataItem);
50         }
51
52         public function getComponents($sender, $param) {
53                 $control = $this->getChildControl($sender->getParent(), self::CHILD_CONTROL);
54                 if (is_object($control)) {
55                         $control->raiseEvent('OnComponentListLoad', $this, null);
56                 }
57         }
58
59         public function bubbleEvent($sender, $param) {
60                 if ($param instanceof TCommandEventParameter) {
61                         $this->loadConfig(null, null);
62                         return true;
63                 } else {
64                         return false;
65                 }
66         }
67
68         public function removeHost($sender, $param) {
69                 if(!$_SESSION['admin']) {
70                         return;
71                 }
72                 $host = $param->getCommandParameter();
73                 if (!empty($host)) {
74                         $host_config = $this->getModule('host_config');
75                         $config = $host_config->getConfig();
76                         unset($config[$host]);
77                         $host_config->setConfig($config);
78                         $this->loadConfig(null, null);
79                         if ($host === HostConfig::MAIN_CATALOG_HOST) {
80                                 $url = $this->Service->constructUrl('WebConfigWizard', array(), false);
81                                 $this->getResponse()->redirect($url);
82                         }
83                 }
84         }
85 }
86 ?>