From 3c568cd3dba29ad1b745d554c4b7e38409aa4acb Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Wed, 29 Apr 2015 16:59:39 +0800 Subject: [PATCH] MDL-49987 upgrade: Make sure messages is in the user menu Because we have removed messages from the navigation tree, it is important that it exists in the user menu. That is the default behaviour, but if sites previously removed it, we need to make sure it is inserted back. --- lib/db/upgrade.php | 21 +++++++++++++++++++++ version.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index bdd749e67d71e..123a5ecedafb0 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -4337,5 +4337,26 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2015040900.02); } + if ($oldversion < 2015050300.00) { + // Make sure we have messages in the user menu because it's no longer in the nav tree. + $oldconfig = get_config('core', 'customusermenuitems'); + $mymessagesconfig = "messages,message|/message/index.php|message"; + $mypreferencesconfig = "mypreferences,moodle|/user/preferences.php|preferences"; + + // See if it exists. + if (strpos($oldconfig, $mymessagesconfig) === false) { + // See if mypreferences exists. + if (strpos($oldconfig, "mypreferences,moodle|/user/preferences.php|preferences") !== false) { + // Insert it before my preferences. + $newconfig = str_replace($mypreferencesconfig, $mymessagesconfig . "\n" . $mypreferencesconfig, $oldconfig); + } else { + // Custom config - we can only insert it at the end. + $newconfig = $oldconfig . "\n" . $mymessagesconfig; + } + set_config('customusermenuitems', $newconfig); + } + + upgrade_main_savepoint(true, 2015050300.00); + } return true; } diff --git a/version.php b/version.php index 4dc6553768741..d31b557b3fda3 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2015050100.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2015050300.00; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes.