From 1dd1de31fd028576feec652f957e964bb23016d1 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 8 Jun 2021 01:08:07 +0000 Subject: [PATCH] [php8-compact] Add in protection for unset variables in admin smarty templates --- templates/CRM/Admin/Form/MessageTemplates.tpl | 6 ++-- .../CRM/Admin/Form/ScheduleReminders.tpl | 9 +++-- templates/CRM/Admin/Page/MessageTemplates.tpl | 2 +- templates/CRM/Admin/Page/Options.tpl | 34 +++++++++---------- .../CRM/Admin/Page/ParticipantStatusType.tpl | 2 +- .../CRM/Admin/Page/PaymentProcessorType.tpl | 2 +- templates/CRM/Admin/Page/RelationshipType.tpl | 4 +-- .../CRM/Admin/Page/ScheduleReminders.tpl | 8 ++--- 8 files changed, 37 insertions(+), 30 deletions(-) diff --git a/templates/CRM/Admin/Form/MessageTemplates.tpl b/templates/CRM/Admin/Form/MessageTemplates.tpl index 34208cc2c4..ddff12a700 100644 --- a/templates/CRM/Admin/Form/MessageTemplates.tpl +++ b/templates/CRM/Admin/Form/MessageTemplates.tpl @@ -8,7 +8,9 @@ +--------------------------------------------------------------------+ *} {* this template is used for adding/editing/deleting Message Templates *} - +{if !isset($isAdmin)} + {assign var="isAdmin" value="0"} +{/if} {if $action neq 8}
{ts}Use this form to add or edit re-usable message templates.{/ts} {help id="id-intro" file="CRM/Admin/Page/MessageTemplates.hlp"} @@ -50,7 +52,7 @@ {$form.file_id.label} {$form.file_id.html} - {if $attachment} + {if !empty($attachment)} {foreach from=$attachment key=attKey item=attVal}
{$attVal.cleanName} diff --git a/templates/CRM/Admin/Form/ScheduleReminders.tpl b/templates/CRM/Admin/Form/ScheduleReminders.tpl index a515604063..db6e95ca71 100644 --- a/templates/CRM/Admin/Form/ScheduleReminders.tpl +++ b/templates/CRM/Admin/Form/ScheduleReminders.tpl @@ -7,6 +7,9 @@ | and copyright information, see https://civicrm.org/licensing | +--------------------------------------------------------------------+ *} +{if !isset($isAdmin)} + {assign var="isAdmin" value="0"} +{/if} {* This template is used for adding/scheduling reminders. *}
{include file="CRM/common/formButtons.tpl" location="top"}
@@ -85,11 +88,13 @@ {$form.group_id.label} {$form.group_id.html} + {if !empty($form.mode)} {$form.mode.label} {$form.mode.html} - {if $multilingual} + {/if} + {if !empty($multilingual)} {$form.filter_contact_language.label} {$form.filter_contact_language.html} {help id="filter_contact_language"} @@ -124,7 +129,7 @@ {include file="CRM/Contact/Form/Task/EmailCommon.tpl" upload=1 noAttach=1}
- {if $sms} + {if !empty($sms)}
{ts}SMS Screen{/ts}
diff --git a/templates/CRM/Admin/Page/MessageTemplates.tpl b/templates/CRM/Admin/Page/MessageTemplates.tpl index 0adf34c5b1..7bc7ac1e23 100644 --- a/templates/CRM/Admin/Page/MessageTemplates.tpl +++ b/templates/CRM/Admin/Page/MessageTemplates.tpl @@ -125,7 +125,7 @@ {foreach from=$template_row item=row} - + {if $type eq 'userTemplates'} diff --git a/templates/CRM/Admin/Page/Options.tpl b/templates/CRM/Admin/Page/Options.tpl index 1ecc70b42f..85ac754194 100644 --- a/templates/CRM/Admin/Page/Options.tpl +++ b/templates/CRM/Admin/Page/Options.tpl @@ -48,7 +48,7 @@ {else} {ts}You can use this page to define one or more general Email Addresses that can be selected as the From Address. EXAMPLE: "Client Services" <clientservices@example.org>{/ts} {/if} - {elseif $isLocked} + {elseif !empty($isLocked)} {ts}This option group is reserved for system use. You cannot add or delete options in this list.{/ts} {else} {ts 1=$gLabel}The existing option choices for %1 group are listed below. You can add, edit or delete them from this screen.{/ts} @@ -58,9 +58,9 @@
{if $rows} -{if $isLocked ne 1} +{if !isset($isLocked) || $isLocked ne 1} {/if} {foreach from=$rows item=row} @@ -76,7 +76,7 @@ {if !empty($hasIcons)}
{/if} - {if $showComponent} + {if !empty($showComponent)} {/if} {if $gName eq "payment_instrument"}{/if} - {if $showCounted}{/if} - {if $showVisibility}{/if} + {if !empty($showCounted)}{/if} + {if !empty($showVisibility)}{/if} - {if $showIsDefault}{/if} + {if !empty($showIsDefault)}{/if} @@ -117,26 +117,26 @@ {if !empty($hasIcons)} {/if} - {if $showComponent} + {if !empty($showComponent)} {/if} {if $gName eq "case_status"} {/if} - + {if $gName eq "payment_instrument"} {/if} - {if $showCounted} + {if !empty($showCounted)} {/if} - {if $showVisibility}{/if} - - - {if $showIsDefault} + {if !empty($showVisibility)}{/if} + + + {if !empty($showIsDefault)} {/if} @@ -156,8 +156,8 @@ {/if} diff --git a/templates/CRM/Admin/Page/ParticipantStatusType.tpl b/templates/CRM/Admin/Page/ParticipantStatusType.tpl index 92e1eedec3..273d3b728d 100644 --- a/templates/CRM/Admin/Page/ParticipantStatusType.tpl +++ b/templates/CRM/Admin/Page/ParticipantStatusType.tpl @@ -32,7 +32,7 @@ - + diff --git a/templates/CRM/Admin/Page/PaymentProcessorType.tpl b/templates/CRM/Admin/Page/PaymentProcessorType.tpl index 7580755844..9c1f9b5171 100644 --- a/templates/CRM/Admin/Page/PaymentProcessorType.tpl +++ b/templates/CRM/Admin/Page/PaymentProcessorType.tpl @@ -34,7 +34,7 @@ - + diff --git a/templates/CRM/Admin/Page/RelationshipType.tpl b/templates/CRM/Admin/Page/RelationshipType.tpl index 7e0a4d3633..974033dba4 100644 --- a/templates/CRM/Admin/Page/RelationshipType.tpl +++ b/templates/CRM/Admin/Page/RelationshipType.tpl @@ -49,10 +49,10 @@ + {if !empty($row.contact_sub_type_a)} - {$row.contact_sub_type_a} {/if}{else} {ts}All Contacts{/ts} {/if} + {if !empty($row.contact_sub_type_b)} - {$row.contact_sub_type_b}{/if} {else} {ts}All Contacts{/ts} {/if} diff --git a/templates/CRM/Admin/Page/ScheduleReminders.tpl b/templates/CRM/Admin/Page/ScheduleReminders.tpl index 0e004c2c88..9fd046b00e 100644 --- a/templates/CRM/Admin/Page/ScheduleReminders.tpl +++ b/templates/CRM/Admin/Page/ScheduleReminders.tpl @@ -8,15 +8,15 @@ +--------------------------------------------------------------------+ *} {* this template is for configuring Scheduled Reminders *} -{if $setTab eq 1} - {if $component eq 'event'} +{if !empty($setTab) and $setTab eq 1} + {if !empty($component) and $component eq 'event'} {include file="CRM/Event/Form/ManageEvent/Tab.tpl"} {/if} {else} {if $action eq 1 or $action eq 2 or $action eq 8 or $action eq 16384} {include file="CRM/Admin/Form/ScheduleReminders.tpl"} {else} - {if !$component} + {if empty($component)} {capture assign=schedRemindersDocLink}{docURL page="user/email/scheduled-reminders/"}{/capture}
{ts}Scheduled reminders allow you to automatically send messages to contacts regarding their memberships, participation in events, or other activities.{/ts} {$schedRemindersDocLink} @@ -35,7 +35,7 @@ {/if}
{$row.msg_title}{$row.msg_subject}{ts}Component{/ts} @@ -101,11 +101,11 @@ {/if} Account{ts}Counted?{/ts}{ts}Visibility{/ts}{ts}Counted?{/ts}{ts}Visibility{/ts}{ts}Description{/ts} {ts}Order{/ts}{ts}Default{/ts}{ts}Default{/ts}{ts}Reserved{/ts} {ts}Enabled?{/ts} {$row.component_name} - {$row.label} + {if !empty($row.label)}{$row.label}{/if} {$row.grouping}{$row.value}{if isset($row.value)}{$row.value}{/if}{$row.financial_account}{icon condition=$row.filter}{ts}Counted{/ts}{/icon}{$row.visibility_label}{$row.description}{$row.weight}{$row.visibility_label}{if isset($row.description)}{$row.description}{/if}{if isset($row.weight)}{$row.weight}{/if}{icon condition=$row.is_default}{ts}Default{/ts}{/icon} {if $row.is_reserved eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}
{$row.label} {$row.name} ({$row.id}){$row.class}{$row.class} {icon condition=$row.is_reserved}{ts}Reserved{/ts}{/icon} {if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if} {icon condition=$row.is_counted}{ts}Counted{/ts}{/icon}
{$row.name} {$row.title}{$row.description}{if isset($row.description)}{$row.description}{/if} {if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if} {icon condition=$row.is_default}{ts}Default{/ts}{/icon}  {$row.action}{$row.label_b_a} {if $row.contact_type_a_display} {$row.contact_type_a_display} - {if $row.contact_sub_type_a} - {$row.contact_sub_type_a} {/if}{else} {ts}All Contacts{/ts} {/if} {if $row.contact_type_b_display} {$row.contact_type_b_display} - {if $row.contact_sub_type_b} - {$row.contact_sub_type_b}{/if} {else} {ts}All Contacts{/ts} {/if} {if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if} {$row.action|replace:'xx':$row.id}