CRM-16417 merge one-off function back in
authorEileen McNaughton <eileen@fuzion.co.nz>
Sat, 27 Jun 2015 20:40:23 +0000 (08:40 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Sat, 27 Jun 2015 20:40:23 +0000 (08:40 +1200)
(This is just a refactoring process - at this stage it's clearer in the main function)

CRM/Member/BAO/Membership.php

index 50841708a6d9a55aae18c009b3c1ac5c9b00ef06..7ae6e3a963a2a5450f977777120e354c15deb379 100644 (file)
@@ -1417,8 +1417,19 @@ AND civicrm_membership.is_test = %2";
           $pending = ($membershipContribution->contribution_status_id == $pendingStatus) ? TRUE : FALSE;
         }
         self::extractPendingFormValue($form, $memType, $pending);
-        $createdMemberships[$memType] = self::createOrRenewMembership($membershipParams, $contactID,
-          $customFieldsFormatted, $membershipID, $memType, $isTest, $numTerms, $membershipContribution, $form, $pending);
+        $membership = self::renewMembershipFormWrapper($contactID, $memType,
+          $isTest, $form, date('YmdHis'),
+          CRM_Utils_Array::value('cms_contactID', $membershipParams),
+          $customFieldsFormatted, $numTerms,
+          $membershipID,
+          $pending
+        );
+
+        if (!empty($membershipContribution)) {
+          // update recurring id for membership record
+          self::updateRecurMembership($membership, $membershipContribution);
+          self::linkMembershipPayment($membership, $membershipContribution);
+        }
       }
       if ($form->_priceSetId && !empty($form->_useForMember) && !empty($form->_lineItem)) {
         foreach ($form->_lineItem[$form->_priceSetId] as & $priceFieldOp) {
@@ -2346,26 +2357,15 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND
    * @param int $numTerms
    * @param $membershipContribution
    * @param CRM_Core_Form $form
+   * @param bool $isPending
    *
    * @return array
    */
   public static function createOrRenewMembership($membershipParams, $contactID, $customFieldsFormatted,
                                                  $membershipID, $memType, $isTest, $numTerms,
                                                  $membershipContribution, &$form, $isPending) {
-    $membership = self::renewMembershipFormWrapper($contactID, $memType,
-      $isTest, $form, date('YmdHis'),
-      CRM_Utils_Array::value('cms_contactID', $membershipParams),
-      $customFieldsFormatted, $numTerms,
-      $membershipID,
-      $isPending
-    );
 
-    if (!empty($membershipContribution)) {
-      // update recurring id for membership record
-      self::updateRecurMembership($membership, $membershipContribution);
 
-      self::linkMembershipPayment($membership, $membershipContribution);
-    }
     return $membership;
   }