From: defacer Date: Mon, 24 May 2004 11:10:00 +0000 (+0000) Subject: Fixed a couple of warnings which happened if you accessed a course while X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2ef75eee2f4d639cdfef7fbcefaf4485e143af4b;p=moodle.git Fixed a couple of warnings which happened if you accessed a course while not being logged in, during the redirection to login screen. --- diff --git a/calendar/lib.php b/calendar/lib.php index ba94217bc4..8216cc4e85 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -929,7 +929,7 @@ function calendar_session_vars() { $SESSION->cal_show_course = true; } if(!isset($SESSION->cal_show_user)) { - $SESSION->cal_show_user = $USER->id; + $SESSION->cal_show_user = isset($USER->id) ? $USER->id : false; } if(empty($SESSION->cal_courses_shown)) { $SESSION->cal_courses_shown = calendar_get_default_courses(true); @@ -1074,6 +1074,10 @@ function calendar_get_default_courses($ignoreref = false) { return array($SESSION->cal_course_referer => 1); } + if(empty($USER)) { + return array(); + } + $courses = array(); if(isadmin($USER->id)) { $courses = get_records_sql('SELECT id, 1 FROM '.$CFG->prefix.'course');