From: eileen Date: Tue, 22 Aug 2017 02:24:02 +0000 (+1200) Subject: towards CRM-15861 consolidate default function on shared class X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f525ec1f1766facf8a5c6300b19762a20d6b4072;p=civicrm-core.git towards CRM-15861 consolidate default function on shared class --- diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index 28043d21b2..7f49e1f50e 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -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; } diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 163147f228..ffd386b54e 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -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'])) { diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 21853f4106..b2da4b31d2 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -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);