]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Portlets/PoolList.php
baculum: Assign Baculum copyright to Kern Sibbald
[bacula/bacula] / gui / baculum / protected / Portlets / PoolList.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.TActiveRepeater');
24 Prado::using('Application.Portlets.ISlideWindow');
25 Prado::using('Application.Portlets.Portlets');
26
27 class PoolList extends Portlets implements ISlideWindow {
28
29         public $ID;
30         public $buttonID;
31         public $windowTitle;
32
33         public function setID($id) {
34                 $this->ID = $id;
35         }
36
37         public function getID($hideAutoID = true) {
38                 return $this->ID;
39         }
40
41         public function setButtonID($id) {
42                 $this->buttonID = $id;
43         }
44
45         public function getButtonID() {
46                 return $this->buttonID;
47         }
48
49         public function setWindowTitle($param) {
50                 $this->windowTitle = $param;
51         }
52
53         public function getWindowTitle() {
54                 return $this->windowTitle;
55         }
56         public function onLoad($param) {
57                 parent::onLoad($param);
58                 $this->prepareData();
59         }
60
61         public function prepareData($forceReload = false) {
62                 $allowedButtons = array('PoolBtn', 'ReloadPools');
63                 if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) {
64                         if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) {
65                                 $params = $this->getUrlParams('pools', $this->getPage()->PoolWindow->ID);
66                                 $pools = $this->Application->getModule('api')->get($params);
67                                 $isDetailView = $_SESSION['view' . $this->getPage()->PoolWindow->ID] == 'details';
68                                 if($isDetailView === true) {
69                                         $this->RepeaterShow->Visible = false;
70                                         $this->DataGridShow->Visible = true;
71                                         $this->DataGrid->DataSource = $this->Application->getModule('misc')->objectToArray($pools->output);
72                                         $this->DataGrid->dataBind();
73                                 } else {
74                                         $this->RepeaterShow->Visible = true;
75                                         $this->DataGridShow->Visible = false;
76                                         $this->Repeater->DataSource = $pools->output;
77                                         $this->Repeater->dataBind();
78                                 }
79                         }
80                 }
81         }
82
83     public function sortDataGrid($sender, $param) {
84                 $params = $this->getUrlParams('pools', $this->getPage()->PoolWindow->ID);
85                 $data = $this->Application->getModule('api')->get($params)->output;
86                 $data = $this->Application->getModule('misc')->objectToArray($data);
87                 $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);
88                 $this->DataGrid->dataBind();
89         }
90
91         public function setShowID($ShowID) {
92                 $this->ShowID = $this->getMaster()->ShowID = $ShowID;
93         }
94
95         public function getShowID() {
96                 return $this->ShowID;
97         }
98
99         public function configure($sender, $param) {
100                 if($this->Page->IsCallBack) {
101                         $this->getPage()->PoolConfiguration->configure($param->CallbackParameter);
102                 }
103         }
104 }
105 ?>