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