Skip to content
Snippets Groups Projects
Commit 194cc073 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Rename the dol_loginfunction2 into dol_loginfunction to keep only one...

Rename the dol_loginfunction2 into dol_loginfunction to keep only one function. This function can support smarty templates and php template.
parent 557e4268
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,9 @@ header("Content-type: text/html; charset=".$conf->file->character_set_client);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Ce DTD est KO car inhibe document.body.scrollTop ->
<!-- print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; -->
<!-- BEGIN TEMPLATE -->
<html>
......@@ -55,10 +58,7 @@ function donnefocus() {
}
</script>
<?php
if ($main_html_header)
echo $main_html_header;
?>
<?php echo $conf->global->MAIN_HTML_HEADER ?>
<!-- HTTP_USER_AGENT = <?php echo $_SERVER['HTTP_USER_AGENT']; ?> -->
</head>
......@@ -107,7 +107,7 @@ function donnefocus() {
<table style="width: 100px;"><tr>
<td><input id="securitycode" class="flat" type="text" size="6" maxlength="5" name="code" tabindex="4"></td>
<td><img src="<?php echo $dol_url_root; ?>/lib/antispamimage.php" border="0" width="128" height="36"></td>
<td><img src="<?php echo DOL_URL_ROOT ?>/lib/antispamimage.php" border="0" width="128" height="36"></td>
<td><a href="<?php echo $php_self; ?>"><?php echo $captcha_refresh; ?></a></td>
</tr></table>
......@@ -124,7 +124,7 @@ function donnefocus() {
if ($forgetpasslink || $helpcenterlink) {
echo '<tr><td colspan="3" align="center">';
if ($forgetpasslink) {
echo '<a style="color: #888888; font-size: 10px" href="'.$dol_url_root.'/user/passwordforgotten.php">(';
echo '<a style="color: #888888; font-size: 10px" href="'.DOL_URL_ROOT.'/user/passwordforgotten.php">(';
echo $langs->trans('PasswordForgotten');
if (! $helpcenterlink) {
echo ')';
......@@ -133,7 +133,7 @@ function donnefocus() {
}
if ($helpcenterlink) {
echo '<a style="color: #888888; font-size: 10px" href="'.$dol_url_root.'/support/index.php" target="_blank">';
echo '<a style="color: #888888; font-size: 10px" href="'.DOL_URL_ROOT.'/support/index.php" target="_blank">';
if ($forgetpasslink) {
echo '&nbsp;-&nbsp;';
} else {
......@@ -165,11 +165,11 @@ function donnefocus() {
<?php if ($main_google_ad_client) { ?>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = <?php echo $main_google_ad_client ?>;
/* {$main_google_ad_width}x{$main_google_ad_height}, {$main_google_ad_name} */
google_ad_slot = <?php echo $main_google_ad_slot ?>;
google_ad_width = <?php echo $main_google_ad_width ?>;
google_ad_height = <?php echo $main_google_ad_height ?>;
google_ad_client = <?php echo $conf->global->MAIN_GOOGLE_AD_CLIENT ?>;
/* {$conf->global->MAIN_GOOGLE_AD_WIDTH}x{$conf->global->MAIN_GOOGLE_AD_HEIGHT}, {$conf->global->MAIN_GOOGLE_AD_NAME} */
google_ad_slot = <?php echo $conf->global->MAIN_GOOGLE_AD_SLOT ?>;
google_ad_width = <?php echo $conf->global->MAIN_GOOGLE_AD_WIDTH ?>;
google_ad_height = <?php echo $conf->global->MAIN_GOOGLE_AD_HEIGHT ?>;
//-->
</script>
<script type="text/javascript"
......@@ -178,14 +178,11 @@ function donnefocus() {
</div>
<?php } ?>
<!-- authentication mode = {$main_authentication} -->
<!-- cookie name used for this session = {$session_name} -->
<!-- urlfrom in this session = {$smarty.session.urlfrom} -->
<!-- authentication mode = <?php echo $main_authentication ?> -->
<!-- cookie name used for this session = <?php echo $session_name ?> -->
<!-- urlfrom in this session = <?php echo $_SESSION["urlfrom"] ?> -->
<?php
if ($main_html_footer)
echo $main_html_footer;
?>
<?php echo $conf->global->MAIN_HTML_FOOTER; ?>
</body>
</html>
......
......@@ -32,7 +32,7 @@
* \param mysoc Company object
* \remarks You must change HTML code in this page to change design of logon page.
*/
function dol_loginfunction($langs,$conf,$mysoc)
function dol_loginfunction_old($langs,$conf,$mysoc)
{
global $dolibarr_main_demo,$db;
......@@ -333,12 +333,10 @@ function dol_loginfunction($langs,$conf,$mysoc)
* \param langs Lang object
* \param conf Conf object
* \param mysoc Company object
* \remarks Test for smarty integration.
*/
function dol_loginfunction2($langs,$conf,$mysoc)
function dol_loginfunction($langs,$conf,$mysoc)
{
global $dolibarr_main_demo,$db;
global $smarty;
$langcode=(empty($_GET["lang"])?'auto':$_GET["lang"]);
$langs->setDefaultLang($langcode);
......@@ -347,47 +345,39 @@ function dol_loginfunction2($langs,$conf,$mysoc)
$langs->load("other");
$langs->load("help");
$smarty->assign('langs', $langs);
if (! empty($conf->global->MAIN_HTML_HEADER)) $smarty->assign('main_html_header', $conf->global->MAIN_HTML_HEADER);
$main_authentication=$conf->file->main_authentication;
$session_name=session_name();
$php_self = $_SERVER['PHP_SELF'];
$php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:'';
$smarty->assign('php_self', $php_self);
$smarty->assign('character_set_client',$conf->file->character_set_client);
// Select templates
if ($conf->browser->phone)
{
if (file_exists(DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone))
{
$smarty->template_dir = DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone."/templates/";
$smarty->assign('theme', 'default');
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone."/templates/";
}
else
{
$smarty->template_dir = DOL_DOCUMENT_ROOT."/theme/phones/others/templates/";
$template_dir=DOL_DOCUMENT_ROOT."/theme/phones/others/templates/";
}
}
else
{
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/templates/login.tpl"))
{
$smarty->template_dir = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/templates/";
$template_dir=DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/templates/";
}
else
{
$smarty->template_dir = DOL_DOCUMENT_ROOT."/core/templates/";
$template_dir=DOL_DOCUMENT_ROOT.'/core/templates/';
}
$conf->css = "theme/".$conf->theme."/".$conf->theme.".css";
$conf->css.=".php?lang=".$langs->defaultlang;
$smarty->assign('conf_css', DOL_URL_ROOT.'/'.$conf->css);
}
$smarty->assign('dol_url_root', DOL_URL_ROOT);
// Set cookie for timeout management
$sessiontimeout='DOLSESSTIMEOUT_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]);
if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', 0);
......@@ -395,21 +385,19 @@ function dol_loginfunction2($langs,$conf,$mysoc)
if (! empty($_REQUEST["urlfrom"])) $_SESSION["urlfrom"]=$_REQUEST["urlfrom"];
else unset($_SESSION["urlfrom"]);
if (! $_REQUEST["username"]) $smarty->assign('focus_element', 'username');
else $smarty->assign('focus_element', 'password');
if (! $_REQUEST["username"]) $focus_element='username';
else $focus_element='password';
$login_background=DOL_URL_ROOT.'/theme/login_background.png';
if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/login_background.png'))
{
$smarty->assign('login_background', DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png');
$login_background=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_background.png';
}
// Title
$title='Dolibarr '.DOL_VERSION;
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE;
$smarty->assign('title', $title);
$demologin='';
$demopassword='';
if (! empty($dolibarr_main_demo))
......@@ -444,8 +432,6 @@ function dol_loginfunction2($langs,$conf,$mysoc)
// Login
$login = (!empty($lastuser)?$lastuser:(isset($_REQUEST["username"])?$_REQUEST["username"]:$demologin));
$password = $demopassword;
$smarty->assign('login', $login);
$smarty->assign('password', $password);
// Show logo (search in order: small company logo, large company logo, theme logo, common logo)
$width=0;
......@@ -468,11 +454,8 @@ function dol_loginfunction2($langs,$conf,$mysoc)
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $rowspan++;
$smarty->assign('logo', $urllogo);
$smarty->assign('logo_width', $width);
$smarty->assign('logo_rowspan', $rowspan);
// Entity field
$select_entity='';
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY))
{
require_once(DOL_DOCUMENT_ROOT.'/multicompany/multicompany.class.php');
......@@ -481,30 +464,30 @@ function dol_loginfunction2($langs,$conf,$mysoc)
$mc->getEntities();
$select_entity=$mc->select_entities($mc->entities,$lastentity,'tabindex="3"');
$smarty->assign('select_entity', $select_entity);
}
// Security graphical code
$captcha=0;
$captcha_refresh='';
if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA))
{
$captcha=1;
$smarty->assign('captcha', $captcha);
$smarty->assign('captcha_refresh', img_refresh());
$captcha_refresh=img_refresh();
}
// Extra link
$forgetpasslink=0;
$helpcenterlink=0;
if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK))
{
if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK))
{
$forgetpasslink=1;
$smarty->assign('forgetpasslink', $forgetpasslink);
}
if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK))
{
$helpcenterlink=1;
$smarty->assign('helpcenterlink', $helpcenterlink);
}
}
......@@ -517,9 +500,48 @@ function dol_loginfunction2($langs,$conf,$mysoc)
$conf->global->MAIN_HOME=preg_replace('/__\('.$reg[1].'\)__/i',$langs->trans($reg[1]),$conf->global->MAIN_HOME);
$i++;
}
$smarty->assign('main_home', nl2br($conf->global->MAIN_HOME));
}
// START SMARTY
if ($conf->global->MAIN_SMARTY)
{
global $smarty;
$smarty->assign('conf_css', DOL_URL_ROOT.'/'.$conf->css);
$smarty->assign('langs', $langs);
if (! empty($conf->global->MAIN_HTML_HEADER)) $smarty->assign('main_html_header', $conf->global->MAIN_HTML_HEADER);
$smarty->assign('php_self', $php_self);
$smarty->assign('character_set_client',$conf->file->character_set_client);
$smarty->assign('theme', 'default');
$smarty->template_dir=$template_dir;
$smarty->assign('dol_url_root', DOL_URL_ROOT);
$smarty->assign('focus_element', $focus_element);
$smarty->assign('login_background', $login_background);
$smarty->assign('title', $title);
$smarty->assign('login', $login);
$smarty->assign('password', $password);
$smarty->assign('logo', $urllogo);
$smarty->assign('logo_width', $width);
$smarty->assign('logo_rowspan', $rowspan);
$smarty->assign('select_entity', $select_entity);
$smarty->assign('captcha', $captcha);
$smarty->assign('captcha_refresh', $captcha_refresh);
$smarty->assign('forgetpasslink', $forgetpasslink);
$smarty->assign('helpcenterlink', $helpcenterlink);
$smarty->assign('main_home', nl2br($conf->global->MAIN_HOME));
// Google Adsense (ex: demo mode)
if (! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))
{
......@@ -534,9 +556,8 @@ function dol_loginfunction2($langs,$conf,$mysoc)
}
if (! empty($conf->global->MAIN_HTML_FOOTER)) $smarty->assign('main_html_footer', $conf->global->MAIN_HTML_FOOTER);
$smarty->assign('main_authentication', $conf->file->main_authentication);
$smarty->assign('session_name', session_name());
$smarty->assign('main_authentication', $main_authentication);
$smarty->assign('session_name', $session_name);
// Message
if (! empty($_SESSION["dol_loginmesg"]))
......@@ -546,11 +567,16 @@ function dol_loginfunction2($langs,$conf,$mysoc)
// Creation du template
$smarty->display('login.tpl'); // To use Smarty
// include(DOL_DOCUMENT_ROOT.'/core/templates/login.tpl.php'); // To use native PHP
// Suppression de la version compilee
$smarty->clear_compiled_tpl('login.tpl');
// END SMARTY
}
else
{
include($template_dir.'login.tpl.php'); // To use native PHP
}
$_SESSION["dol_loginmesg"] = '';
}
......
......@@ -378,15 +378,7 @@ if (! defined('NOLOGIN'))
{
// We show login page
include_once(DOL_DOCUMENT_ROOT."/lib/security.lib.php");
// TODO activer smarty par defaut ?
if (sizeof($conf->need_smarty) > 0 || $conf->global->MAIN_SMARTY)
{
dol_loginfunction2($langs,$conf,$mysoc);
}
else
{
dol_loginfunction($langs,$conf,$mysoc);
}
exit;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment