From 10329730e5c5340a904096d3017b11b59c8d611e Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 6 Oct 2021 14:20:09 -0400 Subject: [PATCH] SearchKit - Fix anonymous access to running search displays This is the same fix as used by afform_civicrm_alterApiRoutePermissions() to remove the barrier to entry for anonymous users. --- ext/search_kit/search_kit.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ext/search_kit/search_kit.php b/ext/search_kit/search_kit.php index ef80c87717..846b2b61b6 100644 --- a/ext/search_kit/search_kit.php +++ b/ext/search_kit/search_kit.php @@ -23,6 +23,21 @@ function search_kit_civicrm_container($container) { ]); } +/** + * Implements hook_civicrm_alterApiRoutePermissions(). + * + * Allow anonymous users to run a search display. Permissions are checked internally. + * + * @see CRM_Utils_Hook::alterApiRoutePermissions + */ +function search_kit_civicrm_alterApiRoutePermissions(&$permissions, $entity, $action) { + if ($entity === 'SearchDisplay') { + if ($action === 'run' || $action === 'download' || $action === 'getSearchTasks') { + $permissions = CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION; + } + } +} + /** * Implements hook_civicrm_xmlMenu(). * -- 2.25.1