LSsession: fix saving context info method to keep existing other info

This commit is contained in:
Benjamin Renard 2023-04-20 17:45:41 +02:00
parent db491f51e7
commit 069dac2afe
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -878,7 +878,7 @@ class LSsession {
self :: loadLSprofiles(); self :: loadLSprofiles();
self :: loadLSaccess(); self :: loadLSaccess();
self :: loadLSaddonsViewsAccess(); self :: loadLSaddonsViewsAccess();
$_SESSION['LSsession']=self :: getContextInfos(); self :: saveContextInfos();
} }
LStemplate :: assign('LSsession_username',self :: getLSuserObject() -> getDisplayName()); LStemplate :: assign('LSsession_username',self :: getLSuserObject() -> getDisplayName());
@ -966,7 +966,7 @@ class LSsession {
self :: loadLSaddonsViewsAccess(); self :: loadLSaddonsViewsAccess();
LStemplate :: assign('LSsession_username',self :: getLSuserObject() -> getDisplayName()); LStemplate :: assign('LSsession_username',self :: getLSuserObject() -> getDisplayName());
LStemplate :: assign('globalSearch', self :: globalSearch()); LStemplate :: assign('globalSearch', self :: globalSearch());
$_SESSION['LSsession']=self :: getContextInfos(); self :: saveContextInfos();
return true; return true;
} }
} }
@ -1260,6 +1260,21 @@ class LSsession {
); );
} }
/**
* Save context information in PHP session
*
* @author Benjamin Renard <brenard@easter-eggs.com
*
* @return void
*/
private static function saveContextInfos() {
$_SESSION['LSsession'] = (
isset($_SESSION['LSsession']) && is_array($_SESSION['LSsession'])?
array_merge($_SESSION['LSsession'], self :: getContextInfos()):
self :: getContextInfos()
);
}
/** /**
* Retrieve connected user LSobject (as reference) * Retrieve connected user LSobject (as reference)
* *
@ -1354,7 +1369,7 @@ class LSsession {
if(self :: loadLSprofiles()) { if(self :: loadLSprofiles()) {
self :: loadLSaccess(); self :: loadLSaccess();
self :: loadLSaddonsViewsAccess(); self :: loadLSaddonsViewsAccess();
$_SESSION['LSsession']=self :: getContextInfos(); self :: saveContextInfos();
self :: log_debug("changeAuthUser(): authenticated user successfully updated."); self :: log_debug("changeAuthUser(): authenticated user successfully updated.");
return true; return true;
} }