Skip to content

Commit

Permalink
MDL-67644 tool_mobile: Add OAuth 2 providers in disabled features
Browse files Browse the repository at this point in the history
  • Loading branch information
dpalou committed Feb 12, 2020
1 parent 59f9476 commit dedb159
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions admin/tool/mobile/classes/api.php
Expand Up @@ -346,6 +346,7 @@ public static function get_autologin_key() {
*/
public static function get_features_list() {
global $CFG;
require_once($CFG->libdir . '/authlib.php');

$general = new lang_string('general');
$mainmenu = new lang_string('mainmenu', 'tool_mobile');
Expand All @@ -355,6 +356,7 @@ public static function get_features_list() {
$user = new lang_string('user');
$files = new lang_string('files');
$remoteaddons = new lang_string('remoteaddons', 'tool_mobile');
$identityproviders = new lang_string('oauth2identityproviders', 'tool_mobile');

$availablemods = core_plugin_manager::instance()->get_plugins_of_type('mod');
$coursemodules = array();
Expand Down Expand Up @@ -473,6 +475,31 @@ public static function get_features_list() {
$features["$remoteaddons"] = $remoteaddonslist;
}

// Display OAuth 2 identity providers.
if (is_enabled_auth('oauth2')) {
$identityproviderslist = array();
$idps = \auth_plugin_base::get_identity_providers(['oauth2']);

foreach ($idps as $idp) {
// Only add identity providers that have an ID.
$id = isset($idp['url']) ? $idp['url']->get_param('id') : null;
if ($id != null) {
$identityproviderslist['NoDelegate_IdentityProvider_' . $id] = $idp['name'];
}
}

if (!empty($identityproviderslist)) {
$features["$identityproviders"] = array();

if (count($identityproviderslist) > 1) {
// Include an option to disable them all.
$features["$identityproviders"]['NoDelegate_IdentityProviders'] = new lang_string('all');
}

$features["$identityproviders"] = array_merge($features["$identityproviders"], $identityproviderslist);
}
}

return $features;
}

Expand Down
1 change: 1 addition & 0 deletions admin/tool/mobile/lang/en/tool_mobile.php
Expand Up @@ -84,6 +84,7 @@
$string['mobilefeatures'] = 'Mobile features';
$string['mobilenotificationsdisabledwarning'] = 'Mobile notifications are not enabled. They should be enabled in Notification settings.';
$string['mobilesettings'] = 'Mobile settings';
$string['oauth2identityproviders'] = 'OAuth 2 identity providers';
$string['offlineuse'] = 'Offline use';
$string['pluginname'] = 'Moodle app tools';
$string['pluginnotenabledorconfigured'] = 'Plugin not enabled or configured.';
Expand Down

0 comments on commit dedb159

Please sign in to comment.