]> git.mjollnir.org Git - moodle.git/commitdiff
Following Eloy's suggestion and Martin's clarification, the wizard is going
authordefacer <defacer>
Thu, 1 Apr 2004 12:51:24 +0000 (12:51 +0000)
committerdefacer <defacer>
Thu, 1 Apr 2004 12:51:24 +0000 (12:51 +0000)
to demonstrate a feat where 10 lines of code turn into 2, and a global var
dependency vanishes at the same time! ;)

calendar/view.php

index fc3c2d6317d08a46f810a9c722d85051c9bf8ffe..1ca4799421465526676946667db78dfee7f58114 100644 (file)
@@ -337,7 +337,7 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
 
 function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
     global $CFG, $SESSION, $USER;
-    global $day, $mon, $yr, $defaultcourses;
+    global $day, $mon, $yr;
 
     $getvars = 'from=month&amp;cal_d='.$day.'&amp;cal_m='.$mon.'&amp;cal_y='.$yr; // For filtering
 
@@ -549,16 +549,8 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
     }
     echo 'style="width: 8px;"></td><td><strong>'.get_string('courseevents', 'calendar').':</strong> ';
 
-    $defaultcourses = array_diff_assoc($defaultcourses, array(1 => 1)); // Filter the site out
-    $getcourses = array_keys($defaultcourses);
-
-    if(!empty($getcourses)) {
-        $select = 'id IN ('.implode(',', $getcourses).')';
-        $coursesdata = get_records_select('course', $select, 'fullname');
-    }
-    else {
-        $coursedata = false;
-    }
+    $coursesdata = get_my_courses($USER->id);
+    $coursesdata = array_diff_assoc($coursesdata, array(1 => 1));
 
     echo '<select name="course" onchange="document.location.href=\''.CALENDAR_URL.'set.php?var=setcourse&amp;'.$getvars.'&amp;id=\' + this.value;">';
     echo '<option value="0"'.($SESSION->cal_show_course === false?' selected':'').'>'.get_string('hidden', 'calendar')."</option>\n";
@@ -566,9 +558,11 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
     if($coursesdata !== false) {
         foreach($coursesdata as $coursedata) {
             echo "\n<option value='$coursedata->id'";
-            if(is_int($SESSION->cal_show_course) && $coursedata->id == $SESSION->cal_show_course) echo ' selected';
-                echo '>'.$coursedata->shortname."</option>\n";
+            if(is_int($SESSION->cal_show_course) && $coursedata->id == $SESSION->cal_show_course) {
+                echo ' selected';
             }
+            echo '>'.$coursedata->shortname."</option>\n";
+        }
     }
     echo '</select>';
     echo '</td>';