MDL-87708 admin: Remove MoodleNet outbound admin settings
Part of MDL-87350
This commit is contained in:
committed by
Huong Nguyen
parent
9a885c5342
commit
f5ccab8dde
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MoodleNet callback.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2023 Huong Nguyen <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use core\moodlenet\moodlenet_client;
|
||||
use core\oauth2\api;
|
||||
|
||||
require_once(__DIR__ . '/../config.php');
|
||||
require_login();
|
||||
|
||||
// Parameters.
|
||||
$issuerid = required_param('issuerid', PARAM_INT);
|
||||
$error = optional_param('error', '', PARAM_RAW);
|
||||
$message = optional_param('error_description', null, PARAM_RAW);
|
||||
|
||||
// Headers to make it not cacheable.
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
|
||||
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_url('/admin/moodlenet_oauth2_callback.php');
|
||||
$PAGE->set_pagelayout('popup');
|
||||
|
||||
// Wait as long as it takes for this script to finish.
|
||||
core_php_time_limit::raise();
|
||||
|
||||
$issuer = api::get_issuer($issuerid);
|
||||
$returnurl = new moodle_url('/admin/moodlenet_oauth2_callback.php');
|
||||
$returnurl->param('issuerid', $issuerid);
|
||||
$returnurl->param('callback', 'yes');
|
||||
$returnurl->param('sesskey', sesskey());
|
||||
$oauthclient = api::get_user_oauth_client($issuer, $returnurl, moodlenet_client::API_SCOPE_CREATE_RESOURCE, true);
|
||||
$oauthclient->is_logged_in(); // Will upgrade the auth code to a token.
|
||||
|
||||
echo $OUTPUT->header();
|
||||
$PAGE->requires->js_call_amd('core/moodlenet/oauth2callback', 'init', [$error, $message]);
|
||||
echo $OUTPUT->footer();
|
||||
@@ -33,11 +33,6 @@ if ($hassiteconfig) { // Speedup for non-admins, add all caps used on this page.
|
||||
new lang_string('enablecourserelativedates', 'core_admin'),
|
||||
new lang_string('enablecourserelativedates_desc', 'core_admin'), 0));
|
||||
|
||||
// Sharing to MoodleNet setting.
|
||||
$temp->add(new admin_setting_configcheckbox('enablesharingtomoodlenet',
|
||||
new lang_string('enablesharingtomoodlenet', 'core_admin'),
|
||||
new lang_string('enablesharingtomoodlenet_desc', 'core_admin'), 0));
|
||||
|
||||
// New communication subsystem setting.
|
||||
$temp->add(new admin_setting_configcheckbox('enablecommunicationsubsystem',
|
||||
new lang_string('enablecommunicationsubsystem', 'core_admin'),
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file gives information about MoodleNet.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2023 Huong Nguyen <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($hassiteconfig) {
|
||||
if (!empty($CFG->enablesharingtomoodlenet)) {
|
||||
if (!$ADMIN->locate('moodlenet')) {
|
||||
$ADMIN->add('root', new admin_category('moodlenet', get_string('pluginname', 'tool_moodlenet')));
|
||||
}
|
||||
|
||||
// Outbound settings page.
|
||||
$settings = new admin_settingpage('moodlenetoutbound', new lang_string('moodlenet:outboundsettings', 'moodle'));
|
||||
$ADMIN->add('moodlenet', $settings);
|
||||
|
||||
// Get all the issuers.
|
||||
$issuers = \core\oauth2\api::get_all_issuers();
|
||||
$oauth2services = [
|
||||
'' => new lang_string('none', 'admin'),
|
||||
];
|
||||
foreach ($issuers as $issuer) {
|
||||
// Get the enabled issuer with the service type is MoodleNet only.
|
||||
if ($issuer->get('servicetype') == 'moodlenet' && $issuer->get('enabled')) {
|
||||
$oauth2services[$issuer->get('id')] = s($issuer->get('name'));
|
||||
}
|
||||
}
|
||||
|
||||
$url = new \moodle_url('/admin/tool/oauth2/issuers.php');
|
||||
|
||||
$settings->add(new admin_setting_configselect('moodlenet/oauthservice', new lang_string('issuer', 'auth_oauth2'),
|
||||
new lang_string('moodlenet:configoauthservice', 'moodle', $url->out()), '', $oauth2services));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
@core @core_admin
|
||||
Feature: MoodleNet outbound configuration
|
||||
In order to send activity/resource to MoodleNet
|
||||
As a Moodle administrator
|
||||
I need to set outbound configuration
|
||||
|
||||
Background:
|
||||
Given I log in as "admin"
|
||||
|
||||
Scenario: Share to MoodleNet experimental flag
|
||||
Given I navigate to "Development > Experimental" in site administration
|
||||
Then "Enable sharing to MoodleNet" "field" should exist
|
||||
And the field "Enable sharing to MoodleNet" matches value "0"
|
||||
|
||||
Scenario: Outbound configuration without experimental flag enable yet
|
||||
Given I navigate to "MoodleNet" in site administration
|
||||
Then I should not see "MoodleNet outbound settings"
|
||||
|
||||
Scenario: Outbound configuration without OAuth 2 service setup yet
|
||||
Given the following config values are set as admin:
|
||||
| enablesharingtomoodlenet | 1 |
|
||||
When I navigate to "MoodleNet" in site administration
|
||||
Then I should see "MoodleNet outbound settings"
|
||||
And I click on "MoodleNet outbound settings" "link"
|
||||
And the field "OAuth 2 service" matches value "None"
|
||||
And I should see "Select a MoodleNet OAuth 2 service to enable sharing to that MoodleNet site. If the service doesn't exist yet, you will need to create it."
|
||||
And I click on "create" "link"
|
||||
And I should see "OAuth 2 services"
|
||||
|
||||
Scenario: Outbound configuration with OAuth 2 service setup
|
||||
Given a MoodleNet mock server is configured
|
||||
And the following config values are set as admin:
|
||||
| enablesharingtomoodlenet | 1 |
|
||||
And I navigate to "Server > OAuth 2 services" in site administration
|
||||
And I press "Custom"
|
||||
And I should see "Create new service: Custom"
|
||||
And I set the following fields to these values:
|
||||
| Name | Testing custom service |
|
||||
| Client ID | thisistheclientid |
|
||||
| Client secret | supersecret |
|
||||
And I press "Save changes"
|
||||
When I navigate to "MoodleNet > MoodleNet outbound settings" in site administration
|
||||
Then the field "OAuth 2 service" matches value "None"
|
||||
And I navigate to "Server > OAuth 2 services" in site administration
|
||||
And I press "MoodleNet"
|
||||
And I should see "Create new service: MoodleNet"
|
||||
And I change the MoodleNet field "Service base URL" to mock server
|
||||
And I press "Save changes"
|
||||
And I navigate to "MoodleNet > MoodleNet outbound settings" in site administration
|
||||
And the "OAuth 2 service" "field" should be enabled
|
||||
And I should see "MoodleNet" in the "OAuth 2 service" "select"
|
||||
And I should not see "Testing custom service" in the "OAuth 2 service" "select"
|
||||
Reference in New Issue
Block a user