Hook 'getAccessForbiddenMessage'

This commit is contained in:
Laurent Destailleur 2019-06-04 12:48:06 +02:00
parent 969e139d5c
commit 79a3e41418
3 changed files with 24 additions and 9 deletions

View File

@ -128,6 +128,7 @@ NEW: Upgrade jquery lib to 3.3.1
NEW: Add hook 'addHtmlHeader()' NEW: Add hook 'addHtmlHeader()'
NEW: Add hook 'createRecurringInvoices()' NEW: Add hook 'createRecurringInvoices()'
NEW: Add hook 'afterSelectContactOptions' NEW: Add hook 'afterSelectContactOptions'
NEW: Add hook 'getAccessForbiddenMessage'
NEW: Add hook support in accountancy index NEW: Add hook support in accountancy index
NEW: Add hook support in list of template invoices NEW: Add hook support in list of template invoices
NEW: Add parameter 'replaceambiguouschars' on getRandomPassword function NEW: Add parameter 'replaceambiguouschars' on getRandomPassword function

View File

@ -165,11 +165,12 @@ class HookManager
'formattachOptions', 'formattachOptions',
'formBuilddocLineOptions', 'formBuilddocLineOptions',
'formatNotificationMessage', 'formatNotificationMessage',
'getFormMail', 'getAccessForbiddenMessage',
'getIdProfUrl',
'getDirList', 'getDirList',
'getFormMail',
'getFormatedCustomerRef', 'getFormatedCustomerRef',
'getFormatedSupplierRef', 'getFormatedSupplierRef',
'getIdProfUrl',
'moveUploadedFile', 'moveUploadedFile',
'moreHtmlStatus', 'moreHtmlStatus',
'pdf_build_address', 'pdf_build_address',

View File

@ -659,7 +659,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
*/ */
function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0) function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0)
{ {
global $conf, $db, $user, $langs; global $conf, $db, $user, $langs, $hookmanager;
if (! is_object($langs)) if (! is_object($langs))
{ {
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
@ -680,17 +680,30 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho
print '</div>'; print '</div>';
print '<br>'; print '<br>';
if (empty($showonlymessage)) if (empty($showonlymessage))
{
global $action, $object;
if (empty($hookmanager))
{
$hookmanager = new HookManager($db);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('main'));
}
$parameters = array('message'=>$message);
$reshook=$hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
print $hookmanager->resPrint;
if (empty($reshook))
{ {
if ($user->login) if ($user->login)
{ {
print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>'; print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>';
print $langs->trans("ErrorForbidden2", $langs->trans("Home"), $langs->trans("Users")); print $langs->trans("ErrorForbidden2",$langs->trans("Home"),$langs->trans("Users"));
} }
else else
{ {
print $langs->trans("ErrorForbidden3"); print $langs->trans("ErrorForbidden3");
} }
} }
}
if ($printfooter && function_exists("llxFooter")) llxFooter(); if ($printfooter && function_exists("llxFooter")) llxFooter();
exit(0); exit(0);
} }