Skip to content

Commit

Permalink
Fixes for smarty grumpy mode with membership
Browse files Browse the repository at this point in the history
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
  • Loading branch information
eileenmcnaughton committed Feb 11, 2022
1 parent f1528c1 commit 871a867
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
8 changes: 6 additions & 2 deletions CRM/Batch/Form/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down Expand Up @@ -462,8 +468,6 @@ public static function formRule($params, $files, $self) {
if (!empty($errors)) {
return $errors;
}

$self->assign('batchAmountMismatch', FALSE);
return TRUE;
}

Expand Down
1 change: 1 addition & 0 deletions CRM/Core/BAO/UFGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions CRM/Member/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down Expand Up @@ -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( );"]
Expand Down
10 changes: 3 additions & 7 deletions CRM/Member/Form/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'])) {
Expand All @@ -272,7 +271,6 @@ public function preProcess() {
);
$mems_by_org[$mem['member_of_contact_id']] = $mem;
}
$this->assign('existingContactMemberships', $mems_by_org);
}
}
else {
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Batch/Form/Entry.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
</div>
{else}
<div class="compressed crm-grid-cell">
{$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}
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Member/Form/Membership.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
{help id="override_membership_type"}
</span>
</td>
<td id="mem_type_id-editable"><span id='mem_type_id'>{$form.membership_type_id.html}</span>
<td id="mem_type_id-editable"><span id='mem_type_id'>{$form.membership_type_id.html|smarty:nodefaults}</span>
{if $hasPriceSets}
<span id='totalAmountORPriceSet'> {ts}OR{/ts}</span>
<span id='selectPriceSet'>{$form.price_set_id.html}</span>
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Member/Form/MembershipRenewal.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</tr>
<tr id="membershipOrgType" class="crm-member-membershiprenew-form-block-renew_org_name hiddenElement">
<td class="label">{$form.membership_type_id.label}</td>
<td>{$form.membership_type_id.html}
<td>{$form.membership_type_id.html|smarty:nodefaults}
{if $member_is_test} {ts}(test){/ts}{/if}<br/>
<span class="description">{ts}Select Membership Organization and then Membership Type.{/ts}</span>
</td>
Expand Down

0 comments on commit 871a867

Please sign in to comment.