CRM-14389 - CiviMember API - Fixes a membership get API regression that caused member...
authorStan Dragnev <sdragnev@airpost.net>
Wed, 2 Apr 2014 14:44:53 +0000 (10:44 -0400)
committerStan Dragnev <sdragnev@airpost.net>
Wed, 2 Apr 2014 14:44:53 +0000 (10:44 -0400)
----------------------------------------
* CRM-14389:
  http://issues.civicrm.org/jira/browse/CRM-14389

api/v3/Membership.php

index 360d94685a82cc435e0df34f3ed77d558fe341a2..3dc34047307a69991145ae57fd4d701482e39b83 100644 (file)
@@ -192,6 +192,18 @@ function civicrm_api3_membership_get($params) {
   }
   $activeOnly = CRM_Utils_Array::value('active_only', $params, $activeOnly);
 
+  //@todo replace this by handling in API layer - we should have enough info to do this
+  // between pseudoconstant & fk - see comments in format_params
+  $membershipTypeId = CRM_Utils_Array::value('membership_type_id', $params);
+  if (!$membershipTypeId) {
+    $membershipType = CRM_Utils_Array::value('membership_type', $params);
+    if ($membershipType) {
+      $membershipTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType',
+          $membershipType, 'id', 'name'
+      );
+    }
+  }
+
   if (CRM_Utils_Array::value('contact_id', $params) && !is_array($params['contact_id'])) {
     $membershipValues = _civicrm_api3_membership_get_customv2behaviour($params, $membershipTypeId, $activeOnly );
   }