From a844855ade32a4a678e211dec49c77731282a6fc Mon Sep 17 00:00:00 2001 From: ksar-ksar <35605507+ksar-ksar@users.noreply.github.com> Date: Fri, 24 Aug 2018 16:40:26 +0200 Subject: [PATCH 1/2] Update hook formConfirm The hook should be called when the $formconfirm is not empty --- htdocs/asset/card.php | 2 +- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/expedition/card.php | 2 +- htdocs/expedition/shipment.php | 2 +- htdocs/modulebuilder/template/myobject_card.php | 2 +- htdocs/product/inventory/card.php | 2 +- htdocs/product/stock/card.php | 2 +- htdocs/supplier_proposal/card.php | 2 +- htdocs/website/websiteaccount_card.php | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 50e09831bff..4cae73edafd 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -221,7 +221,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } - if (! $formconfirm) { + if (!empty($formconfirm)) { $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index daaf9cd01f9..d0d14fe51c2 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1827,7 +1827,7 @@ if ($action == 'create') $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate', '', 0, 1); } - if (! $formconfirm) { + if (!empty($formconfirm)) { $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 10005f3004a..8baeb18c234 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1967,7 +1967,7 @@ if ($action == 'create' && $user->rights->commande->creer) $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneOrder'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - if (! $formconfirm) { + if (!empty($formconfirm)) { $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f2a137f0d8f..a1de09d9706 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3600,7 +3600,7 @@ else if ($id > 0 || ! empty($ref)) $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('CloneInvoice'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - if (! $formconfirm) + if (!empty($formconfirm)) { $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index ea01148cc70..f560f3413ee 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1676,7 +1676,7 @@ else if ($id || $ref) } - if (! $formconfirm) { + if (!empty($formconfirm)) { $parameters = array(); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 0d3111d9f12..859f65ef8d7 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -258,7 +258,7 @@ if ($id > 0 || ! empty($ref)) } - if (! $formconfirm) { + if (!empty($formconfirm)) { $parameters = array(); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 04de3e1e40e..b2ba240aedd 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -274,7 +274,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } - if (! $formconfirm) { + if (!empty($formconfirm)) { $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index d143aa4e3c8..37cf2ae7df8 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -224,7 +224,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); } - if (! $formconfirm) { + if (!empty($formconfirm)) { $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 7e13364d7ca..33336bf6c21 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -298,7 +298,7 @@ else $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("DeleteAWarehouse"),$langs->trans("ConfirmDeleteWarehouse",$object->libelle),"confirm_delete",'',0,2); } - if (! $formconfirm) { + if (!empty($formconfirm)) { $parameters = array(); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index fd74bcd2130..b312f9bd876 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1372,7 +1372,7 @@ if ($action == 'create') $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateAsk'), $text, 'confirm_validate', '', 0, 1); } - if (! $formconfirm) { + if (!empty($formconfirm)) { $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 49009d8f4e7..caca5afc9ae 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -207,7 +207,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteWebsiteAccount'), $langs->trans('ConfirmDeleteWebsiteAccount'), 'confirm_delete', '', 0, 1); } - if (! $formconfirm) { + if (!empty($formconfirm)) { $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; From 49d3bea192a976e72152d72fcccf3802e6103722 Mon Sep 17 00:00:00 2001 From: ksar-ksar <35605507+ksar-ksar@users.noreply.github.com> Date: Thu, 30 Aug 2018 11:27:48 +0200 Subject: [PATCH 2/2] Remove the test After discussion with Frederic, the best solution is to remove the test --- htdocs/asset/card.php | 11 +++++------ htdocs/comm/propal/card.php | 11 +++++------ htdocs/commande/card.php | 11 +++++------ htdocs/compta/facture/card.php | 12 +++++------- htdocs/expedition/card.php | 11 +++++------ htdocs/expedition/shipment.php | 11 +++++------ htdocs/modulebuilder/template/myobject_card.php | 11 +++++------ htdocs/product/inventory/card.php | 11 +++++------ htdocs/product/stock/card.php | 11 +++++------ htdocs/supplier_proposal/card.php | 11 +++++------ htdocs/website/websiteaccount_card.php | 11 +++++------ 11 files changed, 55 insertions(+), 67 deletions(-) diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 4cae73edafd..5b4458d103d 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -221,12 +221,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } - if (!empty($formconfirm)) { - $parameters = array('lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; // Print form confirm print $formconfirm; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index d0d14fe51c2..06d5a7dfa53 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1827,12 +1827,11 @@ if ($action == 'create') $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate', '', 0, 1); } - if (!empty($formconfirm)) { - $parameters = array('lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; // Print form confirm print $formconfirm; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 8baeb18c234..86366125cdc 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1967,12 +1967,11 @@ if ($action == 'create' && $user->rights->commande->creer) $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneOrder'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - if (!empty($formconfirm)) { - $parameters = array('lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; // Print form confirm print $formconfirm; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a1de09d9706..18370b2d6e5 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3600,13 +3600,11 @@ else if ($id > 0 || ! empty($ref)) $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('CloneInvoice'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - if (!empty($formconfirm)) - { - $parameters = array('lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; // Print form confirm print $formconfirm; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index f560f3413ee..7270fec52cc 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1676,12 +1676,11 @@ else if ($id || $ref) } - if (!empty($formconfirm)) { - $parameters = array(); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array(); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; // Print form confirm print $formconfirm; diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 859f65ef8d7..4675680368f 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -258,12 +258,11 @@ if ($id > 0 || ! empty($ref)) } - if (!empty($formconfirm)) { - $parameters = array(); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array(); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; // Print form confirm print $formconfirm; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index b2ba240aedd..233e608a899 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -274,12 +274,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } - if (!empty($formconfirm)) { - $parameters = array('lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; // Print form confirm print $formconfirm; diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 37cf2ae7df8..2784e3c303b 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -224,12 +224,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); } - if (!empty($formconfirm)) { - $parameters = array('lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; // Print form confirm print $formconfirm; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 33336bf6c21..334ccdb0b65 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -298,12 +298,11 @@ else $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("DeleteAWarehouse"),$langs->trans("ConfirmDeleteWarehouse",$object->libelle),"confirm_delete",'',0,2); } - if (!empty($formconfirm)) { - $parameters = array(); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array(); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; // Print form confirm print $formconfirm; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index b312f9bd876..47dec6ae956 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1372,12 +1372,11 @@ if ($action == 'create') $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateAsk'), $text, 'confirm_validate', '', 0, 1); } - if (!empty($formconfirm)) { - $parameters = array('lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; // Print form confirm print $formconfirm; diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index caca5afc9ae..49965b9009a 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -207,12 +207,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteWebsiteAccount'), $langs->trans('ConfirmDeleteWebsiteAccount'), 'confirm_delete', '', 0, 1); } - if (!empty($formconfirm)) { - $parameters = array('lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; // Print form confirm print $formconfirm;