Add: view last user and last entity in login page if cookie is enabled
This commit is contained in:
parent
2e48d482aa
commit
1420692e53
@ -129,10 +129,31 @@ function dol_loginfunction($langs,$conf,$mysoc)
|
|||||||
$demopassword=$tab[1];
|
$demopassword=$tab[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY))
|
||||||
|
{
|
||||||
|
$lastuser = '';
|
||||||
|
$lastentity = '';
|
||||||
|
|
||||||
|
if (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE))
|
||||||
|
{
|
||||||
|
$entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]);
|
||||||
|
if (isset($_COOKIE[$entityCookieName]))
|
||||||
|
{
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/core/cookie.class.php");
|
||||||
|
|
||||||
|
$cryptkey = (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE_CRYPTKEY) ? $conf->global->MAIN_MULTICOMPANY_COOKIE_CRYPTKEY : '' );
|
||||||
|
|
||||||
|
$entityCookie = new DolCookie($cryptkey);
|
||||||
|
$cookieValue = $entityCookie->_getCookie($entityCookieName);
|
||||||
|
list($lastuser, $lastentity) = split('\|', $cookieValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Login field
|
// Login field
|
||||||
print '<td align="left" valign="bottom"> <b>'.$langs->trans("Login").'</b> </td>';
|
print '<td align="left" valign="bottom"> <b>'.$langs->trans("Login").'</b> </td>';
|
||||||
print '<td valign="bottom"><input type="text" id="username" name="username" class="flat" size="15" maxlength="25" value="';
|
print '<td valign="bottom"><input type="text" id="username" name="username" class="flat" size="15" maxlength="25" value="';
|
||||||
print (isset($_REQUEST["username"])?$_REQUEST["username"]:$demologin);
|
print (!empty($lastuser)?$lastuser:(isset($_REQUEST["username"])?$_REQUEST["username"]:$demologin));
|
||||||
print '" tabindex="1" /></td>';
|
print '" tabindex="1" /></td>';
|
||||||
|
|
||||||
// Show logo (search in order: small company logo, large company logo, theme logo, common logo)
|
// Show logo (search in order: small company logo, large company logo, theme logo, common logo)
|
||||||
@ -168,21 +189,6 @@ function dol_loginfunction($langs,$conf,$mysoc)
|
|||||||
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY))
|
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY))
|
||||||
{
|
{
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
$lastentity = '';
|
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE))
|
|
||||||
{
|
|
||||||
$entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]);
|
|
||||||
if (isset($_COOKIE[$entityCookieName]))
|
|
||||||
{
|
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/core/cookie.class.php");
|
|
||||||
|
|
||||||
$cryptkey = (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE_CRYPTKEY) ? $conf->global->MAIN_MULTICOMPANY_COOKIE_CRYPTKEY : '' );
|
|
||||||
|
|
||||||
$entityCookie = new DolCookie($cryptkey);
|
|
||||||
$lastentity = $entityCookie->_getCookie($entityCookieName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: creer class
|
//TODO: creer class
|
||||||
$entity = array('1'=>'company1','2'=>'company2');
|
$entity = array('1'=>'company1','2'=>'company2');
|
||||||
|
|||||||
@ -445,7 +445,7 @@ if (! isset($_SESSION["dol_login"]))
|
|||||||
{
|
{
|
||||||
include_once(DOL_DOCUMENT_ROOT."/core/cookie.class.php");
|
include_once(DOL_DOCUMENT_ROOT."/core/cookie.class.php");
|
||||||
|
|
||||||
$entity = $_POST["entity"];
|
$entity = $_SESSION["dol_login"].'|'.$_POST["entity"];
|
||||||
$entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]);
|
$entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]);
|
||||||
// TTL : sera defini dans la page de config multicompany
|
// TTL : sera defini dans la page de config multicompany
|
||||||
$ttl = (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE_TTL) ? $conf->global->MAIN_MULTICOMPANY_COOKIE_TTL : time()+60*60*8 );
|
$ttl = (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE_TTL) ? $conf->global->MAIN_MULTICOMPANY_COOKIE_TTL : time()+60*60*8 );
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user