Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-08-10-18-35-58
[civicrm-core.git] / api / v3 / ReportTemplate.php
1 <?php
2
3 /**
4 * Retrieve a report template
5 *
6 * FIXME This is a bare-minimum placeholder
7 *
8 * @param array $ params input parameters
9 *
10 * {@example OptionValueGet.php 0}
11 * @example OptionValueGet.php
12 *
13 * @return array details of found Option Values
14 * {@getfields OptionValue_get}
15 * @access public
16 */
17 function civicrm_api3_report_template_get($params) {
18 require_once 'api/v3/OptionValue.php';
19 $params['option_group_id'] = CRM_Core_DAO::getFieldValue(
20 'CRM_Core_DAO_OptionGroup', 'report_template', 'id', 'name'
21 );
22 return civicrm_api3_option_value_get($params);
23 }
24
25 /**
26 * Add a OptionValue. OptionValues are used to classify CRM entities (including Contacts, Groups and Actions).
27 *
28 * Allowed @params array keys are:
29 *
30 * {@example OptionValueCreate.php}
31 *
32 * @return array of newly created option_value property values.
33 * {@getfields OptionValue_create}
34 * @access public
35 */
36 function civicrm_api3_report_template_create($params) {
37 require_once 'api/v3/OptionValue.php';
38 $params['option_group_id'] = CRM_Core_DAO::getFieldValue(
39 'CRM_Core_DAO_OptionGroup', 'report_template', 'id', 'name'
40 );
41 if (!empty($params['component_id']) && !is_numeric($params['component_id'])) {
42 $components = CRM_Core_PseudoConstant::get('CRM_Core_DAO_OptionValue', 'component_id', array('onlyActive' => FALSE, 'labelColumn' => 'name'));
43 $params['component_id'] = array_search($params['component_id'], $components);
44 }
45 return civicrm_api3_option_value_create($params);
46 }
47
48 /**
49 * Adjust Metadata for Create action
50 *
51 * The metadata is used for setting defaults, documentation & validation
52 * @param array $params array or parameters determined by getfields
53 */
54 function _civicrm_api3_report_template_create_spec(&$params) {
55 require_once 'api/v3/OptionValue.php';
56 _civicrm_api3_option_value_create_spec($params);
57 $params['value']['api.aliases'] = array('report_url');
58 $params['name']['api.aliases'] = array('class_name');
59 $params['option_group_id']['api.default'] = CRM_Core_DAO::getFieldValue(
60 'CRM_Core_DAO_OptionGroup', 'report_template', 'id', 'name'
61 );
62 // $params['component']['api.required'] = TRUE;
63 }
64
65 /**
66 * Deletes an existing ReportTemplate
67 *
68 * @param array $params
69 *
70 * {@example ReportTemplateDelete.php 0}
71 *
72 * @return array Api result
73 * {@getfields ReportTemplate_create}
74 * @access public
75 */
76 function civicrm_api3_report_template_delete($params) {
77 require_once 'api/v3/OptionValue.php';
78 return civicrm_api3_option_value_delete($params);
79 }
80
81 /*
82 function civicrm_api3_report_template_getfields($params) {
83 return civicrm_api3_create_success(array(
84 'id' => array(
85 'name' => 'id',
86 'type' => 1,
87 'required' => 1,
88 ),
89 'option_group_id' => array(
90 'name' => 'option_group_id',
91 'type' => 1,
92 'required' => 1,
93 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
94 ),
95 'label' => array(
96 'name' => 'label',
97 'type' => 2,
98 'title' => 'Option Label',
99 'required' => 1,
100 'maxlength' => 255,
101 'size' => 45,
102 ),
103 'value' => array(
104 'name' => 'value',
105 'type' => 2,
106 'title' => 'Option Value',
107 'required' => 1,
108 'maxlength' => 512,
109 'size' => 45,
110 ),
111 'name' => array(
112 'name' => 'name',
113 'type' => 2,
114 'title' => 'Option Name',
115 'maxlength' => 255,
116 'size' => 45,
117 'import' => 1,
118 'where' => 'civicrm_option_value.name',
119 'export' => 1,
120 ),
121 'grouping' => array(
122 'name' => 'grouping',
123 'type' => 2,
124 'title' => 'Option Grouping Name',
125 'maxlength' => 255,
126 'size' => 45,
127 ),
128 'filter' => array(
129 'name' => 'filter',
130 'type' => 1,
131 'title' => 'Filter',
132 ),
133 'is_default' => array(
134 'name' => 'is_default',
135 'type' => 16,
136 ),
137 'weight' => array(
138 'name' => 'weight',
139 'type' => 1,
140 'title' => 'Weight',
141 'required' => 1,
142 ),
143 'description' => array(
144 'name' => 'description',
145 'type' => 32,
146 'title' => 'Description',
147 'rows' => 8,
148 'cols' => 60,
149 ),
150 'is_optgroup' => array(
151 'name' => 'is_optgroup',
152 'type' => 16,
153 ),
154 'is_reserved' => array(
155 'name' => 'is_reserved',
156 'type' => 16,
157 ),
158 'is_active' => array(
159 'name' => 'is_active',
160 'type' => 16,
161 ),
162 'component_id' => array(
163 'name' => 'component_id',
164 'type' => 1,
165 'FKClassName' => 'CRM_Core_DAO_Component',
166 ),
167 'domain_id' => array(
168 'name' => 'domain_id',
169 'type' => 1,
170 'FKClassName' => 'CRM_Core_DAO_Domain',
171 ),
172 'visibility_id' => array(
173 'name' => 'visibility_id',
174 'type' => 1,
175 'default' => 'UL',
176 ),
177 ));
178 }*/