From 17b4daa6134d905d4945947ccc903f83cdaa4442 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Dec 2011 00:29:18 +0100 Subject: [PATCH] Qual: We always save entity into session even if multicompany not used. --- htdocs/main.inc.php | 7 ++----- htdocs/master.inc.php | 12 +++++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f017b66968e..c6555ca0a0c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -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(); diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index d995a768d99..892655272df 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -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.