MDL-10084 propogate course id through calendar pages to ensure consistent display for site front page, my moodle and courses

This commit is contained in:
dwoolhead
2007-06-21 15:46:04 +00:00
parent 8356aa7af1
commit f21ed0f3fc
4 changed files with 53 additions and 38 deletions
+12 -12
View File
@@ -45,11 +45,6 @@
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);
@@ -58,6 +53,11 @@
$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()) {
@@ -70,7 +70,7 @@
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']);
@@ -175,7 +175,7 @@
}
// 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) {
@@ -241,7 +241,7 @@
}
}
// 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) {
@@ -297,7 +297,7 @@
}
}
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 {
@@ -545,13 +545,13 @@
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>';
+15 -10
View File
@@ -641,6 +641,13 @@ function calendar_top_controls($type, $data) {
$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 = '&amp;course='.$data['id'];
}
if(!checkdate($data['m'], $data['d'], $data['y'])) {
$time = time();
}
@@ -678,10 +685,10 @@ function calendar_top_controls($type, $data) {
$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&amp;', 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.'&amp;', 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']);
@@ -689,9 +696,9 @@ function calendar_top_controls($type, $data) {
$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&amp;', 1, $prevmonth, $prevyear);
$content .= calendar_get_link_previous(userdate($prevdate, get_string('strftimemonthyear')), 'view.php?view=month'.$courseid.'&amp;', 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&amp;', 1, $nextmonth, $nextyear);
$content .= '<span class="hide"> | </span>'.calendar_get_link_next(userdate($nextdate, get_string('strftimemonthyear')), 'view.php?view=month'.$courseid.'&amp;', 1, $nextmonth, $nextyear);
$content .= "<span class=\"clearer\"><!-- --></span></div>\n";
break;
case 'day':
@@ -701,7 +708,7 @@ function calendar_top_controls($type, $data) {
$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&amp;', $prevdate['mday'], $prevdate['mon'], $prevdate['year']);
$content .= calendar_get_link_previous($prevname, 'view.php?view=day'.$courseid.'&amp;', $prevdate['mday'], $prevdate['mon'], $prevdate['year']);
// Get the format string
$text = get_string('strftimedaydate');
@@ -715,7 +722,7 @@ function calendar_top_controls($type, $data) {
// 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&amp;', $nextdate['mday'], $nextdate['mon'], $nextdate['year']);
$content .= '<span class="hide"> | </span>'. calendar_get_link_next($nextname, 'view.php?view=day'.$courseid.'&amp;', $nextdate['mday'], $nextdate['mon'], $nextdate['year']);
$content .= "<span class=\"clearer\"><!-- --></span></div>\n";
break;
}
@@ -1168,11 +1175,9 @@ function calendar_session_vars() {
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
+10 -3
View File
@@ -52,6 +52,13 @@
// 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 = '&amp;course='.$id;
}
switch($var) {
case 'setuser':
// Not implemented yet (or possibly at all)
@@ -101,13 +108,13 @@
redirect(CALENDAR_URL.'event.php?action='.$action.'&amp;type='.$type.'&amp;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));
+16 -13
View File
@@ -149,13 +149,13 @@
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;
}
@@ -184,7 +184,7 @@
echo '<td class="sidecalendar">';
list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
$getvars = 'cal_d='.$day.'&amp;cal_m='.$mon.'&amp;cal_y='.$yr; // For filtering
$getvars = 'id='.$courseid.'&amp;cal_d='.$day.'&amp;cal_m='.$mon.'&amp;cal_y='.$yr; // For filtering
echo '<div class="sideblock">';
echo '<div class="header">'.get_string('eventskey', 'calendar').'</div>';
@@ -197,13 +197,13 @@
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>';
@@ -216,7 +216,7 @@
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)) {
@@ -237,6 +237,7 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
$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.'" />';
@@ -248,7 +249,7 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
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.
@@ -302,7 +303,7 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
}
}
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;
@@ -375,6 +376,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
$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').'" />';
@@ -386,7 +388,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
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
@@ -421,7 +423,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
// Reset vars
$cell = '';
$dayhref = calendar_get_link_href(CALENDAR_URL.'view.php?view=day&amp;', $day, $m, $y);
$dayhref = calendar_get_link_href(CALENDAR_URL.'view.php?view=day&amp;course='.$courseid.'&amp;', $day, $m, $y);
if(CALENDAR_WEEKEND & (1 << ($dayweek % 7))) {
// Weekend. This is true no matter what the exact range is.
@@ -507,7 +509,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
}
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);
@@ -519,6 +521,7 @@ function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $
$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.'" />';