Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/user_sql.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Łojewski <marcin.lojewski@mlojewski.me>2018-12-25 12:01:53 +0300
committerMarcin Łojewski <marcin.lojewski@mlojewski.me>2018-12-25 12:01:53 +0300
commit7f84113bca305b16a8520dfc5baf66fa14e6106b (patch)
treea806aafd700df0cc62330a66a36f608b89d01d31
parenta3a2a90d875f5549f0a331eb0bd654b33a907aab (diff)
Handle 0s and 1s
-rw-r--r--js/settings.js24
-rw-r--r--lib/Controller/SettingsController.php2
-rw-r--r--lib/Properties.php41
3 files changed, 50 insertions, 17 deletions
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("<div><label for=\"opt-crypto_param_" + index
- + "\"><span>" + data.data[index]["name"]
- + "</span><input 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></div>");
+ var param = $("<div></div>");
+ var label = $("<label></label>").attr({for: "opt-crypto_param_" + index});
+ var title = $("<span></span>").text(data.data[index]["name"]);
+ var input = $("<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;
@@ -117,6 +120,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.
*
* @return array Array containing strings of the 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;