diff --git a/htdocs/core/conf.class.php b/htdocs/core/conf.class.php index fb02d5b1f14..2ef3d858f11 100644 --- a/htdocs/core/conf.class.php +++ b/htdocs/core/conf.class.php @@ -57,18 +57,18 @@ class Conf /** - * \brief Positionne toutes les variables de configuration + * \brief Load setup values into conf object * \param $db Handler d'acces base * \param $entity Id of company - * \return int < 0 si erreur, >= 0 si succes + * \return int < 0 if KO, >= 0 if OK */ - function setValues($db,$entity) + function setValues($db,$entity=1) { dol_syslog("Conf::setValues"); // Par defaut, a oui $this->global->PRODUIT_CONFIRM_DELETE_LINE=1; - + $this->entity = $entity; /* @@ -77,7 +77,7 @@ class Conf * - En $this->global->key=value */ $sql = "SELECT name, value, entity FROM ".MAIN_DB_PREFIX."const "; - $sql.= " WHERE entity = 0 OR entity = ".$entity; + $sql.= " WHERE entity = 0 OR entity = ".$this->entity; $result = $db->query($sql); if ($result) { @@ -88,7 +88,7 @@ class Conf { $objp = $db->fetch_object($result); $key=$objp->name; - $value=$objp->value; // Pas de stripslashes (ne s'applique pas sur lecture en base mais apres POST quand get_magic_quotes_gpc()==1) + $value=$objp->value; if ($key) { if (! defined("$key")) define ("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_FILE during install) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 486b8db3e82..43b82496e6e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -262,18 +262,23 @@ if (! isset($_SESSION["dol_login"])) if ($login) { $test=false; - $conf->authmode=$mode; // This properties is defined only when login + $conf->authmode=$mode; // This properties is defined only when logged + + // TODO Should not have setting and redirection header here. + // Cookie add must be set at same place than "New session for this login" + // and header call must be removed. Also entity must be set in session. // Call function to check entity if ($conf->multicompany->enabled && isset($_POST["entity"])) { $entitytotest=$_POST["entity"]; - + // Create entity cookie $entityCookieName = "DOLENTITYID_dolibarr"; if (!isset($HTTP_COOKIE_VARS[$entityCookieName])) { setcookie($entityCookieName, $entitytotest, 0, "/", "", 0); } + // Reload index.php $url=DOL_URL_ROOT."/index.php"; header("Location: ".$url); @@ -394,14 +399,14 @@ else } } -// Est-ce une nouvelle session +// Is it a new session ? if (! isset($_SESSION["dol_login"])) { $error=0; - // Nouvelle session pour ce login + // New session for this login $_SESSION["dol_login"]=$user->login; - + $_SESSION["dol_authmode"]=$conf->authmode; dol_syslog("This is a new started user session. _SESSION['dol_login']=".$_SESSION["dol_login"].' Session id='.session_id());