From 13e696ca6ca926e5ad6fd3c5a78f86f6e89e2290 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Tue, 6 Jun 2023 19:21:34 -0400 Subject: [PATCH] fix notice on activity and event mgmt forms --- CRM/Core/Smarty/plugins/function.help.php | 21 ++++++++++++++++++++- templates/CRM/Core/Form/RecurringEntity.hlp | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Smarty/plugins/function.help.php b/CRM/Core/Smarty/plugins/function.help.php index 2a0a2804d9..754d2ec401 100644 --- a/CRM/Core/Smarty/plugins/function.help.php +++ b/CRM/Core/Smarty/plugins/function.help.php @@ -45,7 +45,26 @@ function smarty_function_help($params, &$smarty) { $vars = $smarty->get_template_vars(); $smarty->assign('id', $params['id'] . '-title'); - $name = trim($smarty->fetch($params['file'] . '.hlp')) ?: $vars['form'][$fieldID]['textLabel'] ?? ''; + // The way this works is a bit bonkers. All the .hlp files are expecting an + // assign called $params (which is different from our php var here called + // $params), and it does get assigned via ajax via + // CRM_Core_Page_Inline_Help when you click the help bubble (i.e. the link + // that we return at the bottom below). But right now when we fetch the + // file on the next line, there is no params. So it gives a notice. So + // let's assign something. + // It's also awkward since the ONLY reason we're fetching the file + // now is to get the help section's title and we don't care about the rest + // of the file, but that is a bit of a separate issue. + $temporary_vars = []; + if (!array_key_exists('params', $vars)) { + // In the unlikely event that params already exists, we don't want to + // overwrite it, so only do this if not already set. + $temporary_vars = ['params' => []]; + } + // Note fetchWith adds the temporary ones to the existing scope but then + // will reset, unsetting them if not already present before, which is what + // we want here. + $name = trim($smarty->fetchWith($params['file'] . '.hlp', $temporary_vars)) ?: $vars['form'][$fieldID]['textLabel'] ?? ''; $additionalTPLFile = $params['file'] . '.extra.hlp'; if ($smarty->template_exists($additionalTPLFile)) { $extraoutput = trim($smarty->fetch($additionalTPLFile)); diff --git a/templates/CRM/Core/Form/RecurringEntity.hlp b/templates/CRM/Core/Form/RecurringEntity.hlp index 1666b98935..4351268437 100644 --- a/templates/CRM/Core/Form/RecurringEntity.hlp +++ b/templates/CRM/Core/Form/RecurringEntity.hlp @@ -7,7 +7,7 @@ | and copyright information, see https://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -{capture assign='entityType'}{$params.entityType|lower}{/capture} +{capture assign='entityType'}{if array_key_exists('entityType', $params)}{$params.entityType|lower}{/if}{/capture} {htxt id="id-repeats-title"} {ts}Repeats{/ts} -- 2.25.1