mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 16:04:25 +02:00
MDL-10048 General calendar view enhancements as per spec with regard to event highlighting
This commit is contained in:
parent
870a603f9c
commit
7c50db30f9
@ -173,7 +173,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
|
||||
// We want to have easy access by day, since the display is on a per-day basis.
|
||||
// Arguments passed by reference.
|
||||
//calendar_events_by_day($events, $display->tstart, $eventsbyday, $durationbyday, $typesbyday);
|
||||
calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday);
|
||||
calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday, $courses);
|
||||
|
||||
//Accessibility: added summary and <abbr> elements.
|
||||
///global $CALENDARDAYS; appears to be broken.
|
||||
@ -1032,7 +1032,7 @@ function calendar_sub_month($month, $year) {
|
||||
}
|
||||
}
|
||||
|
||||
function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$durationbyday, &$typesbyday) {
|
||||
function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$durationbyday, &$typesbyday, &$courses) {
|
||||
$eventsbyday = array();
|
||||
$typesbyday = array();
|
||||
$durationbyday = array();
|
||||
@ -1041,9 +1041,6 @@ function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$duratio
|
||||
return;
|
||||
}
|
||||
|
||||
// Define array of course id's
|
||||
$courseids = array();
|
||||
|
||||
foreach($events as $event) {
|
||||
|
||||
$startdate = usergetdate($event->timestart);
|
||||
@ -1075,10 +1072,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
|
||||
if (!in_array($event->courseid, $courseids)) {
|
||||
$courseids[] = $event->courseid;
|
||||
}
|
||||
$events[$event->id]->class = 'event_course'.array_search($event->courseid, $courseids) % 3;
|
||||
$events[$event->id]->class = 'event_course'.array_search($event->courseid, $courses) % 3;
|
||||
}
|
||||
else if($event->groupid) {
|
||||
$typesbyday[$eventdaystart]['startgroup'] = true;
|
||||
@ -1252,6 +1246,17 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
|
||||
foreach ($courses as $index => $value) {
|
||||
if (empty($value)) unset($courses[$index]);
|
||||
}
|
||||
|
||||
// Sort courses for consistent colour highlighting
|
||||
// Effectively ignoring SITEID as setting as last course id
|
||||
$key = array_search(SITEID, $courses);
|
||||
if ($key !== false) {
|
||||
unset($courses[$key]);
|
||||
sort($courses);
|
||||
$courses[] = SITEID;
|
||||
} else {
|
||||
sort($courses);
|
||||
}
|
||||
}
|
||||
|
||||
if($SESSION->cal_show_user || $ignorefilters) {
|
||||
|
@ -117,18 +117,6 @@
|
||||
calendar_set_filters($courses, $groups, $users);
|
||||
}
|
||||
|
||||
// Sort courses for consistent colour highlighting
|
||||
// Effectively ignoring SITEID as setting as last course id
|
||||
// Consider inside calendar_set_filters() and SITEID always last
|
||||
$key = array_search(SITEID, $courses);
|
||||
if ($key !== false) {
|
||||
unset($courses[$key]);
|
||||
sort($courses);
|
||||
$courses[] = SITEID;
|
||||
} else {
|
||||
sort($courses);
|
||||
}
|
||||
|
||||
// Let's see if we are supposed to provide a referring course link
|
||||
// but NOT for the "main page" course
|
||||
if ($SESSION->cal_course_referer != SITEID &&
|
||||
@ -274,6 +262,12 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
|
||||
|
||||
// First, print details about events that start today
|
||||
foreach ($events as $event) {
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
if ($event->timestart >= $starttime && $event->timestart <= $endtime) { // Print it now
|
||||
|
||||
|
||||
@ -286,11 +280,6 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
|
||||
*/
|
||||
//unset($event->time);
|
||||
|
||||
// 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->time = calendar_format_event_time($event, time(), '', false, $starttime);
|
||||
calendar_print_event($event);
|
||||
|
||||
@ -379,7 +368,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
|
||||
}
|
||||
|
||||
// Extract information: events vs. time
|
||||
calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday);
|
||||
calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday, $courses);
|
||||
|
||||
$text = '';
|
||||
if(!isguest() && !empty($USER->id)) {
|
||||
@ -544,20 +533,12 @@ function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $
|
||||
|
||||
if ($events) {
|
||||
|
||||
// Sort courses for consistent colour highlighting (ignoring SITEID)
|
||||
$courseids = $courses;
|
||||
$key = array_search(SITEID, $courseids);
|
||||
if ($key !== false) {
|
||||
unset($courseids[$key]);
|
||||
}
|
||||
sort($courseids);
|
||||
|
||||
echo '<div class="eventlist">';
|
||||
foreach ($events as $event) {
|
||||
|
||||
// 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, $courseids) % 3;
|
||||
$event->class = 'event_course'.array_search($event->courseid, $courses) % 3;
|
||||
}
|
||||
|
||||
calendar_print_event($event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user