From 2fa03859ccf4633271b0290d09e97ef3a20cae81 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 11 Jan 2016 14:52:19 -0500 Subject: [PATCH] CRM-17795 - Api explorer join style improvement --- Civi/API/SelectQuery.php | 21 +++++++-------------- templates/CRM/Admin/Page/APIExplorer.tpl | 8 +++++++- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Civi/API/SelectQuery.php b/Civi/API/SelectQuery.php index 1096b8250e..2a5d115a84 100644 --- a/Civi/API/SelectQuery.php +++ b/Civi/API/SelectQuery.php @@ -456,25 +456,16 @@ class SelectQuery { } /** - * FIXME: This should more properly be done at the api wrapper level + * Perform input validation on params that use the join syntax + * + * Arguably this should be done at the api wrapper level, but doing it here provides a bit more consistency + * in that api permissions to perform the join are checked first. * * @param $fieldName * @param $value * @throws \Exception */ private function validateNestedInput($fieldName, &$value) { - list($entity, $name, $spec) = $this->getNestedField($fieldName); - $params = array($name => $value); - \_civicrm_api3_validate_fields($entity, 'get', $params, $spec); - $value = $params[$name]; - } - - /** - * Helper function for validateNestedInput - should be removed when that function is - * @param $fieldName - * @return array - */ - private function getNestedField($fieldName) { $stack = explode('.', $fieldName); $spec = $this->apiFieldSpec; $fieldName = array_pop($stack); @@ -482,7 +473,9 @@ class SelectQuery { $entity = $spec[$name]['FKApiName']; $spec = $spec[$name]['FKApiSpec']; } - return array($entity, $fieldName, $spec); + $params = array($fieldName => $value); + \_civicrm_api3_validate_fields($entity, 'get', $params, $spec); + $value = $params[$fieldName]; } /** diff --git a/templates/CRM/Admin/Page/APIExplorer.tpl b/templates/CRM/Admin/Page/APIExplorer.tpl index 7ab8599f49..eb9b98dd3a 100644 --- a/templates/CRM/Admin/Page/APIExplorer.tpl +++ b/templates/CRM/Admin/Page/APIExplorer.tpl @@ -101,6 +101,12 @@ margin: 0; padding: 0 0 0.25em 2.5em; } + #api-join li > i { + opacity: .5; + } + #api-join li.join-enabled > i { + opacity: 1; + } #api-generated-wraper, #api-result { overflow: auto; @@ -383,7 +389,7 @@ {literal}