Page MenuHomePhorge

D207.1775437070.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D207.1775437070.diff

diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js
--- a/plugins/calendar/calendar_ui.js
+++ b/plugins/calendar/calendar_ui.js
@@ -1709,20 +1709,23 @@
eventstart = clone_date(event.start, event.allDay ? 1 : 0).getTime(), // calculate with integers
eventend = clone_date(event.end, event.allDay ? 2 : 0).getTime(),
duration = eventend - eventstart - (event.allDay ? HOUR_MS : 0), /* make sure we don't cross day borders on DST change */
- sinterval = freebusy_data.interval * 60000,
+ sinterval = freebusy_data.interval * 60000 / (event.allDay ? 1 : (settings.timeslots || 1)),
intvlslots = 1,
numslots = Math.ceil(duration / sinterval),
- checkdate, slotend, email, ts, slot, slotdate = new Date();
+ fb_start = freebusy_data.start.getTime(),
+ fb_end = freebusy_data.end.getTime(),
+ checkdate, slotend, email, ts, slot, slotdate = new Date(),
+ candidatecount = 0, candidatestart = false, success = false;
// shift event times to next possible slot
eventstart += sinterval * intvlslots * dir;
eventend += sinterval * intvlslots * dir;
// iterate through free-busy slots and find candidates
- var candidatecount = 0, candidatestart = candidateend = success = false;
- for (slot = dir > 0 ? freebusy_data.start.getTime() : freebusy_data.end.getTime() - sinterval;
- (dir > 0 && slot < freebusy_data.end.getTime()) || (dir < 0 && slot >= freebusy_data.start.getTime());
- slot += sinterval * dir) {
+ for (slot = dir > 0 ? fb_start : fb_end - sinterval;
+ (dir > 0 && slot < fb_end) || (dir < 0 && slot >= fb_start);
+ slot += sinterval * dir
+ ) {
slotdate.setTime(slot);
// fix slot if just crossed a DST change
if (event.allDay) {
@@ -1737,7 +1740,7 @@
// respect workingours setting
if (freebusy_ui.workinhoursonly) {
if (is_weekend(slotdate) || (freebusy_data.interval <= 60 && !is_workinghour(slotdate))) { // skip off-hours
- candidatestart = candidateend = false;
+ candidatestart = false;
candidatecount = 0;
continue;
}
@@ -1746,11 +1749,15 @@
if (!candidatestart)
candidatestart = slot;
- // check freebusy data for all attendees
ts = date2timestring(slotdate, freebusy_data.interval > 60);
+ // @TODO: freebusy_data slots should use sinterval not full hour
+ if (!event.allDay)
+ ts = ts.replace(/[0-9]{4}$/, '0000');
+
+ // check freebusy data for all attendees
for (var i=0; i < event_attendees.length; i++) {
if (freebusy_ui.attendees[i].role != 'OPT-PARTICIPANT' && (email = freebusy_ui.attendees[i].email) && freebusy_data[email] && freebusy_data[email][ts] > 1) {
- candidatestart = candidateend = false;
+ candidatestart = false;
break;
}
}
@@ -1761,22 +1768,15 @@
candidatecount = 0;
continue;
}
+ else if (dir < 0)
+ candidatestart = slot;
- // set candidate end to slot end time
candidatecount++;
- if (dir < 0 && !candidateend)
- candidateend = slotend;
// if candidate is big enough, this is it!
if (candidatecount == numslots) {
- if (dir > 0) {
- event.start.setTime(candidatestart);
- event.end.setTime(candidatestart + duration);
- }
- else {
- event.end.setTime(candidateend);
- event.start.setTime(candidateend - duration);
- }
+ event.start.setTime(candidatestart);
+ event.end.setTime(candidatestart + duration);
success = true;
break;
}

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 6, 12:57 AM (1 d, 48 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18835092
Default Alt Text
D207.1775437070.diff (3 KB)

Event Timeline