Merge pull request #7297 from hregis/6.0_bug2

Fix: use resprint instead resarray
This commit is contained in:
Laurent Destailleur 2017-08-28 12:27:26 +02:00 committed by GitHub
commit 73a799b0ce
4 changed files with 75 additions and 33 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2008-2017 Regis Houssin <regis.houssin@capnetworks.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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]; $demopassword=$tab[1];
} }
// Execute hook getLoginPageOptions // Execute hook getLoginPageOptions (for table)
// Should be an array with differents options in $hookmanager->resArray
$parameters=array('entity' => GETPOST('entity','int')); $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. $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 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
$login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username","alpha") ? GETPOST("username","alpha") : $demologin)); $login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username","alpha") ? GETPOST("username","alpha") : $demologin));

View File

@ -123,7 +123,8 @@ if ($disablenofollow) echo '</a>';
</span> </span>
</td></tr> </td></tr>
<?php <?php
if (! empty($morelogincontent) && is_array($morelogincontent)) { if (! empty($morelogincontent)) {
if (is_array($morelogincontent)) {
foreach ($morelogincontent as $format => $option) foreach ($morelogincontent as $format => $option)
{ {
if ($format == 'table') { if ($format == 'table') {
@ -132,8 +133,12 @@ if (! empty($morelogincontent) && is_array($morelogincontent)) {
} }
} }
} }
?> else {
<?php echo '<!-- Option by hook -->';
echo $morelogincontent;
}
}
if ($captcha) { if ($captcha) {
// Add a variable param to force not using cache (jmobile) // Add a variable param to force not using cache (jmobile)
$php_self = preg_replace('/[&\?]time=(\d+)/','',$php_self); // Remove param time $php_self = preg_replace('/[&\?]time=(\d+)/','',$php_self); // Remove param time
@ -275,9 +280,9 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) {
<!-- Common footer is not used for login page, this is same than footer but inside login tpl --> <!-- Common footer is not used for login page, this is same than footer but inside login tpl -->
<?php if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER; ?>
<?php <?php
if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER;
if (! empty($morelogincontent) && is_array($morelogincontent)) { if (! empty($morelogincontent) && is_array($morelogincontent)) {
foreach ($morelogincontent as $format => $option) foreach ($morelogincontent as $format => $option)
{ {
@ -287,9 +292,11 @@ if (! empty($morelogincontent) && is_array($morelogincontent)) {
} }
} }
} }
?> else if (! empty($moreloginextracontent)) {
echo '<!-- Javascript by hook -->';
echo $moreloginextracontent;
}
<?php
// Google Analytics (need Google module) // Google Analytics (need Google module)
if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID)) if (! empty($conf->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 '</script>'."\n"; print '</script>'."\n";
} }
} }
?>
<?php
// Google Adsense // Google Adsense
if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT)) if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))
{ {

View File

@ -88,8 +88,9 @@ if ($disablenofollow) echo '</a>';
</tr> </tr>
<?php <?php
if (! empty($hookmanager->resArray['options'])) { if (! empty($morelogincontent)) {
foreach ($hookmanager->resArray['options'] as $format => $option) if (is_array($morelogincontent)) {
foreach ($morelogincontent as $format => $option)
{ {
if ($format == 'table') { if ($format == 'table') {
echo '<!-- Option by hook -->'; echo '<!-- Option by hook -->';
@ -97,6 +98,11 @@ if (! empty($hookmanager->resArray['options'])) {
} }
} }
} }
else {
echo '<!-- Option by hook -->';
echo $morelogincontent;
}
}
?> ?>
<?php if ($captcha) { <?php if ($captcha) {
@ -175,6 +181,20 @@ if (! empty($hookmanager->resArray['options'])) {
</div> </div>
<?php } ?> <?php } ?>
<?php if (! empty($morelogincontent) && is_array($morelogincontent)) {
foreach ($morelogincontent as $format => $option)
{
if ($format == 'js') {
echo "\n".'<!-- Javascript by hook -->';
echo $option."\n";
}
}
}
else if (! empty($moreloginextracontent)) {
echo '<!-- Javascript by hook -->';
echo $moreloginextracontent;
}
?>
</div> </div>
</div> <!-- end of center --> </div> <!-- end of center -->

View File

@ -224,10 +224,19 @@ if (function_exists("imagecreatefrompng") && ! $disabled)
$captcha_refresh = img_picto($langs->trans("Refresh"),'refresh','id="captcha_refresh_img"'); $captcha_refresh = img_picto($langs->trans("Refresh"),'refresh','id="captcha_refresh_img"');
} }
// Execute hook getPasswordForgottenPageOptions // Execute hook getPasswordForgottenPageOptions (for table)
// Should be an array with differents options in $hookmanager->resArray
$parameters=array('entity' => GETPOST('entity','int')); $parameters=array('entity' => GETPOST('entity','int'));
$hookmanager->executeHooks('getPasswordForgottenPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks $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 include $template_dir.'passwordforgotten.tpl.php'; // To use native PHP