Version of roundcubemail-plugins-kolab: master
CalDAV/CardDAV server: Baikal (https://sabre.io/baikal/)
When trying to create a new calendar from roundcube, Baikal logs the following error:
NOTICE: PHP message: Sabre\DAV\Exception\InvalidResourceType: You can only create calendars and subscriptions in this collection in /var/www/vendor/sabre/dav/lib/CalDAV/CalendarHome.php:253 Stack trace: #0 /var/www/vendor/sabre/dav/lib/DAV/Server.php(1199): Sabre\CalDAV\CalendarHome->createExtendedCollection('f97496140561-c3...', Object(Sabre\DAV\MkCol)) #1 /var/www/vendor/sabre/dav/lib/DAV/CorePlugin.php(560): Sabre\DAV\Server->createCollection('calendars/romai...', Object(Sabre\DAV\MkCol)) #2 /var/www/vendor/sabre/event/lib/WildcardEmitterTrait.php(89): Sabre\DAV\CorePlugin->httpMkcol(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response)) #3 /var/www/vendor/sabre/dav/lib/DAV/Server.php(472): Sabre\DAV\Server->emit('method:MKCOL', Array) #4 /var/www/vendor/sabre/dav/lib/DAV/Server.php(253): Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response)) #5 /var/www/vendor/sabre/dav/lib/DAV/Server.php(321): Sabre\DAV\Server->start() #6 /var/www/Core/Frameworks/Baikal/Core/Server.php(119): Sabre\DAV\Server->exec() #7 /var/www/html/dav.php(69): Baikal\Core\Server->start() #8 {main} 10.89.10.5 - user@example.com 09/Aug/2023:08:48:07 +0000 "MKCOL /baikal/dav.php" 403
Same happens for a new address book:
NOTICE: PHP message: Sabre\DAV\Exception\InvalidResourceType: Unknown resourceType for this collection in /var/www/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php:160 Stack trace: #0 /var/www/vendor/sabre/dav/lib/DAV/Server.php(1199): Sabre\CardDAV\AddressBookHome->createExtendedCollection('9916382c6f22-ff...', Object(Sabre\DAV\MkCol)) #1 /var/www/vendor/sabre/dav/lib/DAV/CorePlugin.php(560): Sabre\DAV\Server->createCollection('addressbooks/ro...', Object(Sabre\DAV\MkCol)) #2 /var/www/vendor/sabre/event/lib/WildcardEmitterTrait.php(89): Sabre\DAV\CorePlugin->httpMkcol(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response)) #3 /var/www/vendor/sabre/dav/lib/DAV/Server.php(472): Sabre\DAV\Server->emit('method:MKCOL', Array) #4 /var/www/vendor/sabre/dav/lib/DAV/Server.php(253): Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response)) #5 /var/www/vendor/sabre/dav/lib/DAV/Server.php(321): Sabre\DAV\Server->start() #6 /var/www/Core/Frameworks/Baikal/Core/Server.php(119): Sabre\DAV\Server->exec() #7 /var/www/html/dav.php(69): Baikal\Core\Server->start() #8 {main} 10.89.10.15 - user@example.com 09/Aug/2023:08:55:40 +0000 "MKCOL /baikal/dav.php" 403
Here is a patch I wrote to fix that:
diff --git a/plugins/libkolab/lib/kolab_dav_client.php b/plugins/libkolab/lib/kolab_dav_client.php index 5fcfb6b2..4193491d 100644 --- a/plugins/libkolab/lib/kolab_dav_client.php +++ b/plugins/libkolab/lib/kolab_dav_client.php @@ -377,8 +377,27 @@ class kolab_dav_client */ public function folderCreate($location, $component, $properties = []) { + $ns = 'xmlns:d="DAV:"'; + $props = ''; + + if ($component == 'VCARD') { + $ns .= ' xmlns:c="urn:ietf:params:xml:ns:carddav"'; + $props = '<d:resourcetype><d:collection/><c:addressbook/></d:resourcetype>'; + } + else { + $ns .= ' xmlns:c="urn:ietf:params:xml:ns:caldav"'; + $props = '<d:resourcetype><d:collection/><c:calendar/></d:resourcetype>'; + } + + $body = '<?xml version="1.0" encoding="utf-8"?>' + . '<d:mkcol ' . $ns . '>' + . '<d:set>' + . '<d:prop>' . $props . '</d:prop>' + . '</d:set>' + . '</d:mkcol>'; + // Create the collection - $response = $this->request($location, 'MKCOL'); + $response = $this->request($location, 'MKCOL', $body); if (empty($response)) { return false;