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.TActiveLinkButton');
24 Prado::using('System.Web.UI.ActiveControls.TActiveRepeater');
25 Prado::using('Application.Web.Portlets.ResourceListTemplate');
27 class BaculaConfigResources extends ResourceListTemplate {
29 const CHILD_CONTROL = 'BaculaConfigDirectives';
31 public $resource_names = array();
33 private function getConfigData($host, $component_type) {
34 $params = array('config', $component_type);
35 $result = $this->Application->getModule('api')->get($params, $host, false);
37 if (is_object($result) && $result->error === 0 && is_array($result->output)) {
38 $config = $result->output;
43 public function loadConfig() {
44 $host = $this->getHost();
45 $component_type = $this->getComponentType();
46 $component_name = $this->getComponentName();
48 $config = $this->getConfigData($host, $component_type);
49 for ($i = 0; $i < count($config); $i++) {
50 $resource_type = $this->getConfigResourceType($config[$i]);
51 $resource_name = property_exists($config[$i]->{$resource_type}, 'Name') ? $config[$i]->{$resource_type}->Name : '';
54 'component_type' => $component_type,
55 'component_name' => $component_name,
56 'resource_type' => $resource_type,
57 'resource_name' => $resource_name
59 array_push($resources, $resource);
60 if (!array_key_exists($resource_type, $this->resource_names)) {
61 $this->resource_names[$resource_type] = array();
63 array_push($this->resource_names[$resource_type], $resource_name);
66 $this->RepeaterResources->DataSource = $resources;
67 $this->RepeaterResources->dataBind();
70 public function createResourceListElement($sender, $param) {
71 $control = $this->getChildControl($param->Item, self::CHILD_CONTROL);
72 if (is_object($control)) {
73 $control->setHost($param->Item->DataItem['host']);
74 $control->setComponentType($param->Item->DataItem['component_type']);
75 $control->setComponentName($param->Item->DataItem['component_name']);
76 $control->setResourceType($param->Item->DataItem['resource_type']);
77 $control->setResourceName($param->Item->DataItem['resource_name']);
78 $control->setResourceNames($this->resource_names);
82 public function getDirectives($sender, $param) {
83 $control = $this->getChildControl($sender->getParent(), self::CHILD_CONTROL);
84 if (is_object($control)) {
85 $control->raiseEvent('OnDirectiveListLoad', $this, null);