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