diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 37299554e..0c50735b0 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -2866,10 +2866,12 @@ class SeedDMS_Core_DMS { if (is_object($this->getUserByLogin($login))) { return false; } - if(is_object($role)) - $role = $role->getID(); - elseif($role == '') - $role = '3'; + if(!is_object($role)) { + if($role == '') + $role = SeedDMS_Core_Role::getInstance(3, $this); + else + $role = SeedDMS_Core_Role::getInstance($role, $this); + } if(trim($pwdexpiration) == '' || trim($pwdexpiration) == 'never') { $pwdexpiration = 'NULL'; } elseif(trim($pwdexpiration) == 'now') { @@ -2877,7 +2879,7 @@ class SeedDMS_Core_DMS { } else { $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); if (!$res) return false;