MDL-49689 navigation: Allow the user to set their homepage.

Part of MDL-45774.
This commit is contained in:
Adrian Greeve 2015-04-09 14:03:26 +08:00
parent 72324523ad
commit d9926e8664
2 changed files with 17 additions and 6 deletions

View File

@ -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)) {
$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);
}
}
}

View 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) {
$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);
}
}
}