From e77c82dc1d210483679c7d207ba52e9a74e95929 Mon Sep 17 00:00:00 2001 From: Andi Permana Date: Fri, 6 Feb 2026 14:32:42 +0700 Subject: [PATCH 1/3] MDL-87708 tool_moodlenet: Clean up moodle.net configs in stable Part of MDL-87351 - Discourage tool_moodlenet unless pointing to custom installation - Clear activity chooser footer if set to MoodleNet - Cleanup happens for: moodle.net URL, www.moodle.net, or empty config - Preserves custom/local MoodleNet installations --- lib/db/upgrade.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++ version.php | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 84660224cf2..c55d0606e79 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1622,5 +1622,53 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2024100705.09); } + if ($oldversion < 2024100710.03) { + // Clean up tool_moodlenet configurations unless pointing to a custom installation. + $moodleneturl = get_config('tool_moodlenet', 'defaultmoodlenet'); + + $shouldcleanup = true; + + // Check if pointing to a custom MoodleNet installation. + if (!empty($moodleneturl)) { + $parsed = parse_url(strtolower(trim($moodleneturl))); + $host = $parsed['host'] ?? ''; + + // Don't cleanup if it's a custom installation (not moodle.net). + if ($host !== 'moodle.net' && $host !== 'www.moodle.net') { + $shouldcleanup = false; + } + } + + if ($shouldcleanup) { + // Reset configs to defaults. + set_config('defaultmoodlenet', '', 'tool_moodlenet'); + set_config('enablemoodlenet', 0, 'tool_moodlenet'); + + // Hide activity chooser footer if set to MoodleNet. + $footer = get_config('core', 'activitychooseractivefooter'); + if ($footer === 'tool_moodlenet') { + set_config('activitychooseractivefooter', 'hidden'); + } + + // Remove the enablesharingtomoodlenet config setting. + unset_config('enablesharingtomoodlenet'); + + // Remove MoodleNet outbound OAuth2 configuration. + unset_config('oauthservice', 'moodlenet'); + $issuerids = $DB->get_fieldset_select('oauth2_issuer', 'id', "servicetype = ?", ['moodlenet']); + if (!empty($issuerids)) { + $DB->delete_records_list('oauth2_endpoint', 'issuerid', $issuerids); + $DB->delete_records_list('oauth2_access_token', 'issuerid', $issuerids); + $DB->delete_records_list('oauth2_refresh_token', 'issuerid', $issuerids); + $DB->delete_records_list('oauth2_system_account', 'issuerid', $issuerids); + $DB->delete_records_list('oauth2_user_field_mapping', 'issuerid', $issuerids); + $DB->delete_records_list('oauth2_issuer', 'id', $issuerids); + } + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2024100710.03); + } + return true; } diff --git a/version.php b/version.php index d4fabd1e866..315b0d3fe79 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2024100710.02; // 20241007 = branching date YYYYMMDD - do not modify! +$version = 2024100710.03; // 20241007 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '4.5.10+ (Build: 20260220)'; // Human-friendly version name From 3ca9f3a5e0b035108f17791e9034c01b97c4409f Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Thu, 12 Mar 2026 09:24:22 +0700 Subject: [PATCH 2/3] MDL-87708 admin: Improve MoodleNet removal warnings message --- lang/en/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en/admin.php b/lang/en/admin.php index a245812db72..3711f058715 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -968,7 +968,7 @@ $string['maxtimelimit'] = 'Maximum time limit'; $string['maxtimelimit_desc'] = 'To restrict the maximum PHP execution time that Moodle will allow without any output being displayed, enter a value in seconds here. 0 means that Moodle default restrictions are used. If you have a front-end server with its own time limit, set this value lower to receive PHP errors in logs. Does not apply to CLI scripts.'; $string['moodlebrandedapp'] = 'Branded Moodle app'; $string['moodlebrandedappreference'] = 'Alternatively, get a Branded Moodle app with your own custom branding.'; -$string['moodlenetremovalwarning'] = 'The MoodleNet service will be shut down on 20 April 2026. If you wish to continue using MoodleNet on your site, install the MoodleNet plugin from the Moodle plugins directory and connect it to a self-hosted MoodleNet instance. Following this, the MoodleNet profile ID field will be removed; please migrate that data if you are using it for other purposes.'; +$string['moodlenetremovalwarning'] = 'The MoodleNet service will be shut down on 20 April 2026. If you wish to continue using MoodleNet on your site, install the MoodleNet plugin from the Moodle HQ GitHub repository and connect it to a self-hosted MoodleNet instance. Following this, the MoodleNet profile ID field will be removed; please migrate that data if you are using it for other purposes.'; $string['noreplyaddress'] = 'No-reply address'; $string['noreplydomain'] = 'No-reply and domain'; $string['noreplydomaindetail'] = 'Settings for No-reply and configured domains'; From f896d4b381ba7630f9e4095394f2a6e61faf3603 Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Thu, 12 Mar 2026 10:47:50 +0700 Subject: [PATCH 3/3] MDL-87708 tool_moodlenet: Remove post install task --- .../moodlenet/classes/task/post_install.php | 35 ------------------- admin/tool/moodlenet/db/install.php | 9 +---- 2 files changed, 1 insertion(+), 43 deletions(-) delete mode 100644 admin/tool/moodlenet/classes/task/post_install.php diff --git a/admin/tool/moodlenet/classes/task/post_install.php b/admin/tool/moodlenet/classes/task/post_install.php deleted file mode 100644 index 55f2ca13881..00000000000 --- a/admin/tool/moodlenet/classes/task/post_install.php +++ /dev/null @@ -1,35 +0,0 @@ -. - -declare(strict_types=1); - -namespace tool_moodlenet\task; - -/** - * Ad-hoc task to perform post install tasks. - * We use this to set the active activity chooser footer plugin to tool_moodlenet. - * We couldn't do this directly in install.php, because there is an admin_apply_default_settings() call after all plugins are - * installed and that would reset whatever value we had set earlier to 'hidden'. - * - * @package tool_moodlenet - * @copyright 2022 Shamim Rezaie - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class post_install extends \core\task\adhoc_task { - public function execute() { - set_config('activitychooseractivefooter', 'tool_moodlenet'); - } -} diff --git a/admin/tool/moodlenet/db/install.php b/admin/tool/moodlenet/db/install.php index d9c1a0f8669..4a43df97ceb 100644 --- a/admin/tool/moodlenet/db/install.php +++ b/admin/tool/moodlenet/db/install.php @@ -28,12 +28,5 @@ declare(strict_types=1); * Perform the post-install procedures. */ function xmldb_tool_moodlenet_install() { - // Use an ad-hoc task to set the active activity chooser footer plugin to tool_moodlenet. - // We couldn't do this in admin/settings/courses.php for 2 reasons: - // - First, because it would be a breach of component communications principles to do so there. - // - Second, because we can't call get_plugins_with_function() during install and upgrade (or it will return []). - // We couldn't do this directly here either, because there is an admin_apply_default_settings() call after all plugins are - // installed and that would reset whatever value we set here to 'hidden'. - $postinstall = new tool_moodlenet\task\post_install(); - core\task\manager::queue_adhoc_task($postinstall); + }