From d800d1076665d2a07dc65651ad5cff7b865f87f7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 27 Aug 2017 13:19:57 +0200 Subject: [PATCH 1/6] Fix: use resprint instead resarray --- htdocs/core/lib/security2.lib.php | 15 ++++++++++----- htdocs/core/tpl/login.tpl.php | 8 +++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 817fd2be8da..39cfb715a28 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2008-2012 Regis Houssin + * Copyright (C) 2008-2017 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -201,11 +201,16 @@ function dol_loginfunction($langs,$conf,$mysoc) $demopassword=$tab[1]; } - // Execute hook getLoginPageOptions - // Should be an array with differents options in $hookmanager->resArray + // Execute hook getLoginPageOptions (for table) $parameters=array('entity' => GETPOST('entity','int')); - $reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks. resArray is filled by hook. - $morelogincontent = $hookmanager->resArray['options']; // TODO Use here a resprints + $reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks. + //$morelogincontent = $hookmanager->resArray['options']; // TODO Use here a resprints + $morelogincontent = $hookmanager->resPrint; + + // Execute hook getLoginPageExtraOptions (eg for js) + $parameters=array('entity' => GETPOST('entity','int')); + $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions',$parameters); // Note that $action and $object may have been modified by some hooks. + $moreloginextracontent = $hookmanager->resPrint; // Login $login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username","alpha") ? GETPOST("username","alpha") : $demologin)); diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 35f6f857526..7b6ad88075b 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -123,7 +123,7 @@ if ($disablenofollow) echo ''; $option) { if ($format == 'table') { @@ -131,6 +131,9 @@ if (! empty($morelogincontent) && is_array($morelogincontent)) { echo $option; } } +}*/ +if (! empty($morelogincontent)) { + echo $morelogincontent; } ?> Date: Sun, 27 Aug 2017 13:24:29 +0200 Subject: [PATCH 2/6] Fix: comment old code --- htdocs/core/tpl/login.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 7b6ad88075b..6abeaf332a3 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -281,7 +281,7 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) { global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER; ?> $option) { if ($format == 'js') { @@ -289,7 +289,7 @@ if (! empty($morelogincontent) && is_array($morelogincontent)) { echo $option."\n"; } } -} +}*/ if (! empty($moreloginextracontent)) { echo $moreloginextracontent; } From 1ce1899a46df1c18d492defa818000a25b7986b3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 27 Aug 2017 13:42:46 +0200 Subject: [PATCH 3/6] Fix: add comment --- htdocs/core/lib/security2.lib.php | 1 - htdocs/core/tpl/login.tpl.php | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 39cfb715a28..fa87294b44f 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -204,7 +204,6 @@ function dol_loginfunction($langs,$conf,$mysoc) // Execute hook getLoginPageOptions (for table) $parameters=array('entity' => GETPOST('entity','int')); $reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks. - //$morelogincontent = $hookmanager->resArray['options']; // TODO Use here a resprints $morelogincontent = $hookmanager->resPrint; // Execute hook getLoginPageExtraOptions (eg for js) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 6abeaf332a3..5c603f531f9 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -133,6 +133,7 @@ if ($disablenofollow) echo ''; } }*/ if (! empty($morelogincontent)) { + echo ''; echo $morelogincontent; } ?> @@ -291,6 +292,7 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) { } }*/ if (! empty($moreloginextracontent)) { + echo ''; echo $moreloginextracontent; } ?> From 526ccc870b652e58768c19bcd7dca9f683c5d6f7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 27 Aug 2017 13:53:08 +0200 Subject: [PATCH 4/6] Fix: add compatibility with old modules --- htdocs/core/lib/security2.lib.php | 6 ++- htdocs/core/tpl/login.tpl.php | 67 +++++++++++++++---------------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index fa87294b44f..d0def9d5627 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -204,7 +204,11 @@ function dol_loginfunction($langs,$conf,$mysoc) // Execute hook getLoginPageOptions (for table) $parameters=array('entity' => GETPOST('entity','int')); $reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks. - $morelogincontent = $hookmanager->resPrint; + if (is_array($hookmanager->resArray) && ! empty($hookmanager->resArray)) { + $morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility + } else { + $morelogincontent = $hookmanager->resPrint; + } // Execute hook getLoginPageExtraOptions (eg for js) $parameters=array('entity' => GETPOST('entity','int')); diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 5c603f531f9..b0616cadb80 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -123,27 +123,28 @@ if ($disablenofollow) echo ''; $option) - { - if ($format == 'table') { - echo ''; - echo $option; +if (! empty($morelogincontent)) { + if (is_array($morelogincontent)) { + foreach ($morelogincontent as $format => $option) + { + if ($format == 'table') { + echo ''; + echo $option; + } } } -}*/ -if (! empty($morelogincontent)) { - echo ''; - echo $morelogincontent; + else { + echo ''; + echo $morelogincontent; + } } -?> - @@ -279,25 +280,25 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) { -global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER; ?> - $option) - { - if ($format == 'js') { - echo "\n".''; - echo $option."\n"; +if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER; + +if (! empty($morelogincontent)) { + if (is_array($morelogincontent)) { + foreach ($morelogincontent as $format => $option) + { + if ($format == 'js') { + echo "\n".''; + echo $option."\n"; + } } } -}*/ -if (! empty($moreloginextracontent)) { - echo ''; - echo $moreloginextracontent; + else { + echo ''; + echo $moreloginextracontent; + } } -?> -google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID)) { @@ -317,9 +318,7 @@ if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID) print ''."\n"; } } -?> -google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT)) { From 80af01c20f0137d4cb2cdc9c2f8678d3c75d5e65 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 27 Aug 2017 13:57:52 +0200 Subject: [PATCH 5/6] Fix: wrong test --- htdocs/core/tpl/login.tpl.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index b0616cadb80..34f2df1f02f 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -283,20 +283,18 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) { global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER; -if (! empty($morelogincontent)) { - if (is_array($morelogincontent)) { - foreach ($morelogincontent as $format => $option) - { - if ($format == 'js') { - echo "\n".''; - echo $option."\n"; - } +if (! empty($morelogincontent) && is_array($morelogincontent)) { + foreach ($morelogincontent as $format => $option) + { + if ($format == 'js') { + echo "\n".''; + echo $option."\n"; } } - else { - echo ''; - echo $moreloginextracontent; - } +} +else if (! empty($moreloginextracontent)) { + echo ''; + echo $moreloginextracontent; } // Google Analytics (need Google module) From 0ce51fcb877d474ea04dbde749f7226ea8cd141f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 28 Aug 2017 09:14:50 +0200 Subject: [PATCH 6/6] Fix: add resprint for passwordforgotten --- htdocs/core/tpl/passwordforgotten.tpl.php | 32 ++++++++++++++++++----- htdocs/user/passwordforgotten.php | 13 +++++++-- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index f901ed14318..9e155be88c9 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -88,14 +88,20 @@ if ($disablenofollow) echo ''; resArray['options'])) { - foreach ($hookmanager->resArray['options'] as $format => $option) - { - if ($format == 'table') { - echo ''; - echo $option; +if (! empty($morelogincontent)) { + if (is_array($morelogincontent)) { + foreach ($morelogincontent as $format => $option) + { + if ($format == 'table') { + echo ''; + echo $option; + } } } + else { + echo ''; + echo $morelogincontent; + } } ?> @@ -175,6 +181,20 @@ if (! empty($hookmanager->resArray['options'])) { + $option) + { + if ($format == 'js') { + echo "\n".''; + echo $option."\n"; + } + } +} +else if (! empty($moreloginextracontent)) { + echo ''; + echo $moreloginextracontent; +} +?> diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index 4efe56b0ac1..9c2aabd3654 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -224,10 +224,19 @@ if (function_exists("imagecreatefrompng") && ! $disabled) $captcha_refresh = img_picto($langs->trans("Refresh"),'refresh','id="captcha_refresh_img"'); } -// Execute hook getPasswordForgottenPageOptions -// Should be an array with differents options in $hookmanager->resArray +// Execute hook getPasswordForgottenPageOptions (for table) $parameters=array('entity' => GETPOST('entity','int')); $hookmanager->executeHooks('getPasswordForgottenPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks +if (is_array($hookmanager->resArray) && ! empty($hookmanager->resArray)) { + $morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility +} else { + $morelogincontent = $hookmanager->resPrint; +} + +// Execute hook getPasswordForgottenPageExtraOptions (eg for js) +$parameters=array('entity' => GETPOST('entity','int')); +$reshook = $hookmanager->executeHooks('getPasswordForgottenPageExtraOptions',$parameters); // Note that $action and $object may have been modified by some hooks. +$moreloginextracontent = $hookmanager->resPrint; include $template_dir.'passwordforgotten.tpl.php'; // To use native PHP