id = $params['id']; if (!$relationBAO->find(TRUE)) { return civicrm_api3_create_error('Relationship id is not valid'); } else { $relationBAO->del($params['id']); return civicrm_api3_create_success('Deleted relationship successfully'); } } /** * get the relationship * * @param array $params * Input parameters. * @todo Result is inconsistent depending on whether contact_id is passed in : * - if you pass in contact_id - it just returns all relationships for 'contact_id' * - if you don't pass in contact_id then it does a filter on the relationship table (DAO based search) * * @return Array API Result Array * {@getfields relationship_get} * @example RelationshipGet.php * @access public */ function civicrm_api3_relationship_get($params) { $options = _civicrm_api3_get_options_from_params($params); if (empty($params['contact_id'])) { if(!empty($params['membership_type_id']) && empty($params['relationship_type_id'])) { CRM_Contact_BAO_Relationship::membershipTypeToRelationshipTypes($params); } $relationships = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Relationship'); } else { $relationships = CRM_Contact_BAO_Relationship::getRelationship($params['contact_id'], CRM_Utils_Array::value('status_id', $params), 0, CRM_Utils_Array::value('is_count', $options), CRM_Utils_Array::value('id', $params), NULL, NULL, FALSE, $params ); } //perhaps we should add a 'getcount' but at this stage lets just handle getcount output if($options['is_count']) { return array('count' => $relationships); } foreach ($relationships as $relationshipId => $values) { _civicrm_api3_custom_data_get($relationships[$relationshipId], 'Relationship', $relationshipId, NULL, CRM_Utils_Array::value('relationship_type_id',$values)); } return civicrm_api3_create_success($relationships, $params); } /** * legacy handling for relationship_type parameter * * @param array $params * Associative array of property name/value. * pairs to insert in new contact. */ function _civicrm_api3_handle_relationship_type(&$params) { if (empty($params['relationship_type_id']) && !empty($params['relationship_type'])) { $relationTypes = CRM_Core_PseudoConstant::relationshipType('name'); foreach ($relationTypes as $relationshipTypeId => $relationshipValue) { if (CRM_Utils_Array::key(ucfirst($params['relationship_type']), $relationshipValue)) { $params['relationship_type_id'] = $relationshipTypeId; } } } }