X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FMember%2FBAO%2FMembership.php;h=bc4b216bdaee5d068c9ef4e720dc8bd454d37c88;hb=7c85dc65cf5d49b62ce1c1a36af2df1d945969d3;hp=1d2b3839af7993cf01317426dfa8fc50b4e7ab95;hpb=7c113627c643171a1d000d50137d359746b2dd83;p=civicrm-core.git diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 1d2b3839af..bc4b216bda 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -311,7 +311,7 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership { $params['membership_id'] = $membership->id; if (isset($ids['membership'])) { $ids['contribution'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', - $ids['membership'], + $membership->id, 'contribution_id', 'membership_id' ); @@ -1308,7 +1308,9 @@ AND civicrm_membership.is_test = %2"; } if ($form->_contributeMode == 'direct') { - if (CRM_Utils_Array::value('contribution_status_id', $paymentResult) == 1) { + if (CRM_Utils_Array::value('payment_status_id', $paymentResult) == 1) { + // Refer to CRM-16737. Payment processors 'should' return payment_status_id + // to denote the outcome of the transaction. try { civicrm_api3('contribution', 'completetransaction', array( 'id' => $paymentResult['contribution']->id, @@ -1322,6 +1324,8 @@ AND civicrm_membership.is_test = %2"; CRM_Core_Error::debug_log_message('contribution ' . $membershipContribution->id . ' not completed with trxn_id ' . $membershipContribution->trxn_id . ' and message ' . $e->getMessage()); } } + // Do not send an email if Recurring transaction is done via Direct Mode + // Email will we sent when the IPN is received. return; } @@ -1740,14 +1744,23 @@ WHERE civicrm_membership.contact_id = civicrm_contact.id } /** + * Build an array of available membership types. + * * @param CRM_Core_Form $form * @param int $membershipTypeID + * @param bool $activeOnly + * Do we only want active ones? + * (probably this should default to TRUE but as a newly added parameter we are leaving default b + * behaviour unchanged). * * @return array */ - public static function buildMembershipTypeValues(&$form, $membershipTypeID = NULL) { + public static function buildMembershipTypeValues(&$form, $membershipTypeID = NULL, $activeOnly = FALSE) { $whereClause = " WHERE domain_id = " . CRM_Core_Config::domainID(); + if ($activeOnly) { + $whereClause .= " AND is_active = 1 "; + } if (is_array($membershipTypeID)) { $allIDs = implode(',', $membershipTypeID); $whereClause .= " AND id IN ( $allIDs )"; @@ -1778,6 +1791,8 @@ FROM civicrm_membership_type 'relationship_type_id', 'relationship_direction', 'max_related', + 'duration_unit', + 'duration_interval', ); while ($dao->fetch()) { @@ -2699,14 +2714,14 @@ WHERE civicrm_membership.is_test = 0"; * @param CRM_Core_Form $qf * @param array $membershipType * Array with membership type and organization. - * @param int $priceSetId * + * @return int $priceSetId */ - public static function createLineItems(&$qf, $membershipType, &$priceSetId) { + public static function createLineItems(&$qf, $membershipType) { $qf->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_membership_type_amount', 'id', 'name'); - if ($priceSetId) { - $qf->_priceSet = $priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId)); - } + $qf->_priceSet = $priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId)); + + // The name of the price field corresponds to the membership_type organization contact. $editedFieldParams = array( 'price_set_id' => $priceSetId, 'name' => $membershipType[0], @@ -2733,6 +2748,7 @@ WHERE civicrm_membership.is_test = 0"; $fieldID = key($qf->_priceSet['fields']); $qf->_params['price_' . $fieldID] = CRM_Utils_Array::value('id', $editedResults); + return $priceSetId; } /**