*/
public function addSelectWhereClause(string $entityName = NULL, int $userId = NULL, array $conditions = []): array {
$clauses = [];
- if (!\CRM_Core_Permission::check('administer queues')) {
- // @todo - the is_template should really be prefixed. We need to add support
- // for that in the compiler & then this would be `{table}.is_template`
- $clauses['created_id'] = '= ' . (int) CRM_Core_Session::getLoggedInContactID() . ' OR is_template = 1';
+ if (!\CRM_Core_Permission::check('administer queues', $userId)) {
+ // Only allow access to users' own jobs (or templates)
+ $clauses['created_id'][] = '= ' . (int) CRM_Core_Session::getLoggedInContactID() . ' OR {is_template} = 1';
}
CRM_Utils_Hook::selectWhereClause($this, $clauses, $userId, $conditions);
return $clauses;