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 'createRecurringInvoices()'
NEW: Add hook 'afterSelectContactOptions'
NEW: Add hook 'getAccessForbiddenMessage'
NEW: Add hook support in accountancy index
NEW: Add hook support in list of template invoices
NEW: Add parameter 'replaceambiguouschars' on getRandomPassword function

View File

@ -165,11 +165,12 @@ class HookManager
'formattachOptions',
'formBuilddocLineOptions',
'formatNotificationMessage',
'getFormMail',
'getIdProfUrl',
'getAccessForbiddenMessage',
'getDirList',
'getFormatedCustomerRef',
'getFormMail',
'getFormatedCustomerRef',
'getFormatedSupplierRef',
'getIdProfUrl',
'moveUploadedFile',
'moreHtmlStatus',
'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)
{
global $conf, $db, $user, $langs;
global $conf, $db, $user, $langs, $hookmanager;
if (! is_object($langs))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
@ -681,14 +681,27 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho
print '<br>';
if (empty($showonlymessage))
{
if ($user->login)
global $action, $object;
if (empty($hookmanager))
{
print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>';
print $langs->trans("ErrorForbidden2", $langs->trans("Home"), $langs->trans("Users"));
$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'));
}
else
$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))
{
print $langs->trans("ErrorForbidden3");
if ($user->login)
{
print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>';
print $langs->trans("ErrorForbidden2",$langs->trans("Home"),$langs->trans("Users"));
}
else
{
print $langs->trans("ErrorForbidden3");
}
}
}
if ($printfooter && function_exists("llxFooter")) llxFooter();