Fix folders discovery on non-kolab DAV servers (T7276)

This commit is contained in:
Aleksander Machniak 2023-06-20 14:31:10 +02:00
parent 5fcf64fd9f
commit 84ef4ac9e3

View file

@ -131,12 +131,6 @@ class kolab_dav_client
} }
} }
$roots = [
'VEVENT' => 'calendars',
'VTODO' => 'calendars',
'VCARD' => 'addressbooks',
];
$path = parse_url($this->url, PHP_URL_PATH); $path = parse_url($this->url, PHP_URL_PATH);
$body = '<?xml version="1.0" encoding="utf-8"?>' $body = '<?xml version="1.0" encoding="utf-8"?>'
@ -147,7 +141,7 @@ class kolab_dav_client
. '</d:propfind>'; . '</d:propfind>';
// Note: Cyrus CardDAV service requires Depth:1 (CalDAV works without it) // Note: Cyrus CardDAV service requires Depth:1 (CalDAV works without it)
$response = $this->request('/' . $roots[$component], 'PROPFIND', $body, ['Depth' => 1, 'Prefer' => 'return-minimal']); $response = $this->request('/', 'PROPFIND', $body, ['Depth' => 1, 'Prefer' => 'return-minimal']);
if (empty($response)) { if (empty($response)) {
return false; return false;
@ -200,14 +194,12 @@ class kolab_dav_client
} }
} }
if (!empty($root_href)) { if (empty($root_href)) {
if ($path && strpos($root_href, $path) === 0) { return false;
$root_href = substr($root_href, strlen($path));
}
} }
else {
// Kolab iRony's calendar root if ($path && strpos($root_href, $path) === 0) {
$root_href = '/' . $roots[$component] . '/' . rawurlencode($this->user); $root_href = substr($root_href, strlen($path));
} }
if ($cache) { if ($cache) {