]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Web/Portlets/MessageTypes.php
baculum: New Baculum API and Baculum Web
[bacula/bacula] / gui / baculum / protected / Web / Portlets / MessageTypes.php
1 <?php
2 /*
3  * Bacula(R) - The Network Backup Solution
4  * Baculum   - Bacula web interface
5  *
6  * Copyright (C) 2013-2017 Kern Sibbald
7  *
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.
11  *
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.
16  *
17  * This notice must be preserved when any source code is
18  * conveyed and/or propagated.
19  *
20  * Bacula(R) is a registered trademark of Kern Sibbald.
21  */
22
23
24 Prado::using('System.Web.Ui.ActiveControls.TActiveRepeater');
25 Prado::using('Application.Web.Portlets.DirectiveListTemplate');
26 Prado::using('Application.Web.Portlets.DirectiveBoolean');
27
28 class MessageTypes extends DirectiveListTemplate {
29
30         public function loadConfig() {
31                 $this->RepeaterMessageTypes->dataSource = $this->getData();
32                 $this->RepeaterMessageTypes->dataBind();
33         }
34
35         public function getDirectiveValues() {
36                 $type_controls = $this->RepeaterMessageTypes->findControlsByType('DirectiveBoolean');
37                 $is_all = false;
38                 $types = array();
39                 for ($i = 0; $i < count($type_controls); $i++) {
40                         $directive_name = $type_controls[$i]->getDirectiveName();
41                         $directive_value = $type_controls[$i]->getDirectiveValue();
42                         if (is_null($directive_value) || $directive_value === false) {
43                                 continue;
44                         }
45                         if ($directive_name === 'All' && $directive_value === true) {
46                                 $is_all = true;
47                         }
48                         $neg = $directive_name != 'All' && $directive_value === true && $is_all === true ? '!' : '';
49                         array_push($types, "{$neg}{$directive_name}");
50                 }
51                 return $types;
52         }
53
54         public function createTypeListElement($sender, $param) {
55                 $control = $this->getChildControl($param->Item, 'DirectiveBoolean');
56                 if (is_object($control)) {
57                         $control->setHost($param->Item->DataItem['host']);
58                         $control->setComponentType($param->Item->DataItem['component_type']);
59                         $control->setComponentName($param->Item->DataItem['component_name']);
60                         $control->setResourceType($param->Item->DataItem['resource_type']);
61                         $control->setResourceName($param->Item->DataItem['resource_name']);
62                         $control->setDirectiveName($param->Item->DataItem['directive_name']);
63                         $control->setDirectiveValue($param->Item->DataItem['directive_value']);
64                         $control->setDefaultValue($param->Item->DataItem['default_value']);
65                         $control->setRequired($param->Item->DataItem['required']);
66                         $control->setLabel($param->Item->DataItem['label']);
67                         $control->setData($param->Item->DataItem['directive_value']);
68                         $control->setInConfig($param->Item->DataItem['in_config']);
69                         $control->setShow($param->Item->DataItem['show']);
70                         $control->setParentName($param->Item->DataItem['parent_name']);
71                 }
72         }
73 }