From eddb05c2b15adc961eb5b459b39d5f67afcb8d4c Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Mon, 24 Aug 2009 11:22:58 +1200 Subject: [PATCH] Preliminary commit to add ability to log caldav actions (untested). --- inc/caldav-DELETE.php | 5 ++++- inc/caldav-PUT-functions.php | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/inc/caldav-DELETE.php b/inc/caldav-DELETE.php index 6b76501e..c0fed397 100644 --- a/inc/caldav-DELETE.php +++ b/inc/caldav-DELETE.php @@ -66,7 +66,7 @@ else { /** * We read the resource first, so we can check if it matches (or does not match) */ - $qry = new PgQuery( "SELECT * FROM caldav_data WHERE user_no = ? AND dav_name = ?;", $request->user_no, $request->path ); + $qry = new PgQuery( "SELECT dav_etag, uid FROM caldav_data JOIN calendar_item USING (dav_id) WHERE user_no = ? AND dav_name = ?;", $request->user_no, $request->path ); if ( $qry->Exec("DELETE") && $qry->rows == 1 ) { $delete_row = $qry->Fetch(); if ( (isset($request->etag_if_match) && $request->etag_if_match != $delete_row->dav_etag) ) { @@ -76,6 +76,9 @@ else { if ( $qry->Exec("DELETE") ) { $qry = new PgQuery( "DELETE FROM property WHERE dav_name = ?;", $request->path ); $qry->Exec("DELETE"); /** @todo we should write a trigger to delete property records when caldav_data or collection is deleted */ @dbg_error_log( "DELETE", "DELETE: User: %d, ETag: %s, Path: %s", $session->user_no, $request->etag_if_match, $request->path); + if ( function_exists('log_caldav_action') ) { + log_caldav_action( 'DELETE', $delete_row->uid, $request->user_no, $request->collection_id, $request->path ); + } $request->DoResponse( 204 ); } else { diff --git a/inc/caldav-PUT-functions.php b/inc/caldav-PUT-functions.php index 4e2e85f8..552b981a 100644 --- a/inc/caldav-PUT-functions.php +++ b/inc/caldav-PUT-functions.php @@ -593,6 +593,10 @@ function putCalendarResource( &$request, $author, $caldav_context ) { COMMIT; EOSQL; + if ( function_exists('log_caldav_action') ) { + log_caldav_action( $put_action_type, $first->GetPValue('UID'), $request->user_no, $request->collection_id, $request->path ); + } + $qry = new PgQuery( $sql, $request->user_no, $request->path, $etag, $first->GetPValue('UID'), $dtstamp, $first->GetPValue('DTSTART'), $first->GetPValue('SUMMARY'), $first->GetPValue('LOCATION'), $class, $first->GetPValue('TRANSP'), $first->GetPValue('DESCRIPTION'), $first->GetPValue('RRULE'), $tzid,