store undelUserIds as array in settings class

This commit is contained in:
Uwe Steinmann 2021-06-26 11:57:02 +02:00
parent 1eb2c3ed9f
commit ece38b9d22
4 changed files with 18 additions and 14 deletions

View File

@ -61,7 +61,7 @@ class Settings { /* {{{ */
// maximum amount of bytes a user may consume, 0 = unlimited
var $_quota = 0;
// comma separated list of undeleteable user ids
var $_undelUserIds = 0;
var $_undelUserIds = array();
// Restricted access: only allow users to log in if they have an entry in
// the local database (irrespective of successful authentication with LDAP).
var $_restricted = true;
@ -574,7 +574,8 @@ class Settings { /* {{{ */
$this->_loginFailure = intval($tab["loginFailure"]);
$this->_autoLoginUser = intval($tab["autoLoginUser"]);
$this->_quota = intval($tab["quota"]);
$this->_undelUserIds = strval($tab["undelUserIds"]);
if(trim(strval($tab["undelUserIds"])))
$this->_undelUserIds = explode(',',strval($tab["undelUserIds"]));
$this->_encryptionKey = strval($tab["encryptionKey"]);
$this->_cookieLifetime = intval($tab["cookieLifetime"]);
$this->_defaultAccessDocs = intval($tab["defaultAccessDocs"]);
@ -930,7 +931,7 @@ class Settings { /* {{{ */
$this->setXMLAttributValue($node, "loginFailure", $this->_loginFailure);
$this->setXMLAttributValue($node, "autoLoginUser", $this->_autoLoginUser);
$this->setXMLAttributValue($node, "quota", $this->_quota);
$this->setXMLAttributValue($node, "undelUserIds", $this->_undelUserIds);
$this->setXMLAttributValue($node, "undelUserIds", implode(',', $this->_undelUserIds));
$this->setXMLAttributValue($node, "encryptionKey", $this->_encryptionKey);
$this->setXMLAttributValue($node, "cookieLifetime", $this->_cookieLifetime);
$this->setXMLAttributValue($node, "defaultAccessDocs", $this->_defaultAccessDocs);

View File

@ -79,6 +79,15 @@ if ($action == "saveSettings")
if(isset($_POST[$name]) && !in_array($name, $settings->_hiddenConfFields))
$settings->{"_".$name} = intval($_POST[$name]);
}
function setArrayValue($name) {
global $_POST, $settings;
if(isset($_POST[$name]) && !in_array($name, $settings->_hiddenConfFields)) {
if($_POST[$name])
$settings->{"_".$name} = $_POST[$name];
else
$settings->{"_".$name} = array();
}
}
function setDirValue($name) {
global $_POST, $settings;
if(isset($_POST[$name]) && !in_array($name, $settings->_hiddenConfFields))
@ -94,10 +103,7 @@ if ($action == "saveSettings")
setStrValue('language');
setStrValue('dateformat');
setStrValue('datetimeformat');
if(empty($_POST["availablelanguages"]))
$settings->_availablelanguages = array();
else
$settings->_availablelanguages = $_POST["availablelanguages"];
setArrayValue('availablelanguages');
setStrValue('theme');
setBoolValue('overrideTheme');
setBoolValue('onePageMode');
@ -113,10 +119,7 @@ if ($action == "saveSettings")
// SETTINGS - SITE - EDITION
setBoolValue('strictFormCheck');
setBoolValue('inlineEditing');
if(empty($_POST["noDocumentFormFields"]))
$settings->_noDocumentFormFields = array();
else
$settings->_noDocumentFormFields = $_POST["noDocumentFormFields"];
setArrayValue('noDocumentFormFields');
$settings->setViewOnlineFileTypesFromString($_POST["viewOnlineFileTypes"]);
$settings->setEditOnlineFileTypesFromString($_POST["editOnlineFileTypes"]);
setBoolValue('enableConverting');
@ -188,7 +191,7 @@ if ($action == "saveSettings")
setIntValue("loginFailure");
setIntValue("autoLoginUser");
setIntValue("quota");
$settings->_undelUserIds = !empty($_POST["undelUserIds"]) ? (is_array($_POST["undelUserIds"]) ? implode(',', $_POST["undelUserIds"]) : strval($_POST["undelUserIds"])) : '';
setArrayValue("undelUserIds");
setStrValue("encryptionKey");
setIntValue("cookieLifetime");
setIntValue("defaultAccessDocs");

View File

@ -159,7 +159,7 @@ else if ($action == "removeuser") {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id"));
}
if(in_array($userid, explode(',', $settings->_undelUserIds))) {
if(in_array($userid, $settings->_undelUserIds)) {
UI::exitError(getMLText("admin_tools"),getMLText("cannot_delete_user"));
}

View File

@ -60,7 +60,7 @@ if($view) {
$view->setParam('passwordexpiration', $settings->_passwordExpiration);
$view->setParam('httproot', $settings->_httpRoot);
$view->setParam('enableuserimage', $settings->_enableUserImage);
$view->setParam('undeluserids', explode(',', $settings->_undelUserIds));
$view->setParam('undeluserids', $settings->_undelUserIds);
$view->setParam('workflowmode', $settings->_workflowMode);
$view->setParam('quota', $settings->_quota);
$view->setParam('strictformcheck', $settings->_strictFormCheck);