From 6f5a91837368f7977121a0c3506116c7327b5d58 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jul 2013 21:53:34 +0200 Subject: [PATCH] New: Add option MAIN_MOTD_SETUPPAGE to add a content onto setup page. Also content for MAIN_MOTD_SETUPPAGE, MAIN_MOTD_SETUPPAGE, MAIN_HOME now accept "|langfile" into translation key to use a specific language file. --- ChangeLog | 3 +++ htdocs/admin/index.php | 25 ++++++++++++++++++++++--- htdocs/core/lib/security2.lib.php | 7 ++++--- htdocs/index.php | 9 +++++++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index def026d92ef..4a2e7625cd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,9 @@ For developers: - New: Upgrade lib of TCPDF to 6.0 - New: Add property "hidden" into module descriptors to allow to hide a module according to some dynamic conditions. +- New: Add option MAIN_MOTD_SETUPPAGE to add a content onto setup page. Also content for + MAIN_MOTD_SETUPPAGE, MAIN_MOTD_SETUPPAGE, MAIN_HOME now accept "|langfile" into translation + key to use a specific language file. ***** ChangeLog for 3.4 compared to 3.3.2 ***** diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 940396718b9..23dcacf4f1d 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -28,8 +28,6 @@ $langs->load("companies"); if (!$user->admin) accessforbidden(); -$mesg=''; - /* * View @@ -43,7 +41,28 @@ $form = new Form($db); print_fiche_titre($langs->trans("SetupArea"),'','setup'); -if ($mesg) print $mesg.'
'; + +if (! empty($conf->global->MAIN_MOTD_SETUPPAGE)) +{ + $conf->global->MAIN_MOTD_SETUPPAGE=preg_replace('//i','
',$conf->global->MAIN_MOTD_SETUPPAGE); + if (! empty($conf->global->MAIN_MOTD_SETUPPAGE)) + { + $i=0; + while (preg_match('/__\(([a-zA-Z|@]+)\)__/i',$conf->global->MAIN_MOTD_SETUPPAGE,$reg) && $i < 100) + { + $tmp=explode('|',$reg[1]); + if (! empty($tmp[1])) $langs->load($tmp[1]); + $conf->global->MAIN_MOTD_SETUPPAGE=preg_replace('/__\('.preg_quote($reg[1]).'\)__/i',$langs->trans($tmp[0]),$conf->global->MAIN_MOTD_SETUPPAGE); + $i++; + } + + print "\n\n"; + print '
'; + print dol_htmlentitiesbr($conf->global->MAIN_MOTD_SETUPPAGE); + print '

'; + print "\n\n"; + } +} print $langs->trans("SetupDescription1").' '; print $langs->trans("AreaForAdminOnly").' '; diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 556007967f4..05f352043ec 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -270,12 +270,13 @@ function dol_loginfunction($langs,$conf,$mysoc) if (! empty($conf->global->MAIN_HOME)) { $i=0; - while (preg_match('/__\(([a-zA-Z]+)\)__/i',$conf->global->MAIN_HOME,$reg) && $i < 100) + while (preg_match('/__\(([a-zA-Z|@]+)\)__/i',$conf->global->MAIN_HOME,$reg) && $i < 100) { - $conf->global->MAIN_HOME=preg_replace('/__\('.$reg[1].'\)__/i',$langs->trans($reg[1]),$conf->global->MAIN_HOME); + $tmp=explode('|',$reg[1]); + if (! empty($tmp[1])) $langs->load($tmp[1]); + $conf->global->MAIN_HOME=preg_replace('/__\('.preg_quote($reg[1]).'\)__/i',$langs->trans($tmp[0]),$conf->global->MAIN_HOME); $i++; } - $main_home=dol_htmlcleanlastbr($conf->global->MAIN_HOME); } diff --git a/htdocs/index.php b/htdocs/index.php index 5d423b18921..26a13b9d20c 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -61,6 +61,15 @@ if (! empty($conf->global->MAIN_MOTD)) $conf->global->MAIN_MOTD=preg_replace('//i','
',$conf->global->MAIN_MOTD); if (! empty($conf->global->MAIN_MOTD)) { + $i=0; + while (preg_match('/__\(([a-zA-Z|@]+)\)__/i',$conf->global->MAIN_MOTD,$reg) && $i < 100) + { + $tmp=explode('|',$reg[1]); + if (! empty($tmp[1])) $langs->load($tmp[1]); + $conf->global->MAIN_MOTD=preg_replace('/__\('.preg_quote($reg[1]).'\)__/i',$langs->trans($tmp[0]),$conf->global->MAIN_MOTD); + $i++; + } + print "\n\n"; print '
'; print dol_htmlentitiesbr($conf->global->MAIN_MOTD);