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 {
37 public $pools = array();
40 public function setID($id) {
44 public function getID($hideAutoID = true) {
48 public function setButtonID($id) {
49 $this->buttonID = $id;
52 public function getButtonID() {
53 return $this->buttonID;
56 public function setWindowTitle($param) {
57 $this->windowTitle = $param;
60 public function getWindowTitle() {
61 return $this->windowTitle;
64 public function prepareData($sender, $param) {
66 $params = $this->getUrlParams(array('volumes'), $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 private function setPoolList() {
84 $pools = $this->Application->getModule('api')->get(array('pools'));
85 for ($i = 0; $i < count($pools->output); $i++) {
86 $this->pools[$pools->output[$i]->poolid] = $pools->output[$i]->name;
90 protected function sortData($data, $key, $id) {
91 if($this->getSortOrder($id) == parent::SORT_DESC) {
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;}');
101 $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] > $b["pool"]["'.$key.'"]) ? 1 : -1;}');
103 $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] > $b["'.$key.'"]) ? 1 : -1;}');
106 usort($data,$compare);
110 public function sortDataGrid($sender, $param) {
111 $params = $this->getUrlParams(array('volumes'), $this->getPage()->VolumeWindow->ID);
112 $data = $this->Application->getModule('api')->get($params)->output;
113 $data = $this->Application->getModule('misc')->objectToArray($data);
114 $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);
115 $this->DataGrid->dataBind();
118 public function configure($sender, $param) {
119 if($this->Page->IsCallBack) {
120 $this->getPage()->VolumeConfiguration->configure($param->CallbackParameter);
124 public function executeAction($action) {
125 $params = explode(';', $this->CheckedValues->Value);
129 for($i = 0; $i < count($params); $i++) {
130 $cmd = array('prune');
131 $cmd[] = 'volume="' . $params[$i] . '"';
134 $commands[] = implode(' ', $cmd);
136 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
137 $this->getPage()->Console->sendCommand(null, null);
141 for($i = 0; $i < count($params); $i++) {
142 $cmd = array('purge');
143 $cmd[] = 'volume="' . $params[$i] . '"';
146 $commands[] = implode(' ', $cmd);
148 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
149 $this->getPage()->Console->sendCommand(null, null);
153 for($i = 0; $i < count($params); $i++) {
154 $cmd = array('delete');
155 $cmd[] = 'volume="' . $params[$i] . '"';
158 $commands[] = implode(' ', $cmd);
160 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
161 $this->getPage()->Console->sendCommand(null, null);
165 $this->CheckedValues->Value = "";
168 public function formatVolumeField($name) {
169 if (strlen($name) > 20) {
170 $name = substr($name, 0, 7) . '...' . substr($name, -10);