Merge pull request #127 from dlobo/CRM-12100
[civicrm-core.git] / api / v3 / OptionGroup.php
1 <?php
2 // $Id$
3
4 require_once 'CRM/Core/BAO/OptionGroup.php';
5 function civicrm_api3_option_group_get($params) {
6
7 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
8 }
9
10 /**
11 * create/update survey
12 *
13 * This API is used to create new survey or update any of the existing
14 * In case of updating existing survey, id of that particular survey must
15 * be in $params array.
16 *
17 * @param array $params (referance) Associative array of property
18 * name/value pairs to insert in new 'survey'
19 *
20 * @return array survey array
21 *
22 * @access public
23 */
24 function civicrm_api3_option_group_create($params) {
25
26 $ids = array();
27 $bao = CRM_Core_BAO_OptionGroup::add($params, $ids);
28
29 if (is_null($bao)) {
30 return civicrm_api3_create_error('Entity not created');
31 }
32 else {
33 $values = array();
34 _civicrm_api3_object_to_array($bao, $values[$bao->id]);
35 return civicrm_api3_create_success($values, $params, 'option_group', 'create', $bao);
36 }
37 }
38
39 /**
40 * Adjust Metadata for Create action
41 *
42 * The metadata is used for setting defaults, documentation & validation
43 * @param array $params array or parameters determined by getfields
44 */
45 function _civicrm_api3_option_group_create_spec(&$params) {
46 $params['name']['api.unique'] = 1;
47 }