3 * Bacula® - The Network Backup Solution
4 * Baculum - Bacula web interface
6 * Copyright (C) 2013-2014 Marcin Haba
8 * The main author of Baculum is Marcin Haba.
9 * The main author of Bacula is Kern Sibbald, with contributions from many
10 * 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 * Bacula® is a registered trademark of Kern Sibbald.
20 Prado::using('System.Web.UI.ActiveControls.TActiveDataGrid');
21 Prado::using('System.Web.UI.ActiveControls.TActiveRepeater');
22 Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
23 Prado::using('System.Web.UI.ActiveControls.TActivePanel');
24 Prado::using('System.Web.UI.ActiveControls.TActiveHiddenField');
25 Prado::using('System.Web.UI.ActiveControls.TCallback');
26 Prado::using('Application.Portlets.ISlideWindow');
27 Prado::using('Application.Portlets.Portlets');
29 class VolumeList extends Portlets implements ISlideWindow {
38 public function setID($id) {
42 public function getID($hideAutoID = true) {
46 public function setButtonID($id) {
47 $this->buttonID = $id;
50 public function getButtonID() {
51 return $this->buttonID;
54 public function setWindowTitle($param) {
55 $this->windowTitle = $param;
58 public function getWindowTitle() {
59 return $this->windowTitle;
62 public function onLoad($param) {
63 parent::onLoad($param);
67 public function prepareData($forceReload = false) {
68 $allowedButtons = array('MediaBtn', 'ReloadVolumes');
69 if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) {
70 if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) {
71 $params = $this->getUrlParams('volumes', $this->getPage()->VolumeWindow->ID);
72 array_push($params, '?showpools=1');
73 $volumes = $this->Application->getModule('api')->get($params);
74 $isDetailView = $_SESSION['view' . $this->getPage()->VolumeWindow->ID] == 'details';
75 if($isDetailView === true) {
76 $this->RepeaterShow->Visible = false;
77 $this->DataGridShow->Visible = true;
78 $this->DataGrid->DataSource = $this->Application->getModule('misc')->objectToArray($volumes->output);
79 $this->DataGrid->dataBind();
82 $this->Repeater->DataSource = $volumes->output;
83 $this->Repeater->dataBind();
84 $this->RepeaterShow->Visible = true;
85 $this->DataGridShow->Visible = false;
91 protected function sortData($data, $key, $id) {
92 if($this->getSortOrder($id) == parent::SORT_DESC) {
95 $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] < $b["pool"]["'.$key.'"]) ? 1 : -1;}');
97 $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] < $b["'.$key.'"]) ? 1 : -1;}');
102 $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] > $b["pool"]["'.$key.'"]) ? 1 : -1;}');
104 $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] > $b["'.$key.'"]) ? 1 : -1;}');
107 usort($data,$compare);
111 public function sortDataGrid($sender, $param) {
112 $params = $this->getUrlParams('volumes', $this->getPage()->VolumeWindow->ID);
113 array_push($params, '?showpools=1');
114 $data = $this->Application->getModule('api')->get($params)->output;
115 $data = $this->Application->getModule('misc')->objectToArray($data);
116 $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);
117 $this->DataGrid->dataBind();
120 public function configure($sender, $param) {
121 if($this->Page->IsCallBack) {
122 $this->getPage()->VolumeConfiguration->configure($param->CallbackParameter);
126 public function executeAction($action) {
127 $params = explode(';', $this->CheckedValues->Value);
131 for($i = 0; $i < count($params); $i++) {
132 $cmd = array('prune');
133 $cmd[] = 'volume="' . $params[$i] . '"';
136 $commands[] = implode(' ', $cmd);
138 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
139 $this->getPage()->Console->sendCommand(null, null);
143 for($i = 0; $i < count($params); $i++) {
144 $cmd = array('purge');
145 $cmd[] = 'volume="' . $params[$i] . '"';
148 $commands[] = implode(' ', $cmd);
150 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
151 $this->getPage()->Console->sendCommand(null, null);
155 for($i = 0; $i < count($params); $i++) {
156 $cmd = array('delete');
157 $cmd[] = 'volume="' . $params[$i] . '"';
160 $commands[] = implode(' ', $cmd);
162 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
163 $this->getPage()->Console->sendCommand(null, null);
167 $this->CheckedValues->Value = "";