From: Coleman Watts Date: Wed, 6 Oct 2021 18:20:09 +0000 (-0400) Subject: SearchKit - Fix anonymous access to running search displays X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=10329730e5c5340a904096d3017b11b59c8d611e;p=civicrm-core.git 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. --- 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(). *