+ /**
+ * Restrict access to the relevant user.
+ *
+ * Note that it is likely we might want to permit other users such as
+ * sysadmins to access other people's user_jobs in future but it has been
+ * kept tightly restricted for initial simplicity (ie do we want to
+ * use an existing permission? a new permission ? do they require
+ * 'view all contacts' etc.
+ *
+ * @inheritDoc
+ */
+ public function addSelectWhereClause(): array {
+ $clauses = [];
+ if (!\CRM_Core_Permission::check('administer queues')) {
+ $clauses['created_id'] = '= ' . (int) CRM_Core_Session::getLoggedInContactID();
+ }
+ CRM_Utils_Hook::selectWhereClause($this, $clauses);
+ return $clauses;
+ }
+