mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-08-22 17:16:06 +00:00
Start of sync-collection report.
This commit is contained in:
parent
4e8effb21f
commit
3d883e975d
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require("DAVObject.php");
|
||||
$responses = array();
|
||||
|
||||
/**
|
||||
@ -6,6 +7,8 @@ $responses = array();
|
||||
*/
|
||||
$sync_tokens = $xmltree->GetPath('/DAV::sync-collection/DAV::sync-token');
|
||||
$sync_token = $sync_tokens[0]->GetContent();
|
||||
if ( !isset($sync_token) ) $sync_token = 0;
|
||||
$sync_token = intval($sync_token);
|
||||
dbg_error_log( 'sync', " sync-token: %s", $sync_token );
|
||||
|
||||
$props = $xmltree->GetPath('/DAV::sync-collection/DAV::prop');
|
||||
@ -17,17 +20,31 @@ function display_status( $status_code ) {
|
||||
return sprintf( 'HTTP/1.1 %03d %s', $status_code, getStatusMessage($status_code) );
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM sync_changes WHERE sync_time > (SELECT modification_time FROM sync_tokens WHERE sync_token = ?)";
|
||||
$qry = new PgQuery($sql);
|
||||
$sql = "SELECT new_sync_token(?,?)";
|
||||
$qry = new PgQuery($sql, $sync_token, $request->CollectionId());
|
||||
if ( !$qry->Exec("REPORT",__LINE__,__FILE__) || $qry->rows <= 0 ) {
|
||||
$request->DoResponse( 500, translate("Database error") );
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM collection LEFT JOIN sync_changes USING(collection_id) sync_changes LEFT JOIN calendar_item USING (dav_id) LEFT JOIN caldav_data USING (dav_id) WHERE collection_id = ? AND sync_time > (SELECT modification_time FROM sync_tokens WHERE sync_token = ?)";
|
||||
$qry = new PgQuery($sql, $request->CollectionId(), $sync_token);
|
||||
|
||||
if ( $qry->Exec("REPORT",__LINE__,__FILE__) && $qry->rows > 0 ) {
|
||||
while( $change = $qry->Fetch() ) {
|
||||
$href = new XMLElement( 'href', $change->href );
|
||||
$status = new XMLElement( 'status', display_status($change->status) );
|
||||
$propstat = $request->GetPropStat($proplist);
|
||||
$responses[] = new XMLElement( 'sync-response', array() );
|
||||
while( $object = $qry->Fetch() ) {
|
||||
$resultset = array(
|
||||
new XMLElement( 'href', $object->href ),
|
||||
new XMLElement( 'status', display_status($object->status) )
|
||||
);
|
||||
if ( $status != 404 ) {
|
||||
$dav_object = new DavObject($object);
|
||||
$resultset[] = $dav_object->GetPropStat( $proplist );
|
||||
}
|
||||
$responses[] = new XMLElement( 'sync-response', $resultset );
|
||||
}
|
||||
}
|
||||
else {
|
||||
$request->DoResponse( 500, translate("Database error") );
|
||||
}
|
||||
|
||||
$multistatus = new XMLElement( "multistatus", $responses, $reply->GetXmlNsArray() );
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user