Skip to content

Commit

Permalink
Enhance get_groups function
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Champ <[email protected]>
  • Loading branch information
izendegi and jrchamp authored Dec 23, 2024
1 parent 2a7d62a commit be42c05
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions classes/webservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,23 +496,24 @@ private function get_least_recently_active_paid_user_id() {
/**
* Get a list of Zoom groups
*
* @return stdClass The call's result in JSON format.
* @return array Group information.
*/
public function get_groups() {
$groups = [];

// Classic: group:read:admin.
// Granular: group:read:list_groups:admin.
// Not essential scope, execute only if scope has been granted.
if ($this->has_scope(['group:read:list_groups:admin']) || $this->has_scope(['group:read:admin'])) {
if ($this->has_scope(['group:read:list_groups:admin', 'group:read:admin'])) {
try {
$response = $this->make_call('/groups');
$groups = $response->groups ?? [];
} catch (moodle_exception $error) {
$response = '';
// Only available for Paid accounts, so ignore error.
}
} else {
$response = '';
}

return $response;
return $groups;
}

/**
Expand Down

0 comments on commit be42c05

Please sign in to comment.