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