Qual: We always save entity into session even if multicompany not used.

This commit is contained in:
Laurent Destailleur 2011-12-05 00:29:18 +01:00
parent 0c25c7cbc8
commit 17b4daa613
2 changed files with 7 additions and 12 deletions

View File

@ -308,10 +308,7 @@ $login='';
if (! defined('NOLOGIN'))
{
// $authmode lists the different means of identification to be tested in order of preference.
// Example: 'http'
// Example: 'dolibarr'
// Example: 'ldap'
// Example: 'http,forceuser'
// Example: 'http', 'dolibarr', 'ldap', 'http,forceuser'
// Authentication mode
if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr';
@ -545,7 +542,7 @@ if (! defined('NOLOGIN'))
$_SESSION["dol_screenwidth"]=isset($dol_screenwidth)?$dol_screenwidth:'';
$_SESSION["dol_screenheight"]=isset($dol_screenheight)?$dol_screenheight:'';
$_SESSION["dol_company"]=$conf->global->MAIN_INFO_SOCIETE_NOM;
if (! empty($conf->multicompany->enabled)) $_SESSION["dol_entity"]=$conf->entity;
$_SESSION["dol_entity"]=$conf->entity;
dol_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"].' Session id='.session_id());
$db->begin();

View File

@ -125,11 +125,11 @@ if (! defined('NOREQUIREUSER'))
if (! defined('NOREQUIREDB'))
{
// By default conf->entity is 1, but we change this if we ask another value.
if (session_id() && ! empty($_SESSION["dol_entity"])) // Entity inside an opened session
if (session_id() && ! empty($_SESSION["dol_entity"])) // Entity inside an opened session
{
$conf->entity = $_SESSION["dol_entity"];
}
elseif (! empty($_ENV["dol_entity"])) // Entity inside a CLI script
elseif (! empty($_ENV["dol_entity"])) // Entity inside a CLI script
{
$conf->entity = $_ENV["dol_entity"];
}
@ -137,24 +137,22 @@ if (! defined('NOREQUIREDB'))
{
$conf->entity = $_POST["entity"];
}
else
else // TODO Does this "else" still usefull ?
{
$prefix=dol_getprefix();
$entityCookieName = 'DOLENTITYID_'.$prefix;
if (! empty($_COOKIE[$entityCookieName]) && ! empty($conf->file->cookie_cryptkey)) // Just for view specific login page
if (! empty($_COOKIE[$entityCookieName]) && ! empty($conf->file->cookie_cryptkey)) // Just for view specific login page
{
include_once(DOL_DOCUMENT_ROOT."/core/class/cookie.class.php");
$lastuser = '';
$lastentity = '';
$entityCookie = new DolCookie($conf->file->cookie_cryptkey);
$cookieValue = $entityCookie->_getCookie($entityCookieName);
list($lastuser, $lastentity) = explode('|', $cookieValue);
$conf->entity = $lastentity;
}
}
//print "Will work with data into entity instance number '".$conf->entity."'";
// Here we read database (llx_const table) and define $conf->global->XXX var.