MDL-48934 navigation: Update the default entries in the user menu.
authorDamyon Wiese <damyon@moodle.com>
Tue, 17 Mar 2015 05:18:19 +0000 (13:18 +0800)
committerAdrian Greeve <adrian@moodle.com>
Fri, 10 Apr 2015 09:17:07 +0000 (17:17 +0800)
Add mypreferences and remove mybadges and myfiles (You should get to the
last 2 through your dashboard).

Part of MDL-45774

admin/settings/appearance.php
lang/en/moodle.php
lib/db/upgrade.php
pix/t/preferences.png [new file with mode: 0644]
pix/t/preferences.svg [new file with mode: 0644]

index d6eb80f..c727532 100644 (file)
@@ -29,8 +29,7 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp
         new lang_string('configcustomusermenuitems', 'admin'),
         'mygrades,grades|/grade/report/mygrades.php|grades
 messages,message|/message/index.php|message
-myfiles,moodle|/user/files.php|download
-mybadges,badges|/badges/mybadges.php|award',
+mypreferences,moodle|/user/preferences.php|preferences',
         PARAM_TEXT,
         '50',
         '10'
index ae2cc6b..b0f8ace 100644 (file)
@@ -1216,6 +1216,7 @@ $string['myfilesmanage'] = 'Manage my private files';
 $string['myhome'] = 'Dashboard';
 $string['mymoodledashboard'] = 'My Moodle dashboard';
 $string['myprofile'] = 'My profile';
+$string['mypreferences'] = 'My preferences';
 $string['name'] = 'Name';
 $string['nameforlink'] = 'What do you want to call this link?';
 $string['nameforpage'] = 'Name';
index 8bd1031..1873ce0 100644 (file)
@@ -4306,11 +4306,36 @@ function xmldb_main_upgrade($oldversion) {
 
     if ($oldversion < 2015040800.01) {
         // Add "My grades" to the user menu.
-        $newconfig = "mygrades,grades|/grade/report/mygrades.php|grades\n" . $CFG->customusermenuitems;
-        set_config('customusermenuitems', $newconfig);
+        $oldconfig = get_config('core', 'customusermenuitems');
+        if (strpos("mygrades,grades|/grade/report/mygrades.php|grades", $oldconfig) === false) {
+            $newconfig = "mygrades,grades|/grade/report/mygrades.php|grades\n" . $CFG->customusermenuitems;
+            set_config('customusermenuitems', $newconfig);
+        }
 
         upgrade_main_savepoint(true, 2015040800.01);
     }
 
+    if ($oldversion < 2015030400.02) {
+        // Update the default user menu (add preferences, remove my files and my badges).
+        $oldconfig = get_config('core', 'customusermenuitems');
+
+        // Add "My preferences" at the end.
+        if (strpos($oldconfig, "mypreferences,moodle|/user/preference.php|preferences") === false) {
+            $newconfig = $oldconfig . "\nmypreferences,moodle|/user/preferences.php|preferences";
+        } else {
+            $newconfig = $oldconfig;
+        }
+        // Remove my files.
+        $newconfig = str_replace("myfiles,moodle|/user/files.php|download", "", $newconfig);
+        // Remove my badges.
+        $newconfig = str_replace("mybadges,badges|/badges/mybadges.php|award", "", $newconfig);
+        // Remove holes.
+        $newconfig = preg_replace('/\n+/', "\n", $newconfig);
+        $newconfig = preg_replace('/(\r\n)+/', "\n", $newconfig);
+        set_config('customusermenuitems', $newconfig);
+
+        upgrade_main_savepoint(true, 2015030400.02);
+    }
+
     return true;
 }
diff --git a/pix/t/preferences.png b/pix/t/preferences.png
new file mode 100644 (file)
index 0000000..bd1c50f
Binary files /dev/null and b/pix/t/preferences.png differ
diff --git a/pix/t/preferences.svg b/pix/t/preferences.svg
new file mode 100644 (file)
index 0000000..eea506b
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In  -->\r
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
+       <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
+]>\r
+<svg version="1.1"\r
+        xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
+        x="0px" y="0px" width="12px" height="12px" viewBox="0 0 12 12" style="overflow:visible;enable-background:new 0 0 12 12;"\r
+        xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
+<defs>\r
+</defs>\r
+<path style="fill:#999999;" d="M11.9,7C12,6.7,12,6.3,12,6c0-0.3,0-0.7-0.1-1l-1.6-0.3c-0.1-0.3-0.2-0.6-0.4-0.9l0.9-1.3\r
+       C10.5,2,10,1.5,9.5,1.1L8.1,2C7.9,1.9,7.6,1.8,7.3,1.7L7,0.1C6.7,0,6.3,0,6,0C5.7,0,5.3,0,5,0.1L4.7,1.7C4.4,1.8,4.1,1.9,3.8,2\r
+       L2.5,1.1C2,1.5,1.5,2,1.1,2.5L2,3.8C1.9,4.1,1.8,4.4,1.7,4.7L0.1,5C0,5.3,0,5.7,0,6c0,0.3,0,0.7,0.1,1l1.6,0.3\r
+       C1.8,7.6,1.9,7.9,2,8.1L1.1,9.5c0.4,0.5,0.9,1,1.4,1.4l1.3-0.9c0.3,0.1,0.6,0.3,0.9,0.4L5,11.9C5.3,12,5.7,12,6,12\r
+       c0.3,0,0.7,0,1-0.1l0.3-1.6c0.3-0.1,0.6-0.2,0.9-0.4l1.3,0.9c0.5-0.4,1-0.9,1.4-1.4L9.9,8.1c0.1-0.3,0.3-0.6,0.4-0.9L11.9,7z M6,7.5\r
+       C5.2,7.5,4.5,6.8,4.5,6c0-0.8,0.7-1.5,1.5-1.5c0.8,0,1.5,0.7,1.5,1.5C7.5,6.8,6.8,7.5,6,7.5z"/>\r
+</svg>\r