diff options
| author | lsces <lester@lsces.co.uk> | 2026-04-05 11:09:56 +0100 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2026-04-05 11:09:56 +0100 |
| commit | c012e3f539bdd682450adab47c4dbcc271b787a5 (patch) | |
| tree | 179efb1c91315a6bb5c0c19299fb265edcde5f02 | |
| parent | 571e6c18b95d320de082f4c97eb98698db1bbdb4 (diff) | |
| download | users-c012e3f539bdd682450adab47c4dbcc271b787a5.tar.gz users-c012e3f539bdd682450adab47c4dbcc271b787a5.tar.bz2 users-c012e3f539bdd682450adab47c4dbcc271b787a5.zip | |
Some tweaks to bring RoleUser in line with BitUser ... It may be more practical going forward to split this into two packages but there is a lot of common stuff.
| -rwxr-xr-x | includes/classes/RolePermUser.php | 7 | ||||
| -rwxr-xr-x | includes/classes/RoleUser.php | 9 |
2 files changed, 9 insertions, 7 deletions
diff --git a/includes/classes/RolePermUser.php b/includes/classes/RolePermUser.php index c3e9b15..18eced2 100755 --- a/includes/classes/RolePermUser.php +++ b/includes/classes/RolePermUser.php @@ -532,9 +532,9 @@ class RolePermUser extends RoleUser { * * @param int $pUserId User ID * @param mixed $pRoleMixed A single role ID or an array of role IDs - * @return array|bool Either an ADO RecordSet (success) or false (failure). + * @return bool Either an ADO RecordSet (success) or false (failure). */ - public static function addUserToRole( ?int $pUserId, array|int $pRoleMixed ): array|bool { + public static function addUserToRole( ?int $pUserId, array|int $pRoleMixed ): bool { global $gBitUser; $result = false; if( BitBase::verifyId( $pUserId ) && !empty( $pRoleMixed )) { @@ -557,7 +557,8 @@ class RolePermUser extends RoleUser { } if( !$isInRole ) { $query = "INSERT INTO `".BIT_DB_PREFIX."users_roles_map` (`user_id`,`role_id`) VALUES(?,?)"; - $result = $gBitUser->mDb->query( $query, [ $pUserId, $roleId ] ); + $gBitUser->mDb->query( $query, [ $pUserId, $roleId ] ); + $result = true; } } } diff --git a/includes/classes/RoleUser.php b/includes/classes/RoleUser.php index 73b69f2..f5147ef 100755 --- a/includes/classes/RoleUser.php +++ b/includes/classes/RoleUser.php @@ -347,6 +347,7 @@ class RoleUser extends \Bitweaver\Liberty\LibertyMime { $pParamHash['registration_date'] = date( "U" ); } $pParamHash['user_store']['registration_date'] = $pParamHash['registration_date']; + $pParamHash['user_store']['registration_ip'] = $pParamHash['registration_ip']; if( !empty( $pParamHash['email'] ) && empty($this->mErrors['email']) ) { $pParamHash['user_store']['email'] = substr( $pParamHash['email'], 0, 200 ) ; @@ -1210,7 +1211,7 @@ class RoleUser extends \Bitweaver\Liberty\LibertyMime { if( $gBitSystem->isFeatureActive( 'users_remember_me' ) && isset( $_REQUEST['rme'] ) && $_REQUEST['rme'] == 'on' ) { $cookieTime = (int)( time() + (int)$gBitSystem->getConfig( 'users_remember_time', 86400 )); $cookiePath = $gBitSystem->getConfig( 'cookie_path', $cookiePath ); - $cookieDomain = $gBitSystem->getConfig( 'cookie_domain', $cookieDomain, parse_url(BIT_ROOT_URL, PHP_URL_HOST) ); + $cookieDomain = $gBitSystem->getConfig( 'cookie_domain', $cookieDomain ?? parse_url(BIT_ROOT_URL, PHP_URL_HOST) ); } } setcookie( $siteCookie, $pCookie, [ @@ -2761,10 +2762,10 @@ class RoleUser extends \Bitweaver\Liberty\LibertyMime { */ public function userExists( $pUserMixed ) { $ret = false; - if ( is_array( $pUserMixed ) ) { + if ( \is_array( $pUserMixed ) ) { if( $cur = current( $pUserMixed ) ) { - $conditionSql = (is_numeric( $cur )) ? " `".key( $pUserMixed )."` " : " UPPER(`".key( $pUserMixed )."`)"; - $query = "SELECT user_id FROM `".BIT_DB_PREFIX."users`".$conditionSql; + $conditionSql = (is_numeric( $cur )) ? " `".key( $pUserMixed )."` " : " `".key( $pUserMixed )."`"; + $query = "SELECT `user_id` FROM `".BIT_DB_PREFIX."users_users` WHERE $conditionSql = ?"; $ret = $this->mDb->getOne( $query, [ strtoupper( $cur ) ] ); } } |
