Merge pull request #18291 from FHenry/14_fix_add_missing_hook_translationproductpage

fix: add hook management into product translation tab
This commit is contained in:
Laurent Destailleur 2021-07-30 15:07:01 +02:00 committed by GitHub
commit a9f5fd497a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,11 +62,20 @@ if ($object->id > 0) {
restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
} }
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('producttranslationcard', 'globalcard'));
/* /*
* Actions * Actions
*/ */
$parameters = array('id'=>$id, 'ref'=>$ref);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
// retour a l'affichage des traduction si annulation // retour a l'affichage des traduction si annulation
if ($cancel == $langs->trans("Cancel")) { if ($cancel == $langs->trans("Cancel")) {
$action = ''; $action = '';
@ -156,6 +165,7 @@ if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && ($user->rights
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
}
$object = new Product($db); $object = new Product($db);
$result = $object->fetch($id, $ref); $result = $object->fetch($id, $ref);
@ -216,6 +226,9 @@ print dol_get_fiche_end();
*/ */
print "\n".'<div class="tabsAction">'."\n"; print "\n".'<div class="tabsAction">'."\n";
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
if (empty($reshook)) {
if ($action == '') { if ($action == '') {
if ($user->rights->produit->creer || $user->rights->service->creer) { if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<a class="butAction" href="' . DOL_URL_ROOT . '/product/traduction.php?action=add&id=' . $object->id . '">' . $langs->trans("Add") . '</a>'; print '<a class="butAction" href="' . DOL_URL_ROOT . '/product/traduction.php?action=add&id=' . $object->id . '">' . $langs->trans("Add") . '</a>';
@ -224,6 +237,7 @@ if ($action == '') {
} }
} }
} }
}
print "\n".'</div>'."\n"; print "\n".'</div>'."\n";
@ -263,6 +277,9 @@ if ($action == 'edit') {
} }
} }
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print '<br>'; print '<br>';
print '<div class="center">'; print '<div class="center">';
@ -334,6 +351,9 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service
} }
print '</table>'; print '</table>';
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print dol_get_fiche_end(); print dol_get_fiche_end();
print '<div class="center">'; print '<div class="center">';