From f5ccab8ddedf8f3f2fe948c63c93c3e32e4ecca9 Mon Sep 17 00:00:00 2001 From: Muhammad Arnaldo Date: Mon, 2 Feb 2026 16:38:44 +0700 Subject: [PATCH] MDL-87708 admin: Remove MoodleNet outbound admin settings Part of MDL-87350 --- public/admin/moodlenet_oauth2_callback.php | 57 ------------------- public/admin/settings/development.php | 5 -- public/admin/settings/moodlenet.php | 55 ------------------ .../tests/behat/moodlenet_outbound.feature | 52 ----------------- 4 files changed, 169 deletions(-) delete mode 100644 public/admin/moodlenet_oauth2_callback.php delete mode 100644 public/admin/settings/moodlenet.php delete mode 100644 public/admin/tests/behat/moodlenet_outbound.feature diff --git a/public/admin/moodlenet_oauth2_callback.php b/public/admin/moodlenet_oauth2_callback.php deleted file mode 100644 index 7be1a4d0d43..00000000000 --- a/public/admin/moodlenet_oauth2_callback.php +++ /dev/null @@ -1,57 +0,0 @@ -. - -/** - * MoodleNet callback. - * - * @package core - * @copyright 2023 Huong Nguyen - * @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(); diff --git a/public/admin/settings/development.php b/public/admin/settings/development.php index c1597cf6507..a20fb0cb940 100644 --- a/public/admin/settings/development.php +++ b/public/admin/settings/development.php @@ -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'), diff --git a/public/admin/settings/moodlenet.php b/public/admin/settings/moodlenet.php deleted file mode 100644 index 22a69a4f6f6..00000000000 --- a/public/admin/settings/moodlenet.php +++ /dev/null @@ -1,55 +0,0 @@ -. - -/** - * This file gives information about MoodleNet. - * - * @package core - * @copyright 2023 Huong Nguyen - * @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)); - - } -} diff --git a/public/admin/tests/behat/moodlenet_outbound.feature b/public/admin/tests/behat/moodlenet_outbound.feature deleted file mode 100644 index a88581ef5ba..00000000000 --- a/public/admin/tests/behat/moodlenet_outbound.feature +++ /dev/null @@ -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"