From 09b6d1aa90daa7c68285ab605cedbcaebe93b096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 13 Aug 2024 12:11:19 +0200 Subject: [PATCH] NEW add hook in dolibarr_set_const admin.lib.php (#30605) * add hook in dolibarr_set_const admin.lib.php * Update admin.lib.php * Update admin.lib.php --- htdocs/core/lib/admin.lib.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 5b5d443b872..16a76979147 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -656,7 +656,7 @@ function dolibarr_get_const($db, $name, $entity = 1) */ function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0, $note = '', $entity = 1) { - global $conf; + global $conf, $hookmanager; // Clean parameters $name = trim($name); @@ -666,6 +666,24 @@ function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0, dol_print_error($db, "Error: Call to function dolibarr_set_const with wrong parameters"); exit; } + if (! is_object($hookmanager)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + } + + $parameters = array( + 'name' => $name, + 'value' => $value, + 'type' => $type, + 'visible' => $visible, + 'note' => $note, + 'entity' => $entity, + ); + + $reshook = $hookmanager->executeHooks('dolibarrSetConst', $parameters); // Note that $action and $object may have been modified by some hooks + if ($reshook != 0) { + return $reshook; + } //dol_syslog("dolibarr_set_const name=$name, value=$value type=$type, visible=$visible, note=$note entity=$entity");