diff --git a/blocks/calendar_upcoming/block_calendar_upcoming.php b/blocks/calendar_upcoming/block_calendar_upcoming.php index 07ca412105c..bcfcccc62df 100644 --- a/blocks/calendar_upcoming/block_calendar_upcoming.php +++ b/blocks/calendar_upcoming/block_calendar_upcoming.php @@ -44,8 +44,9 @@ 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)); - $this->content->text = calendar_get_sideblock_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->content->text)) { $this->content->text = '
'.get_string('noupcomingevents', 'calendar').'
'; diff --git a/calendar/lib.php b/calendar/lib.php index 4701fecf68f..96a3e2e9c0f 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -122,7 +122,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y $morehref = ''; if(!empty($courses)) { - $courses = array_diff($courses, array(1)); + $courses = array_diff($courses, array(SITEID)); if(count($courses) == 1) { $morehref = '&course='.reset($courses); } @@ -308,7 +308,7 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve $morehref = ''; if(!empty($courses)) { - $courses = array_diff($courses, array(1)); + $courses = array_diff($courses, array(SITEID)); if(count($courses) == 1) { $morehref = '&course='.reset($courses); } @@ -727,9 +727,7 @@ function calendar_days_in_month($month, $year) { return intval(date('t', mktime(0, 0, 0, $month, 1, $year))); } -function calendar_get_sideblock_upcoming($courses, $groups, $users, $daysinfuture, $maxevents) { - $events = calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents); - +function calendar_get_sideblock_upcoming($events, $linkhref = NULL) { $content = ''; $lines = count($events); if (!$lines) { @@ -742,7 +740,14 @@ function calendar_get_sideblock_upcoming($courses, $groups, $users, $daysinfutur // That's an activity event, so let's provide the hyperlink $content .= $events[$i]->referer; } else { - $content .= $events[$i]->name; + if(!empty($linkhref)) { + $ed = usergetdate($events[$i]->timestart); + $href = calendar_get_link_href(CALENDAR_URL.$linkhref, $ed['mday'], $ed['mon'], $ed['year']); + $content .= ''.$events[$i]->name.''; + } + else { + $content .= $events[$i]->name; + } } $events[$i]->time = str_replace('->', '
->', $events[$i]->time); $content .= '
'.$events[$i]->time.'
'; @@ -941,10 +946,10 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU else if(is_array($courseeventsfrom)) { $courses = array_keys($courseeventsfrom); } - $courses = array_diff($courses, array(1)); + $courses = array_diff($courses, array(SITEID)); } else if($SESSION->cal_show_global) { - $courses = array(1); + $courses = array(SITEID); } else { $courses = false;