add HTML filtering for meta tokens

This commit is contained in:
Nathan Coad
2018-06-17 10:11:57 +10:00
parent 37c3a3cc02
commit 33899cc483

View File

@@ -1637,9 +1637,12 @@ function _booking_studygroup_email_summary($node) {
'studygroup-role' => _booking_studygroup_role_lookup($node->$roleid),
);
$li_text = variable_get('booking_studygroup_summary_li_text',
'You are a <b>[meta-booking:studygroup-role]</b> for group <b>[meta-booking:studygroup-descrip]</b>, which will occur on [meta-booking:studygroup-weekday].<br /><b>[meta-booking:studygroup-explan]</b>');
$rows[] = token_replace($li_text, $tokens);
$list_element_text = variable_get('booking_studygroup_summary_li_text',
'You are a <b>[meta-booking:studygroup-role]</b> for group <b>[meta-booking:studygroup-descrip]</b>, which will occur on [meta-booking:studygroup-weekday]. ' .
'<br /><b>[meta-booking:studygroup-explan]</b>');
// Make sure there is only HTML in the admin-entered text
$list_element_text = check_markup($list_element_text, 'full_html', '', FALSE);
$rows[] = token_replace($list_element_text, $tokens);
/*
// Add some boldness if we're using html email
if(variable_get('booking_enable_html_mail', 0) == 1) {
@@ -1684,6 +1687,7 @@ function _booking_studygroup_email_summary($node) {
function _booking_leader_helper_email_summary($node) {
global $event;
$rows = array();
$tokens = array();
$found = FALSE;
//display study session data if enabled
@@ -1693,8 +1697,6 @@ function _booking_leader_helper_email_summary($node) {
array(':eid' => $event->eid));
$studygroups = $studygroups_query->fetchAllAssoc('sid');
$rows[] = "<ul>";
foreach ($studygroups as $studygroup) {
//don't print info about the readings groups
if ($studygroup->booking_is_readinggroup == 'Y') {
@@ -1742,24 +1744,50 @@ function _booking_leader_helper_email_summary($node) {
$otherperson_phone = $other->booking_mobile;
}
$rows[] = t('<li>!role for !descrip. Your !otherrole is !other. You can contact them on !phone or !email.</li>',
array('!role' => $role, '!id' => $studygroup->sid, '!descrip' => $studygroup->booking_studygroup_descrip,
'!otherrole' => $otherrole, '!other' => $otherperson_name, '!phone' => $otherperson_phone, '!email' => $otherperson_email,
));
// Generate tokens
$tokens = array(
'studygroup-descrip' => $studygroup->booking_studygroup_descrip,
'studygroup-weekday' => $studygroup->booking_studygroup_weekday,
'studygroup-explan' => $studygroup->booking_studygroup_explanation,
'studygroup-role' => $role,
'studygroup-otherrole' => $otherrole,
'studygroup-othername' => $otherperson_name,
'studygroup-otheremail' => $otherperson_email,
'studygroup-otherphone' => $otherperson_phone,
);
$list_element_text = variable_get('booking_studygroup_leaderhelperpair_text',
'<b>[meta-booking:studygroup-role]</b> for <b>[meta-booking:studygroup-descrip]</b>. ' .
'Your <b>[meta-booking:studygroup-otherrole]</b> is <b>[meta-booking:studygroup-othername]</b>. ' .
'You can contact them on <b>[meta-booking:studygroup-otherphone]</b> or <b>[meta-booking:studygroup-otheremail]</b>.'
);
// Make sure there is only HTML in the admin-entered text
$list_element_text = check_markup($list_element_text, 'full_html', '', FALSE);
$rows[] = token_replace($list_element_text, $tokens);
//$rows[] = t('<li>!role for !descrip. Your !otherrole is !other. You can contact them on !phone or !email.</li>',
// array('!role' => $role, '!id' => $studygroup->sid, '!descrip' => $studygroup->booking_studygroup_descrip,
// '!otherrole' => $otherrole, '!other' => $otherperson_name, '!phone' => $otherperson_phone, '!email' => $otherperson_email,
//));
}
}
}
$rows[] = "</ul>";
//format the output to be used in an email
foreach ($rows as $key => $value) {
$rows[$key] = wordwrap($value);
}
if(variable_get('booking_enable_html_mail', 0) == 1) {
return implode("\n<br />", $rows);
// Turn the rows into an unordered list
$output = "\n<ul>\n";
foreach ($rows as $row) {
$output .= "\t<li>$row</li>\n";
}
$output .= "</ul>\n";
return $output;
}
else {
// Plain text so just separate by newline
return implode("\n", $rows);
}
}