From: Tim Düsterhus Date: Tue, 3 Jul 2012 14:33:15 +0000 (+0200) Subject: Adding additional parameter `$hideSession` to SessionHandler::changeUser() X-Git-Tag: 2.0.0_Beta_1~1036 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e7fcae9d43363dc22ba8e3bd24f3b0476dba3266;p=GitHub%2FWoltLab%2FWCF.git Adding additional parameter `$hideSession` to SessionHandler::changeUser() When set to true the user-change is not reflected in the database. --- diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index 23c1818358..4ba79d24bc 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -463,11 +463,12 @@ class SessionHandler extends SingletonFactory { * logged in, after the login his old session is used to store his full data. * * @param User $user + * @param boolean $hideSession When set to true the database will not be updated. */ - public function changeUser(User $user) { + public function changeUser(User $user, $hideSession = false) { $sessionTable = call_user_func(array($this->sessionClassName, 'getDatabaseTableName')); - if ($user->userID) { + if ($user->userID && !$hideSession) { // user is not a guest, delete all other sessions of this user $sql = "DELETE FROM ".$sessionTable." WHERE sessionID <> ? @@ -479,12 +480,14 @@ class SessionHandler extends SingletonFactory { // update user reference $this->user = $user; - // update session - $sessionEditor = new $this->sessionEditorClassName($this->session); - $sessionEditor->update(array( - 'userID' => $this->user->userID, - 'username' => $this->user->username - )); + if (!$hideSession) { + // update session + $sessionEditor = new $this->sessionEditorClassName($this->session); + $sessionEditor->update(array( + 'userID' => $this->user->userID, + 'username' => $this->user->username + )); + } // reset caches $this->groupData = null;