Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarty notice fix on tell-a-friend #31808

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions CRM/Event/Form/Registration/ThankYou.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,27 +158,30 @@ public function buildQuickForm() {
$params['entity_table'] = 'civicrm_event';

$data = [];
$friendURL = NULL;
$extensionText = [];

if (function_exists('tellafriend_civicrm_config')) {
// @todo - move this to tellafriend extension
CRM_Friend_BAO_Friend::retrieve($params, $data);
if (!empty($data['is_active'])) {
$friendText = $data['title'];
$this->assign('friendText', $friendText);
if ($this->_action & CRM_Core_Action::PREVIEW) {
$friendURL = CRM_Utils_System::url('civicrm/friend',
"eid={$this->_eventId}&reset=1&action=preview&pcomponent=event"
"eid={$this->getEventID()}&reset=1&action=preview&pcomponent=event"
);
}
else {
$friendURL = CRM_Utils_System::url('civicrm/friend',
"eid={$this->_eventId}&reset=1&pcomponent=event"
"eid={$this->getEventID()}&reset=1&pcomponent=event"
);
}
$extensionText[] = '"<div id="tell-a-friend" class="crm-section tell_friend_link-section">
<a href="' . $friendURL . '" title="' . htmlentities($friendText) . '" class="button"><span><i class="crm-i fa-chevron-right" aria-hidden="true"></i> ' . CRM_Utils_String::purifyHTML($friendText) . '</span></a>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, $friendURL also needs htmlentities, but it doesn't really matter in this case.

</div><br /><br />"';
}
}

$this->assign('friendURL', $friendURL);
$this->assign('extensionText', $extensionText);
$this->assign('iCal', CRM_Event_BAO_Event::getICalLinks($this->_eventId));
$this->assign('isShowICalIconsInline', TRUE);

Expand Down
8 changes: 3 additions & 5 deletions templates/CRM/Event/Form/Registration/ThankYou.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
{/if}

{* Show link to Tell a Friend (CRM-2153) *}
{if $friendText}
<div id="tell-a-friend" class="crm-section tell_friend_link-section">
<a href="{$friendURL}" title="{$friendText|escape:'html'}" class="button"><span><i class="crm-i fa-chevron-right" aria-hidden="true"></i> {$friendText}</span></a>
</div><br /><br />
{/if}
{foreach from='extensionText' item='text'}
Copy link

@Sjord Sjord Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be more clear if these variables are named extensionHtml and html, instead of extensionText and text. That makes it more clear that the variables should not be escaped, and that the lack of escaping is intentional.

{$text}
{/foreach}

{* Add button for donor to create their own Personal Campaign page *}
{if $pcpLink}
Expand Down