From f8ea5ac0776e80476a0f41a6bdb418c645feacdd Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Fri, 15 Mar 2024 23:33:51 +0100 Subject: [PATCH 01/23] Proposed function for records that can't be found --- htdocs/core/lib/functions.lib.php | 66 +++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4a6e3a42f01..b8762bb0414 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13905,3 +13905,69 @@ function buildParamDate($prefix, $timestamp = null, $hourTime = '', $gm = 'auto' return '&' . http_build_query($TParam); } + +/** + * Displays an error page when a record is not found. It allows customization of the message, + * whether to include the header and footer, and if only the message should be shown without additional details. + * The function also supports executing additional hooks for customized handling of error pages. + * + * @param string $message Custom error message to display. If empty, a default "Record Not Found" message is shown. + * @param int $printheader Determines if the page header should be printed (1 = yes, 0 = no). + * @param int $printfooter Determines if the page footer should be printed (1 = yes, 0 = no). + * @param int $showonlymessage If set to 1, only the error message is displayed without any additional information or hooks. + * @param mixed $params Optional parameters to pass to hooks for further processing or customization. + * @global object $conf Dolibarr configuration object (global) + * @global object $db Database connection object (global) + * @global object $user Current user object (global) + * @global Translate $langs Language translation object, initialized within the function if not already. + * @global object $hookmanager Hook manager object, initialized within the function if not already for executing hooks. + * @global string $action Current action, can be modified by hooks. + * @global object $object Current object, can be modified by hooks. + * @return void This function terminates script execution after outputting the error page. + */ + +function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null) + { + global $conf, $db, $user, $langs, $hookmanager; + global $action, $object; + + if (!is_object($langs)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; + $langs = new Translate('', $conf); + $langs->setDefaultLang(); + } + + $langs->load("errors"); + + if ($printheader) { + if (function_exists("llxHeader")) { + llxHeader(''); + } elseif (function_exists("llxHeaderVierge")) { + llxHeaderVierge(''); + } + } + print '
'; + if (empty($message)) { + print $langs->trans("ErrorRecordNotFound"); + } else { + print $langs->trans($message); + } + print '
'; + print '
'; + if (empty($showonlymessage)) { + if (empty($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + $hookmanager->initHooks(array('main')); + } + + $parameters = array('message'=>$message, 'params'=>$params); + $reshook = $hookmanager->executeHooks('getErrorRecordNotFound', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + print $hookmanager->resPrint; + } + if ($printfooter && function_exists("llxFooter")) { + llxFooter(); + } + exit(0); + } From 05ee3d482c0ceab0fcde6c4afe775115cc6b5048 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:00:06 +0100 Subject: [PATCH 02/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 35 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b8762bb0414..8c055faf841 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13925,32 +13925,31 @@ function buildParamDate($prefix, $timestamp = null, $hourTime = '', $gm = 'auto' * @global object $object Current object, can be modified by hooks. * @return void This function terminates script execution after outputting the error page. */ - function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null) - { - global $conf, $db, $user, $langs, $hookmanager; +{ + global $conf, $db, $user, $langs, $hookmanager; global $action, $object; - if (!is_object($langs)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; - $langs = new Translate('', $conf); - $langs->setDefaultLang(); + if (!is_object($langs)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; + $langs = new Translate('', $conf); + $langs->setDefaultLang(); } - $langs->load("errors"); + $langs->load("errors"); - if ($printheader) { - if (function_exists("llxHeader")) { - llxHeader(''); + if ($printheader) { + if (function_exists("llxHeader")) { + llxHeader(''); } elseif (function_exists("llxHeaderVierge")) { - llxHeaderVierge(''); + llxHeaderVierge(''); } } print '
'; - if (empty($message)) { - print $langs->trans("ErrorRecordNotFound"); + if (empty($message)) { + print $langs->trans("ErrorRecordNotFound"); } else { - print $langs->trans($message); + print $langs->trans($message); } print '
'; print '
'; @@ -13962,9 +13961,9 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show $hookmanager->initHooks(array('main')); } - $parameters = array('message'=>$message, 'params'=>$params); - $reshook = $hookmanager->executeHooks('getErrorRecordNotFound', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - print $hookmanager->resPrint; + $parameters = array('message'=>$message, 'params'=>$params); + $reshook = $hookmanager->executeHooks('getErrorRecordNotFound', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + print $hookmanager->resPrint; } if ($printfooter && function_exists("llxFooter")) { llxFooter(); From c12af524d57e9169e3ed46a28c16778e8193b578 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:05:34 +0100 Subject: [PATCH 03/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 75 ++++++++++++++++--------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8c055faf841..4651e6a17e6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13927,46 +13927,47 @@ function buildParamDate($prefix, $timestamp = null, $hourTime = '', $gm = 'auto' */ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null) { - global $conf, $db, $user, $langs, $hookmanager; + global $conf, $db, $user, $langs, $hookmanager; global $action, $object; - if (!is_object($langs)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; - $langs = new Translate('', $conf); - $langs->setDefaultLang(); + if (!is_object($langs)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; + $langs = new Translate('', $conf); + $langs->setDefaultLang(); } - $langs->load("errors"); + $langs->load("errors"); - if ($printheader) { - if (function_exists("llxHeader")) { - llxHeader(''); - } elseif (function_exists("llxHeaderVierge")) { - llxHeaderVierge(''); - } - } - print '
'; - if (empty($message)) { - print $langs->trans("ErrorRecordNotFound"); - } else { - print $langs->trans($message); - } - print '
'; - print '
'; - if (empty($showonlymessage)) { - if (empty($hookmanager)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager = new HookManager($db); - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context - $hookmanager->initHooks(array('main')); - } + if ($printheader) { + if (function_exists("llxHeader")) { + llxHeader(''); + } elseif (function_exists("llxHeaderVierge")) { + llxHeaderVierge(''); + } + } + print '
'; + if (empty($message)) { + print $langs->trans("ErrorRecordNotFound"); + } else { + print $langs->trans($message); + } + print '
'; + print '
'; + if (empty($showonlymessage)) { + if (empty($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + $hookmanager->initHooks(array('main')); + } - $parameters = array('message'=>$message, 'params'=>$params); - $reshook = $hookmanager->executeHooks('getErrorRecordNotFound', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - print $hookmanager->resPrint; - } - if ($printfooter && function_exists("llxFooter")) { - llxFooter(); - } - exit(0); - } + $parameters = array('message'=>$message, 'params'=>$params); + $reshook = $hookmanager->executeHooks('getErrorRecordNotFound', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + print $hookmanager->resPrint; + } + if ($printfooter && function_exists("llxFooter")) { + llxFooter(); + } + exit(0); +} + From 48bbc532b9ce94a5d82184c365405c62f8a9d8f7 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:11:06 +0100 Subject: [PATCH 04/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4651e6a17e6..e5d23dc7115 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13927,14 +13927,14 @@ function buildParamDate($prefix, $timestamp = null, $hourTime = '', $gm = 'auto' */ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null) { - global $conf, $db, $user, $langs, $hookmanager; - global $action, $object; - + global $conf, $db, $user, $langs, $hookmanager; + global $action, $object; + if (!is_object($langs)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; - $langs = new Translate('', $conf); - $langs->setDefaultLang(); - } + include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; + $langs = new Translate('', $conf); + $langs->setDefaultLang(); + } $langs->load("errors"); From e1cf39773bf71ad9c29914d045d3c9f3ae08c6ab Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:13:51 +0100 Subject: [PATCH 05/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e5d23dc7115..a6178020bdc 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13930,7 +13930,7 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show global $conf, $db, $user, $langs, $hookmanager; global $action, $object; - if (!is_object($langs)) { + if (!is_object($langs)) { include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; $langs = new Translate('', $conf); $langs->setDefaultLang(); From 13350802e5c04f3821239fa35ae9f62b50d3b334 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:16:15 +0100 Subject: [PATCH 06/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a6178020bdc..c4a99a7ecfa 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13929,7 +13929,6 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show { global $conf, $db, $user, $langs, $hookmanager; global $action, $object; - if (!is_object($langs)) { include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; $langs = new Translate('', $conf); From fb9f9a7c8b4ae71182df185c2b47378ad08407a3 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:22:17 +0100 Subject: [PATCH 07/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c4a99a7ecfa..610eb22a218 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13929,14 +13929,15 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show { global $conf, $db, $user, $langs, $hookmanager; global $action, $object; + if (!is_object($langs)) { include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; $langs = new Translate('', $conf); $langs->setDefaultLang(); } - + $langs->load("errors"); - + if ($printheader) { if (function_exists("llxHeader")) { llxHeader(''); @@ -13944,6 +13945,7 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show llxHeaderVierge(''); } } + print '
'; if (empty($message)) { print $langs->trans("ErrorRecordNotFound"); @@ -13952,18 +13954,20 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show } print '
'; print '
'; + if (empty($showonlymessage)) { if (empty($hookmanager)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager = new HookManager($db); - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('main')); } $parameters = array('message'=>$message, 'params'=>$params); $reshook = $hookmanager->executeHooks('getErrorRecordNotFound', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - print $hookmanager->resPrint; + print $hookmanager->resPrint; } + if ($printfooter && function_exists("llxFooter")) { llxFooter(); } From 4dc118a759bb883ccaa5a77d84d95c3b9bb0871a Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:25:05 +0100 Subject: [PATCH 08/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 610eb22a218..b5d8b656189 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13973,4 +13973,3 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show } exit(0); } - From d339f4252c031148623b40c4f763a6d330886472 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:26:50 +0100 Subject: [PATCH 09/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b5d8b656189..b15deef2f01 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13967,8 +13967,8 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show $reshook = $hookmanager->executeHooks('getErrorRecordNotFound', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; } - - if ($printfooter && function_exists("llxFooter")) { + + if ($printfooter && function_exists("llxFooter")) { llxFooter(); } exit(0); From dd7f84abde2a5f144e9c260e95c4518801aafc1b Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:30:24 +0100 Subject: [PATCH 10/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b15deef2f01..e6b133f3b6f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13929,15 +13929,15 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show { global $conf, $db, $user, $langs, $hookmanager; global $action, $object; - + if (!is_object($langs)) { include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; $langs = new Translate('', $conf); $langs->setDefaultLang(); } - + $langs->load("errors"); - + if ($printheader) { if (function_exists("llxHeader")) { llxHeader(''); @@ -13945,7 +13945,7 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show llxHeaderVierge(''); } } - + print '
'; if (empty($message)) { print $langs->trans("ErrorRecordNotFound"); @@ -13954,7 +13954,7 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show } print '
'; print '
'; - + if (empty($showonlymessage)) { if (empty($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; @@ -13962,7 +13962,7 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('main')); } - + $parameters = array('message'=>$message, 'params'=>$params); $reshook = $hookmanager->executeHooks('getErrorRecordNotFound', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; From cd47aa1aad1be9cf6577e5431de0f46698b0aad4 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:34:09 +0100 Subject: [PATCH 11/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e6b133f3b6f..702f90beeae 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13932,8 +13932,8 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show if (!is_object($langs)) { include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; - $langs = new Translate('', $conf); - $langs->setDefaultLang(); + $langs = new Translate('', $conf); + $langs->setDefaultLang(); } $langs->load("errors"); From 82dc53e796c5ea5440a7956678a8cb618f1a256a Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:36:43 +0100 Subject: [PATCH 12/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 702f90beeae..60de32cfb5e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13936,15 +13936,15 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show $langs->setDefaultLang(); } - $langs->load("errors"); + $langs->load("errors"); - if ($printheader) { - if (function_exists("llxHeader")) { - llxHeader(''); - } elseif (function_exists("llxHeaderVierge")) { - llxHeaderVierge(''); - } - } + if ($printheader) { + if (function_exists("llxHeader")) { + llxHeader(''); + } elseif (function_exists("llxHeaderVierge")) { + llxHeaderVierge(''); + } + } print '
'; if (empty($message)) { From 0c7ed79f40c85a6684fdc99a6e482e123842198b Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:42:57 +0100 Subject: [PATCH 13/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 60de32cfb5e..ea7c71bf971 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13939,21 +13939,21 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show $langs->load("errors"); if ($printheader) { - if (function_exists("llxHeader")) { + if (function_exists("llxHeader")) { llxHeader(''); } elseif (function_exists("llxHeaderVierge")) { llxHeaderVierge(''); } } - print '
'; - if (empty($message)) { - print $langs->trans("ErrorRecordNotFound"); - } else { - print $langs->trans($message); - } - print '
'; - print '
'; + print '
'; + if (empty($message)) { + print $langs->trans("ErrorRecordNotFound"); + } else { + print $langs->trans($message); + } + print '
'; + print '
'; if (empty($showonlymessage)) { if (empty($hookmanager)) { From 3fba583ffadb45f723c0fe72238c1f0fd461beaa Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:46:40 +0100 Subject: [PATCH 14/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ea7c71bf971..16328dfcece 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13955,21 +13955,21 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show print '
'; print '
'; - if (empty($showonlymessage)) { - if (empty($hookmanager)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager = new HookManager($db); - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context - $hookmanager->initHooks(array('main')); - } + if (empty($showonlymessage)) { + if (empty($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + $hookmanager->initHooks(array('main')); + } - $parameters = array('message'=>$message, 'params'=>$params); - $reshook = $hookmanager->executeHooks('getErrorRecordNotFound', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - print $hookmanager->resPrint; - } + $parameters = array('message'=>$message, 'params'=>$params); + $reshook = $hookmanager->executeHooks('getErrorRecordNotFound', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + print $hookmanager->resPrint; + } if ($printfooter && function_exists("llxFooter")) { - llxFooter(); - } - exit(0); + llxFooter(); + } + exit(0); } From 3b0bd0c427312b5f1b6ba72a6043d3772ff2418b Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 00:49:12 +0100 Subject: [PATCH 15/23] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 16328dfcece..99f35c5740f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13969,7 +13969,7 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show } if ($printfooter && function_exists("llxFooter")) { - llxFooter(); + llxFooter(); } exit(0); } From 6b20661c37da2c53b7f612d5a4f6347097ee3421 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:31:35 +0100 Subject: [PATCH 16/23] Update card.php with new function recordNotFound --- htdocs/societe/card.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 52921b28c80..3cc208d270d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -142,9 +142,7 @@ if ($socid > 0) { } if (!($object->id > 0) && $action == 'view') { - $langs->load("errors"); - print($langs->trans('ErrorRecordNotFound')); - exit; + recordNotFound(); } // Get object canvas (By default, this is not defined, so standard usage of dolibarr) From 09b89903ca19962692d6ec2fc3dc646f50001cb3 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:52:04 +0100 Subject: [PATCH 17/23] Update card.php --- htdocs/societe/card.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 3cc208d270d..52921b28c80 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -142,7 +142,9 @@ if ($socid > 0) { } if (!($object->id > 0) && $action == 'view') { - recordNotFound(); + $langs->load("errors"); + print($langs->trans('ErrorRecordNotFound')); + exit; } // Get object canvas (By default, this is not defined, so standard usage of dolibarr) From a516b920405aa1a583a56f46b6cf39cf6c40f238 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 12:02:33 +0100 Subject: [PATCH 18/23] Update card.php with new function record not found --- htdocs/societe/card.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 52921b28c80..3cc208d270d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -142,9 +142,7 @@ if ($socid > 0) { } if (!($object->id > 0) && $action == 'view') { - $langs->load("errors"); - print($langs->trans('ErrorRecordNotFound')); - exit; + recordNotFound(); } // Get object canvas (By default, this is not defined, so standard usage of dolibarr) From a72d772c617a1e8a73c8ed455eadb721a913a674 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 12:24:13 +0100 Subject: [PATCH 19/23] Update card.php From efd11891cc4e7586877709cdb2ae3b54de26bd6c Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 12:43:52 +0100 Subject: [PATCH 20/23] Update card.php From 62e3d499d68729aff9915cd96e5bff636b882664 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 12:47:35 +0100 Subject: [PATCH 21/23] Update knowledgemanagement.php --- htdocs/admin/knowledgemanagement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index c3b7a4be39c..9e0b93c022b 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -95,7 +95,7 @@ if ($action == 'updateMask') { $tmpobjectkey = GETPOST('object', 'aZ09'); if (in_array($tmpobjectkey, $myTmpObjects)) { - $tmpobject = new $tmpobjectkey($db); + $tmpobject = new $tmpobjectkey(); $tmpobject->initAsSpecimen(); // Search template files From ee481d7dd0c7f13f276e9948e65a3ac1f011eaaa Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 12:49:01 +0100 Subject: [PATCH 22/23] Update knowledgemanagement.php --- htdocs/admin/knowledgemanagement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index 9e0b93c022b..c3b7a4be39c 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -95,7 +95,7 @@ if ($action == 'updateMask') { $tmpobjectkey = GETPOST('object', 'aZ09'); if (in_array($tmpobjectkey, $myTmpObjects)) { - $tmpobject = new $tmpobjectkey(); + $tmpobject = new $tmpobjectkey($db); $tmpobject->initAsSpecimen(); // Search template files From 23d656de0dcbf2a892123fb4a4efa848eef918a7 Mon Sep 17 00:00:00 2001 From: Zephyriony <142790847+zephyriony@users.noreply.github.com> Date: Sat, 16 Mar 2024 14:19:59 +0100 Subject: [PATCH 23/23] Update card.php