From 12035ab7e55d1e0779d9951b52007192c61de5aa Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Sat, 26 Jan 2008 22:30:31 +1300 Subject: [PATCH] Actually retrieve the collection_id correctly, and document it too. --- inc/CalDAVRequest.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index bc7edaa6..121ab6ff 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -54,6 +54,16 @@ class CalDAVRequest */ var $user_agent; + /** + * The ID of the collection containing this path, or of this path if it is a collection + */ + var $collection_id; + + /** + * The path corresponding to the collection_id + */ + var $collection_path; + /** * Create a new CalDAVRequest object. */ @@ -178,18 +188,21 @@ class CalDAVRequest header( "Content-Location: $this->path" ); $this->_is_collection = true; $this->collection_id = $row->collection_id; + $this->collection_path = $this->path; } } /** * Get the ID of the collection we are referring to */ - if ( !isset($this->collection_id) && preg_match( '#^(/.+/.+/)[^/]*$#', $this->path ) ) { - $qry = new PgQuery( "SELECT collection_id FROM collection WHERE user_no = ? AND dav_name = ?;", $this->user_no, $this->path ); + if ( !isset($this->collection_id) && preg_match( '#^(/.+/.+/)[^/]*$#', $this->path, $matches ) ) { + $qry = new PgQuery( "SELECT collection_id FROM collection WHERE user_no = ? AND dav_name = ?;", $this->user_no, $matches[1] ); if ( $qry->Exec('caldav') && $qry->rows == 1 && ($row = $qry->Fetch()) ) { $this->collection_id = $row->collection_id; + $this->collection_path = $matches[1]; } } + dbg_error_log( "caldav", " Collection '%s' is %d", $this->collection_path, $this->collection_id ); /**