Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIv4 - Allow creator to read UserJob and Queue records #23690

Merged
merged 1 commit into from
Jun 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CRM/Core/BAO/UserJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 10 additions & 0 deletions CRM/Queue/BAO/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
1 change: 1 addition & 0 deletions Civi/Api4/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
];
}
Expand Down