Fix hook implementation on some thirdparty pages

This commit is contained in:
Laurent Destailleur 2015-12-23 14:31:42 +01:00
parent 932c3f9172
commit 2d3915b88c
3 changed files with 143 additions and 102 deletions

View File

@ -49,6 +49,21 @@ $pagenext = $page + 1;
if (! $sortorder) $sortorder="DESC"; if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="f.datef"; if (! $sortfield) $sortfield="f.datef";
$object = new Societe($db);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('thirdpartymargins','globalcard'));
/*
* Actions
*/
$parameters=array('id'=>$socid);
$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');
/* /*
* View * View

View File

@ -56,14 +56,26 @@ if (! $sortfield) $sortfield="c.lastname";
$now=dol_now(); $now=dol_now();
$object = new Societe($db);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('thirdpartynotification','globalcard'));
/* /*
* Actions * Actions
*/ */
// Add a notification $parameters=array('id'=>$socid);
if ($action == 'add') $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))
{ {
// Add a notification
if ($action == 'add')
{
$error=0; $error=0;
if (empty($contactid)) if (empty($contactid))
@ -108,13 +120,14 @@ if ($action == 'add')
$db->rollback(); $db->rollback();
} }
} }
} }
// Remove a notification // Remove a notification
if ($action == 'delete') if ($action == 'delete')
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".$_GET["actid"]; $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".$_GET["actid"];
$db->query($sql); $db->query($sql);
}
} }
@ -150,7 +163,7 @@ if ($result > 0)
print '</td></tr>'; print '</td></tr>';
// Alias names (commercial, trademark or alias names) // Alias names (commercial, trademark or alias names)
print '<tr><td valign="top">'.$langs->trans('AliasNames').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('AliasNames').'</td><td colspan="3">';
print $object->name_alias; print $object->name_alias;
print "</td></tr>"; print "</td></tr>";

View File

@ -49,12 +49,24 @@ if ($user->societe_id)
$socid = $user->societe_id; $socid = $user->societe_id;
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
$object = new Societe($db);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('thirdpartycustomerprice','globalcard'));
/* /*
* Actions * Actions
*/ */
if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { $parameters=array('id'=>$socid);
$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))
{
if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$update_child_soc = GETPOST('updatechildprice'); $update_child_soc = GETPOST('updatechildprice');
@ -76,9 +88,9 @@ if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->ri
} }
$action = ''; $action = '';
} }
if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) { if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) {
// Delete price by customer // Delete price by customer
$prodcustprice->id = GETPOST('lineid'); $prodcustprice->id = GETPOST('lineid');
$result = $prodcustprice->delete($user); $result = $prodcustprice->delete($user);
@ -89,9 +101,9 @@ if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $use
setEventMessage($langs->trans('Delete'), 'errors'); setEventMessage($langs->trans('Delete'), 'errors');
} }
$action = ''; $action = '';
} }
if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$prodcustprice->fetch(GETPOST('lineid', 'int')); $prodcustprice->fetch(GETPOST('lineid', 'int'));
@ -112,6 +124,7 @@ if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user-
} }
$action = ''; $action = '';
}
} }