From f65770b7f171125928457737d9388194cd9f57d6 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Fri, 17 Apr 2009 01:03:54 +1200 Subject: [PATCH] Add support for publicly readable calendars. --- inc/CalDAVRequest.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index a1936889..7f25e871 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -358,7 +358,9 @@ EOSQL; return; } - $permissions = array(); + $this->permissions = array(); + + if ( $this->IsPublic() ) $this->permissions['read'] = 'read'; /** * In other cases we need to query the database for permissions @@ -366,7 +368,6 @@ EOSQL; $qry = new PgQuery( "SELECT get_permissions( ?, ? ) AS perm;", $session->user_no, $this->user_no); if ( $qry->Exec("caldav") && $permission_result = $qry->Fetch() ) { $permission_result = "!".$permission_result->perm; // We prepend something to ensure we get a non-zero position. - $this->permissions = array(); if ( strpos($permission_result,"A") ) $this->permissions['all'] = 'all'; else { @@ -391,8 +392,6 @@ EOSQL; * @todo This logic does not catch all locking scenarios. For example an infinite * depth request should check the permissions for all collections and resources within * that. At present we only maintain permissions on a per-collection basis though. - * - * @param string $dav_name The resource which we want to know the lock status for */ function IsLocked() { if ( !isset($this->_locks_found) ) { @@ -423,6 +422,17 @@ EOSQL; } + /** + * Checks whether the collection is public + */ + function IsPublic() { + if ( isset($this->collection) && isset($this->collection->publicly_readable) && $this->collection->publicly_readable == 't' ) { + return true; + } + return false; + } + + /** * Returns the name for this depth: 0, 1, infinity */