Hooks 'printLeftBlock' and 'formConfirm' are now compliant with hook

development rules. They are "addreplace" hooks, so you must return
content with"->resprints='mycontent'" and not with "return 'mycontent'"
This commit is contained in:
Laurent Destailleur 2015-03-18 14:31:37 +01:00
parent 2c61717e10
commit cd2fc2f890
8 changed files with 36 additions and 28 deletions

View File

@ -31,8 +31,8 @@ WARNING: Following changes may create regression for some external modules, but
Dolibarr better:
- Removed hoo supplierorderdao into supplier order creation. This is a business event, so we must use the
trigger ORDER_SUPPLIER_CREATE instead.
- printLeftBlock is now compliant with hook development rules. It is an "addreplace" hook so you must
return content by doing ->resprints='mycontent' and not by doing return 'mycontent'
- Hooks 'printLeftBlock' and 'formConfirm' are now compliant with hook development rules. They are
"addreplace" hooks, so you must return content with "->resprints='mycontent'" and not with "return 'mycontent'"
***** ChangeLog for 3.7 compared to 3.6.* *****

View File

@ -1346,9 +1346,9 @@ if ($action == 'create')
if (! $formconfirm) {
$parameters = array('lineid' => $lineid);
$formconfirm = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified
// by
// hook
$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

View File

@ -1680,9 +1680,9 @@ if ($action == 'create')
if (! $formconfirm) {
$parameters = array('lineid' => $lineid);
$formconfirm = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified
// by
// hook
$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

View File

@ -253,7 +253,7 @@ if (empty($reshook))
$object->contactid = GETPOST('contactid');
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
// If creation from another object of another module (Example: origin=propal, originid=1)
if (! empty($origin) && ! empty($originid))
{
@ -523,7 +523,7 @@ if (empty($reshook))
{
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
}
// bank account
else if ($action == 'setbankaccount' && $user->rights->commande->creer) {
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
@ -1726,8 +1726,9 @@ if ($action == 'create' && $user->rights->commande->creer)
if (! $formconfirm) {
$parameters = array('lineid' => $lineid);
$formconfirm = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified
// by hook
$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
@ -1988,10 +1989,10 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</td>';
print '</tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
{
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
@ -2005,13 +2006,13 @@ if ($action == 'create' && $user->rights->commande->creer)
{
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
}
else
else
{
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
}
print '</td></tr>';
}
// Other attributes
$cols = 3;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
@ -2243,10 +2244,10 @@ if ($action == 'create' && $user->rights->commande->creer)
}
// Cancel order
if ($object->statut == 1 &&
if ($object->statut == 1 &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->cloturer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler)))
)
)
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=cancel">' . $langs->trans('Cancel') . '</a></div>';
}

View File

@ -324,7 +324,7 @@ if (empty($reshook))
{
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
}
// bank account
else if ($action == 'setbankaccount' && $user->rights->facture->creer)
{
@ -2289,7 +2289,7 @@ if ($action == 'create')
print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms)?$objectsrc->location_incoterms:''));
print '</td></tr>';
}
// Other attributes
$parameters = array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"');
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
@ -2749,8 +2749,9 @@ if ($action == 'create')
if (! $formconfirm) {
$parameters = array('lineid' => $lineid);
$formconfirm = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by
// hook
$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
@ -3389,10 +3390,10 @@ if ($action == 'create')
print '</td>';
print '</tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
{
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
@ -3406,7 +3407,7 @@ if ($action == 'create')
{
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
}
else
else
{
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
}

View File

@ -1210,7 +1210,9 @@ else if ($id > 0 || ! empty($ref))
if (!$formconfirm)
{
$parameters=array('lineid'=>$lineid);
$formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
$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

View File

@ -1733,7 +1733,9 @@ elseif (! empty($object->id))
if (!$formconfirm) {
$parameters=array('lineid'=>$lineid);
$formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
$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

View File

@ -1716,7 +1716,9 @@ else
if (!$formconfirm) {
$parameters=array('lineid'=>$lineid);
$formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
$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