From: Marco Valente Date: Mon, 8 Jun 2015 17:16:48 +0000 (+0100) Subject: CRM-15829 and CRM-15881 for CiviCRM 4.6 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=358f8960355a7b2ff9d3688940789fe1146648bd;p=civicrm-core.git CRM-15829 and CRM-15881 for CiviCRM 4.6 ----------------------------------- CRM-15829 (Relationships and inherited pending memberships) Add pending memberships to new members of an organisation that has pending memberships CRM/Contact/BAO/Relationship -> line ~1458 CRM/Contact/BAO/Relationship -> line ~1479 CRM/Contact/BAO/Relationship -> line ~1483 Ensure these new pending memberships for an organisation's employees are not set to active CRM/Member/BAO/Membership -> line 265 ----------------------------------- CRM-15881 (Contact relationships (employee of)) Clear current employee when deleting a relationship that is the employer CRM/Contact/BAO/Relationship -> line ~623 Reload the tab ajax views to reflect removed employer display when deleting a relationship that is the employer CRM/Contact/Form/Relationship -> line ~399 If disabling an employer relationship (via the popup modal), unset the is_current_employer, please see comments in code CRM/Contact/Form/Relationship -> line ~444 --- diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index d5cc3ca677..b3d1ff9df9 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -262,9 +262,17 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership { $excludeIsAdmin = TRUE; } - $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($start_date, $end_date, $join_date, - 'today', $excludeIsAdmin, CRM_Utils_Array::value('membership_type_id', $params), $params - ); + //CRM-15829 UPDATES + // When adding memberships to a contact and If a status is pending then there is no need to perform these calculations. Otherwise it will errernously not realise the pending state and set ot to NEW or GRACE depending on the date ranges. + if (isset($params['status_id']) && $params['status_id'] == 5) { + $calcStatus['id'] = $params['status_id']; + } + else { + $calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($start_date, $end_date, $join_date, + 'today', $excludeIsAdmin, CRM_Utils_Array::value('membership_type_id', $params), $params + ); + } + if (empty($calcStatus)) { // Redirect the form in case of error // @todo this redirect in the BAO layer is really bad & should be moved to the form layer