Skip to content

Commit

Permalink
new: when initHook() and restrictedArea() exists always execute first…
Browse files Browse the repository at this point in the history
… initHook()
  • Loading branch information
FHenry committed Aug 20, 2024
1 parent 69bc79b commit 804d039
Show file tree
Hide file tree
Showing 77 changed files with 221 additions and 185 deletions.
6 changes: 3 additions & 3 deletions htdocs/adherents/type_ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
$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
*/
Expand Down
4 changes: 2 additions & 2 deletions htdocs/barcode/printsheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
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
Expand Down
6 changes: 3 additions & 3 deletions htdocs/categories/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
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');

Expand All @@ -72,9 +75,6 @@
$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;


Expand Down
5 changes: 3 additions & 2 deletions htdocs/categories/photos.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
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');

Expand All @@ -65,8 +68,6 @@

$upload_dir = $conf->categorie->multidir_output[$object->entity];

$hookmanager->initHooks(array('categorycard'));

/*
* Actions
*/
Expand Down
6 changes: 3 additions & 3 deletions htdocs/categories/viewcat.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
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');

Expand All @@ -91,9 +94,6 @@
$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
*/
Expand Down
2 changes: 2 additions & 0 deletions htdocs/comm/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
$action = '';
$socid = $user->socid;
}

$hookmanager->initHooks(array('contactlist'));
$result = restrictedArea($user, 'societe', $socid, '');


Expand Down
1 change: 1 addition & 0 deletions htdocs/comm/multiprix.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
$action = '';
$id = $user->socid;
}
$hookmanager->initHooks(array('thirdpartyprice', 'globalcard'));
$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);


Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
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");

Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@
$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
Expand Down
1 change: 0 additions & 1 deletion htdocs/commande/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
$hookmanager->initHooks(array('ordercontact', 'globalcard'));

$result = restrictedArea($user, 'commande', $id, '');
$hookmanager->initHooks(array('ordercontactcard', 'globalcard'));

$usercancreate = $user->hasRight("commande", "creer");

Expand Down
4 changes: 3 additions & 1 deletion htdocs/compta/bank/line.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@
$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);
Expand Down
9 changes: 4 additions & 5 deletions htdocs/compta/bank/treso.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@
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
Expand Down
7 changes: 4 additions & 3 deletions htdocs/compta/bank/various_payment/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@
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');


Expand Down
7 changes: 4 additions & 3 deletions htdocs/compta/deplacement/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,17 @@
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');
$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


Expand Down
3 changes: 2 additions & 1 deletion htdocs/compta/facture/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@
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");

Expand Down
5 changes: 4 additions & 1 deletion htdocs/compta/journal/purchasesjournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@
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
Expand Down
5 changes: 4 additions & 1 deletion htdocs/compta/journal/sellsjournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@
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
Expand Down
7 changes: 3 additions & 4 deletions htdocs/compta/localtax/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@
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
Expand Down
5 changes: 4 additions & 1 deletion htdocs/compta/localtax/clients.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,16 @@
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;
/*
Expand Down
7 changes: 4 additions & 3 deletions htdocs/compta/prelevement/rejets.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
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 {
Expand Down Expand Up @@ -88,9 +92,6 @@
$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,";
Expand Down
5 changes: 3 additions & 2 deletions htdocs/compta/recap-compta.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@
$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);
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;
Expand Down
6 changes: 4 additions & 2 deletions htdocs/compta/resultat/clientfourn.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,16 @@
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
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/resultat/result.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@
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
Expand Down
7 changes: 4 additions & 3 deletions htdocs/compta/stats/cabyprodserv.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
if ($user->socid > 0) {
$socid = $user->socid;
}

// Hook
$hookmanager->initHooks(array('cabyprodservlist'));

if (isModEnabled('comptabilite')) {
$result = restrictedArea($user, 'compta', '', '', 'resultat');
}
Expand Down Expand Up @@ -83,9 +87,6 @@
$selected_type = -1;
}

// Hook
$hookmanager->initHooks(array('cabyprodservlist'));

// Date range
$year = GETPOST("year");
$month = GETPOST("month");
Expand Down
Loading

0 comments on commit 804d039

Please sign in to comment.