MDL-32270 Library: ->defaulthomepage is checked before used

This commit is contained in:
Rajesh Taneja 2012-03-30 12:14:41 +08:00
parent a280078197
commit ab6ec58a2e
2 changed files with 4 additions and 4 deletions

View File

@ -35,7 +35,7 @@
redirect_if_major_upgrade_required(); redirect_if_major_upgrade_required();
$urlparams = array(); $urlparams = array();
if ($CFG->defaulthomepage == HOMEPAGE_MY && optional_param('redirect', 1, PARAM_BOOL) === 0) { if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY) && optional_param('redirect', 1, PARAM_BOOL) === 0) {
$urlparams['redirect'] = 0; $urlparams['redirect'] = 0;
} }
$PAGE->set_url('/', $urlparams); $PAGE->set_url('/', $urlparams);
@ -62,9 +62,9 @@
// Redirect logged-in users to My Moodle overview if required // Redirect logged-in users to My Moodle overview if required
if (optional_param('setdefaulthome', false, PARAM_BOOL)) { if (optional_param('setdefaulthome', false, PARAM_BOOL)) {
set_user_preference('user_home_page_preference', HOMEPAGE_SITE); set_user_preference('user_home_page_preference', HOMEPAGE_SITE);
} else if ($CFG->defaulthomepage == HOMEPAGE_MY && optional_param('redirect', 1, PARAM_BOOL) === 1) { } else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY) && optional_param('redirect', 1, PARAM_BOOL) === 1) {
redirect($CFG->wwwroot .'/my/'); redirect($CFG->wwwroot .'/my/');
} else if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_USER) { } else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_USER)) {
$PAGE->settingsnav->get('usercurrentsettings')->add(get_string('makethismyhome'), new moodle_url('/', array('setdefaulthome'=>true)), navigation_node::TYPE_SETTING); $PAGE->settingsnav->get('usercurrentsettings')->add(get_string('makethismyhome'), new moodle_url('/', array('setdefaulthome'=>true)), navigation_node::TYPE_SETTING);
} }
} }

View File

@ -1038,7 +1038,7 @@ class global_navigation extends navigation_node {
} else { } else {
// The home element should be the site because the root node is my moodle // The home element should be the site because the root node is my moodle
$this->rootnodes['home'] = $this->add(get_string('sitehome'), new moodle_url('/'), self::TYPE_SETTING, null, 'home'); $this->rootnodes['home'] = $this->add(get_string('sitehome'), new moodle_url('/'), self::TYPE_SETTING, null, 'home');
if ($CFG->defaulthomepage == HOMEPAGE_MY) { if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY)) {
// We need to stop automatic redirection // We need to stop automatic redirection
$this->rootnodes['home']->action->param('redirect', '0'); $this->rootnodes['home']->action->param('redirect', '0');
} }