Skip to content

Commit fcd4384

Browse files
author
Jason Oster
committed
Fix overlapping events, Bug #2968512
1 parent ce0ebfc commit fcd4384

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

functions/draw_functions.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ function drawEventTimes ($start, $end, $long_event = FALSE) {
3131
$end_min = "00";
3232
}
3333
}
34-
$draw_len = ($end_h * 60 + $end_min) - ($sta_h * 60 + $sta_min);
34+
$sta = ($sta_h * 60 + $sta_min);
35+
$end = ($end_h * 60 + $end_min);
36+
if ($sta < $end)
37+
$draw_len = $end - $sta;
38+
else
39+
$draw_len = $sta - $end;
3540

3641
return array ("draw_start" => ($sta_h . $sta_min), "draw_end" => ($end_h . $end_min), "draw_length" => $draw_len);
3742
}

functions/parse/overlapping_events.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function flatten_ol_blocks($event_date, $ol_blocks, $new_block_key) {
110110

111111
// Builds $overlap_array structure, and updates event_overlap in $master_array for the given events.
112112
// For a given date,
113-
// - check to see if the event's already in a block, and if so, add it.
113+
// - check to see if the event's already in a block, and if so, add it.
114114
// - make sure the new block doesn't overlap another block, and if so, merge the blocks.
115115
// - check that there aren't any events we already passed that we should handle.
116116
// - "flatten" the structure again, merging the blocks.
@@ -182,7 +182,9 @@ function checkOverlap($event_date, $event_time, $uid) {
182182
foreach ($time as $loop_event_key => $loop_event) {
183183
// Make sure we haven't already dealt with the event, and we're not checking against ourself.
184184
if ($loop_event['event_overlap'] == 0 && $loop_event_key != $uid) {
185-
$loopDrawTimes = drawEventTimes($loop_event['event_start'], $loop_event['display_end']);
185+
$loopDrawTimes = drawEventTimes($loop_event['event_start'], $loop_event['display_end'], ($loop_event['event_length'] >= (60*60*24)));
186+
if ($event_time == "0000") $loopDrawTimes['draw_start'] = "0000";
187+
if ($draw_end == "2400") $loopDrawTimes['draw_end'] = "2400";
186188
if ($loopDrawTimes['draw_start'] < $drawTimes['draw_end'] && $loopDrawTimes['draw_end'] > $drawTimes['draw_start']) {
187189
if ($loopDrawTimes['draw_start'] < $drawTimes['draw_start']) {
188190
$block_start = $loopDrawTimes['draw_start'];

0 commit comments

Comments
 (0)