From d5830dd0bee8ce58ee00bc744621668c42cc6594 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 30 Mar 2012 12:14:41 +0800 Subject: [PATCH] MDL-32270 Library: ->defaulthomepage is checked before used --- index.php | 6 +++--- lib/navigationlib.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index cae43f9ddca..92e9627d1f1 100644 --- a/index.php +++ b/index.php @@ -35,7 +35,7 @@ redirect_if_major_upgrade_required(); $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; } $PAGE->set_url('/', $urlparams); @@ -62,9 +62,9 @@ // Redirect logged-in users to My Moodle overview if required if (optional_param('setdefaulthome', false, PARAM_BOOL)) { 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/'); - } 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); } } diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 19d18793b53..23b31ffba4c 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -1042,7 +1042,7 @@ class global_navigation extends navigation_node { } else { // 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'); - if ($CFG->defaulthomepage == HOMEPAGE_MY) { + if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY)) { // We need to stop automatic redirection $this->rootnodes['home']->action->param('redirect', '0'); }