From b52f4265186e16e49d6e200880aae58e1a166fa6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Aug 2023 18:46:33 +0200 Subject: [PATCH] Remove hardcoded value --- htdocs/core/class/hookmanager.class.php | 4 ++-- htdocs/core/modules/modBom.class.php | 4 ++-- htdocs/modulebuilder/template/myobject_agenda.php | 2 +- htdocs/modulebuilder/template/myobject_card.php | 2 +- htdocs/modulebuilder/template/myobject_contact.php | 2 +- htdocs/modulebuilder/template/myobject_document.php | 2 +- htdocs/modulebuilder/template/myobject_note.php | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 2c0610084aa..1cc1244d8df 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -77,7 +77,7 @@ class HookManager * Then when a hook executeHooks('aMethod'...) is called, the method aMethod found into class will be executed. * * @param string[] $arraycontext Array list of searched hooks tab/features. For example: 'thirdpartycard' (for hook methods into page card thirdparty), 'thirdpartydao' (for hook methods into Societe), ... - * @return int|void Always 1 + * @return int 0 or 1 */ public function initHooks($arraycontext) { @@ -85,7 +85,7 @@ class HookManager // Test if there is hooks to manage if (!is_array($conf->modules_parts['hooks']) || empty($conf->modules_parts['hooks'])) { - return; + return 0; } // For backward compatibility diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index d8c95c3c26b..c3b642626a9 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -89,8 +89,8 @@ class modBom extends DolibarrModules 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - 'css' => array('/bom/css/bom.css.php'), // Set this to relative path of css file if module has its own css file - 'js' => array('/bom/js/bom.js.php'), // Set this to relative path of js file if module must load a js on all pages + 'css' => array('/bom/css/bom.css.php'), // Set this to relative path of css file if module has its own css file + 'js' => array('/bom/js/bom.js.php'), // Set this to relative path of js file if module must load a js on all pages 'hooks' => array('data'=>array('hookcontext1','hookcontext2'), 'entity'=>'0'), // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' 'moduleforexternal' => 0 // Set this to 1 if feature of module are opened to external users */ diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index b93c503fda4..e135c56a485 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -121,7 +121,7 @@ if (!$sortorder) { $object = new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectagenda', 'globalcard')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array($object->element.'agenda', '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/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index b9c3be569aa..774bba36fa1 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -105,7 +105,7 @@ if (!empty($backtopagejsfields)) { $object = new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectcard', 'globalcard')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array($object->element.'card', '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/modulebuilder/template/myobject_contact.php b/htdocs/modulebuilder/template/myobject_contact.php index 4f384a006e5..f2e36488df3 100644 --- a/htdocs/modulebuilder/template/myobject_contact.php +++ b/htdocs/modulebuilder/template/myobject_contact.php @@ -71,7 +71,7 @@ $action = GETPOST('action', 'aZ09'); $object = new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectcontact', 'globalcard')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array($object->element.'contact', '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/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 7ffa467cdc0..949e41e56f4 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -111,7 +111,7 @@ if (!$sortfield) { $object = new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectdocument', 'globalcard')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array($object->element.'document', '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/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index 584a7ccd9e3..c77d0db3378 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -89,7 +89,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); $object = new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectnote', 'globalcard')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array($object->element.'note', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element);