From ffe3e8e43dd40b0d0fe2b6f0ff007908c3e3d080 Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Thu, 13 Apr 2017 21:03:19 +0200 Subject: [PATCH] * [MOD] Set default user's preferences on demo mode --- inc/SP/Controller/LoginController.class.php | 8 +++++++- inc/SP/Core/Language.class.php | 4 +--- inc/SP/Core/UI/Theme.class.php | 4 +--- inc/SP/DataModel/UserPreferencesData.class.php | 4 ++-- inc/SP/Util/Util.class.php | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/inc/SP/Controller/LoginController.class.php b/inc/SP/Controller/LoginController.class.php index a54895bf..2b8756e9 100644 --- a/inc/SP/Controller/LoginController.class.php +++ b/inc/SP/Controller/LoginController.class.php @@ -46,6 +46,7 @@ use SP\Core\SessionUtil; use SP\DataModel\TrackData; use SP\DataModel\UserLoginData; use SP\DataModel\UserPassRecoverData; +use SP\DataModel\UserPreferencesData; use SP\Http\JsonResponse; use SP\Http\Request; use SP\Log\Log; @@ -385,10 +386,15 @@ class LoginController */ protected function loadUserPreferences() { + if (Checks::demoIsEnabled()) { + Session::setUserPreferences(new UserPreferencesData()); + } else { + Session::setUserPreferences($this->UserData->getUserPreferences()); + } + Language::setLanguage(true); DiFactory::getTheme()->initTheme(true); - Session::setUserPreferences($this->UserData->getUserPreferences()); Session::setSessionType(Session::SESSION_INTERACTIVE); Session::setAuthCompleted(true); diff --git a/inc/SP/Core/Language.class.php b/inc/SP/Core/Language.class.php index 948bde77..4587b554 100644 --- a/inc/SP/Core/Language.class.php +++ b/inc/SP/Core/Language.class.php @@ -93,9 +93,7 @@ class Language */ private function getUserLang() { - $userId = Session::getUserData()->getUserId(); - - return ($userId > 0) ? UserPreferences::getItem()->getById($userId)->getLang() : ''; + return (Session::getUserData()->getUserId() > 0) ? Session::getUserPreferences()->getLang() : ''; } /** diff --git a/inc/SP/Core/UI/Theme.class.php b/inc/SP/Core/UI/Theme.class.php index 3d7ee56f..0ce0587b 100644 --- a/inc/SP/Core/UI/Theme.class.php +++ b/inc/SP/Core/UI/Theme.class.php @@ -101,9 +101,7 @@ class Theme implements ThemeInterface */ protected function getUserTheme() { - $userId = Session::getUserData()->getUserId(); - - return ($userId > 0) ? UserPreferences::getItem()->getById($userId)->getTheme() : ''; + return (Session::getUserData()->getUserId() > 0) ? Session::getUserPreferences()->getTheme() : ''; } /** diff --git a/inc/SP/DataModel/UserPreferencesData.class.php b/inc/SP/DataModel/UserPreferencesData.class.php index cb280ad3..ebb1a334 100644 --- a/inc/SP/DataModel/UserPreferencesData.class.php +++ b/inc/SP/DataModel/UserPreferencesData.class.php @@ -231,11 +231,11 @@ class UserPreferencesData * @return void * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.sleep */ - function __wakeup() + public function __wakeup() { // Para realizar la conversión de nombre de propiedades que empiezan por _ foreach (get_object_vars($this) as $name => $value) { - if (substr($name, 0, 1) === '_') { + if (strpos($name, '_') === 0) { $newName = substr($name, 1); $this->$newName = $value; diff --git a/inc/SP/Util/Util.class.php b/inc/SP/Util/Util.class.php index 5e502983..7e4cab06 100644 --- a/inc/SP/Util/Util.class.php +++ b/inc/SP/Util/Util.class.php @@ -407,7 +407,7 @@ class Util */ public static function getVersion($retBuild = false, $normalized = false) { - $build = 17041302; + $build = 17041303; $version = [2, 1, 6]; if ($normalized === true) {