--- 196_unmodified/blocks/calendar_month/block_calendar_month.php 2009-01-31 07:06:40.000000000 -0800 +++ 196/blocks/calendar_month/block_calendar_month.php 2009-12-22 15:37:50.782833600 -0800 @@ -42,7 +42,11 @@ } else { //MDL-14693: fix calendar on resource page - $courseshown = optional_param( 'id', $COURSE->id, PARAM_INT ); + // DES: always take the course id from the session variable as the id in the URL might be a resource id + // since we embed the course block on all pages now + // $courseshown = optional_param( 'id', $COURSE->id, PARAM_INT ); + $courseshown = $COURSE->id; + // Forcibly filter events to include only those from the particular course we are in. $filtercourse = array($courseshown => $COURSE); $groupeventsfrom = array($courseshown => 1); @@ -60,17 +64,44 @@ // Be VERY careful with the format for default courses arguments! // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions. calendar_set_filters($courses, $group, $user, $filtercourse, $groupeventsfrom, false); + + // DES: We now use the calendar block not only on the main course page but throughout the + // course site, so we need to carry over the id from the url as the path will change and + // it needs to reflect not only a course ID but the resource ID of the page we are on + // so we introduce these new variables that we use when building the prev/next links + + // for all regular cases use $id + $id = optional_param( 'id', 0, PARAM_INT ); + + // discussion and forum pages need special URL params + if (optional_param( 'id', 0, PARAM_INT ) != 0) + $paramname = 'id'; + else if (optional_param( 'f', 0, PARAM_INT ) != 0) + $paramname = 'f'; + else if (optional_param( 'd', 0, PARAM_INT ) != 0) + $paramname = 'd'; + else + $paramname = 'id'; // default to id even though it will be set 0 + + $paramval = optional_param( $paramname, 0, PARAM_INT ); + + // the page we have the caledar block on + $pagename = $_SERVER['PHP_SELF']; + if ($courseshown == SITEID) { // For the front page $this->content->text .= calendar_overlib_html(); - $this->content->text .= calendar_top_controls('frontpage', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y)); + $this->content->text .= calendar_top_controls('frontpage', array('id' => $id, 'm' => $cal_m, 'y' => $cal_y)); $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y); // No filters for now } else { // For any other course $this->content->text .= calendar_overlib_html(); - $this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y)); + + $this->content->text .= calendar_top_controls('course', array('pagename' => $pagename, + 'paramname' => $paramname, 'paramval' => $paramval, 'courseid' => $courseshown, 'm' => $cal_m, 'y' => $cal_y)); + $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y); $this->content->text .= '