From cf0311dd6ad1579cb7cdc6c65d38e55fb32041f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Nov 2019 16:13:22 +0100 Subject: [PATCH 1/3] FIX Hook getAccessForbiddenMessage was missing parameters --- htdocs/core/lib/security.lib.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 051f3a5392a..71d52f1bd9d 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -413,7 +413,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f if (! empty($objectid) && $objectid > 0) { $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); - return $ok ? 1 : accessforbidden(); + $params=array('objectid' => $objectid, 'features' => join(',', $featuresarray), 'features2' => $feature2); + return $ok ? 1 : accessforbidden('', 1, 1, 0, $params); } return 1; @@ -651,13 +652,14 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand * Show a message to say access is forbidden and stop program * Calling this function terminate execution of PHP. * - * @param string $message Force error message - * @param int $printheader Show header before - * @param int $printfooter Show footer after - * @param int $showonlymessage Show only message parameter. Otherwise add more information. + * @param string $message Force error message + * @param int $printheader Show header before + * @param int $printfooter Show footer after + * @param int $showonlymessage Show only message parameter. Otherwise add more information. + * @param array|null $params Send params * @return void */ -function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0) +function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null) { global $conf, $db, $user, $langs, $hookmanager; if (! is_object($langs)) @@ -688,7 +690,7 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho // 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); + $parameters = array('message'=>$message, 'params'=>$params); $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)) From 27e4c66dd5c91a926bf843d47c44d60402878e85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Nov 2019 18:11:11 +0100 Subject: [PATCH 2/3] Fix empty --- htdocs/fourn/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 1fd48033047..cba4a5f8b67 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -906,7 +906,7 @@ if (empty($reshook)) // FIXME Missing special_code into addline and updateline methods $object->special_code = $lines[$i]->special_code; - + // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example. $result = $object->addline( $desc, @@ -2643,7 +2643,7 @@ else if ($calculationrule == 'totalofround') $calculationrulenum=1; else $calculationrulenum=2; - if (empty($object->getVentilExportCompta())) { + if ($object->getVentilExportCompta() != 0) { $s=$langs->trans("ReCalculate").' '; $s.=''.$langs->trans("Mode1").''; $s.=' / '; From 98a7a5559fb0bd1a4777b3b5c5cbe8c439faf810 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Nov 2019 18:12:40 +0100 Subject: [PATCH 3/3] Fix bad fix --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index cba4a5f8b67..9933217a8bb 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2643,7 +2643,7 @@ else if ($calculationrule == 'totalofround') $calculationrulenum=1; else $calculationrulenum=2; - if ($object->getVentilExportCompta() != 0) { + if ($object->getVentilExportCompta() == 0) { $s=$langs->trans("ReCalculate").' '; $s.=''.$langs->trans("Mode1").''; $s.=' / ';