From: Marcin Haba Date: Mon, 29 Apr 2019 04:57:45 +0000 (+0200) Subject: baculum: Fix #2466 add plugin directive support in fileset resource X-Git-Tag: Release-9.4.3~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02ca0127d16e0b940ee1783a0e9200ceadccd95c;p=thirdparty%2Fbacula.git baculum: Fix #2466 add plugin directive support in fileset resource --- diff --git a/gui/baculum/protected/Common/Class/Miscellaneous.php b/gui/baculum/protected/Common/Class/Miscellaneous.php index 0c18b1bd4..21f64439a 100644 --- a/gui/baculum/protected/Common/Class/Miscellaneous.php +++ b/gui/baculum/protected/Common/Class/Miscellaneous.php @@ -402,7 +402,7 @@ class Miscellaneous extends TModule { 'name' => $match['name'], 'type' => 'dir' ); - } elseif(preg_match('/^(?P\d+)\t(?P\d+)\t(?P\d+)\t(?P\d+)\t(?P[a-zA-z0-9\+\/\ ]+)\t(?P[^\/]+)$/', $list[$i], $match) == 1) { + } elseif(preg_match('/^(?P\d+)\t(?P\d+)\t(?P\d+)\t(?P\d+)\t(?P[a-zA-z0-9\+\-\/\ ]+)\t(?P[^\/]+)$/', $list[$i], $match) == 1) { if($match['name'] == '.') { continue; } diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo index 4f74e8b41..5c643256f 100644 Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/en/messages.po b/gui/baculum/protected/Web/Lang/en/messages.po index f8cc341c0..bfc857393 100644 --- a/gui/baculum/protected/Web/Lang/en/messages.po +++ b/gui/baculum/protected/Web/Lang/en/messages.po @@ -1988,3 +1988,8 @@ msgstr "Add exclude block" msgid "Add file/directory" msgstr "Add file/directory" +msgid "Plugins" +msgstr "Plugins" + +msgid "Add plugin" +msgstr "Add plugin" diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo index 5696e66f3..1845bf294 100644 Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/ja/messages.po b/gui/baculum/protected/Web/Lang/ja/messages.po index 31cb3f319..3600886f8 100644 --- a/gui/baculum/protected/Web/Lang/ja/messages.po +++ b/gui/baculum/protected/Web/Lang/ja/messages.po @@ -2089,3 +2089,8 @@ msgstr "Add exclude block" msgid "Add file/directory" msgstr "Add file/directory" +msgid "Add plugin" +msgstr "Add plugin" + +msgid "Plugins" +msgstr "Plugins" diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo index 2cbaf9dc9..7c49bdcfb 100644 Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pl/messages.po b/gui/baculum/protected/Web/Lang/pl/messages.po index 6be3f33a0..6d2796206 100644 --- a/gui/baculum/protected/Web/Lang/pl/messages.po +++ b/gui/baculum/protected/Web/Lang/pl/messages.po @@ -1995,3 +1995,8 @@ msgstr "Dodaj blok listy wykluczeń" msgid "Add file/directory" msgstr "Dodaj plik/katalog" +msgid "Add plugin" +msgstr "Dodaj wtyczkę" + +msgid "Plugins" +msgstr "Wtyczki" diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo index 954ed54d9..3e92bc033 100644 Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pt/messages.po b/gui/baculum/protected/Web/Lang/pt/messages.po index 3099b93ec..3a5bd66c2 100644 --- a/gui/baculum/protected/Web/Lang/pt/messages.po +++ b/gui/baculum/protected/Web/Lang/pt/messages.po @@ -2002,3 +2002,9 @@ msgstr "Excluir Arquivos" msgid "Add file/directory" msgstr "Arquivo/diretório" + +msgid "Add plugin" +msgstr "Add plugin" + +msgid "Plugins" +msgstr "Plugins" diff --git a/gui/baculum/protected/Web/Portlets/DirectiveFileSet.php b/gui/baculum/protected/Web/Portlets/DirectiveFileSet.php index 6b73d9d76..89fdb4b4b 100644 --- a/gui/baculum/protected/Web/Portlets/DirectiveFileSet.php +++ b/gui/baculum/protected/Web/Portlets/DirectiveFileSet.php @@ -56,6 +56,7 @@ class DirectiveFileSet extends DirectiveListTemplate { $directives = $this->getData(); $includes = array(); $file = array(); + $plugin = array(); $exclude = array(); $options = array(); if (!is_array($directives) || $directive_name === 'Exclude') { @@ -74,6 +75,10 @@ class DirectiveFileSet extends DirectiveListTemplate { $this->setFile($file, $name, $values); break; } + case 'Plugin': { + $this->setPlugin($plugin, $name, $values); + break; + } case 'Options': { $this->setOption($options, $name, $values); break; @@ -82,9 +87,10 @@ class DirectiveFileSet extends DirectiveListTemplate { } $includes[] = array( 'file' => $file, + 'plugin' => $plugin, 'options' => $options ); - $file = $options = array(); + $file = $plugin = $options = array(); } } elseif ($index === 'Exclude') { if (!key_exists('File', $subres)) { @@ -137,6 +143,41 @@ class DirectiveFileSet extends DirectiveListTemplate { } } + private function setPlugin(&$plugins, $name, $config) { + $host = $this->getHost(); + $component_type = $this->getComponentType(); + $component_name = $this->getComponentName(); + $resource_type = $this->getResourceType(); + $resource_name = $this->getResourceName(); + $directive_name = 'Plugin'; + $field_type = 'TextBox'; + $default_value = ''; + $required = false; + + for ($i = 0; $i < count($config); $i++) { + $plugins[] = array( + 'host' => $host, + 'component_type' => $component_type, + 'component_name' => $component_name, + 'resource_type' => $resource_type, + 'resource_name' => $resource_name, + 'directive_name' => $name, + 'directive_value' => $config[$i], + 'parent_name' => $name, + 'field_type' => $field_type, + 'default_value' => $default_value, + 'required' => $required, + 'data' => null, + 'resource' => null, + 'in_config' => true, + 'label' => $directive_name, + 'show' => true, + 'parent_name' => $name, + 'group_name' => $i + ); + } + } + private function setOption(&$options, $name, $config) { $misc = $this->getModule('misc'); $load_values = $this->getLoadValues(); @@ -281,6 +322,22 @@ class DirectiveFileSet extends DirectiveListTemplate { } $directive_values['Include'][$counter][$directive_name][] = $directive_value; } + $controls = $value->RepeaterFileSetPlugin->findControlsByType($this->directive_types[$i]); + for ($j = 0; $j < count($controls); $j++) { + $directive_name = $controls[$j]->getDirectiveName(); + $directive_value = $controls[$j]->getDirectiveValue(); + if (empty($directive_value)) { + // Include plugin directive removed + continue; + } + if (!key_exists($counter, $directive_values['Include'])) { + $directive_values['Include'][$counter] = array(); + } + if (!key_exists($directive_name, $directive_values['Include'][$counter])) { + $directive_values['Include'][$counter][$directive_name] = array(); + } + $directive_values['Include'][$counter][$directive_name][] = $directive_value; + } } for ($i = 0; $i < count($this->directive_list_types); $i++) { $controls = $value->RepeaterFileSetOptions->findControlsByType($this->directive_list_types[$i]); @@ -330,6 +387,8 @@ class DirectiveFileSet extends DirectiveListTemplate { $param->Item->RepeaterFileSetOptions->dataBind(); $param->Item->RepeaterFileSetInclude->DataSource = $param->Item->Data['file']; $param->Item->RepeaterFileSetInclude->dataBind(); + $param->Item->RepeaterFileSetPlugin->DataSource = $param->Item->Data['plugin']; + $param->Item->RepeaterFileSetPlugin->dataBind(); $param->Item->FileSetFileOptMenu->setItemIndex($param->Item->getItemIndex()); } @@ -372,6 +431,18 @@ class DirectiveFileSet extends DirectiveListTemplate { $this->loadConfig(); } + public function newIncludePlugin($sender, $param) { + $data = $this->getDirectiveValue(); + $inc_index = $sender->Parent->getItemIndex(); + $plugin_index = 0; + if (key_exists($inc_index, $data['Include']) && key_exists('Plugin', $data['Include'][$inc_index])) { + $plugin_index = count($data['Include'][$inc_index]['Plugin']); + } + $data['Include'][$inc_index]['Plugin'][$plugin_index] = ''; + $this->setData($data); + $this->loadConfig(); + } + public function newExcludeFile($sender, $param) { $data = $this->getDirectiveValue(); $file_index = 0; diff --git a/gui/baculum/protected/Web/Portlets/DirectiveFileSet.tpl b/gui/baculum/protected/Web/Portlets/DirectiveFileSet.tpl index 4524c47db..da25a10b5 100644 --- a/gui/baculum/protected/Web/Portlets/DirectiveFileSet.tpl +++ b/gui/baculum/protected/Web/Portlets/DirectiveFileSet.tpl @@ -27,6 +27,15 @@ + + +
+

<%[ Plugins ]%>

+ + +
+ +
diff --git a/gui/baculum/protected/Web/Portlets/NewFileSetFileOptMenu.tpl b/gui/baculum/protected/Web/Portlets/NewFileSetFileOptMenu.tpl index 2dd89c892..4de53da4d 100644 --- a/gui/baculum/protected/Web/Portlets/NewFileSetFileOptMenu.tpl +++ b/gui/baculum/protected/Web/Portlets/NewFileSetFileOptMenu.tpl @@ -28,5 +28,15 @@  <%[ Add options block ]%> +
  • +  <%[ Add plugin ]%> + +