diff --git a/calendar/calendar.php b/calendar/calendar.php index cb32773..e9ab385 100644 --- a/calendar/calendar.php +++ b/calendar/calendar.php @@ -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); @@ -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) { diff --git a/calendar/calendar_ui.js b/calendar/calendar_ui.js index 452ea38..8a28e02 100644 --- a/calendar/calendar_ui.js +++ b/calendar/calendar_ui.js @@ -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); diff --git a/calendar/drivers/caldav/caldav_driver.php b/calendar/drivers/caldav/caldav_driver.php index b39aeff..db8f7a3 100644 --- a/calendar/drivers/caldav/caldav_driver.php +++ b/calendar/drivers/caldav/caldav_driver.php @@ -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 diff --git a/libcalendaring/lib/OldSabre/VObject/Property/DateTime.php b/libcalendaring/lib/OldSabre/VObject/Property/DateTime.php index 60a3781..6a46bad 100644 --- a/libcalendaring/lib/OldSabre/VObject/Property/DateTime.php +++ b/libcalendaring/lib/OldSabre/VObject/Property/DateTime.php @@ -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'), ); } diff --git a/libcalendaring/libcalendaring.php b/libcalendaring/libcalendaring.php index fc5ba32..25b089a 100644 --- a/libcalendaring/libcalendaring.php +++ b/libcalendaring/libcalendaring.php @@ -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);