CRM-15829 and CRM-15881 for CiviCRM 4.6
authorMarco Valente <marco@compucorp.co.uk>
Mon, 8 Jun 2015 17:16:48 +0000 (18:16 +0100)
committerMarco Valente <marco@compucorp.co.uk>
Mon, 8 Jun 2015 17:16:48 +0000 (18:16 +0100)
-----------------------------------

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

CRM/Member/BAO/Membership.php

index d5cc3ca677a08dd7a99ac67b4e06723a74804a49..b3d1ff9df98420230b3c6b139394a48cce1d86e5 100644 (file)
@@ -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