diff --git a/plugin/azure_active_directory/src/AzureActiveDirectory.php b/plugin/azure_active_directory/src/AzureActiveDirectory.php index d0f6e466cec..fce9cf9b689 100644 --- a/plugin/azure_active_directory/src/AzureActiveDirectory.php +++ b/plugin/azure_active_directory/src/AzureActiveDirectory.php @@ -306,6 +306,44 @@ public function registerUser( return $userId; } + /** + * @return array + */ + public function getGroupUidByRole(): array + { + $groupUidList = [ + 'admin' => $this->get(self::SETTING_GROUP_ID_ADMIN), + 'sessionAdmin' => $this->get(self::SETTING_GROUP_ID_SESSION_ADMIN), + 'teacher' => $this->get(self::SETTING_GROUP_ID_TEACHER), + ]; + + return array_filter($groupUidList); + } + + /** + * @return array + */ + public function getUpdateActionByRole(): array + { + return [ + 'admin' => function (User $user) { + $user->setStatus(COURSEMANAGER); + + UserManager::addUserAsAdmin($user, false); + }, + 'sessionAdmin' => function (User $user) { + $user->setStatus(SESSIONADMIN); + + UserManager::removeUserAdmin($user, false); + }, + 'teacher' => function (User $user) { + $user->setStatus(COURSEMANAGER); + + UserManager::removeUserAdmin($user, false); + }, + ]; + } + /** * @throws Exception */ @@ -347,42 +385,4 @@ private function formatUserData( $extra, ]; } - - /** - * @return array - */ - public function getGroupUidByRole(): array - { - $groupUidList = [ - 'admin' => $this->get(self::SETTING_GROUP_ID_ADMIN), - 'sessionAdmin' => $this->get(self::SETTING_GROUP_ID_SESSION_ADMIN), - 'teacher' => $this->get(self::SETTING_GROUP_ID_TEACHER), - ]; - - return array_filter($groupUidList); - } - - /** - * @return array - */ - public function getUpdateActionByRole(): array - { - return [ - 'admin' => function (User $user) { - $user->setStatus(COURSEMANAGER); - - UserManager::addUserAsAdmin($user, false); - }, - 'sessionAdmin' => function (User $user) { - $user->setStatus(SESSIONADMIN); - - UserManager::removeUserAdmin($user, false); - }, - 'teacher' => function (User $user) { - $user->setStatus(COURSEMANAGER); - - UserManager::removeUserAdmin($user, false); - }, - ]; - } } diff --git a/plugin/azure_active_directory/src/AzureCommand.php b/plugin/azure_active_directory/src/AzureCommand.php index 1c0ccd3e7b3..ce79c45ca2f 100644 --- a/plugin/azure_active_directory/src/AzureCommand.php +++ b/plugin/azure_active_directory/src/AzureCommand.php @@ -138,9 +138,9 @@ protected function getAzureGroups(): Generator } /** - * @return Generator> - * * @throws Exception + * + * @return Generator> */ protected function getAzureGroupMembers(string $groupUid): Generator { diff --git a/plugin/azure_active_directory/src/AzureSyncUsergroupsCommand.php b/plugin/azure_active_directory/src/AzureSyncUsergroupsCommand.php index 3f51db2736b..f64975cd251 100644 --- a/plugin/azure_active_directory/src/AzureSyncUsergroupsCommand.php +++ b/plugin/azure_active_directory/src/AzureSyncUsergroupsCommand.php @@ -2,8 +2,6 @@ /* For license terms, see /license.txt */ -use League\OAuth2\Client\Token\AccessTokenInterface; - class AzureSyncUsergroupsCommand extends AzureCommand { /**