]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10048 General calendar view enhancements as per spec with regard to event highlig...
authordwoolhead <dwoolhead>
Wed, 13 Jun 2007 16:26:19 +0000 (16:26 +0000)
committerdwoolhead <dwoolhead>
Wed, 13 Jun 2007 16:26:19 +0000 (16:26 +0000)
calendar/lib.php
calendar/view.php

index f851a3b3fb6c67a8526b31a3079fb0ab0ceb404f..aef7a5d6f7bb3eed1bdcc17cf6524c6f0ce8cdea 100644 (file)
@@ -62,6 +62,8 @@ define ('CALENDAR_URL', $CFG->wwwroot.'/calendar/');
 define ('CALENDAR_TF_24', '%H:%M');
 define ('CALENDAR_TF_12', '%I:%M %p');
 
+define ('CALENDAR_MAXCOURSES', 3);
+
 $CALENDARDAYS = array('sunday','monday','tuesday','wednesday','thursday','friday','saturday');
 
 
@@ -152,7 +154,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
     if (!empty($events)) {
         foreach ($events as $event) {
             if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
-                $event->class = 'event_course'.array_search($event->courseid, $courses) % 3;
+                $event->class = 'event_course'.array_search($event->courseid, $courses) % CALENDAR_MAXCOURSES;
             }
         }
     }
@@ -828,12 +830,12 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL, $courses
         $fields = 'id, shortname';
         $courseshortnames = get_records_select('course', $select, $sort, $fields, 0, 12);
 
-        for ($i = 0; $i < 3; $i++) {
+        for ($i = 0; $i < CALENDAR_MAXCOURSES; $i++) {
 
             // Concatenate shortnames if there are more than 3 courses
             $strshortnames = '';
             $n = 0;
-            for ($j = $i; $j < count($courses); $j += 3) {
+            for ($j = $i; $j < count($courses); $j += CALENDAR_MAXCOURSES) {
                 $strshortnames .= ', <a title="" href="'.$CFG->wwwroot.'/course/view.php?id='.$courses[$j].'">'.(!empty($courseshortnames[$courses[$j]]->shortname) ? $courseshortnames[$courses[$j]]->shortname : $courses[$j]).'</a>';
                 $n++;
             }
@@ -1066,7 +1068,7 @@ function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$duratio
             else if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
                 $typesbyday[$eventdaystart]['startcourse'] = true;
                 // Set event class for course event
-                $events[$event->id]->class = 'event_course'.array_search($event->courseid, $courses) % 3;
+                $events[$event->id]->class = 'event_course'.array_search($event->courseid, $courses) % CALENDAR_MAXCOURSES;
             }
             else if($event->groupid) {
                 $typesbyday[$eventdaystart]['startgroup'] = true;
index 982a1c2178c496d6d6f5cad5e76a60f5f3631dd2..a617d18168b82d3951b678fe239880a104c834f2 100644 (file)
@@ -265,7 +265,7 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
 
             // Set event course class if a course event
             if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
-                $event->class = 'event_course'.array_search($event->courseid, $courses) % 3;
+                $event->class = 'event_course'.array_search($event->courseid, $courses) % CALENDAR_MAXCOURSES;
             }
 
             if ($event->timestart >= $starttime && $event->timestart <= $endtime) {  // Print it now
@@ -538,7 +538,7 @@ function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $
 
             // Set event course class if a course event
             if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
-                $event->class = 'event_course'.array_search($event->courseid, $courses) % 3;
+                $event->class = 'event_course'.array_search($event->courseid, $courses) % CALENDAR_MAXCOURSES;
             }
 
             calendar_print_event($event);