-
- return civicrm_api3_create_success($members, $params, 'membership', 'get');
-
-}
-
-
-/**
- * @deprecated
- * Deprecated function to support membership create. Do not call this. It will be removed in favour of
- * wrapper layer formatting
- * take the input parameter list as specified in the data model and
- * convert it into the same format that we use in QF and BAO object
- *
- * @param array $params Associative array of property name/value
- * pairs to insert in new contact.
- * @param array $values The reformatted properties that we can use internally
- *
- * @param array $create Is the formatted Values array going to
- * be used for CRM_Member_BAO_Membership:create()
- *
- * @return array|error
- * @access public
- */
-function _civicrm_api3_membership_format_params($params, &$values, $create = FALSE) {
-
- $fields = CRM_Member_DAO_Membership::fields();
- _civicrm_api3_store_values($fields, $params, $values);
-
- foreach ($params as $key => $value) {
- // ignore empty values or empty arrays etc
- if (CRM_Utils_System::isNull($value)) {
- continue;
- }
-
- switch ($key) {
-
- case 'membership_type':
- // @todo we still need to adequately figure out how to handle this @ the API layer.
- // it is an FK & a pseudoconstant - we should probably alias it onto membership_type_id &
- // then in the validate_integer function do an if(!is_integer && $fieldInfo['pseudoconstant) look
- // up pseudoconstant & flip it over. By the time it hits api it will be a valid membership_type & handling @
- // api layer not required
- $membershipTypeId = CRM_Utils_Array::key(ucfirst($value),
- CRM_Member_PseudoConstant::membershipType()
- );
- if ($membershipTypeId) {
- if (CRM_Utils_Array::value('membership_type_id', $values) &&
- $membershipTypeId != $values['membership_type_id']
- ) {
- return civicrm_api3_create_error('Mismatched membership Type and Membership Type Id');
- }
- }
- else {
- return civicrm_api3_create_error('Invalid Membership Type');
- }
- $values['membership_type_id'] = $membershipTypeId;
- break;
- default:
- break;
- }
- }
-
- return NULL;
-}
-
-/**
- * When we copied apiv3 from api v2 we brought across some custom behaviours - in the case of
- * membership a complicated return array is constructed. The original
- * behaviour made contact_id a required field. We still need to keep this for v3 when contact_id
- * is passed in as part of the reasonable expectation developers have that we will keep the api
- * as stable as possible
- *
- * @param array $params parameters passed into get function
- * @return array result for calling function
- */
-function _civicrm_api3_membership_get_customv2behaviour(&$params, $contactID, $membershipTypeId, $activeOnly ){
- // get the membership for the given contact ID
- $membershipParams = array( 'contact_id' => $contactID );
- if ( $membershipTypeId ) {
- $membershipParams['membership_type_id'] = $membershipTypeId;
- }
- $membershipValues = array();
- CRM_Member_BAO_Membership::getValues( $membershipParams, $membershipValues, $activeOnly );
- return $membershipValues;