require_login();
- if(isguest()) {
- // Guests cannot do anything with events
- redirect(CALENDAR_URL.'view.php?view=upcoming');
- }
-
$action = required_param('action', PARAM_ALPHA);
$eventid = optional_param('id', 0, PARAM_INT);
$eventtype = optional_param('type', 'select', PARAM_ALPHA);
$cal_m = optional_param('cal_m');
$cal_d = optional_param('cal_d');
+ if(isguest()) {
+ // Guests cannot do anything with events
+ redirect(CALENDAR_URL.'view.php?view=upcoming&course='.$urlcourse);
+ }
+
$focus = '';
if(!$site = get_site()) {
calendar_session_vars();
$now = usergetdate(time());
- $nav = calendar_get_link_tag($strcalendar, CALENDAR_URL.'view.php?view=upcoming&', $now['mday'], $now['mon'], $now['year']);
+ $nav = calendar_get_link_tag($strcalendar, CALENDAR_URL.'view.php?view=upcoming&course='.$urlcourse.'&', $now['mday'], $now['mon'], $now['year']);
$day = intval($now['mday']);
$mon = intval($now['mon']);
$yr = intval($now['year']);
}
// OK, now redirect to day view
- redirect(CALENDAR_URL.'view.php?view=day&cal_d='.$form->startday.'&cal_m='.$form->startmon.'&cal_y='.$form->startyr);
+ redirect(CALENDAR_URL.'view.php?view=day&course='.$urlcourse.'&cal_d='.$form->startday.'&cal_m='.$form->startmon.'&cal_y='.$form->startyr);
}
else {
foreach ($err as $key => $value) {
}
}
// OK, now redirect to day view
- redirect(CALENDAR_URL.'view.php?view=day&cal_d='.$form->startday.'&cal_m='.$form->startmon.'&cal_y='.$form->startyr);
+ redirect(CALENDAR_URL.'view.php?view=day&course='.$urlcourse.'&cal_d='.$form->startday.'&cal_m='.$form->startmon.'&cal_y='.$form->startyr);
}
else {
foreach ($err as $key => $value) {
}
}
- redirect(CALENDAR_URL.'view.php?view=day&cal_d='.$_REQUEST['d'].'&cal_m='.$_REQUEST['m'].'&cal_y='.$_REQUEST['y']);
+ redirect(CALENDAR_URL.'view.php?view=day&course='.$urlcourse.'&cal_d='.$_REQUEST['d'].'&cal_m='.$_REQUEST['m'].'&cal_y='.$_REQUEST['y']);
}
else {
echo '<div class="sideblock">';
echo '<div class="header">'.get_string('monthlyview', 'calendar').'</div>';
echo '<div class="minicalendarblock minicalendartop">';
- echo calendar_top_controls('display', array('m' => $prevmon, 'y' => $prevyr));
+ echo calendar_top_controls('display', array('id' => $urlcourse, 'm' => $prevmon, 'y' => $prevyr));
echo calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr);
echo '</div><div class="minicalendarblock">';
- echo calendar_top_controls('display', array('m' => $mon, 'y' => $yr));
+ echo calendar_top_controls('display', array('id' => $urlcourse, 'm' => $mon, 'y' => $yr));
echo calendar_get_mini($courses, $groups, $users, $mon, $yr);
echo '</div><div class="minicalendarblock">';
- echo calendar_top_controls('display', array('m' => $nextmon, 'y' => $nextyr));
+ echo calendar_top_controls('display', array('id' => $urlcourse, 'm' => $nextmon, 'y' => $nextyr));
echo calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr);
echo '</div>';
echo '</div>';
$data['d'] = 1;
}
+ // Ensure course id passed if relevant
+ // Required due to changes in view/lib.php mainly (calendar_session_vars())
+ $courseid = '';
+ if (!empty($data['id'])) {
+ $courseid = '&course='.$data['id'];
+ }
+
if(!checkdate($data['m'], $data['d'], $data['y'])) {
$time = time();
}
$content .= "<span class=\"clearer\"><!-- --></span></div>\n";
break;
case 'upcoming':
- $content .= '<div style="text-align: center;"><a href="'.CALENDAR_URL.'view.php?view=upcoming">'.userdate($time, get_string('strftimemonthyear'))."</a></div>\n";
+ $content .= '<div style="text-align: center;"><a href="'.CALENDAR_URL.'view.php?view=upcoming"'.$courseid.'>'.userdate($time, get_string('strftimemonthyear'))."</a></div>\n";
break;
case 'display':
- $content .= '<div style="text-align: center;"><a href="'.calendar_get_link_href(CALENDAR_URL.'view.php?view=month&', 1, $data['m'], $data['y']).'">'.userdate($time, get_string('strftimemonthyear'))."</a></div>\n";
+ $content .= '<div style="text-align: center;"><a href="'.calendar_get_link_href(CALENDAR_URL.'view.php?view=month'.$courseid.'&', 1, $data['m'], $data['y']).'">'.userdate($time, get_string('strftimemonthyear'))."</a></div>\n";
break;
case 'month':
list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']);
$prevdate = make_timestamp($prevyear, $prevmonth, 1);
$nextdate = make_timestamp($nextyear, $nextmonth, 1);
$content .= "\n".'<div class="calendar-controls">';
- $content .= calendar_get_link_previous(userdate($prevdate, get_string('strftimemonthyear')), 'view.php?view=month&', 1, $prevmonth, $prevyear);
+ $content .= calendar_get_link_previous(userdate($prevdate, get_string('strftimemonthyear')), 'view.php?view=month'.$courseid.'&', 1, $prevmonth, $prevyear);
$content .= '<span class="hide"> | </span><span class="current">'.userdate($time, get_string('strftimemonthyear'))."</span>\n";
- $content .= '<span class="hide"> | </span>'.calendar_get_link_next(userdate($nextdate, get_string('strftimemonthyear')), 'view.php?view=month&', 1, $nextmonth, $nextyear);
+ $content .= '<span class="hide"> | </span>'.calendar_get_link_next(userdate($nextdate, get_string('strftimemonthyear')), 'view.php?view=month'.$courseid.'&', 1, $nextmonth, $nextyear);
$content .= "<span class=\"clearer\"><!-- --></span></div>\n";
break;
case 'day':
$prevname = calendar_wday_name($CALENDARDAYS[$prevdate['wday']]);
$nextname = calendar_wday_name($CALENDARDAYS[$nextdate['wday']]);
$content .= "\n".'<div class="calendar-controls">';
- $content .= calendar_get_link_previous($prevname, 'view.php?view=day&', $prevdate['mday'], $prevdate['mon'], $prevdate['year']);
+ $content .= calendar_get_link_previous($prevname, 'view.php?view=day'.$courseid.'&', $prevdate['mday'], $prevdate['mon'], $prevdate['year']);
// Get the format string
$text = get_string('strftimedaydate');
// Print the actual thing
$content .= '<span class="hide"> | </span><span class="current">'.$text.'</span>';
- $content .= '<span class="hide"> | </span>'. calendar_get_link_next($nextname, 'view.php?view=day&', $nextdate['mday'], $nextdate['mon'], $nextdate['year']);
+ $content .= '<span class="hide"> | </span>'. calendar_get_link_next($nextname, 'view.php?view=day'.$courseid.'&', $nextdate['mday'], $nextdate['mon'], $nextdate['year']);
$content .= "<span class=\"clearer\"><!-- --></span></div>\n";
break;
}
if(!isset($SESSION->cal_show_user)) {
$SESSION->cal_show_user = true;
}
- // Version 1.76 to version 1.77 change, which commented out following if
- // statement prevented individual course from being selected! Investigate
- if(empty($SESSION->cal_courses_shown)) {
+ // if(empty($SESSION->cal_courses_shown)) {
$SESSION->cal_courses_shown = calendar_get_default_courses(true);
- }
+ //}
if(empty($SESSION->cal_users_shown)) {
// The empty() instead of !isset() here makes a whole world of difference,
// as it will automatically change to the user's id when the user first logs
// Initialize the session variables
calendar_session_vars();
+ // Ensure course id passed if relevant
+ // Required due to changes in view/lib.php mainly (calendar_session_vars())
+ $courseid = '';
+ if (!empty($id)) {
+ $courseid = '&course='.$id;
+ }
+
switch($var) {
case 'setuser':
// Not implemented yet (or possibly at all)
redirect(CALENDAR_URL.'event.php?action='.$action.'&type='.$type.'&id='.intval($id));
break;
case 'month':
- redirect(CALENDAR_URL.'view.php?view=month&cal_d='.$cal_d.'&cal_m='.$cal_m.'&cal_y='.$cal_y);
+ redirect(CALENDAR_URL.'view.php?view=month'.$courseid.'&cal_d='.$cal_d.'&cal_m='.$cal_m.'&cal_y='.$cal_y);
break;
case 'upcoming':
- redirect(CALENDAR_URL.'view.php?view=upcoming');
+ redirect(CALENDAR_URL.'view.php?view=upcoming'.$courseid);
break;
case 'day':
- redirect(CALENDAR_URL.'view.php?view=day&cal_d='.$cal_d.'&cal_m='.$cal_m.'&cal_y='.$cal_y);
+ redirect(CALENDAR_URL.'view.php?view=day'.$courseid.'&cal_d='.$cal_d.'&cal_m='.$cal_m.'&cal_y='.$cal_y);
break;
case 'course':
redirect($CFG->wwwroot.'/course/view.php?id='.intval($id));
switch($view) {
case 'day':
- calendar_show_day($day, $mon, $yr, $courses, $groups, $users);
+ calendar_show_day($day, $mon, $yr, $courses, $groups, $users, $courseid);
break;
case 'month':
- calendar_show_month_detailed($mon, $yr, $courses, $groups, $users);
+ calendar_show_month_detailed($mon, $yr, $courses, $groups, $users, $courseid);
break;
case 'upcoming':
- calendar_show_upcoming_events($courses, $groups, $users, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS));
+ calendar_show_upcoming_events($courses, $groups, $users, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS), $courseid);
break;
}
echo '<td class="sidecalendar">';
list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
- $getvars = 'cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; // For filtering
+ $getvars = 'id='.$courseid.'&cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; // For filtering
echo '<div class="sideblock">';
echo '<div class="header">'.get_string('eventskey', 'calendar').'</div>';
echo '<div class="header">'.get_string('monthlyview', 'calendar').'</div>';
echo '<div class="minicalendarblock minicalendartop">';
- echo calendar_top_controls('display', array('m' => $prevmon, 'y' => $prevyr));
+ echo calendar_top_controls('display', array('id' => $courseid, 'm' => $prevmon, 'y' => $prevyr));
echo calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr);
echo '</div><div class="minicalendarblock">';
- echo calendar_top_controls('display', array('m' => $mon, 'y' => $yr));
+ echo calendar_top_controls('display', array('id' => $courseid, 'm' => $mon, 'y' => $yr));
echo calendar_get_mini($courses, $groups, $users, $mon, $yr);
echo '</div><div class="minicalendarblock">';
- echo calendar_top_controls('display', array('m' => $nextmon, 'y' => $nextyr));
+ echo calendar_top_controls('display', array('id' => $courseid, 'm' => $nextmon, 'y' => $nextyr));
echo calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr);
echo '</div>';
echo '</div>';
-function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
+function calendar_show_day($d, $m, $y, $courses, $groups, $users, $courseid) {
global $CFG, $USER;
if (!checkdate($m, $d, $y)) {
$text.= '<form action="'.CALENDAR_URL.'event.php" method="get">';
$text.= '<div>';
$text.= '<input type="hidden" name="action" value="new" />';
+ $text.= '<input type="hidden" name="course" value="'.$courseid.'" />';
$text.= '<input type="hidden" name="cal_d" value="'.$d.'" />';
$text.= '<input type="hidden" name="cal_m" value="'.$m.'" />';
$text.= '<input type="hidden" name="cal_y" value="'.$y.'" />';
echo '<div class="header">'.$text.'</div>';
- echo '<div class="controls">'.calendar_top_controls('day', array('d' => $d, 'm' => $m, 'y' => $y)).'</div>';
+ echo '<div class="controls">'.calendar_top_controls('day', array('id' => $courseid, 'd' => $d, 'm' => $m, 'y' => $y)).'</div>';
if (empty($events)) {
// There is nothing to display today.
}
}
-function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
+function calendar_show_month_detailed($m, $y, $courses, $groups, $users, $courseid) {
global $CFG, $SESSION, $USER, $CALENDARDAYS;
global $day, $mon, $yr;
$text.= '<div class="buttons"><form action="'.CALENDAR_URL.'event.php" method="get">';
$text.= '<div>';
$text.= '<input type="hidden" name="action" value="new" />';
+ $text.= '<input type="hidden" name="course" value="'.$courseid.'" />';
$text.= '<input type="hidden" name="cal_m" value="'.$m.'" />';
$text.= '<input type="hidden" name="cal_y" value="'.$y.'" />';
$text.= '<input type="submit" value="'.get_string('newevent', 'calendar').'" />';
echo '<div class="header">'.$text.'</div>';
echo '<div class="controls">';
- echo calendar_top_controls('month', array('m' => $m, 'y' => $y));
+ echo calendar_top_controls('month', array('id' => $courseid, 'm' => $m, 'y' => $y));
echo '</div>';
// Start calendar display
// Reset vars
$cell = '';
- $dayhref = calendar_get_link_href(CALENDAR_URL.'view.php?view=day&', $day, $m, $y);
+ $dayhref = calendar_get_link_href(CALENDAR_URL.'view.php?view=day&course='.$courseid.'&', $day, $m, $y);
if(CALENDAR_WEEKEND & (1 << ($dayweek % 7))) {
// Weekend. This is true no matter what the exact range is.
}
-function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $maxevents) {
+function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $maxevents, $courseid) {
global $USER;
$events = calendar_get_upcoming($courses, $groups, $users, $futuredays, $maxevents);
$text.= '<form action="'.CALENDAR_URL.'event.php" method="get">';
$text.= '<div>';
$text.= '<input type="hidden" name="action" value="new" />';
+ $text.= '<input type="hidden" name="course" value="'.$courseid.'" />';
/*
$text.= '<input type="hidden" name="cal_m" value="'.$m.'" />';
$text.= '<input type="hidden" name="cal_y" value="'.$y.'" />';