From d38a3b106c8cd3c1e57cece56c8fd789689513a8 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 11 Nov 2021 09:46:11 +1300 Subject: [PATCH] Ensure contact values are always assigned to the template --- CRM/Contact/Page/View/Summary.php | 26 +++++++++++++++++-- templates/CRM/Contact/Page/Inline/Basic.tpl | 2 +- .../Page/Inline/CommunicationPreferences.tpl | 2 +- .../CRM/Contact/Page/Inline/ContactInfo.tpl | 10 +++---- .../CRM/Contact/Page/Inline/Demographics.tpl | 6 ++--- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/CRM/Contact/Page/View/Summary.php b/CRM/Contact/Page/View/Summary.php index 9b995c2741..221f21c47e 100644 --- a/CRM/Contact/Page/View/Summary.php +++ b/CRM/Contact/Page/View/Summary.php @@ -121,7 +121,30 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { $this->assignFieldMetadataToTemplate('Contact'); $params = []; - $defaults = []; + $defaults = [ + // Set empty default values for these - they will be overwritten when the contact is + // loaded in CRM_Contact_BAO_Contact::retrieve if there are real values + // but since we are not using apiV4 they will be left unset if empty. + // However, the wind up assigned as smarty variables so we ensure they are set to prevent e-notices + // used by ContactInfo.tpl + 'job_title' => '', + 'current_employer_id' => '', + 'nick_name' => '', + 'legal_name' => '', + 'source' => '', + 'sic_code' => '', + 'external_identifier' => '', + // for CommunicationPreferences.tpl + 'postal_greeting_custom' => '', + 'email_greeting_custom' => '', + 'addressee_custom' => '', + 'communication_style_display' => '', + // for Demographics.tpl + 'age' => ['y' => '', 'm' => ''], + 'birth_date' => '', + // for Website.tpl (the others don't seem to enotice for some reason). + 'website' => '', + ]; $params['id'] = $params['contact_id'] = $this->_contactId; $params['noRelationships'] = $params['noNotes'] = $params['noGroups'] = TRUE; @@ -243,7 +266,6 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { } } - $defaults['external_identifier'] = $contact->external_identifier; $this->assign($defaults); // FIXME: when we sort out TZ isssues with DATETIME/TIMESTAMP, we can skip next query diff --git a/templates/CRM/Contact/Page/Inline/Basic.tpl b/templates/CRM/Contact/Page/Inline/Basic.tpl index 6da2613464..6da6177212 100644 --- a/templates/CRM/Contact/Page/Inline/Basic.tpl +++ b/templates/CRM/Contact/Page/Inline/Basic.tpl @@ -35,7 +35,7 @@
{ts}External ID{/ts}
- {if isset($external_identifier)}{$external_identifier}{/if} + {$external_identifier}
diff --git a/templates/CRM/Contact/Page/Inline/CommunicationPreferences.tpl b/templates/CRM/Contact/Page/Inline/CommunicationPreferences.tpl index 22fa7db810..62585ae567 100644 --- a/templates/CRM/Contact/Page/Inline/CommunicationPreferences.tpl +++ b/templates/CRM/Contact/Page/Inline/CommunicationPreferences.tpl @@ -44,7 +44,7 @@ {$preferred_mail_format} - {if isset($communication_style_display)} + {if $communication_style_display}
{ts}Communication Style{/ts}
diff --git a/templates/CRM/Contact/Page/Inline/ContactInfo.tpl b/templates/CRM/Contact/Page/Inline/ContactInfo.tpl index 92ca7fe9fe..e6f23db339 100644 --- a/templates/CRM/Contact/Page/Inline/ContactInfo.tpl +++ b/templates/CRM/Contact/Page/Inline/ContactInfo.tpl @@ -27,27 +27,27 @@
{ts}Job Title{/ts}
-
{if isset($job_title)}{$job_title}{/if}
+
{$job_title}
{/if}
{ts}Nickname{/ts}
-
{if isset($nick_name)}{$nick_name}{/if}
+
{$nick_name}
{if $contact_type eq 'Organization'}
{ts}Legal Name{/ts}
- +
{ts}SIC Code{/ts}
-
{if isset($sic_code)}{$sic_code}{/if}
+
{$sic_code}
{/if}
{ts}Source{/ts}
-
{if isset($source)}{$source}{/if}
+
{$source}
diff --git a/templates/CRM/Contact/Page/Inline/Demographics.tpl b/templates/CRM/Contact/Page/Inline/Demographics.tpl index 7951f284cf..742ea17c83 100644 --- a/templates/CRM/Contact/Page/Inline/Demographics.tpl +++ b/templates/CRM/Contact/Page/Inline/Demographics.tpl @@ -23,7 +23,7 @@
{ts}Date of Birth{/ts}
{assign var="date_format" value=$fields.birth_date.smarty_view_format} - {if !empty($birth_date)} + {if $birth_date} {$birth_date|crmDate:$date_format} {/if}
@@ -35,7 +35,7 @@
{assign var="date_format" value = $fields.birth_date.smarty_view_format} {$deceased_date|crmDate:$date_format} - {if !empty($birth_date)}({ts}Age{/ts} {if !empty($age.y)}{ts count=$age.y plural='%count years'}%count year{/ts}{elseif !empty($age.m)}{ts count=$age.m plural='%count months'}%count month{/ts}{/if}){/if} + {if $birth_date}({ts}Age{/ts} {if $age.y}{ts count=$age.y plural='%count years'}%count year{/ts}{elseif $age.m}{ts count=$age.m plural='%count months'}%count month{/ts}{/if}){/if}
{else} @@ -47,7 +47,7 @@ {else}
{ts}Age{/ts}
-
{if !empty($age.y)}{ts count=$age.y plural='%count years'}%count year{/ts}{elseif !empty($age.m)}{ts count=$age.m plural='%count months'}%count month{/ts}{/if}
+
{if $age.y}{ts count=$age.y plural='%count years'}%count year{/ts}{elseif $age.m}{ts count=$age.m plural='%count months'}%count month{/ts}{/if}
{/if} -- 2.25.1