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')) if (! defined('NOLOGIN'))
{ {
// $authmode lists the different means of identification to be tested in order of preference. // $authmode lists the different means of identification to be tested in order of preference.
// Example: 'http' // Example: 'http', 'dolibarr', 'ldap', 'http,forceuser'
// Example: 'dolibarr'
// Example: 'ldap'
// Example: 'http,forceuser'
// Authentication mode // Authentication mode
if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr'; 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_screenwidth"]=isset($dol_screenwidth)?$dol_screenwidth:'';
$_SESSION["dol_screenheight"]=isset($dol_screenheight)?$dol_screenheight:''; $_SESSION["dol_screenheight"]=isset($dol_screenheight)?$dol_screenheight:'';
$_SESSION["dol_company"]=$conf->global->MAIN_INFO_SOCIETE_NOM; $_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()); dol_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"].' Session id='.session_id());
$db->begin(); $db->begin();

View File

@ -125,11 +125,11 @@ if (! defined('NOREQUIREUSER'))
if (! defined('NOREQUIREDB')) if (! defined('NOREQUIREDB'))
{ {
// By default conf->entity is 1, but we change this if we ask another value. // 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"]; $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"]; $conf->entity = $_ENV["dol_entity"];
} }
@ -137,24 +137,22 @@ if (! defined('NOREQUIREDB'))
{ {
$conf->entity = $_POST["entity"]; $conf->entity = $_POST["entity"];
} }
else else // TODO Does this "else" still usefull ?
{ {
$prefix=dol_getprefix(); $prefix=dol_getprefix();
$entityCookieName = 'DOLENTITYID_'.$prefix; $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"); include_once(DOL_DOCUMENT_ROOT."/core/class/cookie.class.php");
$lastuser = ''; $lastuser = '';
$lastentity = ''; $lastentity = '';
$entityCookie = new DolCookie($conf->file->cookie_cryptkey); $entityCookie = new DolCookie($conf->file->cookie_cryptkey);
$cookieValue = $entityCookie->_getCookie($entityCookieName); $cookieValue = $entityCookie->_getCookie($entityCookieName);
list($lastuser, $lastentity) = explode('|', $cookieValue); list($lastuser, $lastentity) = explode('|', $cookieValue);
$conf->entity = $lastentity; $conf->entity = $lastentity;
} }
} }
//print "Will work with data into entity instance number '".$conf->entity."'"; //print "Will work with data into entity instance number '".$conf->entity."'";
// Here we read database (llx_const table) and define $conf->global->XXX var. // Here we read database (llx_const table) and define $conf->global->XXX var.