MDL-49689 navigation: Allow the user to set their homepage.
authorAdrian Greeve <adrian@moodle.com>
Thu, 9 Apr 2015 06:03:26 +0000 (14:03 +0800)
committerAdrian Greeve <adrian@moodle.com>
Mon, 13 Apr 2015 07:54:24 +0000 (15:54 +0800)
Part of MDL-45774.

index.php
my/index.php

index 9c9bdef..8e218cd 100644 (file)
--- a/index.php
+++ b/index.php
@@ -71,10 +71,19 @@ if (get_home_page() != HOMEPAGE_SITE) {
     } else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY) && $redirect === 1) {
         redirect($CFG->wwwroot .'/my/');
     } else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_USER)) {
     } else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY) && $redirect === 1) {
         redirect($CFG->wwwroot .'/my/');
     } else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_USER)) {
-        $PAGE->settingsnav->find('usercurrentsettings', null)->add(
-            get_string('makethismyhome'),
-            new moodle_url('/', array('setdefaulthome' => true)),
-            navigation_node::TYPE_SETTING);
+        $frontpagenode = $PAGE->settingsnav->find('frontpage', null);
+        if ($frontpagenode) {
+            $frontpagenode->add(
+                get_string('makethismyhome'),
+                new moodle_url('/', array('setdefaulthome' => true)),
+                navigation_node::TYPE_SETTING);
+        } else {
+            $frontpagenode = $PAGE->settingsnav->add(get_string('frontpagesettings'), null, navigation_node::TYPE_SETTING, null);
+            $frontpagenode->force_open();
+            $frontpagenode->add(get_string('makethismyhome'),
+                new moodle_url('/', array('setdefaulthome' => true)),
+                navigation_node::TYPE_SETTING);
+        }
     }
 }
 
     }
 }
 
index bc1b07f..7287d3d 100644 (file)
@@ -90,8 +90,10 @@ if (!isguestuser()) {   // Skip default home page for guests
         if (optional_param('setdefaulthome', false, PARAM_BOOL)) {
             set_user_preference('user_home_page_preference', HOMEPAGE_MY);
         } else if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_USER) {
         if (optional_param('setdefaulthome', false, PARAM_BOOL)) {
             set_user_preference('user_home_page_preference', HOMEPAGE_MY);
         } else if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_USER) {
-            $PAGE->settingsnav->find('usercurrentsettings', null)->add(get_string('makethismyhome'),
-                    new moodle_url('/my/', array('setdefaulthome' => true)), navigation_node::TYPE_SETTING);
+            $frontpagenode = $PAGE->settingsnav->add(get_string('frontpagesettings'), null, navigation_node::TYPE_SETTING, null);
+            $frontpagenode->force_open();
+            $frontpagenode->add(get_string('makethismyhome'), new moodle_url('/my/', array('setdefaulthome' => true)),
+                    navigation_node::TYPE_SETTING);
         }
     }
 }
         }
     }
 }