From 45512950a0111d82365685cd90b932b1568576a3 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Fri, 25 Sep 2009 22:15:57 +1200 Subject: [PATCH] Some tidy ups around scheduling inbox and passing collection type on. --- inc/CalDAVRequest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index 27e9b664..123432a0 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -189,6 +189,11 @@ class CalDAVRequest $this->path = (isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : "/"); $this->path = rawurldecode($this->path); + /** Allow a request for .../calendar.ics to translate into the calendar URL */ + if ( preg_match( '#^(/[^/]+/[^/]+).ics$#', $this->path, $matches ) ) { + $this->path = $matches[1]. '/'; + } + // dbg_error_log( "caldav", "Sanitising path '%s'", $this->path ); $bad_chars_regex = '/[\\^\\[\\(\\\\]/'; if ( preg_match( $bad_chars_regex, $this->path ) ) { @@ -234,13 +239,15 @@ class CalDAVRequest $this->collection_path = $row->dav_name; $this->collection_type = ($row->is_calendar == 't' ? 'calendar' : 'collection'); $this->collection = $row; + $this->collection->type = $this->collection_type; } else if ( preg_match( '#^((/[^/]+/)\.(in|out)/)[^/]*$#', $this->path, $matches ) ) { // The request is for a scheduling inbox or outbox (or something inside one) and we should auto-create it $displayname = $session->fullname . ($matches[3] == 'in' ? ' Inbox' : ' Outbox'); + $this->collection_type = 'schedule-'. $matches[3]. 'box'; $sql = <<user_no, $matches[2] , $matches[1], $displayname ); $qry->Exec('caldav'); @@ -251,6 +258,7 @@ EOSQL; $this->collection_id = $row->collection_id; $this->collection_path = $matches[1]; $this->collection = $row; + $this->collection->type = $this->collection_type; } } else if ( preg_match( '#^((/[^/]+/)calendar-proxy-(read|write))/?[^/]*$#', $this->path, $matches ) ) { @@ -315,6 +323,7 @@ EOSQL; 'is_principal' => 'f', 'user_no' => 0, 'dav_displayname' => $c->system_name, + 'type' => 'root', 'created' => date('Ymd\THis') ); } @@ -324,6 +333,7 @@ EOSQL; 'is_calendar' => 'f', 'is_principal' => 't', 'is_proxy' => 't', + 'type' => 'proxy', 'proxy_type' => $this->proxy_type, 'dav_displayname' => sprintf('Proxy %s for %s', $this->proxy_type, $this->principal->username), 'collection_id' => 0,