Skip to content

Commit

Permalink
CIVICRM-832: Removing related memberships if parent membership type i…
Browse files Browse the repository at this point in the history
…s changed which does not have relation type associated.
  • Loading branch information
agilewarealok committed May 22, 2018
1 parent a4ee75b commit d7df5ed
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions CRM/Member/BAO/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ public static function create(&$params, &$ids, $skipRedirect = FALSE) {
/**
* Check the membership extended through relationship.
*
* @param int $membershipId
* Membership id.
* @param int $membershipTypeID
* Membership type id.
* @param int $contactId
* Contact id.
*
Expand All @@ -460,9 +460,8 @@ public static function create(&$params, &$ids, $skipRedirect = FALSE) {
* @return array
* array of contact_id of all related contacts.
*/
public static function checkMembershipRelationship($membershipId, $contactId, $action = CRM_Core_Action::ADD) {
public static function checkMembershipRelationship($membershipTypeID, $contactId, $action = CRM_Core_Action::ADD) {
$contacts = array();
$membershipTypeID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $membershipId, 'membership_type_id');

$membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipTypeID);
$relationships = array();
Expand Down Expand Up @@ -1388,7 +1387,7 @@ public static function createRelatedMemberships(&$params, &$dao, $reset = FALSE)
$allRelatedContacts = array();
$relatedContacts = array();
if (!is_a($membership, 'CRM_Core_Error')) {
$allRelatedContacts = CRM_Member_BAO_Membership::checkMembershipRelationship($membership->id,
$allRelatedContacts = CRM_Member_BAO_Membership::checkMembershipRelationship($membership->membership_type_id,
$membership->contact_id,
CRM_Utils_Array::value('action', $params)
);
Expand Down

0 comments on commit d7df5ed

Please sign in to comment.