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