diff --git a/admin/tool/oauth2/classes/form/issuer.php b/admin/tool/oauth2/classes/form/issuer.php index 16db966f504..3a0b64d3cf5 100644 --- a/admin/tool/oauth2/classes/form/issuer.php +++ b/admin/tool/oauth2/classes/form/issuer.php @@ -50,9 +50,15 @@ class issuer extends persistent { global $PAGE, $OUTPUT; $mform = $this->_form; - $endpoint = $this->get_persistent(); + $issuer = $this->get_persistent(); - $mform->addElement('html', $OUTPUT->page_doc_link(get_string('issuersetup', 'tool_oauth2'))); + $docslink = optional_param('docslink', '', PARAM_ALPHAEXT); + if ($docslink) { + $name = s($issuer->get('name')); + $mform->addElement('html', $OUTPUT->doc_link($docslink, get_string('issuersetuptype', 'tool_oauth2', $name))); + } else { + $mform->addElement('html', $OUTPUT->page_doc_link(get_string('issuersetup', 'tool_oauth2'))); + } // Name. $mform->addElement('text', 'name', get_string('issuername', 'tool_oauth2')); @@ -119,10 +125,10 @@ class issuer extends persistent { $mform->addElement('hidden', 'action', 'edit'); $mform->setType('action', PARAM_ALPHA); - $mform->addElement('hidden', 'enabled', $endpoint->get('enabled')); + $mform->addElement('hidden', 'enabled', $issuer->get('enabled')); $mform->setType('enabled', PARAM_BOOL); - $mform->addElement('hidden', 'id', $endpoint->get('id')); + $mform->addElement('hidden', 'id', $issuer->get('id')); $mform->setType('id', PARAM_INT); $this->add_action_buttons(true, get_string('savechanges', 'tool_oauth2')); diff --git a/admin/tool/oauth2/issuers.php b/admin/tool/oauth2/issuers.php index 1115ae21465..5bb4c4f9dc9 100644 --- a/admin/tool/oauth2/issuers.php +++ b/admin/tool/oauth2/issuers.php @@ -89,9 +89,10 @@ if ($mform && $mform->is_cancelled()) { } else if ($action == 'edittemplate') { $type = required_param('type', PARAM_ALPHA); + $docs = required_param('docslink', PARAM_ALPHAEXT); require_sesskey(); $issuer = core\oauth2\api::create_standard_issuer($type); - $params = ['action' => 'edit', 'id' => $issuer->get('id')]; + $params = ['action' => 'edit', 'id' => $issuer->get('id'), 'docslink' => $docs]; $editurl = new moodle_url('/admin/tool/oauth2/issuers.php', $params); redirect($editurl, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS); } else if ($action == 'enable') { @@ -156,13 +157,17 @@ if ($mform && $mform->is_cancelled()) { $issuers = core\oauth2\api::get_all_issuers(); echo $renderer->issuers_table($issuers); - $params = ['action' => 'edittemplate', 'type' => 'google', 'sesskey' => sesskey()]; + $docs = 'admin/tool/oauth2/issuers/google'; + $params = ['action' => 'edittemplate', 'type' => 'google', 'sesskey' => sesskey(), 'docslink' => $docs]; $addurl = new moodle_url('/admin/tool/oauth2/issuers.php', $params); echo $renderer->single_button($addurl, get_string('createnewgoogleissuer', 'tool_oauth2')); - $params = ['action' => 'edittemplate', 'type' => 'microsoft', 'sesskey' => sesskey()]; + $docs = 'admin/tool/oauth2/issuers/microsoft'; + $params = ['action' => 'edittemplate', 'type' => 'microsoft', 'sesskey' => sesskey(), 'docslink' => $docs]; $addurl = new moodle_url('/admin/tool/oauth2/issuers.php', $params); echo $renderer->single_button($addurl, get_string('createnewmicrosoftissuer', 'tool_oauth2')); - $params = ['action' => 'edittemplate', 'type' => 'facebook', 'sesskey' => sesskey()]; + $docs = 'admin/tool/oauth2/issuers/facebook'; + $params = ['action' => 'edittemplate', 'type' => 'microsoft', 'sesskey' => sesskey(), 'docslink' => $docs]; + $params = ['action' => 'edittemplate', 'type' => 'facebook', 'sesskey' => sesskey(), 'docslink' => $docs]; $addurl = new moodle_url('/admin/tool/oauth2/issuers.php', $params); echo $renderer->single_button($addurl, get_string('createnewfacebookissuer', 'tool_oauth2')); $addurl = new moodle_url('/admin/tool/oauth2/issuers.php', ['action' => 'edit']); diff --git a/admin/tool/oauth2/lang/en/tool_oauth2.php b/admin/tool/oauth2/lang/en/tool_oauth2.php index 558eafa943a..d2c9a2a8736 100644 --- a/admin/tool/oauth2/lang/en/tool_oauth2.php +++ b/admin/tool/oauth2/lang/en/tool_oauth2.php @@ -54,6 +54,7 @@ $string['endpointsforissuer'] = 'Endpoints for issuer: {$a}'; $string['endpointurl_help'] = 'URL for this endpoint. Must use https:// protocol.'; $string['endpointurl'] = 'Url'; $string['issuersetup'] = 'Detailed instructions on configuring the common OAuth 2 Services'; +$string['issuersetuptype'] = 'Detailed instructions on setting up the {$a} OAuth 2 provider'; $string['issueralloweddomains_help'] = 'If set, this setting is a comma separated list of domains that logins will be restricted to when using this provider.'; $string['issueralloweddomains_link'] = 'OAuth_2_login_domains'; $string['issueralloweddomains'] = 'Login domains'; @@ -87,7 +88,7 @@ $string['notdiscovered'] = 'Service discovery not successful'; $string['notloginissuer'] = 'Do not allow login'; $string['pluginname'] = 'OAuth 2 Services'; $string['savechanges'] = 'Save changes'; -$string['serviceshelp'] = 'Service provider setup instructions: (Google, Facebook, Microsoft).'; +$string['serviceshelp'] = 'Service provider setup instructions.'; $string['systemaccountconnected_help'] = 'System accounts are used to provide advanced functionality for plugins. They are not required for login functionality only, but other plugins using the OAuth service may offer a reduced set of features if the system account has not been connected. For example repositories cannot support "controlled links" without a system account to perform file operations.'; $string['systemaccountconnected'] = 'System account connected'; $string['systemaccountnotconnected'] = 'System account not connected';