diff --git a/CRM/Core/BAO/UserJob.php b/CRM/Core/BAO/UserJob.php index 193d7186e09b..a8cafe65d721 100644 --- a/CRM/Core/BAO/UserJob.php +++ b/CRM/Core/BAO/UserJob.php @@ -32,7 +32,11 @@ class CRM_Core_BAO_UserJob extends CRM_Core_DAO_UserJob { * @inheritDoc */ public function addSelectWhereClause(): array { - $clauses['created_id'] = '= ' . (int) CRM_Core_Session::getLoggedInContactID(); + $clauses = []; + if (!\CRM_Core_Permission::check('administer queues')) { + $clauses['created_id'] = '= ' . (int) CRM_Core_Session::getLoggedInContactID(); + } + CRM_Utils_Hook::selectWhereClause($this, $clauses); return $clauses; } diff --git a/CRM/Queue/BAO/Queue.php b/CRM/Queue/BAO/Queue.php index 35f8be2b9d5e..db62b4128915 100644 --- a/CRM/Queue/BAO/Queue.php +++ b/CRM/Queue/BAO/Queue.php @@ -20,6 +20,16 @@ */ class CRM_Queue_BAO_Queue extends CRM_Queue_DAO_Queue implements \Civi\Core\HookInterface { + public function addSelectWhereClause(): array { + $clauses = []; + if (!\CRM_Core_Permission::check('administer queues')) { + $cid = (int) CRM_Core_Session::getLoggedInContactID(); + $clauses['id'] = "IN (SELECT queue_id FROM `civicrm_user_job` WHERE created_id = $cid)"; + } + CRM_Utils_Hook::selectWhereClause($this, $clauses); + return $clauses; + } + /** * Get a list of valid statuses. * diff --git a/Civi/Api4/Queue.php b/Civi/Api4/Queue.php index 86173f6d3c64..f50486245719 100644 --- a/Civi/Api4/Queue.php +++ b/Civi/Api4/Queue.php @@ -34,6 +34,7 @@ public static function permissions() { return [ 'meta' => ['access CiviCRM'], 'default' => ['administer queues'], + 'get' => ['access CiviCRM'], 'runItem' => [\CRM_Core_Permission::ALWAYS_DENY_PERMISSION], ]; }