Skip to content

Commit

Permalink
Cleaned up code style. No expected functional change.
Browse files Browse the repository at this point in the history
  • Loading branch information
universalhandle authored and eileenmcnaughton committed Jun 9, 2018
1 parent 35bdddf commit c5ce325
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions CRM/Contribute/Form/Contribution/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2396,26 +2396,19 @@ protected function doMembershipProcessing($contactID, $membershipParams, $premiu
$priceFieldIds = $this->get('memberPriceFieldIDS');

if (!empty($priceFieldIds)) {
$financialTypeID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceFieldIds['id'], 'financial_type_id');
$membershipParams['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceFieldIds['id'], 'financial_type_id');
unset($priceFieldIds['id']);
$membershipTypeIds = array();
$membershipTypeTerms = array();
foreach ($priceFieldIds as $priceFieldId) {
if ($id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_type_id')) {
$membershipTypeIds[] = $id;
//@todo the value for $term is immediately overwritten. It is unclear from the code whether it was intentional to
// do this or a double = was intended (this ambiguity is the reason many IDEs complain about 'assignment in condition'
$term = 1;
if ($term = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_num_terms')) {
$membershipTypeTerms[$id] = ($term > 1) ? $term : 1;
}
else {
$membershipTypeTerms[$id] = 1;
}
$membershipTypeId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_type_id');
if ($membershipTypeId) {
$membershipTypeIds[] = $membershipTypeId;
$term = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_num_terms') ?: 1;
$membershipTypeTerms[$membershipTypeId] = ($term > 1) ? $term : 1;
}
}
$membershipParams['selectMembership'] = $membershipTypeIds;
$membershipParams['financial_type_id'] = $financialTypeID;
$membershipParams['types_terms'] = $membershipTypeTerms;
}
if (!empty($membershipParams['selectMembership'])) {
Expand Down

0 comments on commit c5ce325

Please sign in to comment.