Skip to content

Commit

Permalink
MDL-49987 upgrade: Make sure messages is in the user menu
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Damyon Wiese committed May 3, 2015
1 parent 24a2bab commit 3c568cd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -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.

Expand Down

0 comments on commit 3c568cd

Please sign in to comment.