diff --git a/js/settings.js b/js/settings.js index 979770b..cf49ac5 100644 --- a/js/settings.js +++ b/js/settings.js @@ -73,13 +73,23 @@ user_sql.adminSettingsUI = function () { if (data.status === "success") { for (var index = 0, length = data.data.length; index < length; ++index) { - content.append("
"); + var param = $(""); + var label = $("").attr({for: "opt-crypto_param_" + index}); + var title = $("").text(data.data[index]["name"]); + var input = $("").attr({ + type: "number", + id: "opt-crypto_param_" + index, + name: "opt-crypto_param_" + index, + step: 1, + min: data.data[index]["min"], + max: data.data[index]["max"], + value: data.data[index]["value"] + }); + + label.append(title); + param.append(label); + param.append(input); + content.append(param); content.show(); } } diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 5532f23..70de2f5 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -399,7 +399,7 @@ class SettingsController extends Controller "CRYPTO_PARAM_" . $key )]; - if (!empty($param)) { + if (!is_null($param)) { $value->value = $param; } } diff --git a/lib/Properties.php b/lib/Properties.php index b030b82..6e20ef8 100644 --- a/lib/Properties.php +++ b/lib/Properties.php @@ -70,7 +70,8 @@ class Properties implements \ArrayAccess */ public function __construct( $AppName, IConfig $config, ILogger $logger, Cache $cache - ) { + ) + { $this->appName = $AppName; $this->config = $config; $this->logger = $logger; @@ -99,10 +100,12 @@ class Properties implements \ArrayAccess foreach ($params as $param) { $value = $this->config->getAppValue($this->appName, $param, null); - if ($value === App::FALSE_VALUE) { - $value = false; - } elseif ($value === App::TRUE_VALUE) { - $value = true; + if ($this->isBooleanParam($param)) { + if ($value === App::FALSE_VALUE) { + $value = false; + } elseif ($value === App::TRUE_VALUE) { + $value = true; + } } $this->data[$param] = $value; @@ -116,6 +119,24 @@ class Properties implements \ArrayAccess ); } + /** + * Is given parameter a boolean parameter. + * + * @param $param string Parameter name. + * + * @return bool Is a boolean parameter. + */ + private function isBooleanParam($param) + { + return in_array( + $param, [ + Opt::APPEND_SALT, Opt::CASE_INSENSITIVE_USERNAME, + Opt::NAME_CHANGE, Opt::PASSWORD_CHANGE, Opt::PREPEND_SALT, + Opt::REVERSE_ACTIVE, Opt::USE_CACHE + ] + ); + } + /** * Return an array with all supported parameters. * @@ -186,10 +207,12 @@ class Properties implements \ArrayAccess { $this->config->setAppValue($this->appName, $offset, $value); - if ($value === App::FALSE_VALUE) { - $value = false; - } elseif ($value === App::TRUE_VALUE) { - $value = true; + if ($this->isBooleanParam($offset)) { + if ($value === App::FALSE_VALUE) { + $value = false; + } elseif ($value === App::TRUE_VALUE) { + $value = true; + } } $this->data[$offset] = $value;