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 {
39 public function setID($id) {
43 public function getID($hideAutoID = true) {
47 public function setButtonID($id) {
48 $this->buttonID = $id;
51 public function getButtonID() {
52 return $this->buttonID;
55 public function setWindowTitle($param) {
56 $this->windowTitle = $param;
59 public function getWindowTitle() {
60 return $this->windowTitle;
63 public function prepareData($sender, $param) {
64 $params = $this->getUrlParams(array('volumes'), $this->getPage()->VolumeWindow->ID);
65 $volumes = $this->Application->getModule('api')->get($params);
66 $isDetailView = $_SESSION['view' . $this->getPage()->VolumeWindow->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($volumes->output);
71 $this->DataGrid->dataBind();
74 $this->Repeater->DataSource = $volumes->output;
75 $this->Repeater->dataBind();
76 $this->RepeaterShow->Visible = true;
77 $this->DataGridShow->Visible = false;
81 protected function sortData($data, $key, $id) {
82 if($this->getSortOrder($id) == parent::SORT_DESC) {
85 $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] < $b["pool"]["'.$key.'"]) ? 1 : -1;}');
87 $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] < $b["'.$key.'"]) ? 1 : -1;}');
92 $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] > $b["pool"]["'.$key.'"]) ? 1 : -1;}');
94 $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] > $b["'.$key.'"]) ? 1 : -1;}');
97 usort($data,$compare);
101 public function sortDataGrid($sender, $param) {
102 $params = $this->getUrlParams(array('volumes'), $this->getPage()->VolumeWindow->ID);
103 $data = $this->Application->getModule('api')->get($params)->output;
104 $data = $this->Application->getModule('misc')->objectToArray($data);
105 $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);
106 $this->DataGrid->dataBind();
109 public function configure($sender, $param) {
110 if($this->Page->IsCallBack) {
111 $this->getPage()->VolumeConfiguration->configure($param->CallbackParameter);
115 public function executeAction($action) {
116 $params = explode(';', $this->CheckedValues->Value);
120 for($i = 0; $i < count($params); $i++) {
121 $cmd = array('prune');
122 $cmd[] = 'volume="' . $params[$i] . '"';
125 $commands[] = implode(' ', $cmd);
127 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
128 $this->getPage()->Console->sendCommand(null, null);
132 for($i = 0; $i < count($params); $i++) {
133 $cmd = array('purge');
134 $cmd[] = 'volume="' . $params[$i] . '"';
137 $commands[] = implode(' ', $cmd);
139 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
140 $this->getPage()->Console->sendCommand(null, null);
144 for($i = 0; $i < count($params); $i++) {
145 $cmd = array('delete');
146 $cmd[] = 'volume="' . $params[$i] . '"';
149 $commands[] = implode(' ', $cmd);
151 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
152 $this->getPage()->Console->sendCommand(null, null);
156 $this->CheckedValues->Value = "";
159 public function formatVolumeField($name) {
160 if (strlen($name) > 20) {
161 $name = substr($name, 0, 7) . '...' . substr($name, -10);