Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new CalDAV calendar in Roundcube 1.2.1 & All-day events #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions calendar/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -3368,7 +3368,7 @@ public function mail_import_attachment()

// establish imap connection
$imap = $this->rc->get_storage();
$imap->set_mailbox($mbox);
$imap->set_folder($mbox);

if ($uid && $mime_id) {
$part = $imap->get_message_part($uid, $mime_id);
Expand Down Expand Up @@ -3431,7 +3431,7 @@ public function mail_message2event()

// establish imap connection
$imap = $this->rc->get_storage();
$imap->set_mailbox($mbox);
$imap->set_folder($mbox);
$message = new rcube_message($uid);

if ($message->headers) {
Expand Down
2 changes: 1 addition & 1 deletion calendar/calendar_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -4215,7 +4215,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
rcmail.register_command('print', function(){ cal.print_calendars(); }, true);

// configure list operations
rcmail.register_command('calendar-create', function(props){ cal.calendar_edit_dialog($.extend($.parseJSON(props), { name:'', color:'cc0000', editable:true, showalarms:true })); }, true);
rcmail.register_command('calendar-create', function(props){ props='{"driver":"caldav"}'; cal.calendar_edit_dialog($.extend($.parseJSON(props), { name:'', color:'cc0000', editable:true, showalarms:true })); }, true);
rcmail.register_command('calendar-edit', function(){ cal.calendar_edit_dialog(cal.calendars[cal.selected_calendar]); }, false);
rcmail.register_command('calendar-remove', function(){ cal.calendar_remove(cal.calendars[cal.selected_calendar]); }, false);
rcmail.register_command('calendar-delete', function(){ cal.calendar_delete(cal.calendars[cal.selected_calendar]); }, false);
Expand Down
30 changes: 30 additions & 0 deletions calendar/drivers/caldav/caldav_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,40 @@ private function _save_preprocess($event)
{
// shift dates to server's timezone (except for all-day events)
if (!$event['allday']) {
$orig_weekday = $event['start']->format('N');
$event['start'] = clone $event['start'];
$event['start']->setTimezone($this->server_timezone);
$event['end'] = clone $event['end'];
$event['end']->setTimezone($this->server_timezone);
$weekday = $event['start']->format('N');
if($orig_weekday != $weekday && !empty($event['recurrence']['BYDAY'])) {
$weekdays = array(
'MO' => 0,
'TU' => 1,
'WE' => 2,
'TH' => 3,
'FR' => 4,
'SA' => 5,
'SU' => 6,
);
$vcaldays = array('MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU');
$vcaldays[$orig_weekday-1];
if ($weekday > $orig_weekday) {
for ($i = 0; $i < $weekday - $orig_weekday; $i++) {
array_push($vcaldays, array_shift($vcaldays));
}
} else {
for ($i = 0; $i < $orig_weekday - $weekday; $i++) {
array_unshift($vcaldays, array_pop($vcaldays));
}
}

$byday = "";
foreach (explode(',', $event['recurrence']['BYDAY']) as $day) {
$byday .= ($byday == "" ? "" : ",").$vcaldays[$weekdays[$day]];
}
$event['recurrence']['BYDAY'] = $byday;
}
}

// compose vcalendar-style recurrencue rule from structured data
Expand Down
2 changes: 1 addition & 1 deletion libcalendaring/lib/OldSabre/VObject/Property/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static public function parseData($propertyValue, VObject\Property $property = nu
// Date-only
return array(
self::DATE,
new \DateTime($matches['year'] . '-' . $matches['month'] . '-' . $matches['date'] . ' 00:00:00', new \DateTimeZone('UTC')),
new \DateTime($matches['year'] . '-' . $matches['month'] . '-' . $matches['date'] . ' 00:00:00'),
);
}

Expand Down
2 changes: 1 addition & 1 deletion libcalendaring/libcalendaring.php
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ public function mail_get_itip_object($mbox, $uid, $mime_id, $type = null)

// establish imap connection
$imap = $this->rc->get_storage();
$imap->set_mailbox($mbox);
$imap->set_folder($mbox);

if ($uid && $mime_id) {
list($mime_id, $index) = explode(':', $mime_id);
Expand Down