From a2407bc03284724ccadd34cf9291bdd531495d6a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 24 Mar 2015 10:44:52 -0400 Subject: [PATCH] Make api.getoptons contexts more discoverable --- CRM/Core/DAO.php | 12 ++++++------ api/v3/Generic.php | 6 ++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 721acc77ff..654c0935d6 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -2204,12 +2204,12 @@ SELECT contact_id */ public static function buildOptionsContext($context = NULL) { $contexts = array( - 'get' => "All options are returned, even if they are disabled. Labels are translated.", - 'create' => "Options are filtered appropriately for the object being created/updated. Labels are translated.", - 'search' => "Searchable options are returned. Labels are translated.", - 'validate' => "All options are returned, even if they are disabled. Machine names are used in place of labels.", - 'abbreviate' => "Active options are returned, and labels are replaced with abbreviations.", - 'match' => "Enabled options are returned using machine names as keys. Labels are translated.", + 'get' => "get: all options are returned, even if they are disabled; labels are translated.", + 'create' => "create: options are filtered appropriately for the object being created/updated; labels are translated.", + 'search' => "search: searchable options are returned; labels are translated.", + 'validate' => "validate: all options are returned, even if they are disabled; machine names are used in place of labels.", + 'abbreviate' => "abbreviate: enabled options are returned; labels are replaced with abbreviations.", + 'match' => "match: enabled options are returned using machine names as keys; labels are translated.", ); // Validation: enforce uniformity of this param if ($context !== NULL && !isset($contexts[$context])) { diff --git a/api/v3/Generic.php b/api/v3/Generic.php index 6bc8fb3ff9..78df58812f 100644 --- a/api/v3/Generic.php +++ b/api/v3/Generic.php @@ -382,13 +382,11 @@ function _civicrm_api3_generic_getoptions_spec(&$params, $apiRequest) { 'context' => array( 'title' => 'Context', 'type' => CRM_Utils_Type::T_STRING, + 'options' => CRM_Core_DAO::buildOptionsContext(), ), ); - // Add available options to these params if requested - if (array_intersect(array('all', 'context'), $apiRequest['params']['options']['get_options'])) { - $params['context']['options'] = array_combine(array_keys(CRM_Core_DAO::buildOptionsContext()), array_keys(CRM_Core_DAO::buildOptionsContext())); - } + // Add available fields if requested if (array_intersect(array('all', 'field'), $apiRequest['params']['options']['get_options'])) { $fields = civicrm_api3_generic_getfields(array('entity' => $apiRequest['entity'], array('params' => array('action' => 'create')))); $params['field']['options'] = array(); -- 2.25.1