From 871a867457ab80e5b78f224e1240b18fd0161295 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 11 Feb 2022 14:04:46 +1300 Subject: [PATCH] Fixes for smarty grumpy mode with membership Generally we bypass escaping for qf html elements in CRM_Core_Smarty pretty bluntly but these bypass that. Probably ideally we would actually escape all qf html in the end anyway. One notice fix --- CRM/Batch/Form/Entry.php | 8 ++++++-- CRM/Core/BAO/UFGroup.php | 1 + CRM/Member/Form.php | 5 ++--- CRM/Member/Form/Membership.php | 10 +++------- templates/CRM/Batch/Form/Entry.tpl | 2 +- templates/CRM/Member/Form/Membership.tpl | 2 +- templates/CRM/Member/Form/MembershipRenewal.tpl | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index c523454cc60b..f08fac43702a 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -212,6 +212,12 @@ public function preProcess() { ->addSetting(['setting' => ['monetaryDecimalPoint' => CRM_Core_Config::singleton()->monetaryDecimalPoint]]); $this->assign('defaultCurrencySymbol', CRM_Core_BAO_Country::defaultCurrencySymbol()); + // This could be updated to TRUE in the formRule + $this->addExpectedSmartyVariable('batchAmountMismatch'); + // It is unclear where this is otherwise assigned but the template expects it. + $this->addExpectedSmartyVariable('contactFields'); + // The not-always-present refresh button. + $this->addOptionalQuickFormElement('_qf_Batch_refresh'); } /** @@ -462,8 +468,6 @@ public static function formRule($params, $files, $self) { if (!empty($errors)) { return $errors; } - - $self->assign('batchAmountMismatch', FALSE); return TRUE; } diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index cbf2aac51e31..5464ecbdc16b 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -503,6 +503,7 @@ protected static function formatUFField( 'skipDisplay' => 0, 'data_type' => CRM_Utils_Type::getDataTypeFromFieldMetadata($fieldMetaData), 'bao' => $fieldMetaData['bao'] ?? NULL, + 'html_type' => $fieldMetaData['html']['type'] ?? NULL, ]; $formattedField = CRM_Utils_Date::addDateMetadataToField($fieldMetaData, $formattedField); diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index a8ffd62a2a9e..c1003f622694 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -159,6 +159,7 @@ public function preProcess() { $this->assign('context', $this->_context); $this->assign('membershipMode', $this->_mode); + $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()); $this->allMembershipTypeDetails = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, [], TRUE); foreach ($this->allMembershipTypeDetails as $index => $membershipType) { if ($membershipType['auto_renew']) { @@ -237,10 +238,8 @@ public function buildQuickForm() { $this->assign('recurProcessor', json_encode($this->_recurPaymentProcessors)); // Build the form for auto renew. This is displayed when in credit card mode or update mode. // The reason for showing it in update mode is not that clear. + $this->assign('allowAutoRenew', $this->_mode && !empty($this->_recurPaymentProcessors)); if ($this->_mode || ($this->_action & CRM_Core_Action::UPDATE)) { - if (!empty($this->_recurPaymentProcessors)) { - $this->assign('allowAutoRenew', TRUE); - } $autoRenewElement = $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'), NULL, ['onclick' => "showHideByValue('auto_renew','','send-receipt','table-row','radio',true); showHideNotice( );"] diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 9766a5e3d5aa..983d4bd45e5d 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -234,7 +234,7 @@ public function preProcess() { CRM_Core_Error::statusBounce(ts("This Membership is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record.")); } } - + $mems_by_org = []; if ($this->_action & CRM_Core_Action::ADD) { if ($this->_contactID) { //check whether contact has a current membership so we can alert user that they may want to do a renewal instead @@ -249,7 +249,6 @@ public function preProcess() { foreach ($cMemTypes as $memTypeID) { $memberorgs[$memTypeID] = CRM_Member_BAO_MembershipType::getMembershipType($memTypeID)['member_of_contact_id']; } - $mems_by_org = []; foreach ($contactMemberships as $mem) { $mem['member_of_contact_id'] = $memberorgs[$mem['membership_type_id']] ?? NULL; if (!empty($mem['membership_end_date'])) { @@ -272,7 +271,6 @@ public function preProcess() { ); $mems_by_org[$mem['member_of_contact_id']] = $mem; } - $this->assign('existingContactMemberships', $mems_by_org); } } else { @@ -287,6 +285,7 @@ public function preProcess() { $resources->addSetting(['existingMems' => $passthru]); } } + $this->assign('existingContactMemberships', $mems_by_org); if (!$this->_memType) { $params = CRM_Utils_Request::exportValues(); @@ -377,10 +376,7 @@ public function setDefaultValues() { if (empty($defaults['join_date'])) { $defaults['join_date'] = CRM_Utils_Time::date('Y-m-d'); } - - if (!empty($defaults['membership_end_date'])) { - $this->assign('endDate', $defaults['membership_end_date']); - } + $this->assign('endDate', $defaults['membership_end_date'] ?? NULL); return $defaults; } diff --git a/templates/CRM/Batch/Form/Entry.tpl b/templates/CRM/Batch/Form/Entry.tpl index 14581e634359..082c31679a84 100644 --- a/templates/CRM/Batch/Form/Entry.tpl +++ b/templates/CRM/Batch/Form/Entry.tpl @@ -102,7 +102,7 @@ {else}
- {$form.field.$rowNumber.$n.html} + {$form.field.$rowNumber.$n.html|smarty:nodefaults} {if $fields.$n.html_type eq 'File' && !empty($form.field.$rowNumber.$fieldName.value.size)} {ts}Attached{/ts}: {$form.field.$rowNumber.$fieldName.value.name} {/if} diff --git a/templates/CRM/Member/Form/Membership.tpl b/templates/CRM/Member/Form/Membership.tpl index e35c0d60f223..479653804574 100644 --- a/templates/CRM/Member/Form/Membership.tpl +++ b/templates/CRM/Member/Form/Membership.tpl @@ -85,7 +85,7 @@ {help id="override_membership_type"} - {$form.membership_type_id.html} + {$form.membership_type_id.html|smarty:nodefaults} {if $hasPriceSets} {ts}OR{/ts} {$form.price_set_id.html} diff --git a/templates/CRM/Member/Form/MembershipRenewal.tpl b/templates/CRM/Member/Form/MembershipRenewal.tpl index 0c6afa812d50..5674d2670068 100644 --- a/templates/CRM/Member/Form/MembershipRenewal.tpl +++ b/templates/CRM/Member/Form/MembershipRenewal.tpl @@ -61,7 +61,7 @@ {$form.membership_type_id.label} - {$form.membership_type_id.html} + {$form.membership_type_id.html|smarty:nodefaults} {if $member_is_test} {ts}(test){/ts}{/if}
{ts}Select Membership Organization and then Membership Type.{/ts}