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); ...@@ -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"> <!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 --> <!-- BEGIN TEMPLATE -->
<html> <html>
...@@ -55,10 +58,7 @@ function donnefocus() { ...@@ -55,10 +58,7 @@ function donnefocus() {
} }
</script> </script>
<?php <?php echo $conf->global->MAIN_HTML_HEADER ?>
if ($main_html_header)
echo $main_html_header;
?>
<!-- HTTP_USER_AGENT = <?php echo $_SERVER['HTTP_USER_AGENT']; ?> --> <!-- HTTP_USER_AGENT = <?php echo $_SERVER['HTTP_USER_AGENT']; ?> -->
</head> </head>
...@@ -107,7 +107,7 @@ function donnefocus() { ...@@ -107,7 +107,7 @@ function donnefocus() {
<table style="width: 100px;"><tr> <table style="width: 100px;"><tr>
<td><input id="securitycode" class="flat" type="text" size="6" maxlength="5" name="code" tabindex="4"></td> <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> <td><a href="<?php echo $php_self; ?>"><?php echo $captcha_refresh; ?></a></td>
</tr></table> </tr></table>
...@@ -124,7 +124,7 @@ function donnefocus() { ...@@ -124,7 +124,7 @@ function donnefocus() {
if ($forgetpasslink || $helpcenterlink) { if ($forgetpasslink || $helpcenterlink) {
echo '<tr><td colspan="3" align="center">'; echo '<tr><td colspan="3" align="center">';
if ($forgetpasslink) { 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'); echo $langs->trans('PasswordForgotten');
if (! $helpcenterlink) { if (! $helpcenterlink) {
echo ')'; echo ')';
...@@ -133,7 +133,7 @@ function donnefocus() { ...@@ -133,7 +133,7 @@ function donnefocus() {
} }
if ($helpcenterlink) { 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) { if ($forgetpasslink) {
echo '&nbsp;-&nbsp;'; echo '&nbsp;-&nbsp;';
} else { } else {
...@@ -165,11 +165,11 @@ function donnefocus() { ...@@ -165,11 +165,11 @@ function donnefocus() {
<?php if ($main_google_ad_client) { ?> <?php if ($main_google_ad_client) { ?>
<div align="center"> <div align="center">
<script type="text/javascript"><!-- <script type="text/javascript"><!--
google_ad_client = <?php echo $main_google_ad_client ?>; google_ad_client = <?php echo $conf->global->MAIN_GOOGLE_AD_CLIENT ?>;
/* {$main_google_ad_width}x{$main_google_ad_height}, {$main_google_ad_name} */ /* {$conf->global->MAIN_GOOGLE_AD_WIDTH}x{$conf->global->MAIN_GOOGLE_AD_HEIGHT}, {$conf->global->MAIN_GOOGLE_AD_NAME} */
google_ad_slot = <?php echo $main_google_ad_slot ?>; google_ad_slot = <?php echo $conf->global->MAIN_GOOGLE_AD_SLOT ?>;
google_ad_width = <?php echo $main_google_ad_width ?>; google_ad_width = <?php echo $conf->global->MAIN_GOOGLE_AD_WIDTH ?>;
google_ad_height = <?php echo $main_google_ad_height ?>; google_ad_height = <?php echo $conf->global->MAIN_GOOGLE_AD_HEIGHT ?>;
//--> //-->
</script> </script>
<script type="text/javascript" <script type="text/javascript"
...@@ -178,14 +178,11 @@ function donnefocus() { ...@@ -178,14 +178,11 @@ function donnefocus() {
</div> </div>
<?php } ?> <?php } ?>
<!-- authentication mode = {$main_authentication} --> <!-- authentication mode = <?php echo $main_authentication ?> -->
<!-- cookie name used for this session = {$session_name} --> <!-- cookie name used for this session = <?php echo $session_name ?> -->
<!-- urlfrom in this session = {$smarty.session.urlfrom} --> <!-- urlfrom in this session = <?php echo $_SESSION["urlfrom"] ?> -->
<?php <?php echo $conf->global->MAIN_HTML_FOOTER; ?>
if ($main_html_footer)
echo $main_html_footer;
?>
</body> </body>
</html> </html>
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* \param mysoc Company object * \param mysoc Company object
* \remarks You must change HTML code in this page to change design of logon page. * \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; global $dolibarr_main_demo,$db;
...@@ -333,12 +333,10 @@ function dol_loginfunction($langs,$conf,$mysoc) ...@@ -333,12 +333,10 @@ function dol_loginfunction($langs,$conf,$mysoc)
* \param langs Lang object * \param langs Lang object
* \param conf Conf object * \param conf Conf object
* \param mysoc Company 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 $dolibarr_main_demo,$db;
global $smarty;
$langcode=(empty($_GET["lang"])?'auto':$_GET["lang"]); $langcode=(empty($_GET["lang"])?'auto':$_GET["lang"]);
$langs->setDefaultLang($langcode); $langs->setDefaultLang($langcode);
...@@ -347,47 +345,39 @@ function dol_loginfunction2($langs,$conf,$mysoc) ...@@ -347,47 +345,39 @@ function dol_loginfunction2($langs,$conf,$mysoc)
$langs->load("other"); $langs->load("other");
$langs->load("help"); $langs->load("help");
$smarty->assign('langs', $langs); $main_authentication=$conf->file->main_authentication;
$session_name=session_name();
if (! empty($conf->global->MAIN_HTML_HEADER)) $smarty->assign('main_html_header', $conf->global->MAIN_HTML_HEADER);
$php_self = $_SERVER['PHP_SELF']; $php_self = $_SERVER['PHP_SELF'];
$php_self.= $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:''; $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 // Select templates
if ($conf->browser->phone) if ($conf->browser->phone)
{ {
if (file_exists(DOL_DOCUMENT_ROOT."/theme/phones/".$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/"; $template_dir=DOL_DOCUMENT_ROOT."/theme/phones/".$conf->browser->phone."/templates/";
$smarty->assign('theme', 'default');
} }
else else
{ {
$smarty->template_dir = DOL_DOCUMENT_ROOT."/theme/phones/others/templates/"; $template_dir=DOL_DOCUMENT_ROOT."/theme/phones/others/templates/";
} }
} }
else else
{ {
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/templates/login.tpl")) 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 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 = "theme/".$conf->theme."/".$conf->theme.".css";
$conf->css.=".php?lang=".$langs->defaultlang; $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 // Set cookie for timeout management
$sessiontimeout='DOLSESSTIMEOUT_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]); $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); 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) ...@@ -395,21 +385,19 @@ function dol_loginfunction2($langs,$conf,$mysoc)
if (! empty($_REQUEST["urlfrom"])) $_SESSION["urlfrom"]=$_REQUEST["urlfrom"]; if (! empty($_REQUEST["urlfrom"])) $_SESSION["urlfrom"]=$_REQUEST["urlfrom"];
else unset($_SESSION["urlfrom"]); else unset($_SESSION["urlfrom"]);
if (! $_REQUEST["username"]) $smarty->assign('focus_element', 'username'); if (! $_REQUEST["username"]) $focus_element='username';
else $smarty->assign('focus_element', 'password'); else $focus_element='password';
$login_background=DOL_URL_ROOT.'/theme/login_background.png'; $login_background=DOL_URL_ROOT.'/theme/login_background.png';
if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/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
$title='Dolibarr '.DOL_VERSION; $title='Dolibarr '.DOL_VERSION;
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE; if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE;
$smarty->assign('title', $title);
$demologin=''; $demologin='';
$demopassword=''; $demopassword='';
if (! empty($dolibarr_main_demo)) if (! empty($dolibarr_main_demo))
...@@ -444,8 +432,6 @@ function dol_loginfunction2($langs,$conf,$mysoc) ...@@ -444,8 +432,6 @@ function dol_loginfunction2($langs,$conf,$mysoc)
// Login // Login
$login = (!empty($lastuser)?$lastuser:(isset($_REQUEST["username"])?$_REQUEST["username"]:$demologin)); $login = (!empty($lastuser)?$lastuser:(isset($_REQUEST["username"])?$_REQUEST["username"]:$demologin));
$password = $demopassword; $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) // Show logo (search in order: small company logo, large company logo, theme logo, common logo)
$width=0; $width=0;
...@@ -468,11 +454,8 @@ function dol_loginfunction2($langs,$conf,$mysoc) ...@@ -468,11 +454,8 @@ function dol_loginfunction2($langs,$conf,$mysoc)
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $rowspan++; if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $rowspan++;
$smarty->assign('logo', $urllogo);
$smarty->assign('logo_width', $width);
$smarty->assign('logo_rowspan', $rowspan);
// Entity field // Entity field
$select_entity='';
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY))
{ {
require_once(DOL_DOCUMENT_ROOT.'/multicompany/multicompany.class.php'); require_once(DOL_DOCUMENT_ROOT.'/multicompany/multicompany.class.php');
...@@ -481,30 +464,30 @@ function dol_loginfunction2($langs,$conf,$mysoc) ...@@ -481,30 +464,30 @@ function dol_loginfunction2($langs,$conf,$mysoc)
$mc->getEntities(); $mc->getEntities();
$select_entity=$mc->select_entities($mc->entities,$lastentity,'tabindex="3"'); $select_entity=$mc->select_entities($mc->entities,$lastentity,'tabindex="3"');
$smarty->assign('select_entity', $select_entity);
} }
// Security graphical code // Security graphical code
$captcha=0;
$captcha_refresh='';
if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA))
{ {
$captcha=1; $captcha=1;
$smarty->assign('captcha', $captcha); $captcha_refresh=img_refresh();
$smarty->assign('captcha_refresh', img_refresh());
} }
// Extra link // 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) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK))
{ {
if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK))
{ {
$forgetpasslink=1; $forgetpasslink=1;
$smarty->assign('forgetpasslink', $forgetpasslink);
} }
if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK))
{ {
$helpcenterlink=1; $helpcenterlink=1;
$smarty->assign('helpcenterlink', $helpcenterlink);
} }
} }
...@@ -517,9 +500,48 @@ function dol_loginfunction2($langs,$conf,$mysoc) ...@@ -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); $conf->global->MAIN_HOME=preg_replace('/__\('.$reg[1].'\)__/i',$langs->trans($reg[1]),$conf->global->MAIN_HOME);
$i++; $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) // Google Adsense (ex: demo mode)
if (! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT)) 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) ...@@ -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); if (! empty($conf->global->MAIN_HTML_FOOTER)) $smarty->assign('main_html_footer', $conf->global->MAIN_HTML_FOOTER);
$smarty->assign('main_authentication', $main_authentication);
$smarty->assign('main_authentication', $conf->file->main_authentication); $smarty->assign('session_name', $session_name);
$smarty->assign('session_name', session_name());
// Message // Message
if (! empty($_SESSION["dol_loginmesg"])) if (! empty($_SESSION["dol_loginmesg"]))
...@@ -546,11 +567,16 @@ function dol_loginfunction2($langs,$conf,$mysoc) ...@@ -546,11 +567,16 @@ function dol_loginfunction2($langs,$conf,$mysoc)
// Creation du template // Creation du template
$smarty->display('login.tpl'); // To use Smarty $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 // Suppression de la version compilee
$smarty->clear_compiled_tpl('login.tpl'); $smarty->clear_compiled_tpl('login.tpl');
// END SMARTY
}
else
{
include($template_dir.'login.tpl.php'); // To use native PHP
}
$_SESSION["dol_loginmesg"] = ''; $_SESSION["dol_loginmesg"] = '';
} }
......
...@@ -378,15 +378,7 @@ if (! defined('NOLOGIN')) ...@@ -378,15 +378,7 @@ if (! defined('NOLOGIN'))
{ {
// We show login page // We show login page
include_once(DOL_DOCUMENT_ROOT."/lib/security.lib.php"); 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); dol_loginfunction($langs,$conf,$mysoc);
}
exit; exit;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment