handle role in addUser() propperly

This commit is contained in:
Uwe Steinmann 2022-02-17 12:29:37 +01:00
parent b57dc78e2a
commit b9c613ff83

View File

@ -2866,10 +2866,12 @@ class SeedDMS_Core_DMS {
if (is_object($this->getUserByLogin($login))) { if (is_object($this->getUserByLogin($login))) {
return false; return false;
} }
if(is_object($role)) if(!is_object($role)) {
$role = $role->getID(); if($role == '')
elseif($role == '') $role = SeedDMS_Core_Role::getInstance(3, $this);
$role = '3'; else
$role = SeedDMS_Core_Role::getInstance($role, $this);
}
if(trim($pwdexpiration) == '' || trim($pwdexpiration) == 'never') { if(trim($pwdexpiration) == '' || trim($pwdexpiration) == 'never') {
$pwdexpiration = 'NULL'; $pwdexpiration = 'NULL';
} elseif(trim($pwdexpiration) == 'now') { } elseif(trim($pwdexpiration) == 'now') {
@ -2877,7 +2879,7 @@ class SeedDMS_Core_DMS {
} else { } else {
$pwdexpiration = $db->qstr($pwdexpiration); $pwdexpiration = $db->qstr($pwdexpiration);
} }
$queryStr = "INSERT INTO `tblUsers` (`login`, `pwd`, `fullName`, `email`, `language`, `theme`, `comment`, `role`, `hidden`, `disabled`, `pwdExpiration`, `quota`, `homefolder`) VALUES (".$db->qstr($login).", ".$db->qstr($pwd).", ".$db->qstr($fullName).", ".$db->qstr($email).", '".$language."', '".$theme."', ".$db->qstr($comment).", '".intval($role)."', '".intval($isHidden)."', '".intval($isDisabled)."', ".$pwdexpiration.", '".intval($quota)."', ".($homefolder ? intval($homefolder) : "NULL").")"; $queryStr = "INSERT INTO `tblUsers` (`login`, `pwd`, `fullName`, `email`, `language`, `theme`, `comment`, `role`, `hidden`, `disabled`, `pwdExpiration`, `quota`, `homefolder`) VALUES (".$db->qstr($login).", ".$db->qstr($pwd).", ".$db->qstr($fullName).", ".$db->qstr($email).", '".$language."', '".$theme."', ".$db->qstr($comment).", '".intval($role->getId())."', '".intval($isHidden)."', '".intval($isDisabled)."', ".$pwdexpiration.", '".intval($quota)."', ".($homefolder ? intval($homefolder) : "NULL").")";
$res = $this->db->getResult($queryStr); $res = $this->db->getResult($queryStr);
if (!$res) if (!$res)
return false; return false;