/** * Add or update a Contribution. * * @param array $params * Input parameters. * * @throws API_Exception * @return array * Api result array */ function civicrm_api3_contribution_create(&$params) { $values = array(); _civicrm_api3_custom_format_params($params, $values, 'Contribution'); $params = array_merge($params, $values); if (!empty($params['id']) && !empty($params['contribution_status_id'])) { $error = array(); //throw error for invalid status change such as setting completed back to pending //@todo this sort of validation belongs in the BAO not the API - if it is not an OK // action it needs to be blocked there. If it is Ok through a form it needs to be OK through the api CRM_Contribute_BAO_Contribution::checkStatusValidation(NULL, $params, $error); if (array_key_exists('contribution_status_id', $error)) { throw new API_Exception($error['contribution_status_id']); } } if (!empty($params['id']) && !empty($params['financial_type_id'])) { $error = array(); CRM_Contribute_BAO_Contribution::checkFinancialTypeChange($params['financial_type_id'], $params['id'], $error); if (array_key_exists('financial_type_id', $error)) { throw new API_Exception($error['financial_type_id']); } } _civicrm_api3_contribution_create_legacy_support_45($params); // Make sure tax calculation is handled via api. $params = CRM_Contribute_BAO_Contribution::checkTaxAmount($params); return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Contribution'); }
/** * HRJobContract.get API * * @param array $params * @return array API result descriptor * @throws API_Exception */ function civicrm_api3_h_r_job_contract_get($params) { $returnFields = array(); if (!empty($params['return'])) { if (is_array($params['return'])) { $returnFields = $params['return']; } else { $returnFields = explode(',', $params['return']); } } $contracts = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); foreach ($contracts['values'] as $key => $contract) { $isCurrent = true; $contractDetails = civicrm_api3('HRJobDetails', 'get', array('sequential' => 1, 'jobcontract_id' => $contract['id'])); $details = CRM_Utils_Array::first($contractDetails['values']); if (!empty($details['period_end_date'])) { if ($details['period_end_date'] < date('Y-m-d')) { $isCurrent = false; } } $contracts['values'][$key]['is_current'] = (int) $isCurrent; foreach ($returnFields as $returnField) { if (!empty($details[$returnField])) { $contracts['values'][$key][$returnField] = $details[$returnField]; } } } return $contracts; }
/** * Creates or updates an Activity. See the example for usage * * @param array $params Associative array of property name/value * pairs for the activity. * {@getfields pledge_create} * * @return array Array containing 'is_error' to denote success or failure and details of the created pledge * * @example PledgeCreate.php Standard create example * */ function civicrm_api3_pledge_create($params) { _civicrm_api3_pledge_format_params($params, TRUE); $values = $params; //format the custom fields _civicrm_api3_custom_format_params($params, $values, 'Pledge'); return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $values); }
/** * Add a OptionValue. OptionValues are used to classify CRM entities (including Contacts, Groups and Actions). * * Allowed @params array keys are: * * {@example OptionValueCreate.php} * * @param $params * * @throws API_Exception * @return array of newly created option_value property values. * {@getfields OptionValue_create} * @access public */ function civicrm_api3_option_value_create($params) { $result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); if (!empty($params['id']) && !array_key_exists('option_group_id', $params)) { $groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $params['id'], 'option_group_id', 'id'); } else { $groupId = $params['option_group_id']; } civicrm_api('option_value', 'getfields', array('version' => 3, 'cache_clear' => 1, 'option_group_id' => $groupId)); return $result; }
/** * Retrieve one or more OptionValues * * @param array $ params input parameters * * {@example OptionValueGet.php 0} * @example OptionValueGet.php * * @return array details of found Option Values * {@getfields OptionValue_get} * @access public */ function civicrm_api3_option_value_get($params) { if (empty($params['option_group_id']) && !empty($params['option_group_name'])) { $opt = array('version' => 3, 'name' => $params['option_group_name']); $optionGroup = civicrm_api('OptionGroup', 'Get', $opt); if (empty($optionGroup['id'])) { return civicrm_api3_create_error("option group name does not correlate to a single option group"); } $params['option_group_id'] = $optionGroup['id']; } return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); }
/** * Returns array of groups matching a set of one or more Group properties. * * @param array $params * Array of properties. If empty, all records will be returned. * * @return array * Array of matching groups */ function civicrm_api3_group_get($params) { $options = _civicrm_api3_get_options_from_params($params, TRUE, 'Group', 'get'); if (empty($options['return']) || !in_array('member_count', $options['return'])) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Group'); } $groups = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Group'); foreach ($groups as $id => $group) { $groups[$id]['member_count'] = CRM_Contact_BAO_Group::memberCount($id); } return civicrm_api3_create_success($groups, $params, 'Group', 'get'); }
/** * Create a Event * * This API is used for creating a Event * * @param array $params input parameters * Allowed @params array keys are: * {@getfields event_create} * * @return array API result Array. * @access public */ function civicrm_api3_event_create($params) { civicrm_api3_verify_one_mandatory($params, NULL, array('event_type_id', 'template_id')); // Clone event from template if (!empty($params['template_id']) && empty($params['id'])) { $copy = CRM_Event_BAO_Event::copy($params['template_id']); $params['id'] = $copy->id; unset($params['template_id']); } _civicrm_api3_event_create_legacy_support_42($params); return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Event'); }
/** * Add a OptionValue. OptionValues are used to classify CRM entities (including Contacts, Groups and Actions). * * Allowed @params array keys are: * * {@example OptionValueCreate.php} * * @return array of newly created option_value property values. * {@getfields OptionValue_create} * @access public */ function civicrm_api3_option_value_create($params) { $result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); // CRM-13814 : evalute option group id // option group id would be passed in case of adding a new option value record if (!empty($params['id']) && !array_key_exists('option_group_id', $params)) { $groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $params['id'], 'option_group_id', 'id'); } else { $groupId = $params['option_group_id']; } civicrm_api('option_value', 'getfields', array('version' => 3, 'cache_clear' => 1, 'option_group_id' => $groupId)); return $result; }
/** * HRJobContractRevision.get API * * @param array $params * @return array API result descriptor * @throws API_Exception */ function civicrm_api3_h_r_job_contract_revision_get($params) { $revisions = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); foreach ($revisions['values'] as $key => $revision) { $editorName = ''; if (!empty($revision['editor_uid'])) { $civiUser = civicrm_custom_user_profile_get_contact($revision['editor_uid']); $editorName = $civiUser['sort_name']; } $revisions['values'][$key]['editor_name'] = $editorName; } return $revisions; }
/** * Get entity tags. * * @param array $params * * @return array */ function civicrm_api3_entity_tag_get($params) { if (empty($params['entity_id'])) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } else { //do legacy non-standard behaviour $values = CRM_Core_BAO_EntityTag::getTag($params['entity_id'], $params['entity_table']); $result = array(); foreach ($values as $v) { $result[$v] = array('tag_id' => $v); } return civicrm_api3_create_success($result, $params, 'EntityTag'); } }
/** * Activity.GetAbsences API * * This is a variation on Activity.get with additional filtering behavior suitable for activities. * * @param array $params * @return array API result descriptor * @see civicrm_api3_create_success * @see civicrm_api3_create_error * @throws API_Exception */ function civicrm_api3_activity_getabsences($params) { // activity_type_id: int|string|array(int|string) // period_id: int|array(int) // target_contact_id: int $activityTypes = CRM_Core_PseudoConstant::activityType(); // ****** Defaults ****** if (!isset($params['activity_type_id'])) { $params['activity_type_id'] = CRM_HRAbsence_BAO_HRAbsenceType::getActivityTypes(); } // ****** Build query ****** $select = new CRM_HRAbsence_DGWDIHTWT('civicrm_activity request'); $select->select('request.*')->groupBy('request.id')->join('absence', 'INNER JOIN civicrm_activity absence ON (absence.source_record_id = request.id AND absence.activity_type_id = #typeId)', array('#typeId' => array_search('Absence', $activityTypes))); if (!empty($params['period_id'])) { $periodIds = (array) $params['period_id']; $dateExprs = array(); // array(string $sqlExpression) foreach ($periodIds as $periodId) { $period = civicrm_api3('HRAbsencePeriod', 'getsingle', array('id' => $periodId)); $dateExprs[] = $select->interpolate('min(absence.activity_date_time) between @start and @end', array('@start' => $period['start_date'], '@end' => $period['end_date'])); } $select->having(implode(' or ', $dateExprs)); } if (!empty($params['activity_type_id'])) { $typeIds = (array) $params['activity_type_id']; foreach (array_keys($typeIds) as $key) { if (!is_numeric($typeIds[$key])) { $typeIds[$key] = array_search($typeIds[$key], $activityTypes); if ($typeIds[$key] === FALSE) { throw new API_Exception("Invalid activity type"); } } } $select->where('request.activity_type_id IN (#typeIds)', array('#typeIds' => $typeIds)); } if (!empty($params['target_contact_id'])) { $activityContactTypes = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $select->join('tgt', 'INNER JOIN civicrm_activity_contact tgt ON tgt.activity_id = request.id AND tgt.record_type_id = #tgt AND tgt.contact_id IN (#targetIds)', array('#tgt' => CRM_Utils_Array::key('Activity Targets', $activityContactTypes), '#targetIds' => (array) $params['target_contact_id'])); } // ****** Execute query ****** $entity = _civicrm_api3_get_BAO(__FUNCTION__); $bao = CRM_Core_DAO::executeQuery($select->toSQL(), array(), TRUE, 'CRM_Activity_BAO_Activity'); $activities = _civicrm_api3_dao_to_array($bao, $params, FALSE, $entity, FALSE); $activities = _civicrm_api3_activity_get_formatResult($params, $activities); return civicrm_api3_create_success($activities, $params, $entity, 'getAbsences'); }
/** * Returns array of groups matching a set of one or more Group properties. * * @param array $params * Array of properties. If empty, all records will be returned. * * @return array * Array of matching groups */ function civicrm_api3_group_get($params) { $options = _civicrm_api3_get_options_from_params($params, TRUE, 'Group', 'get'); if ((empty($options['return']) || !in_array('member_count', $options['return'])) && empty($params['check_permissions'])) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Group'); } $groups = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Group'); foreach ($groups as $id => $group) { if (!empty($params['check_permissions']) && !CRM_Contact_BAO_Group::checkPermission($group['id'])) { unset($groups[$id]); } elseif (!empty($options['return']) && in_array('member_count', $options['return'])) { $groups[$id]['member_count'] = CRM_Contact_BAO_Group::memberCount($id); } } return civicrm_api3_create_success($groups, $params, 'Group', 'get'); }
/** * Create a Event. * * @param array $params * Input parameters. * * @return array * API result Array. */ function civicrm_api3_event_create($params) { // Required fields for creating an event if (empty($params['id']) && empty($params['is_template'])) { civicrm_api3_verify_mandatory($params, NULL, array('start_date', 'title', array('event_type_id', 'template_id'))); } elseif (empty($params['id']) && !empty($params['is_template'])) { civicrm_api3_verify_mandatory($params, NULL, array('template_title')); } // Clone event from template if (!empty($params['template_id']) && empty($params['id'])) { $copy = CRM_Event_BAO_Event::copy($params['template_id']); $params['id'] = $copy->id; unset($params['template_id']); } _civicrm_api3_event_create_legacy_support_42($params); return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Event'); }
/** * Helper function for adding the permissioned subquery from one entity onto another * * @param string $entity * @param string $joinColumn * @return array */ public static function mergeSubquery($entity, $joinColumn = 'id') { require_once 'api/v3/utils.php'; $baoName = _civicrm_api3_get_BAO($entity); $bao = new $baoName(); $clauses = $subclauses = array(); foreach ((array) $bao->addSelectWhereClause() as $field => $vals) { if ($vals && $field == $joinColumn) { $clauses = array_merge($clauses, (array) $vals); } elseif ($vals) { $subclauses[] = "{$field} " . implode(" AND {$field} ", (array) $vals); } } if ($subclauses) { $clauses[] = "IN (SELECT `{$joinColumn}` FROM `" . $bao->tableName() . "` WHERE " . implode(' AND ', $subclauses) . ")"; } return $clauses; }
/** * Returns array of needs matching a set of one or more group properties * * @param array $params Array of one or more valid * property_name=>value pairs. If $params is set * as null, all needs will be returned * * @return array (referance) Array of matching needs * {@getfields need_get} * @access public */ function civicrm_api3_volunteer_need_get($params) { $result = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); if (!empty($result['values'])) { foreach ($result['values'] as &$need) { if (!empty($need['start_time'])) { $need['display_time'] = CRM_Volunteer_BAO_Need::getTimes($need['start_time'], CRM_Utils_Array::value('duration', $need)); } else { $need['display_time'] = ts('Flexible', array('domain' => 'org.civicrm.volunteer')); } if (isset($need['role_id'])) { $need['role_label'] = CRM_Core_OptionGroup::getLabel(CRM_Volunteer_Upgrader::customOptionGroupName, $need['role_id']); } elseif (CRM_Utils_Array::value('is_flexible', $need)) { $need['role_label'] = CRM_Volunteer_BAO_Need::getFlexibleRoleLabel(); } } } return $result; }
/** * Add or update a Contribution. * * @param array $params * Input parameters. * * @throws API_Exception * @return array * Api result array */ function civicrm_api3_contribution_create(&$params) { $values = array(); _civicrm_api3_custom_format_params($params, $values, 'Contribution'); $params = array_merge($params, $values); if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) { if (empty($params['id'])) { $op = CRM_Core_Action::ADD; } else { if (empty($params['financial_type_id'])) { $params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $params['id'], 'financial_type_id'); } $op = CRM_Core_Action::UPDATE; } CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types, $op); if (!in_array($params['financial_type_id'], array_keys($types))) { return civicrm_api3_create_error('You do not have permission to create this contribution'); } } if (!empty($params['id']) && !empty($params['contribution_status_id'])) { $error = array(); //throw error for invalid status change such as setting completed back to pending //@todo this sort of validation belongs in the BAO not the API - if it is not an OK // action it needs to be blocked there. If it is Ok through a form it needs to be OK through the api CRM_Contribute_BAO_Contribution::checkStatusValidation(NULL, $params, $error); if (array_key_exists('contribution_status_id', $error)) { throw new API_Exception($error['contribution_status_id']); } } if (!empty($params['id']) && !empty($params['financial_type_id'])) { $error = array(); CRM_Contribute_BAO_Contribution::checkFinancialTypeChange($params['financial_type_id'], $params['id'], $error); if (array_key_exists('financial_type_id', $error)) { throw new API_Exception($error['financial_type_id']); } } _civicrm_api3_contribution_create_legacy_support_45($params); // Make sure tax calculation is handled via api. // @todo this belongs in the BAO NOT the api. $params = CRM_Contribute_BAO_Contribution::checkTaxAmount($params); return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Contribution'); }
/** * Add or update a contribution * * @param array $params (reference ) input parameters * * @return array Api result array * @static void * @access public * @example ContributionCreate.php * {@getfields Contribution_create} */ function civicrm_api3_contribution_create(&$params) { $values = array(); _civicrm_api3_custom_format_params($params, $values, 'Contribution'); $params = array_merge($params, $values); //legacy soft credit handling - recommended approach is chaining if (!empty($params['soft_credit_to'])) { $params['soft_credit'] = array(array('contact_id' => $params['soft_credit_to'], 'amount' => $params['total_amount'])); } if (CRM_Utils_Array::value('id', $params) && CRM_Utils_Array::value('contribution_status_id', $params)) { $error = array(); //throw error for invalid status change such as setting completed back to pending //@todo this sort of validation belongs in the BAO not the API - if it is not an OK // action it needs to be blocked there. If it is Ok through a form it needs to be OK through the api CRM_Contribute_BAO_Contribution::checkStatusValidation(NULL, $params, $error); if (array_key_exists('contribution_status_id', $error)) { throw new API_Exception($error['contribution_status_id']); } } return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Contribution'); }
/** * Returns array of needs matching a set of one or more group properties * * @param array $params Array of one or more valid * property_name=>value pairs. If $params is set * as null, all needs will be returned * * @return array (referance) Array of matching needs * {@getfields need_get} * @access public */ function civicrm_api3_volunteer_need_get($params) { $result = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); if (!empty($result['values'])) { foreach ($result['values'] as &$need) { if (!empty($need['start_time'])) { $need['display_time'] = CRM_Volunteer_BAO_Need::getTimes($need['start_time'], CRM_Utils_Array::value('duration', $need), CRM_Utils_Array::value('end_time', $need)); } else { $need['display_time'] = CRM_Volunteer_BAO_Need::getFlexibleDisplayTime(); } if (isset($need['role_id'])) { $role = CRM_Core_OptionGroup::getRowValues(CRM_Volunteer_BAO_Assignment::ROLE_OPTION_GROUP, $need['role_id'], 'value'); $need['role_label'] = $role['label']; $need['role_description'] = $role['description']; } elseif (CRM_Utils_Array::value('is_flexible', $need)) { $need['role_label'] = CRM_Volunteer_BAO_Need::getFlexibleRoleLabel(); $need['role_description'] = NULL; } } } return $result; }
/** * Create a new Domain. * * @param array $params * * @return array */ function civicrm_api3_domain_create($params) { $params['version'] = $params['domain_version']; return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); }
/** * @param $params * * @return array */ function civicrm_api3_system_log_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, True, 'SystemLog'); }
/** * Retrieve one or more PaymentProcessor. * * @param array $params * Array of name/value pairs. * * @return array * API result array */ function civicrm_api3_payment_processor_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); }
/** * Fallback implementation of getlist_output. May be overridden by individual api functions. * * @param array $result * @param array $request * @param string $entity * @param array $fields * * @return array */ function _civicrm_api3_generic_getlist_output($result, $request, $entity, $fields) { $output = array(); if (!empty($result['values'])) { foreach ($result['values'] as $row) { $data = array('id' => $row[$request['id_field']], 'label' => $row[$request['label_field']]); if (!empty($request['description_field'])) { $data['description'] = array(); foreach ((array) $request['description_field'] as $field) { if (!empty($row[$field])) { if (!isset($fields[$field]['pseudoconstant'])) { $data['description'][] = $row[$field]; } else { $data['description'][] = CRM_Core_PseudoConstant::getLabel(_civicrm_api3_get_BAO($entity), $field, $row[$field]); } } } } if (!empty($request['image_field'])) { $data['image'] = isset($row[$request['image_field']]) ? $row[$request['image_field']] : ''; } $output[] = $data; } } return $output; }
/** * Get a ActivityContact. * * @example ActivityContact.php * * @param array $params an associative array of name/value pairs. * * @return array details of found tags else error * * @access public */ function civicrm_api3_activity_contact_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); }
/** * Delete an existing PriceSet. * * This method is used to delete any existing PriceSet given its id. * * @param array $params * Array containing id of the group to be deleted. * * @return array * API result array */ function civicrm_api3_price_set_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); }
/** * Get details of a particular case, or search for cases, depending on params * * Please provide one (and only one) of the four get/search parameters: * * @param array( 'id' => if set, will get all available info about a case, including contacts and activities * * // if no case_id provided, this function will use one of the following search parameters: * 'client_id' => finds all cases with a specific client * 'activity_id' => returns the case containing a specific activity * 'contact_id' => finds all cases associated with a contact (in any role, not just client) * * {@getfields case_get} * * @return (get mode, case_id provided): Array with case details, case roles, case activity ids, (search mode, case_id not provided): Array of cases found * @access public * @todo Erik Hommel 16 dec 2010 check if all DB fields are returned */ function civicrm_api3_case_get($params) { $options = _civicrm_api3_get_options_from_params($params); //search by client if (!empty($params['contact_id'])) { $ids = array(); foreach ((array) $params['contact_id'] as $cid) { if (is_numeric($cid)) { $ids = array_merge($ids, CRM_Case_BAO_Case::retrieveCaseIdsByContactId($cid, TRUE)); } } $cases = array(); foreach ($ids as $id) { if ($case = _civicrm_api3_case_read($id, $options)) { $cases[$id] = $case; } } return civicrm_api3_create_success($cases, $params, 'case', 'get'); } //search by activity if (!empty($params['activity_id'])) { if (!is_numeric($params['activity_id'])) { return civicrm_api3_create_error('Invalid parameter: activity_id. Must provide a numeric value.'); } $caseId = CRM_Case_BAO_Case::getCaseIdByActivityId($params['activity_id']); if (!$caseId) { return civicrm_api3_create_success(array(), $params, 'case', 'get'); } $case = array($caseId => _civicrm_api3_case_read($caseId, $options)); return civicrm_api3_create_success($case, $params, 'case', 'get'); } //search by contacts if ($contact = CRM_Utils_Array::value('contact_id', $params)) { if (!is_numeric($contact)) { return civicrm_api3_create_error('Invalid parameter: contact_id. Must provide a numeric value.'); } $sql = "\nSELECT DISTINCT case_id\n FROM civicrm_relationship\n WHERE (contact_id_a = {$contact}\n OR contact_id_b = {$contact})\n AND case_id IS NOT NULL"; $dao =& CRM_Core_DAO::executeQuery($sql); $cases = array(); while ($dao->fetch()) { $cases[$dao->case_id] = _civicrm_api3_case_read($dao->case_id, $options); } return civicrm_api3_create_success($cases, $params, 'case', 'get'); } // For historic reasons we always return these when an id is provided $caseId = CRM_Utils_Array::value('id', $params); if ($caseId) { $options['return'] = array('contacts' => 1, 'activities' => 1); } $foundcases = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Case'); $cases = array(); foreach ($foundcases['values'] as $foundcase) { if ($case = _civicrm_api3_case_read($foundcase['id'], $options)) { $cases[$foundcase['id']] = $case; } } return civicrm_api3_create_success($cases, $params, 'case', 'get'); }
/** * API wrapper for getoptions function. * * @param array $apiRequest * Api request as an array. * * @return array * Array of results */ function civicrm_api3_generic_getoptions($apiRequest) { // Resolve aliases. $fieldName = _civicrm_api3_api_resolve_alias($apiRequest['entity'], $apiRequest['params']['field']); if (!$fieldName) { return civicrm_api3_create_error("The field '{$apiRequest['params']['field']}' doesn't exist."); } // Validate 'context' from params $context = CRM_Utils_Array::value('context', $apiRequest['params']); CRM_Core_DAO::buildOptionsContext($context); unset($apiRequest['params']['context'], $apiRequest['params']['field']); $baoName = _civicrm_api3_get_BAO($apiRequest['entity']); $options = $baoName::buildOptions($fieldName, $context, $apiRequest['params']); if ($options === FALSE) { return civicrm_api3_create_error("The field '{$fieldName}' has no associated option list."); } // Support 'sequential' output as a non-associative array if (!empty($apiRequest['params']['sequential'])) { $options = CRM_Utils_Array::makeNonAssociative($options); } return civicrm_api3_create_success($options, $apiRequest['params'], $apiRequest['entity'], 'getoptions'); }
/** * HRJobPension.get API * * @param array $params * @return array API result descriptor * @throws API_Exception */ function civicrm_api3_h_r_job_pension_get($params) { _civicrm_hrjobcontract_api3_set_current_revision($params, _civicrm_get_table_name(_civicrm_api3_get_BAO(__FUNCTION__))); return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); }
/** * Retrieve one or more Location Types * * @param array input parameters * * * @example LocationTypeGet.php Standard Get Example * * @param array $params an associative array of name/value pairs. * * @return array api result * {@getfields LocationType_get} * @access public */ function civicrm_api3_location_type_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); }
/** * Create a Membership Status. * * @param array $params * Array of name/value property values of civicrm_membership_status. * * @return array */ function civicrm_api3_membership_status_create($params) { return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); }
/** * Delete a mailing_component * * Allowed @params array keys are: * {@getfields mailing_component_delete} * @example mailing_componentCreate.php * * @return array of deleted values. * @access public */ function civicrm_api3_mailing_component_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); }