mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-08-31 18:46:02 +00:00
advertise support for principal-match REPORT
and a few more bits inspired by CalDAV/aclreports.xml:
- strict Depth header checking
- principal-match: match on dav_name if not $match_self
- principal-match can "alternatively" return resources in a collection
that belong to a principal, like a user's calendars when we query
the principal URI
This commit is contained in:
parent
f37daa4ed7
commit
a7ba436f2f
@ -925,6 +925,7 @@ EOQRY;
|
||||
'DAV::principal-property-search' => '',
|
||||
'DAV::principal-search-property-set' => '',
|
||||
'DAV::expand-property' => '',
|
||||
'DAV::principal-match' => '',
|
||||
'DAV::sync-collection' => ''
|
||||
);
|
||||
|
||||
|
||||
@ -25,6 +25,10 @@ $principal_search_property_set = array(
|
||||
'urn:ietf:params:xml:ns:caldav:calendar-user-address-set'
|
||||
);
|
||||
|
||||
if ( $request->depth > 0 ) {
|
||||
$request->DoResponse( 400, 'The principal-search-property-set REPORT is only defined for Depth "0".' );
|
||||
}
|
||||
|
||||
$responses = array();
|
||||
foreach( $principal_search_property_set AS $k => $tag ) {
|
||||
$responses[] = property_response( $reply, $tag );
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
$responses = array();
|
||||
|
||||
$request->NeedPrivilege(array('DAV::read','DAV::read-current-user-privilege-set','DAV::read-acl'));
|
||||
|
||||
if ( $request->depth > 0 ) {
|
||||
$request->DoResponse( 400, 'The principal-match REPORT is only defined for Depth "0".' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the array of properties to include in the report output
|
||||
* Determine which principal we're looking for
|
||||
*/
|
||||
$match = $xmltree->GetPath('/DAV::principal-match/DAV::self');
|
||||
if ( count ( $match ) == 0 ) {
|
||||
@ -31,20 +32,31 @@ if ( $match_self ) {
|
||||
$params = array(':username' => $session->username );
|
||||
}
|
||||
else {
|
||||
$where = 'dav_name = :dav_name';
|
||||
$params = array(':dav_name'=>'/'.$request->principal->GetProperty('username').'/');
|
||||
}
|
||||
$sql = "SELECT * FROM dav_principal WHERE $where ORDER BY principal_id LIMIT 100";
|
||||
|
||||
if ( $target->IsPrincipal() ) {
|
||||
// The request path is more specific, so ALTERNATIVELY,
|
||||
// we find this principal's resources (collections) instead
|
||||
$sql = "SELECT * FROM collection WHERE user_no = :user_no";
|
||||
$params = array(':user_no' => $target->user_no() );
|
||||
}
|
||||
|
||||
if ( $where != "" ) $where = "WHERE $where";
|
||||
$sql = "SELECT * FROM dav_principal $where ORDER BY principal_id LIMIT 100";
|
||||
$qry = new AwlQuery($sql, $params);
|
||||
|
||||
|
||||
/**
|
||||
* Build the array of properties to include in the report output
|
||||
*/
|
||||
$get_props = $xmltree->GetPath('/DAV::principal-match/DAV::prop/*');
|
||||
$properties = array();
|
||||
foreach( $get_props AS $k1 => $v1 ) {
|
||||
$properties[] = $v1->GetNSTag();
|
||||
}
|
||||
|
||||
$responses = array();
|
||||
if ( $qry->Exec("REPORT",__LINE__,__FILE__) && $qry->rows() > 0 ) {
|
||||
while( $row = $qry->Fetch() ) {
|
||||
$principal = new DAVResource($row);
|
||||
@ -54,4 +66,4 @@ if ( $qry->Exec("REPORT",__LINE__,__FILE__) && $qry->rows() > 0 ) {
|
||||
|
||||
$multistatus = new XMLElement( "multistatus", $responses, $reply->GetXmlNsArray() );
|
||||
|
||||
$request->XMLResponse( 207, $multistatus );
|
||||
$request->XMLResponse( 207, $multistatus );
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
$responses = array();
|
||||
|
||||
if ( $request->depth > 0 ) {
|
||||
$request->DoResponse( 400, 'The principal-property-search REPORT is only defined for Depth "0".' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the array of properties to include in the report output
|
||||
@ -71,6 +72,7 @@ foreach( $get_props AS $k1 => $v1 ) {
|
||||
$properties[] = $v1->GetNSTag();
|
||||
}
|
||||
|
||||
$responses = array();
|
||||
if ( $qry->Exec("REPORT",__LINE__,__FILE__) && $qry->rows() > 0 ) {
|
||||
while( $row = $qry->Fetch() ) {
|
||||
$principal = new DAVResource($row);
|
||||
|
||||
@ -2,8 +2,8 @@ HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
||||
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
||||
ETag: "ae6b3ed31d2295a38ad54bdf12fe02a7"
|
||||
Content-Length: 1655
|
||||
ETag: "1c7781ef8567ba3018e5924858102296"
|
||||
Content-Length: 1761
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
@ -51,6 +51,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
|
||||
@ -4,8 +4,8 @@ HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
||||
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
||||
ETag: "e76e5a37264c0b44f88f8456c27a7aaa"
|
||||
Content-Length: 27747
|
||||
ETag: "e6d929727ad5e85f7db37f1e7c091f6a"
|
||||
Content-Length: 28701
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
@ -80,6 +80,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
@ -204,6 +209,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
@ -330,6 +340,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
@ -460,6 +475,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
@ -604,6 +624,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
@ -733,6 +758,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
@ -854,6 +884,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
@ -981,6 +1016,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
@ -1121,6 +1161,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
|
||||
@ -2,8 +2,8 @@ HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
||||
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
||||
ETag: "8d5e76c5b7b5676fc36e38cfad77c5db"
|
||||
Content-Length: 1277
|
||||
ETag: "be4b763e94c9a88fb82f45f25d0a6e89"
|
||||
Content-Length: 1383
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
@ -37,6 +37,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
|
||||
@ -2,8 +2,8 @@ HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
||||
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
||||
ETag: "3447a04184df5d673f50e8c7a0952a68"
|
||||
Content-Length: 1611
|
||||
ETag: "f36602c450120819191b73e42c5fccaa"
|
||||
Content-Length: 1717
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
@ -49,6 +49,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
|
||||
@ -2,8 +2,8 @@ HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
||||
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
||||
ETag: "25501a258bef17f959a7045cac35322a"
|
||||
Content-Length: 2027
|
||||
ETag: "a55aa07ee821b9f4dd4eea96e192aa89"
|
||||
Content-Length: 2133
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
@ -48,6 +48,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
|
||||
@ -2,8 +2,8 @@ HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
||||
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
||||
ETag: "98ceb8bb48fbdd547226d0b28aadd942"
|
||||
Content-Length: 1699
|
||||
ETag: "be682462fd8bacf3d7189fbac09a7af5"
|
||||
Content-Length: 1805
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
@ -48,6 +48,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
|
||||
@ -2,8 +2,8 @@ HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
||||
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
|
||||
ETag: "f4ace4415ef70e47f318ae774aaaac48"
|
||||
Content-Length: 1636
|
||||
ETag: "6cd1545a5b4de69844a890f732119fa0"
|
||||
Content-Length: 1742
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
@ -46,6 +46,11 @@ Content-Type: text/xml; charset="utf-8"
|
||||
<expand-property/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<principal-match/>
|
||||
</report>
|
||||
</supported-report>
|
||||
<supported-report>
|
||||
<report>
|
||||
<sync-collection/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user