3 * Bacula(R) - The Network Backup Solution
4 * Baculum - Bacula web interface
6 * Copyright (C) 2013-2016 Kern Sibbald
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.Web.Portlets.ISlideWindow');
30 Prado::using('Application.Web.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 prepareData($sender, $param) {
66 $params = $this->getUrlParams(array('volumes', 'withpools'), $this->getPage()->VolumeWindow->ID);
67 $volumes = $this->Application->getModule('api')->get($params);
68 $isDetailView = $_SESSION['view' . $this->getPage()->VolumeWindow->ID] == 'details';
69 if($isDetailView === true) {
70 $this->RepeaterShow->Visible = false;
71 $this->DataGridShow->Visible = true;
72 $this->DataGrid->DataSource = $this->Application->getModule('misc')->objectToArray($volumes->output);
73 $this->DataGrid->dataBind();
76 $this->Repeater->DataSource = $volumes->output;
77 $this->Repeater->dataBind();
78 $this->RepeaterShow->Visible = true;
79 $this->DataGridShow->Visible = false;
83 protected function sortData($data, $key, $id) {
84 if($this->getSortOrder($id) == parent::SORT_DESC) {
87 $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] < $b["pool"]["'.$key.'"]) ? 1 : -1;}');
89 $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] < $b["'.$key.'"]) ? 1 : -1;}');
94 $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] > $b["pool"]["'.$key.'"]) ? 1 : -1;}');
96 $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] > $b["'.$key.'"]) ? 1 : -1;}');
99 usort($data,$compare);
103 public function sortDataGrid($sender, $param) {
104 $params = $this->getUrlParams(array('volumes', 'withpools'), $this->getPage()->VolumeWindow->ID);
105 $data = $this->Application->getModule('api')->get($params)->output;
106 $data = $this->Application->getModule('misc')->objectToArray($data);
107 $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);
108 $this->DataGrid->dataBind();
111 public function configure($sender, $param) {
112 if($this->Page->IsCallBack) {
113 $this->getPage()->VolumeConfiguration->configure($param->CallbackParameter);
117 public function executeAction($action) {
118 $params = explode(';', $this->CheckedValues->Value);
122 for($i = 0; $i < count($params); $i++) {
123 $cmd = array('prune');
124 $cmd[] = 'volume="' . $params[$i] . '"';
127 $commands[] = implode(' ', $cmd);
129 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
130 $this->getPage()->Console->sendCommand(null, null);
134 for($i = 0; $i < count($params); $i++) {
135 $cmd = array('purge');
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('delete');
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 $this->CheckedValues->Value = "";
161 public function formatVolumeField($name) {
162 if (strlen($name) > 20) {
163 $name = substr($name, 0, 7) . '...' . substr($name, -10);