Merge remote-tracking branch 'upstream/4.4' into 4.4-4.5-2014-09-29-14-51-22
[civicrm-core.git] / api / v3 / CustomSearch.php
1 <?php
2
3 /**
4 * Retrieve a CustomSearches
5 *
6 * FIXME This is a bare-minimum placeholder
7 *
8 * @param $params
9 *
10 * @internal param $array $ params input parameters
11 *
12 * {@example OptionValueGet.php 0}
13 * @example OptionValueGet.php
14 *
15 * @return array details of found Option Values
16 * {@getfields OptionValue_get}
17 * @access public
18 */
19 function civicrm_api3_custom_search_get($params) {
20 require_once 'api/v3/OptionValue.php';
21 $params['option_group_id'] = CRM_Core_DAO::getFieldValue(
22 'CRM_Core_DAO_OptionGroup', 'custom_search', 'id', 'name'
23 );
24 return civicrm_api3_option_value_get($params);
25 }
26
27 /**
28 * Add a CustomSearch
29 *
30 * Allowed @params array keys are:
31 *
32 * {@example OptionValueCreate.php}
33 *
34 * @param $params
35 *
36 * @return array of newly created option_value property values.
37 * {@getfields OptionValue_create}
38 * @access public
39 */
40 function civicrm_api3_custom_search_create($params) {
41 require_once 'api/v3/OptionValue.php';
42 $params['option_group_id'] = CRM_Core_DAO::getFieldValue(
43 'CRM_Core_DAO_OptionGroup', 'custom_search', 'id', 'name'
44 );
45 // empirically, class name goes to both 'name' and 'label'
46 if (array_key_exists('name', $params)) {
47 $params['label'] = $params['name'];
48 }
49 return civicrm_api3_option_value_create($params);
50 }
51
52 /**
53 * Adjust Metadata for Create action
54 *
55 * The metadata is used for setting defaults, documentation & validation
56 * @param array $params array or parameters determined by getfields
57 */
58 function _civicrm_api3_custom_search_create_spec(&$params) {
59 require_once 'api/v3/OptionValue.php';
60 _civicrm_api3_option_value_create_spec($params);
61 $params['option_group_id']['api.default'] = CRM_Core_DAO::getFieldValue(
62 'CRM_Core_DAO_OptionGroup', 'custom_search', 'id', 'name'
63 );
64 $params['name']['api.aliases'] = array('class_name');
65 }
66
67 /**
68 * Deletes an existing ReportTemplate
69 *
70 * @param array $params
71 *
72 * {@example ReportTemplateDelete.php 0}
73 *
74 * @return array Api result
75 * {@getfields ReportTemplate_create}
76 * @access public
77 */
78 function civicrm_api3_custom_search_delete($params) {
79 require_once 'api/v3/OptionValue.php';
80 return civicrm_api3_option_value_delete($params);
81 }