towards CRM-15861 consolidate default function on shared class
authoreileen <emcnaughton@wikimedia.org>
Tue, 22 Aug 2017 02:24:02 +0000 (14:24 +1200)
committereileen <emcnaughton@wikimedia.org>
Tue, 22 Aug 2017 02:32:19 +0000 (14:32 +1200)
CRM/Member/Form.php
CRM/Member/Form/Membership.php
CRM/Member/Form/MembershipRenewal.php

index 28043d21b269b9e136d2d316d5a772a73dbdf26c..7f49e1f50ec6b6b90e0ad25ef85c2885a5617a9c 100644 (file)
@@ -153,6 +153,21 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment {
         $defaults['member_of_contact_id'], 'display_name'
       );
     }
+    if (!empty($defaults['membership_type_id'])) {
+      $this->_memType = $defaults['membership_type_id'];
+    }
+    if (is_numeric($this->_memType)) {
+      $defaults['membership_type_id'] = array();
+      $defaults['membership_type_id'][0] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType',
+        $this->_memType,
+        'member_of_contact_id',
+        'id'
+      );
+      $defaults['membership_type_id'][1] = $this->_memType;
+    }
+    else {
+      $defaults['membership_type_id'] = $this->_memType;
+    }
     return $defaults;
   }
 
index 163147f228763a586b63aff7a678beda0137daa8..ffd386b54ed0d3d174da82b3ad515232b4a548c3 100644 (file)
@@ -280,19 +280,6 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
       $defaults['receive_date_time'] = $currentTime;
     }
 
-    if (is_numeric($this->_memType)) {
-      $defaults['membership_type_id'] = array();
-      $defaults['membership_type_id'][0] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType',
-        $this->_memType,
-        'member_of_contact_id',
-        'id'
-      );
-      $defaults['membership_type_id'][1] = $this->_memType;
-    }
-    else {
-      $defaults['membership_type_id'] = $this->_memType;
-    }
-
     $defaults['num_terms'] = 1;
 
     if (!empty($defaults['id'])) {
index 21853f410612b435f6b9a682622dc4fbfa65563c..b2da4b31d279d7b93c9533df2c01c423c9b8cee1 100644 (file)
@@ -176,7 +176,6 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
   public function setDefaultValues() {
 
     $defaults = parent::setDefaultValues();
-    $this->_memType = $defaults['membership_type_id'];
 
     // set renewal_date and receive_date to today in correct input format (setDateDefaults uses today if no value passed)
     list($now, $currentTime) = CRM_Utils_Date::setDateDefaults();
@@ -192,19 +191,6 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
       );
     }
 
-    if (is_numeric($this->_memType)) {
-      $defaults['membership_type_id'] = array();
-      $defaults['membership_type_id'][0] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType',
-        $this->_memType,
-        'member_of_contact_id',
-        'id'
-      );
-      $defaults['membership_type_id'][1] = $this->_memType;
-    }
-    else {
-      $defaults['membership_type_id'] = $this->_memType;
-    }
-
     $defaults['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'financial_type_id');
 
     //CRM-13420
@@ -245,7 +231,6 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
     parent::buildQuickForm();
 
     $defaults = parent::setDefaultValues();
-    $this->_memType = $defaults['membership_type_id'];
     $this->assign('customDataType', 'Membership');
     $this->assign('customDataSubType', $this->_memType);
     $this->assign('entityID', $this->_id);