From c2c02215358c63d1cb975e684fa60e9e88bdec8a Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Mon, 22 May 2017 14:57:03 +0000 Subject: [PATCH] N.542 Refactored the code so that query placeholders (current_contact->attcode or current_user->attcode) become available in template too.... BUT this will not work if the notifications are sent asynchronously (thus the logged in user is an account dedicated to the cron). SVN:trunk[4747] --- core/metamodel.class.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/core/metamodel.class.php b/core/metamodel.class.php index bb0f1e39c..7c65bca7b 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -2673,22 +2673,32 @@ abstract class MetaModel } } } + $aScalarArgs = static::AddMagicPlaceholders($aScalarArgs); + return $aScalarArgs; + } + + /** + * @param $aPlaceholders The array into which standard placeholders should be added + * @return array of placeholder (or name->object()) => value (or object) + */ + public static function AddMagicPlaceholders($aPlaceholders) + { // Add standard magic arguments // - $aScalarArgs['current_contact_id'] = UserRights::GetContactId(); // legacy + $aPlaceholders['current_contact_id'] = UserRights::GetContactId(); // legacy $oUser = UserRights::GetUserObject(); if (!is_null($oUser)) { - $aScalarArgs['current_user->object()'] = $oUser; + $aPlaceholders['current_user->object()'] = $oUser; $oContact = UserRights::GetContactObject(); if (!is_null($oContact)) { - $aScalarArgs['current_contact->object()'] = $oContact; + $aPlaceholders['current_contact->object()'] = $oContact; } } - return $aScalarArgs; + return $aPlaceholders; } public static function MakeModifierProperties($oFilter) @@ -5085,6 +5095,8 @@ abstract class MetaModel */ static public function ApplyParams($sInput, $aParams) { + $aParams = static::AddMagicPlaceholders($aParams); + // Declare magic parameters $aParams['APP_URL'] = utils::GetAbsoluteUrlAppRoot(); $aParams['MODULES_URL'] = utils::GetAbsoluteUrlModulesRoot();