diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index e85d39c1d36..e7bb1edb40d 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -36,15 +36,15 @@ $langs->loadLangs(array("admin", "members", "ldap")); $id = GETPOSTINT('rowid'); $action = GETPOST('action', 'aZ09'); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('membertypeldapcard', 'globalcard')); + // Security check $result = restrictedArea($user, 'adherent', $id, 'adherent_type'); $object = new AdherentType($db); $object->fetch($id); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('membertypeldapcard', 'globalcard')); - /* * Actions */ diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 82ea04051c5..a59a19155fd 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -68,11 +68,11 @@ if (!isModEnabled('barcode')) { if (!$user->hasRight('barcode', 'read')) { accessforbidden(); } -restrictedArea($user, 'barcode'); - // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('printsheettools')); +restrictedArea($user, 'barcode'); + $parameters = array(); // Note that $action and $object may have been modified by some diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index f93254da64b..b199380b9be 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -54,6 +54,9 @@ if ($id == "") { exit(); } +// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('categorycard')); + // Security check $result = restrictedArea($user, 'categorie', $id, '&category'); @@ -72,9 +75,6 @@ if (is_numeric($type)) { $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); -// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('categorycard')); - $error = 0; diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 8b47e14e4bc..b3680e517a5 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -48,6 +48,9 @@ if ($id == '' && $label == '') { exit(); } +// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('categorycard')); + // Security check $result = restrictedArea($user, 'categorie', $id, '&category'); @@ -65,8 +68,6 @@ if (is_numeric($type)) { $upload_dir = $conf->categorie->multidir_output[$object->entity]; -$hookmanager->initHooks(array('categorycard')); - /* * Actions */ diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 545bd9b3306..e4b081e7e47 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -73,6 +73,9 @@ if ($id == "" && $label == "") { exit(); } +// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('categorycard', 'globalcard')); + // Security check $result = restrictedArea($user, 'categorie', $id, '&category'); @@ -91,9 +94,6 @@ if (is_numeric($type)) { $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); -// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('categorycard', 'globalcard')); - /* * Actions */ diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 7d6e5e7a4ab..d8e70c31c9e 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -59,6 +59,8 @@ if ($user->socid) { $action = ''; $socid = $user->socid; } + +$hookmanager->initHooks(array('contactlist')); $result = restrictedArea($user, 'societe', $socid, ''); diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index c9a4dd839ed..1e54374a795 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -47,6 +47,7 @@ if ($user->socid > 0) { $action = ''; $id = $user->socid; } +$hookmanager->initHooks(array('thirdpartyprice', 'globalcard')); $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 3e47a6921e3..abfcd72a41d 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -68,8 +68,8 @@ $socid = ''; if (!empty($user->socid)) { $socid = $user->socid; } -$result = restrictedArea($user, 'propal', $object->id); $hookmanager->initHooks(array('proposalcontactcard', 'globalcard')); +$result = restrictedArea($user, 'propal', $object->id); $usercancreate = $user->hasRight("propal", "creer"); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 2dccb456e9e..9e50a579a13 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -177,13 +177,13 @@ if (!empty($socid)) { $module = 'societe'; $dbtable = '&societe'; } +$hookmanager->initHooks(array('propallist')); $result = restrictedArea($user, $module, $objectid, $dbtable); $diroutputmassaction = $conf->propal->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id; // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $object = new Propal($db); -$hookmanager->initHooks(array('propallist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 3b20df2931e..0c0e1d7c346 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -49,7 +49,6 @@ if ($user->socid) { $hookmanager->initHooks(array('ordercontact', 'globalcard')); $result = restrictedArea($user, 'commande', $id, ''); -$hookmanager->initHooks(array('ordercontactcard', 'globalcard')); $usercancreate = $user->hasRight("commande", "creer"); diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 278f5cf5b55..90fcdd02f30 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -74,12 +74,14 @@ if ($user->socid) { $socid = $user->socid; } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('bankline')); + $result = restrictedArea($user, 'banque', $accountoldid, 'bank_account'); if (!$user->hasRight('banque', 'lire') && !$user->hasRight('banque', 'consolidate')) { accessforbidden(); } -$hookmanager->initHooks(array('bankline')); $object = new AccountLine($db); $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->element); diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index e9add12186e..f9710114614 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -49,15 +49,14 @@ $fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid'; if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); - - -$vline = GETPOST('vline'); -$page = GETPOSTISSET("page") ? GETPOST("page") : 0; // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('banktreso', 'globalcard')); +$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); + +$vline = GETPOST('vline'); +$page = GETPOSTISSET("page") ? GETPOST("page") : 0; /* * View diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 3cd1e1f3477..0cc15df0101 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -67,13 +67,14 @@ $socid = GETPOSTINT("socid"); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'banque', '', '', ''); - -$object = new PaymentVarious($db); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('variouscard', 'globalcard')); +$result = restrictedArea($user, 'banque', '', '', ''); + +$object = new PaymentVarious($db); + $permissiontoadd = $user->hasRight('banque', 'modifier'); diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index b4aed3ce32e..cfe75817e68 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -43,6 +43,10 @@ $id = GETPOSTINT('id'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('tripsandexpensescard', 'globalcard')); + $result = restrictedArea($user, 'deplacement', $id, ''); $action = GETPOST('action', 'aZ09'); @@ -50,9 +54,6 @@ $confirm = GETPOST('confirm', 'alpha'); $object = new Deplacement($db); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('tripsandexpensescard', 'globalcard')); - $permissionnote = $user->hasRight('deplacement', 'creer'); // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 2eeadafc1fc..01a73a53990 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -56,9 +56,10 @@ $object = new Facture($db); if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref, '', '', (getDolGlobalString('INVOICE_USE_SITUATION') ? $conf->global->INVOICE_USE_SITUATION : 0)); } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('invoicecontactcard', 'globalcard')); $result = restrictedArea($user, 'facture', $object->id); -$hookmanager->initHooks(array('invoicecontactcard', 'globalcard')); $usercancreate = $user->hasRight("facture", "creer"); diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 1e9aff0869d..653a007a74e 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -50,13 +50,16 @@ $date_endyear = GETPOST('date_endyear'); if ($user->socid > 0) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(['purchasejournallist']); + if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } if (isModEnabled('accounting')) { $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); } -$hookmanager->initHooks(['purchasejournallist']); /* * Actions diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 64d06b3ed09..3292a395ee8 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -52,13 +52,16 @@ $date_endyear = GETPOST('date_endyear'); if ($user->socid > 0) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(['selljournallist']); + if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } if (isModEnabled('accounting')) { $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); } -$hookmanager->initHooks(['selljournallist']); /* * Actions diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 3e939d40f1b..0b6453cc81a 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -48,13 +48,12 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'tax', '', '', 'charges'); - -$object = new Localtax($db); - // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('localtaxvatcard', 'globalcard')); +$result = restrictedArea($user, 'tax', '', '', 'charges'); + +$object = new Localtax($db); /** * Actions diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 7a493817ce7..f69a32bdd3c 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -105,13 +105,16 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(['customerlocaltaxlist']); + $result = restrictedArea($user, 'tax', '', '', 'charges'); if (empty($local)) { accessforbidden('Parameter localTaxType is missing'); exit; } -$hookmanager->initHooks(['customerlocaltaxlist']); $calc = 0; /* diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index 88d1f736422..1b6d440c62d 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -56,6 +56,10 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist')); + if ($type == 'bank-transfer') { $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); } else { @@ -88,9 +92,6 @@ $line = new LignePrelevement($db); $thirdpartystatic = new Societe($db); $userstatic = new User($db); -$hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist')); - - // List of invoices $sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId,"; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index f916930e148..2c3ff9d23c3 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -42,6 +42,9 @@ if ($user->socid > 0) { $id = $user->socid; } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('recapcomptacard', 'globalcard')); + $result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Societe($db); @@ -49,8 +52,6 @@ if ($id > 0) { $object->fetch($id); } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('recapcomptacard', 'globalcard')); // Load variable for pagination $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index f1e5e79d063..6adb5762ad9 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -151,14 +151,16 @@ $socid = GETPOSTINT('socid'); if ($user->socid > 0) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(['customersupplierreportlist']); + if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } if (isModEnabled('accounting')) { $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); } -$hookmanager->initHooks(['customersupplierreportlist']); - /* * View diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 306a32157f8..a5d4ef0ddec 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -159,13 +159,13 @@ $socid = GETPOSTINT('socid'); if ($user->socid > 0) { $socid = $user->socid; } +$hookmanager->initHooks(['resultreportlist']); if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } if (isModEnabled('accounting')) { $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); } -$hookmanager->initHooks(['resultreportlist']); /* * View diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 133f83ece71..4401b262a9f 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -44,6 +44,10 @@ $socid = GETPOSTINT('socid'); if ($user->socid > 0) { $socid = $user->socid; } + +// Hook +$hookmanager->initHooks(array('cabyprodservlist')); + if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } @@ -83,9 +87,6 @@ if ($selected_type == '') { $selected_type = -1; } -// Hook -$hookmanager->initHooks(array('cabyprodservlist')); - // Date range $year = GETPOST("year"); $month = GETPOST("month"); diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 38619a7eacf..ab2220a8e77 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -40,13 +40,13 @@ $socid = GETPOSTINT('socid'); if ($user->socid > 0) { $socid = $user->socid; } +$hookmanager->initHooks(['cabyuserreportlist']); if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } if (isModEnabled('accounting')) { $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); } -$hookmanager->initHooks(['cabyuserreportlist']); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') $modecompta = getDolGlobalString('ACCOUNTING_MODE'); if (GETPOST("modecompta")) { diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 75f8e8ec709..0b935ba2664 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -72,6 +72,10 @@ if (GETPOST('subcat', 'alpha') === 'yes') { if ($user->socid > 0) { $socid = $user->socid; } + +// Hook +$hookmanager->initHooks(array('casoclist')); + if (isModEnabled('comptabilite')) { $result = restrictedArea($user, 'compta', '', '', 'resultat'); } @@ -79,9 +83,6 @@ if (isModEnabled('accounting')) { $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); } -// Hook -$hookmanager->initHooks(array('casoclist')); - // Date range $year = GETPOSTINT("year"); $month = GETPOSTINT("month"); diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 29764e77757..1950d33111c 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -90,6 +90,10 @@ $search_agenda_label = GETPOST('search_agenda_label'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('contactagenda', 'globalcard')); + $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; @@ -109,9 +113,6 @@ if (!$sortorder) { $sortorder = 'DESC'; } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('contactagenda', 'globalcard')); - /* * Actions diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 94b296c79b7..e35a62608b0 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -65,10 +65,6 @@ if ($contextpage == 'poslist') { $id = GETPOSTINT('id'); $contactid = GETPOSTINT('id'); $ref = ''; // There is no ref for contacts -if ($user->socid > 0) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'contact', $contactid, ''); $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars @@ -189,6 +185,11 @@ $object = new Contact($db); $extrafields = new ExtraFields($db); $hookmanager->initHooks(array($contextpage)); +if ($user->socid > 0) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'contact', $contactid, ''); + // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 70fa0def19e..0ee8f0afeb4 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -49,15 +49,13 @@ if ($user->socid > 0) { accessforbidden(); } } -$result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); - - -$permissionnote = $user->hasRight('societe', 'creer'); // Used by the include of actions_setnotes.inc.php // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -// $hookmanager->initHooks(array('contactcard')); -> Name conflict with product/card.php $hookmanager->initHooks(array('contactnote')); +$result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); + +$permissionnote = $user->hasRight('societe', 'creer'); // Used by the include of actions_setnotes.inc.php /* * Actions diff --git a/htdocs/contact/project.php b/htdocs/contact/project.php index d4b56b31d06..c60b90b198f 100644 --- a/htdocs/contact/project.php +++ b/htdocs/contact/project.php @@ -30,11 +30,12 @@ $langs->loadLangs(array("contacts", "companies", "projects")); // Security check $id = GETPOSTINT('id'); -$result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('projectcontact')); +$result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); + /* * Actions */ diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index 1e3f4e86d52..5387ccd0a6b 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -64,6 +64,10 @@ if ($user->socid) { // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($id) ? 'rowid' : 'ref'); + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('agendacontract', 'globalcard')); + $result = restrictedArea($user, 'contrat', $fieldvalue, '', '', '', $fieldtype); $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; @@ -89,9 +93,6 @@ if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('agendacontract', 'globalcard')); - $permissiontoadd = $user->hasRight('contrat', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $result = restrictedArea($user, 'contrat', $object->id); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 60722a34607..0d935b95721 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -135,6 +135,9 @@ $id = GETPOSTINT('id'); if ($user->socid > 0) { $socid = $user->socid; } + +$hookmanager->initHooks(array('contractlist')); + $result = restrictedArea($user, 'contrat', $id); $diroutputmassaction = $conf->contrat->dir_output.'/temp/massgeneration/'.$user->id; @@ -148,7 +151,6 @@ if ($search_status == '') { // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $object = new Contrat($db); -$hookmanager->initHooks(array('contractlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index 24c47fd1f51..9f989484963 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -65,6 +65,10 @@ $id = GETPOSTINT('id'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('deliverycard', 'globalcard')); + $result = restrictedArea($user, 'expedition', $id, 'delivery', 'delivery'); $object = new Delivery($db); @@ -79,9 +83,6 @@ $extrafields->fetch_name_optionals_label($object->table_element_line); // Load object. Make an object->fetch include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once' -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('deliverycard', 'globalcard')); - $error = 0; diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 4e25d22675b..40e88635b75 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -82,6 +82,9 @@ $error = 0; if ($user->socid) { $socid = $user->socid; } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('ecmindexcard', 'globalcard')); + $result = restrictedArea($user, 'ecm', 0); $permissiontoread = $user->hasRight('ecm', 'read'); @@ -90,9 +93,6 @@ $permissiontocreatedir = $user->hasRight('ecm', 'setup'); $permissiontodelete = $user->hasRight('ecm', 'upload'); $permissiontodeletedir = $user->hasRight('ecm', 'setup'); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('ecmindexcard', 'globalcard')); - /* * Actions */ diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 7a33cd6de59..881fe61dae4 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -87,16 +87,16 @@ $error = 0; if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'ecm', 0); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('ecmautocard', 'globalcard')); + +$result = restrictedArea($user, 'ecm', 0); /* * Actions */ -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('ecmautocard', 'globalcard')); - // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_doc_ref = ''; diff --git a/htdocs/ecm/index_medias.php b/htdocs/ecm/index_medias.php index 250837be6ad..bf5ca78cd16 100644 --- a/htdocs/ecm/index_medias.php +++ b/htdocs/ecm/index_medias.php @@ -92,6 +92,10 @@ $error = 0; if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('ecmmediascard', 'globalcard')); + $result = restrictedArea($user, 'ecm', 0); $permissiontouploadfile = ($user->hasRight('ecm', 'setup') || $user->hasRight('mailing', 'creer') || $user->hasRight('website', 'write')); @@ -104,9 +108,6 @@ $websitekey = ''; $permissiontoadd = $permissiontouploadfile; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('ecmmediascard', 'globalcard')); - /* * Actions */ diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 85640453e84..9575a417508 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -69,8 +69,8 @@ if ($id > 0 || !empty($ref)) { if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'expedition', $object->id, ''); $hookmanager->initHooks(array('shipmentcontactcard', 'globalcard')); +$result = restrictedArea($user, 'expedition', $object->id, ''); /* * Actions diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 1c4d6a56d48..eee296c0f35 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -55,12 +55,6 @@ $mode = GETPOST('mode', 'alpha'); $childids = $user->getAllChildIds(1); -// Security check -$socid = GETPOSTINT('socid'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'expensereport', '', ''); $id = GETPOSTINT('id'); // If we are on the view of a specific user if ($id > 0) { @@ -137,9 +131,16 @@ if ($search_user == '') { $search_user = -1; } +// Security check +$socid = GETPOSTINT('socid'); +if ($user->socid) { + $socid = $user->socid; +} +$hookmanager->initHooks(array('expensereportlist')); +$result = restrictedArea($user, 'expensereport', '', ''); + // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $object = new ExpenseReport($db); -$hookmanager->initHooks(array('expensereportlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 7bf13bee5dc..c86f2735a66 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -66,6 +66,10 @@ $id = (GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id')); if ($user->socid) { $id = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('thirdpartysupplier', 'globalcard')); + $result = restrictedArea($user, 'societe&fournisseur', $id, '&societe', '', 'rowid'); $object = new Fournisseur($db); @@ -74,8 +78,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('thirdpartysupplier', 'globalcard')); + // Security check $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index 2821e48f771..1491fb1269f 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -46,8 +46,8 @@ $action = GETPOST('action', 'aZ09'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); $hookmanager->initHooks(array('ordersuppliercardcontact', 'ordersuppliercontactcard', 'globalcard')); +$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); $object = new CommandeFournisseur($db); diff --git a/htdocs/fourn/commande/info.php b/htdocs/fourn/commande/info.php index 57ca5558c7f..bb5126b63af 100644 --- a/htdocs/fourn/commande/info.php +++ b/htdocs/fourn/commande/info.php @@ -76,15 +76,15 @@ $socid = 0; if ($user->socid) { $socid = $user->socid; } +// Init Hooks +$hookmanager->initHooks(array('ordersuppliercardinfo')); + $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); if (!$user->hasRight("fournisseur", "commande", "lire")) { accessforbidden(); } -// Init Hooks -$hookmanager->initHooks(array('ordersuppliercardinfo')); - $usercancreate = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index c896656c791..8abbf086867 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -47,8 +47,8 @@ $action = GETPOST('action', 'aZ09'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $hookmanager->initHooks(array('invoicesuppliercardcontact','invoicesuppliercontactcard', 'globalcard')); +$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $object = new FactureFournisseur($db); diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 5f31ab179cd..843c9f41211 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -51,8 +51,8 @@ $ref = GETPOST('ref', 'alpha'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $hookmanager->initHooks(array('invoicesuppliercarddocument')); +$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); // Get parameters $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index 46671b03d4c..afade92390a 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -44,8 +44,8 @@ $ref = GETPOST("ref", 'alpha'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $hookmanager->initHooks(array('invoicesuppliercardinfo')); +$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); $object = new FactureFournisseur($db); diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 1ce43edf5ac..0e7bbc1bfee 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -38,6 +38,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/import.lib.php'; // Load translation files required by the page $langs->loadLangs(array('exports', 'compta', 'errors', 'projects', 'admin')); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('imports')); + // Security check $result = restrictedArea($user, 'import'); @@ -147,11 +150,6 @@ $enclosure = (GETPOST('enclosure', 'nohtml') ? GETPOST('enclosure', 'nohtml') $charset = GETPOST('charset', 'aZ09'); $separator_used = str_replace('\t', "\t", $separator); - -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('imports')); - - $objimport = new Import($db); $objimport->load_arrays($user, ($step == 1 ? '' : $datatoimport)); diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index ef4457e9177..fc5c392d5a7 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -58,12 +58,11 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } +$hookmanager->initHooks(array('loancard', 'globalcard')); $result = restrictedArea($user, 'loan', $id, '', ''); $object = new Loan($db); -$hookmanager->initHooks(array('loancard', 'globalcard')); - $error = 0; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index c484f01495e..cc1e061623f 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -78,12 +78,13 @@ if (!empty($enddatemonth)) { $enddate = dol_mktime(23, 59, 59, $enddatemonth, $enddateday, $enddateyear); } +$hookmanager->initHooks(array('marginagentlist')); + // Security check $result = restrictedArea($user, 'margins'); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $object = new User($db); -$hookmanager->initHooks(array('marginagentlist')); /* * Actions diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 8d5cdd75ab6..95694b1b193 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -61,14 +61,14 @@ if (!$sortfield) { $sortfield = "f.datef"; } +$hookmanager->initHooks(array('tabproductmarginlist')); + $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); if (!$user->hasRight('margins', 'liretous')) { accessforbidden(); } -$hookmanager->initHooks(array('tabproductmarginlist')); - $search_invoice_date_start = ''; $search_invoice_date_end = ''; if (GETPOSTINT('search_invoice_date_start_month')) { diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index 91781a7d148..c6ebcdbb8e3 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -76,6 +76,9 @@ if (isset($user->socid) && $user->socid > 0) { $socid = $user->socid; } +// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array +//$hookmanager->initHooks(array($object->element.'index')); + // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index ac95b0a8e33..458bda8d606 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -187,6 +187,9 @@ if (!empty($canvas)) { $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($id) ? 'rowid' : 'ref'); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('productcard', 'globalcard')); + if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { restrictedArea($user, 'produit', $object->id, 'product&product', '', ''); @@ -198,9 +201,6 @@ if ($object->id > 0) { restrictedArea($user, 'produit|service', 0, 'product&product', '', '', $fieldtype); } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('productcard', 'globalcard')); - // Permissions $usercanread = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'read')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); $usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 2fc3e789ac5..a56f734d006 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -42,6 +42,8 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'in $backtopage = GETPOST('backtopage', 'alpha'); $include_sub_warehouse = !empty(GETPOST('include_sub_warehouse')) ? GETPOST('include_sub_warehouse') : 0; +$hookmanager->initHooks(array('inventorycard', 'globalcard')); // Note that conf->hooks_modules contains array + if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { $result = restrictedArea($user, 'stock', $id); } else { @@ -55,7 +57,6 @@ $extrafields = new ExtraFields($db); $includedocgeneration = false; $diroutputmassaction = null; // $diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('inventorycard', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 9f4660815fb..af420a87464 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -59,6 +59,7 @@ $lineid = GETPOSTINT('lineid'); $batch = GETPOST('batch', 'alphanohtml'); $totalExpectedValuation = 0; $totalRealValuation = 0; +$hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { $result = restrictedArea($user, 'stock', $id); } else { @@ -69,7 +70,7 @@ if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { $object = new Inventory($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array + // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); diff --git a/htdocs/product/note.php b/htdocs/product/note.php index b718f9894ec..f5e431fc313 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -52,6 +52,8 @@ if ($id > 0 || !empty($ref)) { $permissionnote = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')); // Used by the include of actions_setnotes.inc.php +$hookmanager->initHooks(array('productnote')); + if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { restrictedArea($user, 'product', $object->id, 'product&product', '', ''); @@ -63,10 +65,6 @@ if ($object->id > 0) { restrictedArea($user, 'product|service', $fieldvalue, 'product&product', '', '', $fieldtype); } - -$hookmanager->initHooks(array('productnote')); - - /* * Actions */ diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index ba148724206..62af7f3dd3b 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -42,14 +42,16 @@ $ref = GETPOST('ref', 'alpha'); $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); $socid = ''; + if (!empty($user->socid)) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('productstatspropal')); +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); + // Load variable for pagination $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index b89e5f16929..c69ed74ff58 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -72,13 +72,13 @@ if (!$sortorder) { $sortorder = "DESC"; } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('warehousecard', 'stocklist', 'globalcard')); + // Security check //$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); $result = restrictedArea($user, 'stock'); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('warehousecard', 'stocklist', 'globalcard')); - $object = new Entrepot($db); $extrafields = new ExtraFields($db); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index df89401e1c8..a1c8906f6aa 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -50,9 +50,6 @@ if (isModEnabled('productbatch')) { $langs->load("productbatch"); } -// Security check -$result = restrictedArea($user, 'stock'); - $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); $msid = GETPOSTINT('msid'); @@ -92,9 +89,13 @@ if (!$sortorder) { $pdluoid = GETPOSTINT('pdluoid'); +$hookmanager->initHooks(array('movementlist')); + +// Security check +$result = restrictedArea($user, 'stock'); + // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $object = new MouvementStock($db); -$hookmanager->initHooks(array('movementlist')); $extrafields = new ExtraFields($db); $formfile = new FormFile($db); diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index e594d612f73..30924bcde8f 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -54,11 +54,12 @@ $fieldtype = 'rowid'; if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service'); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('productlotdocuments')); +$result = restrictedArea($user, 'produit|service'); + // Get parameters $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index cf358161eb4..e895b6d792b 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -45,11 +45,12 @@ $langs->loadLangs(array('products', 'stocks', 'orders')); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'produit|service'); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('stockreplenishlist')); +$result = restrictedArea($user, 'produit|service'); + //checks if a product has been ordered $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index ca9529267b4..0eb8369a4ef 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -53,6 +53,9 @@ if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('producttranslationcard', 'globalcard')); + if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { restrictedArea($user, 'produit', $object->id, 'product&product', '', ''); @@ -64,10 +67,6 @@ if ($object->id > 0) { restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('producttranslationcard', 'globalcard')); - - /* * Actions */ diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index 1a1c14ac052..773e7fad1a1 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -61,11 +61,12 @@ if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($obj // Security check $socid = 0; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignment. -$result = restrictedArea($user, 'projet', $id, 'projet&project'); $hookmanager->initHooks(array('projectcontactcard', 'globalcard')); +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignment. +$result = restrictedArea($user, 'projet', $id, 'projet&project'); + /* * Actions diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 2b983efa0aa..24459f7dcbd 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -187,11 +187,12 @@ if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($obj // Security check $socid = $object->socid; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignment. -$result = restrictedArea($user, 'projet', $object->id, 'projet&project'); $hookmanager->initHooks(array('projectOverview')); +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignment. +$result = restrictedArea($user, 'projet', $object->id, 'projet&project'); + /* * View diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 86e7771c855..fc11ddad28e 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -139,14 +139,15 @@ if (!$sortorder) { // Security check $socid = 0; + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('projecttaskscard', 'globalcard')); + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignment. $result = restrictedArea($user, 'projet', $id, 'projet&project'); $diroutputmassaction = $conf->project->dir_output.'/tasks/temp/massgeneration/'.$user->id; -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('projecttaskscard', 'globalcard')); - $progress = GETPOSTINT('progress'); $budget_amount = GETPOSTFLOAT('budget_amount'); $billable = (GETPOST('billable', 'aZ') == 'yes'? 1 : 0); diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index eb692907114..d4591534da6 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -69,6 +69,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. +$hookmanager->initHooks(array('resource', 'resource_card', 'globalcard')); $result = restrictedArea($user, 'resource', $object->id, 'resource'); @@ -80,7 +81,6 @@ $permissiontodelete = $user->hasRight('resource', 'delete'); * Actions */ -$hookmanager->initHooks(array('resource', 'resource_card', 'globalcard')); $parameters = array('resource_id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 22cb2326c1a..253b273d774 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -46,6 +46,10 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('consumptionthirdparty', 'globalcard')); + $result = restrictedArea($user, 'societe', $socid, '&societe'); $object = new Societe($db); if ($socid > 0) { @@ -90,11 +94,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $thirdTypeSelect = GETPOST("third_select_id", 'aZ09'); $type_element = GETPOST('type_element') ? GETPOST('type_element') : ''; - -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('consumptionthirdparty', 'globalcard')); - - /* * Actions */ diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 720b03549f6..19fe3cda5fd 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -44,6 +44,10 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('thirdpartynotification', 'globalcard')); + $result = restrictedArea($user, 'societe', '', ''); $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; @@ -67,11 +71,6 @@ $now = dol_now(); $object = new Societe($db); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('thirdpartynotification', 'globalcard')); - - - /* * Actions */ diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index d67568189a6..b5f35699e90 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -59,14 +59,15 @@ $socid = GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id'); if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('thirdpartycustomerprice', 'globalcard')); + $result = restrictedArea($user, 'societe', $socid, '&societe'); // Initialize objects $object = new Societe($db); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('thirdpartycustomerprice', 'globalcard')); - $error = 0; diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index 2e3c84654bc..a12272c94ab 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -53,11 +53,12 @@ $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'societe', $socid, '&societe'); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('projectthirdparty')); +$result = restrictedArea($user, 'societe', $socid, '&societe'); + $object = new Societe($db); $permissiontodelete = $user->hasRight('societe', 'supprimer'); diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 227de670c38..3c6b3ce3850 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -65,16 +65,16 @@ $pagenext = $page + 1; if ($user->socid) { $socid = $user->socid; } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('contactthirdparty', 'globalcard')); + $result = restrictedArea($user, 'societe', $id, ''); // Initialize objects $object = new Societe($db); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('contactthirdparty', 'globalcard')); - - /* * Actions */ diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index adb7956d743..cd82efbe336 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -47,14 +47,15 @@ $action = GETPOST('action', 'aZ09'); if ($user->socid) { $socid = $user->socid; } + +$hookmanager->initHooks(array('supplier_proposalcontactcard', 'globalcard')); + $result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal', ''); $object = new SupplierProposal($db); $permissiontoedit = $user->hasRight('supplier_proposal', 'creer'); -$hookmanager->initHooks(array('supplier_proposalcontactcard', 'globalcard')); - /* * Actions diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index 9c435ca8485..ec8ba488e95 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -68,6 +68,9 @@ if ($user->socid > 0) { } $feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user'); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard')); + $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); // If user is not user that read and no permission to read other users, we stop @@ -75,9 +78,6 @@ if (($object->id != $user->id) && (!$user->hasRight('user', 'user', 'lire'))) { accessforbidden(); } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard')); - /* * Actions */ diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 6b540e1f407..647853897e2 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -39,11 +39,10 @@ if ($user->socid > 0) { } $feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user'); -$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); - // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('usercard', 'globalcard')); +$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); /* * Actions diff --git a/htdocs/user/document.php b/htdocs/user/document.php index 06b51074c95..e0a08cd272f 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -75,6 +75,9 @@ if ($user->socid > 0) { } $feature2 = 'user'; +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('usercard', 'userdoc', 'globalcard')); + $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); if ($user->id != $id && !$canreaduser) { @@ -108,11 +111,6 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->user->dir_output."/".$object->id; } -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('usercard', 'userdoc', 'globalcard')); - - - /* * Actions */ diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index a40826c632f..b79f33a0655 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -43,15 +43,15 @@ if ($user->socid > 0) { } $feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user'); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('usercard', 'userldap', 'globalcard')); + $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $object = new User($db); $object->fetch($id, '', '', 1); $object->loadRights(); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('usercard', 'userldap', 'globalcard')); - /* * Actions diff --git a/htdocs/user/note.php b/htdocs/user/note.php index c6db1416a7b..b90b2bba740 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -59,11 +59,11 @@ if ($user->socid > 0) { } $feature2 = (($socid && $user->hasRight("user", "self", "write")) ? '' : 'user'); -$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); - // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('usercard', 'usernote', 'globalcard')); +$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); + /* * Actions diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index e51f7469f5d..0f45e53cb49 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -58,6 +58,9 @@ if ($user->socid > 0) { } $feature2 = (($socid && $user->hasRight("user", "self", "write")) ? '' : 'user'); +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('usercard', 'userihm', 'globalcard')); + $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); if ($user->id != $id && !$canreaduser) { accessforbidden(); @@ -81,10 +84,6 @@ $searchformtitle=array($langs->trans("Companies"),$langs->trans("Contacts"),$lan $form = new Form($db); $formadmin = new FormAdmin($db); -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('usercard', 'userihm', 'globalcard')); - - /* * Actions */ diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 6d93054cee1..1ab6fa0f09e 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -74,6 +74,9 @@ if ($user->id == $id && (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user accessforbidden(); } +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('usercard', 'userperms', 'globalcard')); + $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); if ($user->id != $id && !$canreaduser) { accessforbidden(); @@ -85,10 +88,6 @@ $object->loadRights(); $entity = $conf->entity; -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('usercard', 'userperms', 'globalcard')); - - /* * Actions */ diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index 67afacc7de6..5cf4220d79a 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -49,6 +49,10 @@ if (!isModEnabled('variants')) { if ($user->socid > 0) { // Protection if external user accessforbidden(); } + +// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context +$hookmanager->initHooks(array('productattributecard', 'globalcard')); + $result = restrictedArea($user, 'variants'); $object = new ProductAttribute($db); @@ -56,9 +60,6 @@ $object = new ProductAttribute($db); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once' -// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context -$hookmanager->initHooks(array('productattributecard', 'globalcard')); - $permissiontoread = $user->hasRight('variants', 'read'); $permissiontoadd = $user->hasRight('variants', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontoedit = $user->hasRight('variants', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php