Skip to content

Commit

Permalink
Merge branch 'wip-MSFTMPP-648-m32' into MOODLE_32_RC
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmcq committed Oct 31, 2017
2 parents 8a5d88d + b1918c1 commit a4b44a0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 3 additions & 3 deletions local/o365/classes/feature/usersync/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ protected function check_usercreationrestriction($aaddata) {
\local_o365\utils::debug('Could not find group (1)', 'check_usercreationrestriction', $group);
return false;
}
$members = $apiclient->get_group_members($group['id']);
foreach ($members['value'] as $member) {
if ($member['id'] === $aaddata['id']) {
$usersgroups = $apiclient->get_users_groups($group['id'],$aaddata['id']);
foreach ($usersgroups['value'] as $usergroup) {
if ($group['id'] === $usergroup) {
return true;
}
}
Expand Down
15 changes: 15 additions & 0 deletions local/o365/classes/rest/unified.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,21 @@ public function restore_deleted_group($objectid) {
return $response;
}

/**
* Get a list of all groups a user is member of.
*
* @param string $groupobjectid The object ID of the group.
* @param string $userobjecttid The user ID.
* @return array Array of groups user is member of.
*/
public function get_users_groups($groupobjectid, $userobjectid) {
$endpoint = 'users/'.$userobjectid.'/getMemberGroups';
$postdata = '{ "securityEnabledOnly": false }';
$response = $this->apicall('post', $endpoint, $postdata);
$expectedparams = ['value' => null];
return $this->process_apicall_response($response, $expectedparams);
}

/**
* Get a list of group members.
*
Expand Down

0 comments on commit a4b44a0

Please sign in to comment.