Try to add hook in main login page
This commit is contained in:
parent
585f386ba3
commit
0dbef2d784
@ -162,7 +162,15 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod
|
||||
function dol_loginfunction($langs,$conf,$mysoc)
|
||||
{
|
||||
global $dolibarr_main_demo,$db;
|
||||
global $smartphone,$mc;
|
||||
global $smartphone,$hookmanager;
|
||||
|
||||
// Instantiate hooks of thirdparty module only if not already define
|
||||
if (! is_object($hookmanager))
|
||||
{
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
||||
$hookmanager=new HookManager($db);
|
||||
}
|
||||
$hookmanager->initHooks(array('mainloginpage'));
|
||||
|
||||
$langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang'));
|
||||
$langs->setDefaultLang($langcode);
|
||||
@ -229,37 +237,18 @@ function dol_loginfunction($langs,$conf,$mysoc)
|
||||
$demologin=$tab[0];
|
||||
$demopassword=$tab[1];
|
||||
}
|
||||
|
||||
// Entity cookie
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
$lastuser = '';
|
||||
$lastentity = $_POST['entity'];
|
||||
|
||||
if (! empty($conf->global->MULTICOMPANY_COOKIE_ENABLED))
|
||||
{
|
||||
$prefix=dol_getprefix();
|
||||
$entityCookieName = 'DOLENTITYID_'.$prefix;
|
||||
if (isset($_COOKIE[$entityCookieName]))
|
||||
{
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/cookie.class.php");
|
||||
|
||||
$cryptkey = (! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' );
|
||||
|
||||
$entityCookie = new DolCookie($cryptkey);
|
||||
$cookieValue = $entityCookie->_getCookie($entityCookieName);
|
||||
list($lastuser, $lastentity) = explode('|', $cookieValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Execute hook getLoginPageOptions
|
||||
// Should be an array with differents options in $hookmanager->resArray
|
||||
$parameters=array('entity' => $_POST['entity']);
|
||||
$hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
// Login
|
||||
$login = (!empty($lastuser)?$lastuser:(GETPOST("username","alpha",2)?GETPOST("username","alpha",2):$demologin));
|
||||
$login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username","alpha",2) ? GETPOST("username","alpha",2) : $demologin));
|
||||
$password = $demopassword;
|
||||
|
||||
// Show logo (search in order: small company logo, large company logo, theme logo, common logo)
|
||||
$width=0;
|
||||
$rowspan=2;
|
||||
$urllogo=DOL_URL_ROOT.'/theme/login_logo.png';
|
||||
|
||||
if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
|
||||
@ -281,14 +270,6 @@ function dol_loginfunction($langs,$conf,$mysoc)
|
||||
|
||||
}
|
||||
|
||||
// Entity field
|
||||
$select_entity='';
|
||||
if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_HIDE_LOGIN_COMBOBOX))
|
||||
{
|
||||
$rowspan++;
|
||||
$select_entity = $mc->select_entities($lastentity, 'entity', ' tabindex="3"', 1);
|
||||
}
|
||||
|
||||
// Security graphical code
|
||||
$captcha=0;
|
||||
$captcha_refresh='';
|
||||
|
||||
@ -234,14 +234,18 @@ jQuery(document).ready(function () {
|
||||
<input id="password" name="password" class="flat" type="password" size="15" maxlength="30" value="<?php echo $password; ?>" tabindex="2" />
|
||||
</td></tr>
|
||||
|
||||
<?php if ($select_entity) { ?>
|
||||
<tr><td valign="top" nowrap="nowrap"> <strong><?php echo $langs->trans('Entity'); ?></strong> </td>
|
||||
<td valign="top" nowrap="nowrap">
|
||||
<?php echo $select_entity; ?>
|
||||
</td></tr>
|
||||
<?php } ?>
|
||||
<?php
|
||||
if (! empty($hookmanager->resArray['options'])) {
|
||||
foreach ($hookmanager->resArray['options'] as $option)
|
||||
{
|
||||
echo '<!-- Option by hook -->';
|
||||
echo $option;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ($captcha) { ?>
|
||||
<!-- Captcha -->
|
||||
<tr><td valign="middle" nowrap="nowrap"> <b><?php echo $langs->trans('SecurityCode'); ?></b></td>
|
||||
<td valign="top" nowrap="nowrap" align="left" class="none">
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user