3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * This api exposes CiviCRM profile group.
15 * @package CiviCRM_APIv3
19 * Adjust metadata for create action.
21 * @param array $params
23 function _civicrm_api3_uf_group_create_spec(&$params) {
24 $session = CRM_Core_Session
::singleton();
25 $params['title']['api.required'] = 1;
26 $params['is_active']['api.default'] = 1;
27 $params['is_update_dupe']['api.default'] = 1;
28 // Default to the logged in user.
29 $params['created_id']['api.default'] = 'user_contact_id';
30 $params['created_date']['api.default'] = 'now';
34 * Use this API to create a new group.
36 * See the CRM Data Model for uf_group property definitions
38 * @param array $params
39 * Array per getfields metadata.
44 function civicrm_api3_uf_group_create($params) {
45 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__
), $params, 'UFGroup');
49 * Returns array of uf groups (profiles) matching a set of one or more group properties.
51 * @param array $params
52 * Array of properties. If empty, all records will be returned.
55 * Array of matching profiles
57 function civicrm_api3_uf_group_get($params) {
59 return _civicrm_api3_basic_get('CRM_Core_BAO_UFGroup', $params);
65 * @param array $params
69 function civicrm_api3_uf_group_delete($params) {
70 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
74 * Set default getlist parameters.
76 * @see _civicrm_api3_generic_getlist_defaults
78 * @param array $request
82 function _civicrm_api3_uf_group_getlist_defaults(&$request) {
84 'description_field' => [
95 * Format getlist output
97 * @see _civicrm_api3_generic_getlist_output
99 * @param array $result
100 * @param array $request
101 * @param string $entity
102 * @param array $fields
106 function _civicrm_api3_uf_group_getlist_output($result, $request, $entity, $fields) {
108 if (!empty($result['values'])) {
109 foreach ($result['values'] as $row) {
111 'id' => $row[$request['id_field']],
112 'label' => $row[$request['label_field']],
114 if (!empty($request['description_field'])) {
115 $data['description'] = [];
116 foreach ((array) $request['description_field'] as $field) {
117 if (!empty($row[$field])) {
118 // Special formatting for group_type field
119 if ($field == 'group_type') {
120 $groupTypes = CRM_UF_Page_Group
::extractGroupTypes($row[$field]);
121 $data['description'][] = CRM_UF_Page_Group
::formatGroupTypes($groupTypes);
124 if (!isset($fields[$field]['pseudoconstant'])) {
125 $data['description'][] = $row[$field];
128 $data['description'][] = CRM_Core_PseudoConstant
::getLabel(
129 _civicrm_api3_get_BAO($entity),
137 if (!empty($request['image_field'])) {
138 $data['image'] = $row[$request['image_field']] ??
'';