/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* @package CiviCRM_APIv3
* @subpackage API_Membership
*
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* @version $Id: MembershipContact.php 30171 2010-10-14 09:11:27Z mover $
*/
$action = CRM_Core_Action::ADD;
// we need user id during add mode
$ids = array ();
- if(CRM_Utils_Array::value('contact_id', $params)) {
+ if (!empty($params['contact_id'])) {
$ids['userId'] = $params['contact_id'];
}
//for edit membership id should be present
- if (CRM_Utils_Array::value('id', $params)) {
+ if (!empty($params['id'])) {
$ids['membership'] = $params['id'];
$action = CRM_Core_Action::UPDATE;
}
'title' => 'Skip status calculation. By default this is 0 if id is not set and 1 if it is set.'
);
$params['num_terms'] = array(
- 'title' => 'Number of terms to add/renew. If this parameter is passed, dates will be calculated automatically. If no id is passed (new membership) and no dates are given, num_terms will be assumed to be 1.'
+ 'title' => 'Number of terms to add/renew. If this parameter is passed, dates will be calculated automatically. If no id is passed (new membership) and no dates are given, num_terms will be assumed to be 1.',
+ 'type' => CRM_Utils_Type::T_INT,
);
}
/**
$activeOnly = $membershipTypeId = $membershipType = NULL;
$contactID = CRM_Utils_Array::value('contact_id', $params);
- if (!empty($params['filters']) && is_array($params['filters'])) {
- $activeOnly = CRM_Utils_Array::value('is_current', $params['filters'], FALSE);
+ if (!empty($params['filters']) && is_array($params['filters']) && isset($params['filters']['is_current'])) {
+ $activeOnly = $params['filters']['is_current'];
+ unset($params['filters']['is_current']);
}
$activeOnly = CRM_Utils_Array::value('active_only', $params, $activeOnly);
+ if ($activeOnly && empty($params['status_id'])) {
+ $params['status_id'] = array('IN' => CRM_Member_BAO_MembershipStatus::getMembershipStatusCurrent());
+ }
- if (CRM_Utils_Array::value('contact_id', $params) && !is_array($params['contact_id'])) {
+ if (!empty($params['contact_id']) && !is_array($params['contact_id'])) {
$membershipValues = _civicrm_api3_membership_get_customv2behaviour($params, $membershipTypeId, $activeOnly );
}
else {
$membershipValues = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE);
}
- $options = _civicrm_api3_get_options_from_params($params, TRUE,'membership','get');
+ $options = _civicrm_api3_get_options_from_params($params, TRUE,'membership', 'get');
+ if ($options['is_count']) {
+ return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+ }
+
$return = $options['return'];
if(empty($membershipValues) ||
(!empty($return)
$membershipValues[$membershipId]['membership_name'] = $membershipType['name'];
- if (CRM_Utils_Array::value('relationship_type_id', $membershipType)) {
+ if (!empty($membershipType['relationship_type_id'])) {
$relationships[$membershipType['relationship_type_id']] = $membershipId;
}