Merge branch '4.4' of https://github.com/civicrm/civicrm-core
[civicrm-core.git] / api / v3 / Membership.php
index d00ca9fb3d154668dfda0ebfb5372e44e8a7b928..0f58352e0507cf914f23a9201635837f4cdace11 100644 (file)
@@ -112,11 +112,11 @@ function civicrm_api3_membership_create($params) {
   $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;
   }
@@ -154,7 +154,8 @@ function _civicrm_api3_membership_create_spec(&$params) {
     '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,
   );
 }
 /**
@@ -191,7 +192,7 @@ function civicrm_api3_membership_get($params) {
   }
   $activeOnly = CRM_Utils_Array::value('active_only', $params, $activeOnly);
 
-  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 {
@@ -249,7 +250,7 @@ function _civicrm_api3_membership_relationsship_get_customv2behaviour(&$params,
 
     $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;
     }