From: moodler Date: Thu, 30 Sep 2004 08:35:55 +0000 (+0000) Subject: Fixed a notice as per bug 2020 (and tidied some code) X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f54e245898635325d6f71f7ae23d9276422a6b20;p=moodle.git Fixed a notice as per bug 2020 (and tidied some code) --- diff --git a/blocks/calendar_upcoming/block_calendar_upcoming.php b/blocks/calendar_upcoming/block_calendar_upcoming.php index 752888762f..6b77a8c816 100644 --- a/blocks/calendar_upcoming/block_calendar_upcoming.php +++ b/blocks/calendar_upcoming/block_calendar_upcoming.php @@ -38,12 +38,11 @@ class CourseBlock_calendar_upcoming extends MoodleBlock { '/calendar/event.php?action=new&course='.$this->course->id.'">'. get_string('newevent', 'calendar').'...'; - if($this->course->id == SITEID) { + if ($this->course->id == SITEID) { // Being displayed at site level. This will cause the filter to fall back to auto-detecting // the list of courses it will be grabbing events from. $filtercourse = NULL; - } - else { + } else { // Forcibly filter events to include only those from the particular course we are in. $filtercourse = array($courseshown => 1); } @@ -56,12 +55,18 @@ class CourseBlock_calendar_upcoming extends MoodleBlock { // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions. calendar_set_filters($courses, $group, $user, $filtercourse, $filtercourse, false); - $events = calendar_get_upcoming($courses, $group, $user, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS)); + $events = calendar_get_upcoming($courses, $group, $user, + get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), + get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS)); - $this->content->text = calendar_get_sideblock_upcoming($events, 'view.php?view=day&course='.$this->course->id.'&'); + if (!empty($this->course)) { + $this->content->text = calendar_get_sideblock_upcoming($events, + 'view.php?view=day&course='.$this->course->id.'&'); + } - if(empty($this->content->text)) { - $this->content->text = '
'.get_string('noupcomingevents', 'calendar').'
'; + if (empty($this->content->text)) { + $this->content->text = '
'. + get_string('noupcomingevents', 'calendar').'
'; } return $this->content;