diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php index f921b530..90ea0844 100644 --- a/plugins/calendar/drivers/kolab/kolab_driver.php +++ b/plugins/calendar/drivers/kolab/kolab_driver.php @@ -1359,9 +1359,9 @@ class kolab_driver extends calendar_driver return false; } - list($uid, $folder) = $this->_resolve_event_identity($event); + list($uid, $mailbox) = $this->_resolve_event_identity($event); - $result = $this->bonnie_api->changelog('event', $uid, $folder); + $result = $this->bonnie_api->changelog('event', $uid, $mailbox); if (is_array($result) && $result['uid'] == $uid) { return $result['changes']; } @@ -1384,10 +1384,10 @@ class kolab_driver extends calendar_driver return false; } - list($uid, $folder) = $this->_resolve_event_identity($event); + list($uid, $mailbox) = $this->_resolve_event_identity($event); // call Bonnie API - $result = $this->bonnie_api->diff('event', $uid, $rev, $folder); + $result = $this->bonnie_api->diff('event', $uid, $rev, $mailbox); if (is_array($result) && $result['uid'] == $uid) { $result['rev'] = $rev; @@ -1502,23 +1502,17 @@ class kolab_driver extends calendar_driver } $calid = $event['calendar']; - list($uid, $folder) = $this->_resolve_event_identity($event); + list($uid, $mailbox) = $this->_resolve_event_identity($event); // call Bonnie API - $result = $this->bonnie_api->get('event', $uid, $rev, $folder); + $result = $this->bonnie_api->get('event', $uid, $rev, $mailbox); if (is_array($result) && $result['uid'] == $uid && !empty($result['xml'])) { $format = kolab_format::factory('event'); $format->load($result['xml']); $event = $format->to_array(); if ($format->is_valid()) { - if ($result['folder'] && ($cal = $this->get_calendar(kolab_storage::id_encode($result['folder'])))) { - $event['calendar'] = $cal->id; - } - else { - $event['calendar'] = $calid; - } - + $event['calendar'] = $calid; $event['rev'] = $result['rev']; return self::to_rcube_event($event); } @@ -1534,11 +1528,11 @@ class kolab_driver extends calendar_driver */ private function _resolve_event_identity($event) { - $folder = null; + $mailbox = null; if (is_array($event)) { $uid = $event['id'] ?: $event['uid']; - if ($cal = $this->get_calendar($event['calendar']) && !($cal instanceof kolab_invitation_calendar)) { - $folder = $cal->name; + if (($cal = $this->get_calendar($event['calendar'])) && !($cal instanceof kolab_invitation_calendar)) { + $mailbox = $cal->get_mailbox_id(); } } else { @@ -1550,7 +1544,7 @@ class kolab_driver extends calendar_driver if (!in_array($uid, $demo_uids)) $uid = reset($demo_uids); - return array($uid, $folder); + return array($uid, $mailbox); } /** diff --git a/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php b/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php index ac3740a7..24fad592 100644 --- a/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php +++ b/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php @@ -114,6 +114,17 @@ class kolab_invitation_calendar return $this->get_name(); } + /** + * Getter for the Cyrus mailbox identifier corresponding to this folder + * + * @return string Mailbox ID + */ + public function get_mailbox_id() + { + // this is a virtual collection and has no concrete mailbox ID + return null; + } + /** * Return color to display this calendar */ diff --git a/plugins/libkolab/lib/kolab_bonnie_api.php b/plugins/libkolab/lib/kolab_bonnie_api.php index 732d29b5..23dafd82 100644 --- a/plugins/libkolab/lib/kolab_bonnie_api.php +++ b/plugins/libkolab/lib/kolab_bonnie_api.php @@ -50,25 +50,25 @@ class kolab_bonnie_api /** * Wrapper function for .changelog() API call */ - public function changelog($type, $uid, $folder=null) + public function changelog($type, $uid, $mailbox=null) { - return $this->client->execute($type.'.changelog', array('uid' => $uid, 'folder' => $folder)); + return $this->client->execute($type.'.changelog', array('uid' => $uid, 'mailbox' => $mailbox)); } /** * Wrapper function for .diff() API call */ - public function diff($type, $uid, $rev, $folder=null) + public function diff($type, $uid, $rev, $mailbox=null) { - return $this->client->execute($type.'.diff', array('uid' => $uid, 'rev' => $rev, 'folder' => $folder)); + return $this->client->execute($type.'.diff', array('uid' => $uid, 'rev' => $rev, 'mailbox' => $mailbox)); } /** * Wrapper function for .get() API call */ - public function get($type, $uid, $rev, $folder=null) + public function get($type, $uid, $rev, $mailbox=null) { - return $this->client->execute($type.'.get', array('uid' => $uid, 'rev' => intval($rev), 'folder' => $folder)); + return $this->client->execute($type.'.get', array('uid' => $uid, 'rev' => intval($rev), 'mailbox' => $mailbox)); } /** diff --git a/plugins/libkolab/lib/kolab_storage_folder_api.php b/plugins/libkolab/lib/kolab_storage_folder_api.php index 4a904671..ef3309e0 100644 --- a/plugins/libkolab/lib/kolab_storage_folder_api.php +++ b/plugins/libkolab/lib/kolab_storage_folder_api.php @@ -167,6 +167,38 @@ abstract class kolab_storage_folder_api return join('/', $path); } + /** + * Getter for the Cyrus mailbox identifier corresponding to this folder + * (e.g. user/john.doe/Calendar/Personal@example.org) + * + * @return string Mailbox ID + */ + public function get_mailbox_id() + { + $info = $this->get_folder_info(); + $owner = $this->get_owner(); + list($user, $domain) = explode('@', $owner); + + switch ($info['namespace']) { + case 'personal': + return sprintf('user/%s/%s@%s', $user, $this->name, $domain); + + case 'shared': + $ns = $this->imap->get_namespace('shared'); + $prefix = is_array($ns) ? $ns[0][0] : ''; + list(, $domain) = explode('@', rcube::get_instance()->get_user_name()); + return substr($this->name, strlen($prefix)) . '@' . $domain; + + default: + $ns = $this->imap->get_namespace('other'); + $prefix = is_array($ns) ? $ns[0][0] : ''; + list($user, $folder) = explode($this->imap->get_hierarchy_delimiter(), substr($info['name'], strlen($prefix)), 2); + if (strpos($user, '@')) { + list($user, $domain) = explode('@', $user); + } + return sprintf('user/%s/%s@%s', $user, $folder, $domain); + } + } /** * Get the color value stored in metadata