Changeset View
Changeset View
Standalone View
Standalone View
src/app/Backends/DAV.php
Show First 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | public function listFolders(string $component) | ||||
} | } | ||||
$folders = []; | $folders = []; | ||||
foreach ($response->getElementsByTagName('response') as $element) { | foreach ($response->getElementsByTagName('response') as $element) { | ||||
$folder = DAV\Folder::fromDomElement($element); | $folder = DAV\Folder::fromDomElement($element); | ||||
// Note: Addressbooks don't have 'type' specified | // Note: Addressbooks don't have 'type' specified | ||||
if (($component == self::TYPE_VCARD && in_array('addressbook', $folder->types)) | if ( | ||||
($component == self::TYPE_VCARD && in_array('addressbook', $folder->types)) | |||||
|| in_array($component, $folder->components) | || in_array($component, $folder->components) | ||||
) { | ) { | ||||
$folders[] = $folder; | $folders[] = $folder; | ||||
} | } | ||||
} | } | ||||
return $folders; | return $folders; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | public function search(string $location, string $component) | ||||
} | } | ||||
// TODO: Make filter an argument of this function to build all kind of queries. | // TODO: Make filter an argument of this function to build all kind of queries. | ||||
// It probably should be a separate object e.g. DAV\Filter. | // It probably should be a separate object e.g. DAV\Filter. | ||||
// TODO: List of object props to return should also be an argument, so we not only | // TODO: List of object props to return should also be an argument, so we not only | ||||
// could fetch "an index" but also any of object's data. | // could fetch "an index" but also any of object's data. | ||||
$body = '<?xml version="1.0" encoding="utf-8"?>' | $body = '<?xml version="1.0" encoding="utf-8"?>' | ||||
.' <c:' . $queries[$component] . ' xmlns:d="DAV:" xmlns:c="' . self::NAMESPACES[$component] . '">' | . ' <c:' . $queries[$component] . ' xmlns:d="DAV:" xmlns:c="' . self::NAMESPACES[$component] . '">' | ||||
. '<d:prop>' | . '<d:prop>' | ||||
. '<d:getetag />' | . '<d:getetag />' | ||||
. '</d:prop>' | . '</d:prop>' | ||||
. ($filter ? "<c:filter>$filter</c:filter>" : '') | . ($filter ? "<c:filter>$filter</c:filter>" : '') | ||||
. '</c:' . $queries[$component] . '>'; | . '</c:' . $queries[$component] . '>'; | ||||
$response = $this->request($location, 'REPORT', $body, ['Depth' => 1, 'Prefer' => 'return-minimal']); | $response = $this->request($location, 'REPORT', $body, ['Depth' => 1, 'Prefer' => 'return-minimal']); | ||||
Show All 39 Lines | public function getObjects(string $location, string $component, array $hrefs = []) | ||||
$types = [ | $types = [ | ||||
self::TYPE_VEVENT => 'calendar-data', | self::TYPE_VEVENT => 'calendar-data', | ||||
self::TYPE_VTODO => 'calendar-data', | self::TYPE_VTODO => 'calendar-data', | ||||
self::TYPE_VCARD => 'address-data', | self::TYPE_VCARD => 'address-data', | ||||
]; | ]; | ||||
$body = '<?xml version="1.0" encoding="utf-8"?>' | $body = '<?xml version="1.0" encoding="utf-8"?>' | ||||
.' <c:' . $queries[$component] . ' xmlns:d="DAV:" xmlns:c="' . self::NAMESPACES[$component] . '">' | . ' <c:' . $queries[$component] . ' xmlns:d="DAV:" xmlns:c="' . self::NAMESPACES[$component] . '">' | ||||
. '<d:prop>' | . '<d:prop>' | ||||
. '<d:getetag />' | . '<d:getetag />' | ||||
. '<c:' . $types[$component] . ' />' | . '<c:' . $types[$component] . ' />' | ||||
. '</d:prop>' | . '</d:prop>' | ||||
. $body | . $body | ||||
. '</c:' . $queries[$component] . '>'; | . '</c:' . $queries[$component] . '>'; | ||||
$response = $this->request($location, 'REPORT', $body, ['Depth' => 1, 'Prefer' => 'return-minimal']); | $response = $this->request($location, 'REPORT', $body, ['Depth' => 1, 'Prefer' => 'return-minimal']); | ||||
▲ Show 20 Lines • Show All 138 Lines • Show Last 20 Lines |