3 * Bacula(R) - The Network Backup Solution
4 * Baculum - Bacula web interface
6 * Copyright (C) 2013-2015 Marcin Haba
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.
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.
17 * This notice must be preserved when any source code is
18 * conveyed and/or propagated.
20 * Bacula(R) is a registered trademark of Kern Sibbald.
23 Prado::using('System.Web.UI.ActiveControls.TActiveDataGrid');
24 Prado::using('System.Web.UI.ActiveControls.TActiveRepeater');
25 Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
26 Prado::using('System.Web.UI.ActiveControls.TActivePanel');
27 Prado::using('System.Web.UI.ActiveControls.TActiveHiddenField');
28 Prado::using('System.Web.UI.ActiveControls.TCallback');
29 Prado::using('Application.Portlets.ISlideWindow');
30 Prado::using('Application.Portlets.Portlets');
32 class VolumeList extends Portlets implements ISlideWindow {
41 public function setID($id) {
45 public function getID($hideAutoID = true) {
49 public function setButtonID($id) {
50 $this->buttonID = $id;
53 public function getButtonID() {
54 return $this->buttonID;
57 public function setWindowTitle($param) {
58 $this->windowTitle = $param;
61 public function getWindowTitle() {
62 return $this->windowTitle;
65 public function onLoad($param) {
66 parent::onLoad($param);
70 public function prepareData($forceReload = false) {
71 $allowedButtons = array('MediaBtn', 'ReloadVolumes');
72 if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) {
73 if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) {
74 $params = $this->getUrlParams('volumes', $this->getPage()->VolumeWindow->ID);
75 array_push($params, '?showpools=1');
76 $volumes = $this->Application->getModule('api')->get($params);
77 $isDetailView = $_SESSION['view' . $this->getPage()->VolumeWindow->ID] == 'details';
78 if($isDetailView === true) {
79 $this->RepeaterShow->Visible = false;
80 $this->DataGridShow->Visible = true;
81 $this->DataGrid->DataSource = $this->Application->getModule('misc')->objectToArray($volumes->output);
82 $this->DataGrid->dataBind();
85 $this->Repeater->DataSource = $volumes->output;
86 $this->Repeater->dataBind();
87 $this->RepeaterShow->Visible = true;
88 $this->DataGridShow->Visible = false;
94 protected function sortData($data, $key, $id) {
95 if($this->getSortOrder($id) == parent::SORT_DESC) {
98 $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] < $b["pool"]["'.$key.'"]) ? 1 : -1;}');
100 $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] < $b["'.$key.'"]) ? 1 : -1;}');
105 $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] > $b["pool"]["'.$key.'"]) ? 1 : -1;}');
107 $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] > $b["'.$key.'"]) ? 1 : -1;}');
110 usort($data,$compare);
114 public function sortDataGrid($sender, $param) {
115 $params = $this->getUrlParams('volumes', $this->getPage()->VolumeWindow->ID);
116 array_push($params, '?showpools=1');
117 $data = $this->Application->getModule('api')->get($params)->output;
118 $data = $this->Application->getModule('misc')->objectToArray($data);
119 $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);
120 $this->DataGrid->dataBind();
123 public function configure($sender, $param) {
124 if($this->Page->IsCallBack) {
125 $this->getPage()->VolumeConfiguration->configure($param->CallbackParameter);
129 public function executeAction($action) {
130 $params = explode(';', $this->CheckedValues->Value);
134 for($i = 0; $i < count($params); $i++) {
135 $cmd = array('prune');
136 $cmd[] = 'volume="' . $params[$i] . '"';
139 $commands[] = implode(' ', $cmd);
141 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
142 $this->getPage()->Console->sendCommand(null, null);
146 for($i = 0; $i < count($params); $i++) {
147 $cmd = array('purge');
148 $cmd[] = 'volume="' . $params[$i] . '"';
151 $commands[] = implode(' ', $cmd);
153 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
154 $this->getPage()->Console->sendCommand(null, null);
158 for($i = 0; $i < count($params); $i++) {
159 $cmd = array('delete');
160 $cmd[] = 'volume="' . $params[$i] . '"';
163 $commands[] = implode(' ', $cmd);
165 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
166 $this->getPage()->Console->sendCommand(null, null);
170 $this->CheckedValues->Value = "";