Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117999078
D4656.1775543636.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
D4656.1775543636.diff
View Options
diff --git a/plugins/libkolab/lib/kolab_dav_client.php b/plugins/libkolab/lib/kolab_dav_client.php
--- a/plugins/libkolab/lib/kolab_dav_client.php
+++ b/plugins/libkolab/lib/kolab_dav_client.php
@@ -375,15 +375,18 @@
*/
public function folderCreate($location, $component, $properties = [])
{
- $ns = 'xmlns:d="DAV:"';
- $props = '';
+ [$props, $ns] = $this->folderPropertiesToXml($properties, 'xmlns:d="DAV:"');
if ($component == 'VCARD') {
$ns .= ' xmlns:c="urn:ietf:params:xml:ns:carddav"';
- $props = '<d:resourcetype><d:collection/><c:addressbook/></d:resourcetype>';
+ $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>';
+ $props .= '<d:resourcetype><d:collection/><c:calendar/></d:resourcetype>'
+ // Note: Some clients, but also Cyrus by default allows everything in calendar folders,
+ // i.e. VEVENT, VTODO, VJOURNAL, VFREEBUSY, VAVAILABILITY, but we prefer a single-type folders,
+ // to keep tasks and event separated
+ . '<c:supported-calendar-component-set><c:comp name="' . $component . '"/></c:supported-calendar-component-set>';
}
$body = '<?xml version="1.0" encoding="utf-8"?>'
@@ -396,12 +399,7 @@
// Create the collection
$response = $this->request($location, 'MKCOL', $body);
- if (empty($response)) {
- return false;
- }
-
- // Update collection properties
- return $this->folderUpdate($location, $component, $properties);
+ return $response !== false;
}
/**
@@ -429,29 +427,35 @@
*/
public function folderUpdate($location, $component, $properties = [])
{
- $ns = 'xmlns:d="DAV:"';
- $props = '';
+ // Note: Changing resourcetype property is forbidden (at least by Cyrus)
- if ($component == 'VCARD') {
- $ns .= ' xmlns:c="urn:ietf:params:xml:ns:carddav"';
- // Resourcetype property is protected
- // $props = '<d:resourcetype><d:collection/><c:addressbook/></d:resourcetype>';
- } else {
- $ns .= ' xmlns:c="urn:ietf:params:xml:ns:caldav"';
- // Resourcetype property is protected
- // $props = '<d:resourcetype><d:collection/><c:calendar/></d:resourcetype>';
- /*
- // Note: These are set by Cyrus automatically for calendars
- . '<c:supported-calendar-component-set>'
- . '<c:comp name="VEVENT"/>'
- . '<c:comp name="VTODO"/>'
- . '<c:comp name="VJOURNAL"/>'
- . '<c:comp name="VFREEBUSY"/>'
- . '<c:comp name="VAVAILABILITY"/>'
- . '</c:supported-calendar-component-set>';
- */
+ [$props, $ns] = $this->folderPropertiesToXml($properties, 'xmlns:d="DAV:"');
+
+ if (empty($props)) {
+ return true;
}
+ $body = '<?xml version="1.0" encoding="utf-8"?>'
+ . '<d:propertyupdate ' . $ns . '>'
+ . '<d:set>'
+ . '<d:prop>' . $props . '</d:prop>'
+ . '</d:set>'
+ . '</d:propertyupdate>';
+
+ $response = $this->request($location, 'PROPPATCH', $body);
+
+ // TODO: Should we make sure "200 OK" status is set for all requested properties?
+
+ return $response !== false;
+ }
+
+ /**
+ * Parse folder properties input into XML string to use in a request
+ */
+ protected function folderPropertiesToXml($properties, $ns = '')
+ {
+ $props = '';
+
foreach ($properties as $name => $value) {
if ($name == 'name') {
$props .= '<d:displayname>' . htmlspecialchars($value, ENT_XML1, 'UTF-8') . '</d:displayname>';
@@ -471,22 +475,7 @@
}
}
- if (empty($props)) {
- return true;
- }
-
- $body = '<?xml version="1.0" encoding="utf-8"?>'
- . '<d:propertyupdate ' . $ns . '>'
- . '<d:set>'
- . '<d:prop>' . $props . '</d:prop>'
- . '</d:set>'
- . '</d:propertyupdate>';
-
- $response = $this->request($location, 'PROPPATCH', $body);
-
- // TODO: Should we make sure "200 OK" status is set for all requested properties?
-
- return $response !== false;
+ return [$props, $ns];
}
/**
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 7, 6:33 AM (13 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18841478
Default Alt Text
D4656.1775543636.diff (4 KB)
Attached To
Mode
D4656: DAV: Single-type calendar and tasks folders
Attached
Detach File
Event Timeline