]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Fix numeric password setting bug reported by Heitor Faria
authorMarcin Haba <marcin.haba@bacula.pl>
Thu, 9 Nov 2017 20:14:23 +0000 (21:14 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Thu, 9 Nov 2017 20:14:23 +0000 (21:14 +0100)
Add integer type control.

18 files changed:
gui/baculum/protected/API/Class/BaculaSetting.php
gui/baculum/protected/Web/Data/data_desc.json
gui/baculum/protected/Web/Lang/en/messages.mo
gui/baculum/protected/Web/Lang/en/messages.po
gui/baculum/protected/Web/Lang/ja/messages.mo
gui/baculum/protected/Web/Lang/ja/messages.po
gui/baculum/protected/Web/Lang/pl/messages.mo
gui/baculum/protected/Web/Lang/pl/messages.po
gui/baculum/protected/Web/Lang/pt/messages.mo
gui/baculum/protected/Web/Lang/pt/messages.po
gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.php
gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.tpl
gui/baculum/protected/Web/Portlets/DirectiveFileSet.php
gui/baculum/protected/Web/Portlets/DirectiveFileSet.tpl
gui/baculum/protected/Web/Portlets/DirectiveInteger.php [new file with mode: 0644]
gui/baculum/protected/Web/Portlets/DirectiveInteger.tpl [new file with mode: 0644]
gui/baculum/protected/Web/Portlets/DirectiveRunscript.php
gui/baculum/themes/Baculum-v1/bacula-config.css

index 48ccaa9798fc2602adc72e3793356ad6b07e51c7..5ce79633f28e83d86ddd9c9423d58f5f6449dfb1 100644 (file)
@@ -385,7 +385,7 @@ class BaculaSetting extends APIModule {
                $directive_value = null;
                if (is_bool($value)) {
                        $directive_value = ($value === true) ? 'yes' : 'no';
-               } elseif (is_numeric($value)) {
+               } elseif (is_int($value)) {
                        $directive_value = $value;
                } elseif (is_string($value)) {
                        $value = str_replace('"', '\"', $value);
index e3ff2f9a0cfe0894b2dbc451bbedc69099e0a674..74a331789994e82718b3069d898fbcd214e1d498 100644 (file)
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 1,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "MaximumReloadRequests": {
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 32,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "MaximumConsoleConnections": {
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 20,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "Password": {
                                "Required": true,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 9102,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "fdpassword": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 1,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "TlsAuthenticate": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 1,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "MaximumSpawnedJobs": {
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 600,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "RescheduleOnError": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "Priority": {
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 10,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "AllowMixedPriority": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 9103,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "sdaddress": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 1,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "MaximumConcurrentReadjobs": {
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "sddport": {
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "TlsAuthenticate": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "dbpassword": {
                                "Required": false,
                                                "Required": false,
                                                "ValueType": "int32",
                                                "DefaultValue": 0,
-                                               "FieldType": "TextBox"
+                                               "FieldType": "Integer"
                                        }
                                }
                        },
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "MaximumVolumeJobs": {
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "MaximumVolumeFiles": {
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "MaximumVolumeBytes": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "int32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "Maximum": {
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 2147483647,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "WrapCounter": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 1,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "MaximumSpawnedJobs": {
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 600,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "RescheduleOnError": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "Priority": {
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 10,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "AllowMixedPriority": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 20,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "ClientConnectTimeout": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "VolumePollInterval": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "SpoolDirectory": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "MaximumPartSize": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 20,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "Messages": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "PkiSignatures": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 9101,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "TlsAuthenticate": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 20,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "Messages": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 0,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "PkiSignatures": {
                                "Required": false,
                                "Required": false,
                                "ValueType": "pint32",
                                "DefaultValue": 9101,
-                               "FieldType": "TextBox"
+                               "FieldType": "Integer"
                        },
                        "Address": {
                                "Required": false,
index b0210ab00fd5acd19a096164b8bf9b264a6e0cca..3d7319622b01c4eb4215e6a21d177524156845d1 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ
index 2e7e436ed739400b5a6f5106ded1a9c3cdd2311c..b588d8968e6e640434528f6028192b2a648a45f6 100644 (file)
@@ -1414,3 +1414,9 @@ msgstr "API host:"
 
 msgid "Select host"
 msgstr "Select host"
+
+msgid "Field required."
+msgstr "Field required."
+
+msgid "Invalid value. Integer value required."
+msgstr "Invalid value. Integer value required."
index 2063d2634f26dcee0dcfcc1708dc17054ad17227..02a0e29f7d1591b4d3721a73c30346d864605a2c 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ
index 044f2d8618de90c38f949f90ab00640ab15ca2e8..a4eab462d5076eb5a953a2496364900110790b57 100644 (file)
@@ -1165,3 +1165,9 @@ msgstr "OAuth2 scopes (space separated):"
 
 msgid "Please enter OAuth2 scopes."
 msgstr "Please enter OAuth2 scopes."
+
+msgid "Field required."
+msgstr "Field required."
+
+msgid "Invalid value. Integer value required."
+msgstr "Invalid value. Integer value required."
index bfc88600fa298670828ac7f466209ec423f7686a..15040e068183a1772bcddf94cbb455177bc322a6 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ
index eb416ab76a2fec84015b1120eea9bd387be1b0da..84f967b446f65dc97ab5f3466a0acb5854ef1aa4 100644 (file)
@@ -1421,3 +1421,9 @@ msgstr "Zakresy OAuth2 (oddzielone spacją):"
 
 msgid "Please enter OAuth2 scopes."
 msgstr "Proszę wprowadzić zakresy OAuth2."
+
+msgid "Field required."
+msgstr "Pole wymagane."
+
+msgid "Invalid value. Integer value required."
+msgstr "Niepoprawna wartość. Wymagane jest podanie liczby całkowitej."
index cc548ba2d621e1f9a2b80a969d3893fadb833196..2b901fd01cd575a1897f0adfbfa33904718ed835 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ
index dda003ead0f8481cd1e983a4875d9db1d4108070..09cb86ec7efd9fba243230df822d4d87da5aa0bd 100644 (file)
@@ -1429,3 +1429,9 @@ msgstr "Escopo OAuth2 (separado por espaço):"
 
 msgid "Please enter OAuth2 scopes."
 msgstr "Informe o escopo OAuth2."
+
+msgid "Field required."
+msgstr "Field required."
+
+msgid "Invalid value. Integer value required."
+msgstr "Invalid value. Integer value required."
index 45906f07ec08d17da5dae2f5f837695d5d5d3cbe..befe637a22271b3debc6cd7fd5c75ce07ae04fa5 100644 (file)
@@ -25,6 +25,8 @@ Prado::using('System.Web.UI.ActiveControls.TActiveLabel');
 Prado::using('Application.Web.Portlets.BConditional');
 Prado::using('Application.Web.Portlets.DirectiveListTemplate');
 Prado::using('Application.Web.Portlets.DirectiveBoolean');
+Prado::using('Application.Web.Portlets.DirectiveComboBox');
+Prado::using('Application.Web.Portlets.DirectiveInteger');
 Prado::using('Application.Web.Portlets.DirectiveText');
 Prado::using('Application.Web.Portlets.DirectiveTimePeriod');
 Prado::using('Application.Web.Portlets.DirectiveRunscript');
@@ -42,6 +44,7 @@ class BaculaConfigDirectives extends DirectiveListTemplate {
        private $directive_types = array(
                'DirectiveBoolean',
                'DirectiveComboBox',
+               'DirectiveInteger',
                'DirectiveText',
                'DirectiveTimePeriod'
        );
@@ -243,6 +246,8 @@ class BaculaConfigDirectives extends DirectiveListTemplate {
                                }
                                if ($this->directive_types[$i] === 'DirectiveBoolean') {
                                        settype($default_value, 'bool');
+                               } elseif ($this->directive_types[$i] === 'DirectiveInteger') {
+                                       settype($directive_value, 'int');
                                }
                                if ($directive_value === $default_value && $in_config === false) {
                                        // value the same as default value, skip it
index 3c25ff40b78aa17dad365de2f822d544b823b0be..3c0c69f27803b0d85e26db3594123d568539d09e 100644 (file)
                                                <com:Application.Web.Portlets.DirectiveText />
                                        </prop:TrueTemplate>
                                </com:Application.Web.Portlets.BConditional>
+                               <com:Application.Web.Portlets.BConditional BCondition="<%#($this->DataItem['field_type'] === 'Integer')%>">
+                                       <prop:TrueTemplate>
+                                               <com:Application.Web.Portlets.DirectiveInteger />
+                                       </prop:TrueTemplate>
+                               </com:Application.Web.Portlets.BConditional>
                                <com:Application.Web.Portlets.BConditional BCondition="<%#($this->DataItem['field_type'] === 'CheckBox')%>">
                                        <prop:TrueTemplate>
                                                <com:Application.Web.Portlets.DirectiveBoolean />
index 538d9b7906e6ea8c9ee9d7bbdd5b8455bdeffa33..e0244e2be6adbc01998d2ccbc3bf3bc9dc81a80d 100644 (file)
 Prado::using('System.Web.UI.ActiveControls.TActiveRepeater');
 Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
 Prado::using('Application.Web.Portlets.DirectiveListTemplate');
+Prado::using('Application.Web.Portlets.DirectiveBoolean');
+Prado::using('Application.Web.Portlets.DirectiveText');
+Prado::using('Application.Web.Portlets.DirectiveComboBox');
+Prado::using('Application.Web.Portlets.DirectiveInteger');
 
 class DirectiveFileSet extends DirectiveListTemplate {
 
@@ -31,7 +35,8 @@ class DirectiveFileSet extends DirectiveListTemplate {
        private $directive_types = array(
                'DirectiveBoolean',
                'DirectiveText',
-               'DirectiveComboBox'
+               'DirectiveComboBox',
+               'DirectiveInteger'
        );
 
        private $directive_inc_exc_types = array(
index 5efe8a5bbf7a3f211c57162b85e39b7c60bd3acc..548fbb0c8c298869b650d5bf72d4601dffdd21eb 100644 (file)
                                <com:Application.Web.Portlets.DirectiveBoolean />
                        </prop:TrueTemplate>
                </com:Application.Web.Portlets.BConditional>
+               <com:Application.Web.Portlets.BConditional BCondition="<%#($this->DataItem['field_type'] === 'Integer')%>">
+                       <prop:TrueTemplate>
+                               <com:Application.Web.Portlets.DirectiveInteger />
+                       </prop:TrueTemplate>
+               </com:Application.Web.Portlets.BConditional>
        </prop:ItemTemplate>
        <prop:FooterTemplate>
        </fieldset>
diff --git a/gui/baculum/protected/Web/Portlets/DirectiveInteger.php b/gui/baculum/protected/Web/Portlets/DirectiveInteger.php
new file mode 100644 (file)
index 0000000..e55df26
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum   - Bacula web interface
+ *
+ * Copyright (C) 2013-2017 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+Prado::using('System.Web.UI.ActiveControls.TActiveLabel');
+Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
+Prado::using('Application.Web.Portlets.DirectiveTemplate');
+
+class DirectiveInteger extends DirectiveTemplate {
+
+       public function getValue() {
+               $value = $this->Directive->getText();
+               if (empty($value)) {
+                       $value = null;
+               }
+               return $value;
+       }
+
+       public function createDirective() {
+               $this->Label->Text = $this->getLabel();
+               $directive_value = $this->getDirectiveValue();
+               $default_value = $this->getDefaultValue();
+               settype($default_value, 'int');
+               if ($this->getInConfig() === false) {
+                       if ($default_value !== 0) {
+                               $directive_value = $default_value;
+                       } else {
+                               $directive_value = '';
+                       }
+               }
+               $this->Directive->setText($directive_value);
+               $validate = $this->getRequired();
+               $this->DirectiveValidator->setVisible($validate);
+       }
+}
+?>
diff --git a/gui/baculum/protected/Web/Portlets/DirectiveInteger.tpl b/gui/baculum/protected/Web/Portlets/DirectiveInteger.tpl
new file mode 100644 (file)
index 0000000..56ffbee
--- /dev/null
@@ -0,0 +1,29 @@
+<div class="line<%=!$this->display_directive ? ' hide' : '';%>">
+       <div class="text"><com:TActiveLabel ID="Label" ActiveControl.EnableUpdate="false" Visible="<%=$this->display_directive%>" />:</div>
+       <div class="field directive_value">
+               <com:TActiveTextBox ID="Directive"
+                       OnTextChanged="saveValue"
+                       CssClass="ftype_integer"
+                       Visible="<%=$this->display_directive%>"
+                       ActiveControl.EnableUpdate="false"
+                       AutoTrim="true"
+               />
+               <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/switch.png" class="reset_btn" onclick="document.getElementById('<%=$this->Directive->ClientID%>').value = '<%=$this->getDefaultValue() === 0 ? '' : $this->getDefaultValue()%>';" alt="<%[ Reset to default value ]%>" title="<%[ Reset to default value ]%>" />
+               <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/icon_err.png" class="remove_btn" onclick="document.getElementById('<%=$this->Directive->ClientID%>').value = '';" alt="<%[ Remove directive ]%>" title="<%[ Remove directive ]%>" />
+               <com:TRequiredFieldValidator
+                       ID="DirectiveValidator"
+                       ValidationGroup="Directive"
+                       Display="Dynamic"
+                       ControlToValidate="Directive"
+                       FocusOnError="true"
+                       Text="<%[ Field required. ]%>"
+                       Enabled="<%=$this->getRequired() && $this->getShow()%>"
+               />
+               <com:TDataTypeValidator
+                       ValidationGroup="Directive"
+                       ControlToValidate="Directive"
+                       DataType="Integer"
+                       Text="<%[ Invalid value. Integer value required. ]%>"
+               />
+       </div>
+</div>
index 9c10e1612c7b7249cf92c026815b5b6afee214c0..2e6b227f835d578d8f25af7ca7efb3d6e449ca97 100644 (file)
@@ -21,6 +21,9 @@
  */
 
 Prado::using('Application.Web.Portlets.DirectiveListTemplate');
+Prado::using('Application.Web.Portlets.DirectiveBoolean');
+Prado::using('Application.Web.Portlets.DirectiveText');
+Prado::using('Application.Web.Portlets.DirectiveComboBox');
 
 class DirectiveRunscript extends DirectiveListTemplate {
 
index bf5a964eda121a7851a192f8a5e047672cd5e349..daad1260822b2b411d5c2b36e175caa42894f32f 100644 (file)
@@ -93,7 +93,7 @@ div.directive_setting fieldset {
        margin-left: 64px;
 }
 
-input.ftype_textbox, input.ftype_timeperiod, select.ftype_combobox {
+input.ftype_textbox, input.ftype_timeperiod, input.ftype_integer, select.ftype_combobox {
        font-size: 12px;
 }
 
@@ -110,6 +110,10 @@ select.ftype_combobox {
        min-width: 265px;
 }
 
+input.ftype_integer {
+       width: 161px;
+}
+
 table.host td:nth-of-type(1) {
        width: 205px;
 }