From 79b954362b1439d85cc532e3fe8c80242f5cce92 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Fri, 19 Jan 2024 19:20:25 +0100 Subject: [PATCH] #815 [Substitution] fix: fatal saturne_completesubstitutionarray function --- core/substitutions/functions_saturne.lib.php | 33 +++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/core/substitutions/functions_saturne.lib.php b/core/substitutions/functions_saturne.lib.php index 15b8e50c..1d7f4a58 100644 --- a/core/substitutions/functions_saturne.lib.php +++ b/core/substitutions/functions_saturne.lib.php @@ -34,26 +34,29 @@ */ function saturne_completesubstitutionarray(array &$substitutionarray, Translate $langs, $object) { - // Global variables definitions - global $conf, $db; + $signatoryID = GETPOST('signatoryID', 'int'); - // Get module parameters - $moduleName = GETPOST('module_name', 'alpha'); - $objectType = GETPOST('object_type', 'alpha'); - $documentType = GETPOST('document_type', 'alpha'); + if (GETPOSTISSET('signatoryID') && $signatoryID > 0) { + // Global variables definitions + global $conf, $db; - $moduleNameLowerCase = strtolower($moduleName); + // Get module parameters + $moduleName = GETPOST('module_name', 'alpha'); + $objectType = GETPOST('object_type', 'alpha'); + $documentType = GETPOST('document_type', 'alpha'); - // Load Saturne libraries - require_once __DIR__ . '/../../class/saturnesignature.class.php'; + $moduleNameLowerCase = strtolower($moduleName); - // Initialize technical objects - $signatory = new SaturneSignature($db, $moduleNameLowerCase, $object->element); + // Load Saturne libraries + require_once __DIR__ . '/../../class/saturnesignature.class.php'; - $signatoryID = GETPOST('signatoryID', 'int'); - $signatory->fetch($signatoryID); + // Initialize technical objects + $signatory = new SaturneSignature($db, $moduleNameLowerCase, $object->element); + + $signatory->fetch($signatoryID); - $url = dol_buildpath('/custom/saturne/public/signature/add_signature.php?track_id=' . $signatory->signature_url . '&entity=' . $conf->entity . '&module_name=' . $moduleNameLowerCase . '&object_type=' . $object->element . '&document_type=' . $documentType . '&modal_to_open=modal-signature' . $signatory->id, 3); + $url = dol_buildpath('/custom/saturne/public/signature/add_signature.php?track_id=' . $signatory->signature_url . '&entity=' . $conf->entity . '&module_name=' . $moduleNameLowerCase . '&object_type=' . $object->element . '&document_type=' . $documentType . '&modal_to_open=modal-signature' . $signatory->id, 3); - $substitutionarray['__SATURNE_SIGNATORY_URL__'] = '' . $langs->transnoentities('SignatureEmailURL') . ''; + $substitutionarray['__SATURNE_SIGNATORY_URL__'] = '' . $langs->transnoentities('SignatureEmailURL') . ''; + } }