Merge pull request #227 from deepak-srivastava/crm
[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 $params['component_id'] = array_search($params['component_id'], CRM_Core_PseudoConstant::component());
43 }
44 return civicrm_api3_option_value_create($params);
45 }
46
47 /**
48 * Adjust Metadata for Create action
49 *
50 * The metadata is used for setting defaults, documentation & validation
51 * @param array $params array or parameters determined by getfields
52 */
53 function _civicrm_api3_report_template_create_spec(&$params) {
54 require_once 'api/v3/OptionValue.php';
55 _civicrm_api3_option_value_create_spec($params);
56 $params['value']['api.aliases'] = array('report_url');
57 $params['name']['api.aliases'] = array('class_name');
58 $params['option_group_id']['api.default'] = CRM_Core_DAO::getFieldValue(
59 'CRM_Core_DAO_OptionGroup', 'report_template', 'id', 'name'
60 );
61 // $params['component']['api.required'] = TRUE;
62 }
63
64 /**
65 * Deletes an existing ReportTemplate
66 *
67 * @param array $params
68 *
69 * {@example ReportTemplateDelete.php 0}
70 *
71 * @return array Api result
72 * {@getfields ReportTemplate_create}
73 * @access public
74 */
75 function civicrm_api3_report_template_delete($params) {
76 require_once 'api/v3/OptionValue.php';
77 return civicrm_api3_option_value_delete($params);
78 }
79
80 /*
81 function civicrm_api3_report_template_getfields($params) {
82 return civicrm_api3_create_success(array(
83 'id' => array(
84 'name' => 'id',
85 'type' => 1,
86 'required' => 1,
87 ),
88 'option_group_id' => array(
89 'name' => 'option_group_id',
90 'type' => 1,
91 'required' => 1,
92 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
93 ),
94 'label' => array(
95 'name' => 'label',
96 'type' => 2,
97 'title' => 'Option Label',
98 'required' => 1,
99 'maxlength' => 255,
100 'size' => 45,
101 ),
102 'value' => array(
103 'name' => 'value',
104 'type' => 2,
105 'title' => 'Option Value',
106 'required' => 1,
107 'maxlength' => 512,
108 'size' => 45,
109 ),
110 'name' => array(
111 'name' => 'name',
112 'type' => 2,
113 'title' => 'Option Name',
114 'maxlength' => 255,
115 'size' => 45,
116 'import' => 1,
117 'where' => 'civicrm_option_value.name',
118 'export' => 1,
119 ),
120 'grouping' => array(
121 'name' => 'grouping',
122 'type' => 2,
123 'title' => 'Option Grouping Name',
124 'maxlength' => 255,
125 'size' => 45,
126 ),
127 'filter' => array(
128 'name' => 'filter',
129 'type' => 1,
130 'title' => 'Filter',
131 ),
132 'is_default' => array(
133 'name' => 'is_default',
134 'type' => 16,
135 ),
136 'weight' => array(
137 'name' => 'weight',
138 'type' => 1,
139 'title' => 'Weight',
140 'required' => 1,
141 ),
142 'description' => array(
143 'name' => 'description',
144 'type' => 32,
145 'title' => 'Description',
146 'rows' => 8,
147 'cols' => 60,
148 ),
149 'is_optgroup' => array(
150 'name' => 'is_optgroup',
151 'type' => 16,
152 ),
153 'is_reserved' => array(
154 'name' => 'is_reserved',
155 'type' => 16,
156 ),
157 'is_active' => array(
158 'name' => 'is_active',
159 'type' => 16,
160 ),
161 'component_id' => array(
162 'name' => 'component_id',
163 'type' => 1,
164 'FKClassName' => 'CRM_Core_DAO_Component',
165 ),
166 'domain_id' => array(
167 'name' => 'domain_id',
168 'type' => 1,
169 'FKClassName' => 'CRM_Core_DAO_Domain',
170 ),
171 'visibility_id' => array(
172 'name' => 'visibility_id',
173 'type' => 1,
174 'default' => 'UL',
175 ),
176 ));
177 }*/