]> git.mjollnir.org Git - moodle.git/commitdiff
Behavior change, according to Gustav's remarks on the forums. Events from
authordefacer <defacer>
Fri, 14 May 2004 12:48:50 +0000 (12:48 +0000)
committerdefacer <defacer>
Fri, 14 May 2004 12:48:50 +0000 (12:48 +0000)
courses other than the one you are browsing are not displayed in the month
views or as upcoming events, except only if you explicitly do it in the
full month view. However, if you manually go to a day with such an event and
get a day view, you will see the event. Should I find a way to hide that too?

calendar/lib.php
calendar/view.php

index ad313a70ce5cb6bf60b6582803ce3d6e14cfda7f..39e3a0195087f5d9b69eddca4a05f87ff9dd4797 100644 (file)
@@ -1145,8 +1145,12 @@ function calendar_edit_event_allowed($event) {
     return false;
 }
 
-function calendar_get_default_courses() {
-    global $USER, $CFG;
+function calendar_get_default_courses($overridereferer = true) {
+    global $USER, $CFG, $SESSION;
+
+    if(!empty($SESSION->cal_course_referer) && $overridereferer) {
+        return array($SESSION->cal_course_referer => 1);
+    }
 
     $courses = array();
     if(isadmin($USER->id)) {
index 178f7d87ff1d31cf74608148694bd5ba05287660..db762e7ad52d2be0faff7b84ef674a6bb433bce7 100644 (file)
 
     echo '<td width="100%" valign="top">';
 
-    $defaultcourses = calendar_get_default_courses();
+    $conform = ($_GET['view'] == 'month' && $SESSION->cal_show_course === true);
+
+    $defaultcourses = calendar_get_default_courses(!$conform);
     $courses = array();
 
     calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
 
     // Are we left with a bad filter in effect?
-    if($_GET['view'] != 'month') {
-        if(is_int($SESSION->cal_show_course)) {
-            // There is a filter in action that shows events from courses other than the current.
-            // Reset the filter... this effectively allows course filtering only in the month display.
-            // This filter resetting is also done in the course sideblock display, in case someone
-            // sets a filter for course X and then goes to view course Y.
-            $SESSION->cal_show_course = true;
+    if($_GET['view'] != 'month' && !empty($SESSION->cal_course_referer)) {
+        if(is_numeric($SESSION->cal_show_course)) {
+            if($SESSION->cal_course_referer != $SESSION->cal_show_course) {
+                $SESSION->cal_show_course = intval($SESSION->cal_course_referer);
+            }
+        }
+        if(is_array($SESSION->cal_show_course) && !in_array($SESSION->cal_course_referer, $SESSION->cal_show_course)) {
+            $SESSION->cal_show_course = intval($SESSION->cal_course_referer);
         }
     }