diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 817fd2be8da..d0def9d5627 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,19 @@ 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. + 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')); + $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 bcf62d40460..251540b004e 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -123,23 +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; + } } } + else { + echo ''; + echo $morelogincontent; + } } -?> - @@ -275,9 +280,9 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) { -global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER; ?> - global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER; + if (! empty($morelogincontent) && is_array($morelogincontent)) { foreach ($morelogincontent as $format => $option) { @@ -287,9 +292,11 @@ if (! empty($morelogincontent) && is_array($morelogincontent)) { } } } -?> +else if (! empty($moreloginextracontent)) { + echo ''; + echo $moreloginextracontent; +} -google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID)) { @@ -309,9 +316,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)) { 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