mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-09-04 10:14:13 +08:00
[Legacy] Load new preferences if not same user
This commit is contained in:
parent
70b442a613
commit
1de29d158d
1 changed files with 12 additions and 2 deletions
|
@ -98,10 +98,15 @@ class UserPreference extends SugarBean
|
||||||
$name,
|
$name,
|
||||||
$category = 'global'
|
$category = 'global'
|
||||||
) {
|
) {
|
||||||
global $sugar_config;
|
global $sugar_config, $current_user;
|
||||||
|
|
||||||
$user = $this->_userFocus;
|
$user = $this->_userFocus;
|
||||||
|
|
||||||
|
if ($user->user_name !== $current_user->user_name){
|
||||||
|
$this->loadPreferences($category);
|
||||||
|
return $user->user_preferences[$category][$name] ?? $this->getDefaultPreference($name, $category);
|
||||||
|
}
|
||||||
|
|
||||||
// if the unique key in session doesn't match the app or prefereces are empty
|
// if the unique key in session doesn't match the app or prefereces are empty
|
||||||
if (!isset($_SESSION[$user->user_name.'_PREFERENCES'][$category]) || (!empty($_SESSION['unique_key']) && $_SESSION['unique_key'] != $sugar_config['unique_key'])) {
|
if (!isset($_SESSION[$user->user_name.'_PREFERENCES'][$category]) || (!empty($_SESSION['unique_key']) && $_SESSION['unique_key'] != $sugar_config['unique_key'])) {
|
||||||
$this->loadPreferences($category);
|
$this->loadPreferences($category);
|
||||||
|
@ -203,13 +208,18 @@ class UserPreference extends SugarBean
|
||||||
public function loadPreferences(
|
public function loadPreferences(
|
||||||
$category = 'global'
|
$category = 'global'
|
||||||
) {
|
) {
|
||||||
global $sugar_config;
|
global $sugar_config, $current_user;
|
||||||
|
|
||||||
$user = $this->_userFocus;
|
$user = $this->_userFocus;
|
||||||
|
|
||||||
if ($user->object_name != 'User') {
|
if ($user->object_name != 'User') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($user->user_name !== $current_user->user_name) {
|
||||||
|
return $this->reloadPreferences($category);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($user->id) && (!isset($_SESSION[$user->user_name . '_PREFERENCES'][$category]) || (!empty($_SESSION['unique_key']) && $_SESSION['unique_key'] != $sugar_config['unique_key']))) {
|
if (!empty($user->id) && (!isset($_SESSION[$user->user_name . '_PREFERENCES'][$category]) || (!empty($_SESSION['unique_key']) && $_SESSION['unique_key'] != $sugar_config['unique_key']))) {
|
||||||
// cn: moving this to only log when valid - throwing errors on install
|
// cn: moving this to only log when valid - throwing errors on install
|
||||||
return $this->reloadPreferences($category);
|
return $this->reloadPreferences($category);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue