mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-30 03:24:47 +00:00
Changes to the way PROPPATCH returns errors.
This is cleaner and perhaps a little more informative.
This commit is contained in:
parent
beecb1674d
commit
8158eaa1ea
@ -45,6 +45,30 @@ $rmprops = $xmltree->GetPath("/DAV::propertyupdate/DAV::remove/DAV::prop/*");
|
|||||||
$failure = array();
|
$failure = array();
|
||||||
$success = array();
|
$success = array();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Small utility function to add propstat for one failure
|
||||||
|
* @param unknown_type $tag
|
||||||
|
* @param unknown_type $status
|
||||||
|
* @param unknown_type $description
|
||||||
|
* @param unknown_type $error_tag
|
||||||
|
*/
|
||||||
|
function add_failure( $type, $tag, $status, $description=null, $error_tag = null) {
|
||||||
|
global $failure;
|
||||||
|
$propstat = array(
|
||||||
|
new XMLElement( 'prop', new XMLElement($tag)),
|
||||||
|
new XMLElement( 'status', $status )
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( isset($description))
|
||||||
|
$propstat[] = new XMLElement( 'responsedescription', $description );
|
||||||
|
if ( isset($error_tag) )
|
||||||
|
$propstat[] = new XMLElement( 'error', new XMLElement( $error_tag ) );
|
||||||
|
|
||||||
|
$failure[$type.'-'.$tag] = new XMLElement('propstat', $propstat );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not much for it but to process the incoming settings in a big loop, doing
|
* Not much for it but to process the incoming settings in a big loop, doing
|
||||||
* the special-case stuff as needed and falling through to a default which
|
* the special-case stuff as needed and falling through to a default which
|
||||||
@ -79,15 +103,8 @@ foreach( $setprops AS $k => $setting ) {
|
|||||||
$success[$tag] = 1;
|
$success[$tag] = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$failure['set-'.$tag] = new XMLElement( 'propstat', array(
|
add_failure('set', $tag, 'HTTP/1.1 403 Forbidden',
|
||||||
new XMLElement( 'prop', new XMLElement($tag)),
|
translate("The displayname may only be set on collections, principals or bindings."), 'cannot-modify-protected-property');
|
||||||
new XMLElement( 'status', 'HTTP/1.1 403 Forbidden' ),
|
|
||||||
new XMLElement( 'responsedescription', array(
|
|
||||||
new XMLElement( 'error', new XMLElement( 'cannot-modify-protected-property') ),
|
|
||||||
translate("The displayname may only be set on collections, principals or bindings.") )
|
|
||||||
)
|
|
||||||
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -109,14 +126,8 @@ foreach( $setprops AS $k => $setting ) {
|
|||||||
$success[$tag] = 1;
|
$success[$tag] = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$failure['set-'.$tag] = new XMLElement( 'propstat', array(
|
add_failure('set', $tag, 'HTTP/1.1 403 Forbidden',
|
||||||
new XMLElement( 'prop', new XMLElement($tag)),
|
translate("Resources may not be changed to / from collections."), 'cannot-modify-protected-property');
|
||||||
new XMLElement( 'status', 'HTTP/1.1 403 Forbidden' ),
|
|
||||||
new XMLElement( 'responsedescription', array(
|
|
||||||
new XMLElement( 'error', new XMLElement( 'cannot-modify-protected-property') ),
|
|
||||||
translate("Resources may not be changed to / from collections.") )
|
|
||||||
)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -129,23 +140,14 @@ foreach( $setprops AS $k => $setting ) {
|
|||||||
$success[$tag] = 1;
|
$success[$tag] = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$failure['set-'.$tag] = new XMLElement( 'propstat', array(
|
add_failure('set', $tag, 'HTTP/1.1 409 Conflict',
|
||||||
new XMLElement( 'prop', new XMLElement($tag)),
|
translate("The CalDAV:schedule-calendar-transp property may only be set on calendars."));
|
||||||
new XMLElement( 'status', 'HTTP/1.1 403 Forbidden' ),
|
|
||||||
new XMLElement( 'responsedescription', array(
|
|
||||||
new XMLElement( 'error', new XMLElement( 'cannot-modify-protected-property') ),
|
|
||||||
translate("The CalDAV:schedule-calendar-transp property may only be set on calendars.") )
|
|
||||||
)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'urn:ietf:params:xml:ns:caldav:calendar-free-busy-set':
|
case 'urn:ietf:params:xml:ns:caldav:calendar-free-busy-set':
|
||||||
$failure['set-'.$tag] = new XMLElement( 'propstat', array(
|
add_failure('set', $tag, 'HTTP/1.1 409 Conflict',
|
||||||
new XMLElement( 'prop', new XMLElement($tag)),
|
translate("The calendar-free-busy-set is superseded by the schedule-calendar-transp property of a calendar collection.") );
|
||||||
new XMLElement( 'status', 'HTTP/1.1 409 Conflict' ),
|
|
||||||
new XMLElement( 'responsedescription', translate("The calendar-free-busy-set is superseded by the schedule-transp property of a calendar collection.") )
|
|
||||||
));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'urn:ietf:params:xml:ns:caldav:calendar-timezone':
|
case 'urn:ietf:params:xml:ns:caldav:calendar-timezone':
|
||||||
@ -169,14 +171,7 @@ foreach( $setprops AS $k => $setting ) {
|
|||||||
array( ':tzid' => $tzid, ':dav_name' => $dav_resource->dav_name()) );
|
array( ':tzid' => $tzid, ':dav_name' => $dav_resource->dav_name()) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$failure['set-'.$tag] = new XMLElement( 'propstat', array(
|
add_failure('set', $tag, 'HTTP/1.1 409 Conflict', translate("calendar-timezone property is only valid for a calendar."));
|
||||||
new XMLElement( 'prop', new XMLElement($tag)),
|
|
||||||
new XMLElement( 'status', 'HTTP/1.1 403 Forbidden' ),
|
|
||||||
new XMLElement( 'responsedescription', array(
|
|
||||||
new XMLElement( 'error', new XMLElement( 'cannot-modify-protected-property') ),
|
|
||||||
translate("calendar-timezone property is only valid for a calendar.") )
|
|
||||||
)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -196,14 +191,7 @@ foreach( $setprops AS $k => $setting ) {
|
|||||||
case 'DAV::creationdate':
|
case 'DAV::creationdate':
|
||||||
case 'DAV::lockdiscovery':
|
case 'DAV::lockdiscovery':
|
||||||
case 'DAV::supportedlock':
|
case 'DAV::supportedlock':
|
||||||
$failure['set-'.$tag] = new XMLElement( 'propstat', array(
|
add_failure('set', $tag, 'HTTP/1.1 409 Conflict', translate("Property is read-only"), new XMLElement( 'cannot-modify-protected-property'));
|
||||||
new XMLElement( 'prop', new XMLElement($tag)),
|
|
||||||
new XMLElement( 'status', 'HTTP/1.1 403 Forbidden' ),
|
|
||||||
new XMLElement( 'responsedescription', array(
|
|
||||||
new XMLElement( 'error', new XMLElement( 'cannot-modify-protected-property') ),
|
|
||||||
translate("Property is read-only") )
|
|
||||||
)
|
|
||||||
));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -217,8 +205,6 @@ foreach( $setprops AS $k => $setting ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach( $rmprops AS $k => $setting ) {
|
foreach( $rmprops AS $k => $setting ) {
|
||||||
$tag = $setting->GetTag();
|
$tag = $setting->GetTag();
|
||||||
$content = $setting->RenderContent();
|
$content = $setting->RenderContent();
|
||||||
@ -226,14 +212,8 @@ foreach( $rmprops AS $k => $setting ) {
|
|||||||
switch( $tag ) {
|
switch( $tag ) {
|
||||||
|
|
||||||
case 'DAV::resourcetype':
|
case 'DAV::resourcetype':
|
||||||
$failure['rm-'.$tag] = new XMLElement( 'propstat', array(
|
add_failure('rm', $tag, 'HTTP/1.1 409 Conflict',
|
||||||
new XMLElement( 'prop', new XMLElement($tag)),
|
translate("DAV::resourcetype may only be set to a new value, it may not be removed."), 'cannot-modify-protected-property');
|
||||||
new XMLElement( 'status', 'HTTP/1.1 403 Forbidden' ),
|
|
||||||
new XMLElement( 'responsedescription', array(
|
|
||||||
new XMLElement( 'error', new XMLElement( 'cannot-modify-protected-property') ),
|
|
||||||
translate("DAV::resourcetype may only be set to a new value, it may not be removed.") )
|
|
||||||
)
|
|
||||||
));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'urn:ietf:params:xml:ns:caldav:calendar-timezone':
|
case 'urn:ietf:params:xml:ns:caldav:calendar-timezone':
|
||||||
@ -241,14 +221,8 @@ foreach( $rmprops AS $k => $setting ) {
|
|||||||
$qry->QDo('UPDATE collection SET timezone = NULL WHERE dav_name = :dav_name', array( ':dav_name' => $dav_resource->dav_name()) );
|
$qry->QDo('UPDATE collection SET timezone = NULL WHERE dav_name = :dav_name', array( ':dav_name' => $dav_resource->dav_name()) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$failure['set-'.$tag] = new XMLElement( 'propstat', array(
|
add_failure('rm', $tag, 'HTTP/1.1 409 Conflict',
|
||||||
new XMLElement( 'prop', new XMLElement($tag)),
|
translate("calendar-timezone property is only valid for a calendar."), 'cannot-modify-protected-property');
|
||||||
new XMLElement( 'status', 'HTTP/1.1 403 Forbidden' ),
|
|
||||||
new XMLElement( 'responsedescription', array(
|
|
||||||
new XMLElement( 'error', new XMLElement( 'cannot-modify-protected-property') ),
|
|
||||||
translate("calendar-timezone property is only valid for a calendar.") )
|
|
||||||
)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -269,11 +243,7 @@ foreach( $rmprops AS $k => $setting ) {
|
|||||||
case 'DAV::displayname':
|
case 'DAV::displayname':
|
||||||
case 'DAV::lockdiscovery':
|
case 'DAV::lockdiscovery':
|
||||||
case 'DAV::supportedlock':
|
case 'DAV::supportedlock':
|
||||||
$failure['rm-'.$tag] = new XMLElement( 'propstat', array(
|
add_failure('rm', $tag, 'HTTP/1.1 409 Conflict', translate("Property is read-only"));
|
||||||
new XMLElement( 'prop', new XMLElement($tag)),
|
|
||||||
new XMLElement( 'status', 'HTTP/1.1 409 Conflict' ),
|
|
||||||
new XMLElement('responsedescription', translate("Property is read-only") )
|
|
||||||
));
|
|
||||||
dbg_error_log( 'PROPPATCH', ' RMProperty %s is read only and cannot be removed', $tag);
|
dbg_error_log( 'PROPPATCH', ' RMProperty %s is read only and cannot be removed', $tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ HTTP/1.1 207 Multi-Status
|
|||||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||||
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
||||||
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
||||||
Content-Length: 623
|
Content-Length: 608
|
||||||
Content-Type: text/xml; charset="utf-8"
|
Content-Type: text/xml; charset="utf-8"
|
||||||
|
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
@ -13,12 +13,8 @@ Content-Type: text/xml; charset="utf-8"
|
|||||||
<prop>
|
<prop>
|
||||||
<urn:ietf:params:xml:ns:caldav:calendar-timezone/>
|
<urn:ietf:params:xml:ns:caldav:calendar-timezone/>
|
||||||
</prop>
|
</prop>
|
||||||
<status>HTTP/1.1 403 Forbidden</status>
|
<status>HTTP/1.1 409 Conflict</status>
|
||||||
<responsedescription>
|
<responsedescription>calendar-timezone property is only valid for a calendar.</responsedescription>
|
||||||
<error>
|
|
||||||
<cannot-modify-protected-property/>
|
|
||||||
</error>
|
|
||||||
</responsedescription>
|
|
||||||
</propstat>
|
</propstat>
|
||||||
<propstat>
|
<propstat>
|
||||||
<prop>
|
<prop>
|
||||||
|
|||||||
@ -2,7 +2,7 @@ HTTP/1.1 207 Multi-Status
|
|||||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||||
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
||||||
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
||||||
Content-Length: 742
|
Content-Length: 806
|
||||||
Content-Type: text/xml; charset="utf-8"
|
Content-Type: text/xml; charset="utf-8"
|
||||||
|
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
@ -13,12 +13,11 @@ Content-Type: text/xml; charset="utf-8"
|
|||||||
<prop>
|
<prop>
|
||||||
<DAV::resourcetype/>
|
<DAV::resourcetype/>
|
||||||
</prop>
|
</prop>
|
||||||
<status>HTTP/1.1 403 Forbidden</status>
|
<status>HTTP/1.1 409 Conflict</status>
|
||||||
<responsedescription>
|
<responsedescription>DAV::resourcetype may only be set to a new value, it may not be removed.</responsedescription>
|
||||||
<error>
|
<error>
|
||||||
<cannot-modify-protected-property/>
|
<cannot-modify-protected-property/>
|
||||||
</error>
|
</error>
|
||||||
</responsedescription>
|
|
||||||
</propstat>
|
</propstat>
|
||||||
<propstat>
|
<propstat>
|
||||||
<prop>
|
<prop>
|
||||||
|
|||||||
@ -2,7 +2,7 @@ HTTP/1.1 207 Multi-Status
|
|||||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||||
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
||||||
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
||||||
Content-Length: 469
|
Content-Length: 533
|
||||||
Content-Type: text/xml; charset="utf-8"
|
Content-Type: text/xml; charset="utf-8"
|
||||||
|
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
@ -13,12 +13,11 @@ Content-Type: text/xml; charset="utf-8"
|
|||||||
<prop>
|
<prop>
|
||||||
<DAV::resourcetype/>
|
<DAV::resourcetype/>
|
||||||
</prop>
|
</prop>
|
||||||
<status>HTTP/1.1 403 Forbidden</status>
|
<status>HTTP/1.1 409 Conflict</status>
|
||||||
<responsedescription>
|
<responsedescription>DAV::resourcetype may only be set to a new value, it may not be removed.</responsedescription>
|
||||||
<error>
|
<error>
|
||||||
<cannot-modify-protected-property/>
|
<cannot-modify-protected-property/>
|
||||||
</error>
|
</error>
|
||||||
</responsedescription>
|
|
||||||
</propstat>
|
</propstat>
|
||||||
<responsedescription>Some properties were not able to be changed.</responsedescription>
|
<responsedescription>Some properties were not able to be changed.</responsedescription>
|
||||||
</response>
|
</response>
|
||||||
|
|||||||
@ -2,7 +2,7 @@ HTTP/1.1 207 Multi-Status
|
|||||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||||
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
||||||
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
||||||
Content-Length: 469
|
Content-Length: 513
|
||||||
Content-Type: text/xml; charset="utf-8"
|
Content-Type: text/xml; charset="utf-8"
|
||||||
|
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
@ -14,11 +14,10 @@ Content-Type: text/xml; charset="utf-8"
|
|||||||
<DAV::resourcetype/>
|
<DAV::resourcetype/>
|
||||||
</prop>
|
</prop>
|
||||||
<status>HTTP/1.1 403 Forbidden</status>
|
<status>HTTP/1.1 403 Forbidden</status>
|
||||||
<responsedescription>
|
<responsedescription>Resources may not be changed to / from collections.</responsedescription>
|
||||||
<error>
|
<error>
|
||||||
<cannot-modify-protected-property/>
|
<cannot-modify-protected-property/>
|
||||||
</error>
|
</error>
|
||||||
</responsedescription>
|
|
||||||
</propstat>
|
</propstat>
|
||||||
<responsedescription>Some properties were not able to be changed.</responsedescription>
|
<responsedescription>Some properties were not able to be changed.</responsedescription>
|
||||||
</response>
|
</response>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user