X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FUFGroup.php;h=89fb6c284ba49af4ead81e3bbe3bd941f4b315fb;hb=81621fee4d9c2e8c6f5272a1c6b38a86186fe185;hp=209fcada12c88d7ca3bfa19eca4e62967ce85146;hpb=b081365f52508bfd1fb0d3d15f3a0d48f5e9df12;p=civicrm-core.git diff --git a/api/v3/UFGroup.php b/api/v3/UFGroup.php index 209fcada12..89fb6c284b 100644 --- a/api/v3/UFGroup.php +++ b/api/v3/UFGroup.php @@ -1,9 +1,9 @@ array( + 'description', + 'group_type', + ), + 'params' => array( + 'is_active' => 1, + ), + ); +} + +/** + * Format getlist output + * + * @see _civicrm_api3_generic_getlist_output + * + * @param array $result + * @param array $request + * @param string $entity + * @param array $fields + * + * @return array + */ +function _civicrm_api3_uf_group_getlist_output($result, $request, $entity, $fields) { + $output = array(); + if (!empty($result['values'])) { + foreach ($result['values'] as $row) { + $data = array( + 'id' => $row[$request['id_field']], + 'label' => $row[$request['label_field']], + ); + if (!empty($request['description_field'])) { + $data['description'] = array(); + foreach ((array) $request['description_field'] as $field) { + if (!empty($row[$field])) { + // Special formatting for group_type field + if ($field == 'group_type') { + $groupTypes = CRM_UF_Page_Group::extractGroupTypes($row[$field]); + $data['description'][] = CRM_UF_Page_Group::formatGroupTypes($groupTypes); + continue; + } + if (!isset($fields[$field]['pseudoconstant'])) { + $data['description'][] = $row[$field]; + } + else { + $data['description'][] = CRM_Core_PseudoConstant::getLabel( + _civicrm_api3_get_BAO($entity), + $field, + $row[$field] + ); + } + } + } + }; + if (!empty($request['image_field'])) { + $data['image'] = isset($row[$request['image_field']]) ? $row[$request['image_field']] : ''; + } + $output[] = $data; + } + } + return $output; +}