]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Portlets/StorageList.php
baculum: Improve stability by replace framework session calls to raw PHP sessions
[bacula/bacula] / gui / baculum / protected / Portlets / StorageList.php
1 <?php\r
2 /**\r
3  * Bacula® - The Network Backup Solution\r
4  * Baculum - Bacula web interface\r
5  *\r
6  * Copyright (C) 2013-2014 Marcin Haba\r
7  *\r
8  * The main author of Baculum is Marcin Haba.\r
9  * The main author of Bacula is Kern Sibbald, with contributions from many\r
10  * others, a complete list can be found in the file AUTHORS.\r
11  *\r
12  * You may use this file and others of this release according to the\r
13  * license defined in the LICENSE file, which includes the Affero General\r
14  * Public License, v3.0 ("AGPLv3") and some additional permissions and\r
15  * terms pursuant to its AGPLv3 Section 7.\r
16  *\r
17  * Bacula® is a registered trademark of Kern Sibbald.\r
18  */\r
19  \r
20 Prado::using('System.Web.UI.ActiveControls.TActiveRepeater');\r
21 Prado::using('Application.Portlets.Portlets');\r
22 \r
23 class StorageList extends Portlets {
24 \r
25         public $ShowID, $windowTitle;\r
26 \r
27         public function onLoad($param) {
28                 parent::onLoad($param);\r
29                 $this->prepareData();\r
30         }\r
31 \r
32         public function setWindowTitle($param) {
33                 $this->windowTitle = $param;
34         }\r
35 \r
36         public function prepareData($forceReload = false) {
37                 $allowedButtons = array('StorageBtn');\r
38                 if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) {\r
39                         if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) {\r
40                                 $params = $this->getUrlParams('storages', $this->getPage()->StorageWindow->ID);\r
41                                 $storages = $this->Application->getModule('api')->get($params);\r
42                                 $isDetailView = $_SESSION['view' . $this->getPage()->StorageWindow->ID] == 'details';\r
43                                 $this->RepeaterShow->Visible = !$isDetailView;\r
44                                 $this->Repeater->DataSource = $isDetailView === false ? $storages->output : array();\r
45                                 $this->Repeater->dataBind();\r
46                                 $this->DataGridShow->Visible = $isDetailView;\r
47                                 $this->DataGrid->DataSource = $isDetailView === true ? $this->Application->getModule('misc')->objectToArray($storages->output) : array();\r
48                                 $this->DataGrid->dataBind();\r
49                         }\r
50                 }
51         }\r
52  \r
53     public function sortDataGrid($sender, $param) {\r
54                 $params = $this->getUrlParams('storages', $this->getPage()->StorageWindow->ID);\r
55                 $data = $this->Application->getModule('api')->get($params)->output;\r
56                 $data = $this->Application->getModule('misc')->objectToArray($data);\r
57                 $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);\r
58                 $this->DataGrid->dataBind();\r
59         }\r
60 \r
61         public function setShowID($ShowID) {\r
62                 $this->ShowID = $this->getMaster()->ShowID = $ShowID;\r
63         }\r
64 \r
65         public function getShowID() {\r
66                 return $this->ShowID;\r
67         }\r
68 \r
69         public function configure($sender, $param) {\r
70                 if($this->Page->IsCallBack) {\r
71                         $this->getPage()->StorageConfiguration->configure($param->CallbackParameter);\r
72                 }\r
73         }\r
74 }\r
75 ?>