From 04656674f7f5a4d757a2c64776f43df64963424d Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Sat, 27 Oct 2007 00:11:44 +1300 Subject: [PATCH] Make puck's patches for PUBLIC events actually work. --- dba/patches/1.1.10.sql | 3 ++- dba/rscds.sql | 3 ++- inc/caldav-PUT-functions.php | 18 +++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/dba/patches/1.1.10.sql b/dba/patches/1.1.10.sql index 532a3bb0..2a059cb6 100644 --- a/dba/patches/1.1.10.sql +++ b/dba/patches/1.1.10.sql @@ -10,8 +10,9 @@ UPDATE calendar_item SET class = 'PUBLIC' WHERE class IS NULL; -- Allow forcing all events in a calendar to be public ALTER TABLE collection ADD COLUMN public_events_only BOOLEAN; +UPDATE collection SET public_events_only = FALSE; ALTER TABLE collection ALTER public_events_only SET NOT NULL; -ALTER TABLE collection ALTER public_events_only SET DEFAULT 'f'; +ALTER TABLE collection ALTER public_events_only SET DEFAULT FALSE; SELECT new_db_revision(1,1,10, 'October' ); COMMIT; diff --git a/dba/rscds.sql b/dba/rscds.sql index 2e76a617..33382bfa 100644 --- a/dba/rscds.sql +++ b/dba/rscds.sql @@ -77,6 +77,7 @@ CREATE TABLE collection ( is_calendar BOOLEAN, created TIMESTAMP WITH TIME ZONE, modified TIMESTAMP WITH TIME ZONE, + public_events_only BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY ( user_no, dav_name ) ); @@ -141,4 +142,4 @@ CREATE TABLE freebusy_ticket ( GRANT INSERT,SELECT,UPDATE,DELETE ON TABLE freebusy_ticket TO general; -SELECT new_db_revision(1,1,9, 'September' ); +SELECT new_db_revision(1,1,10, 'October' ); diff --git a/inc/caldav-PUT-functions.php b/inc/caldav-PUT-functions.php index 8bea00a2..8a33f938 100644 --- a/inc/caldav-PUT-functions.php +++ b/inc/caldav-PUT-functions.php @@ -92,11 +92,11 @@ function controlRequestContainer( $username, $user_no, $path, $caldav_context ) function public_events_only( $user_no, $dav_name ) { $sql = "SELECT public_events_only "; $sql .= "FROM collection "; - $sql .= "WHERE user_no=? AND dav_name=?"); + $sql .= "WHERE user_no=? AND dav_name=?"; - $qry = new PgQuery($sql); + $qry = new PgQuery($sql, $user_no, $dav_name); - if( $qry->Exec($user_no, $dav_name) && $qry->rows == 1 ) { + if( $qry->Exec('PUT') && $qry->rows == 1 ) { $collection = $qry->Fetch(); if ($collection->public_events_only == 't') { @@ -215,14 +215,14 @@ function import_collection( $ics_content, $user_no, $path, $caldav_context ) { if ( public_events_only($user_no, $path) ) { $class = 'PUBLIC'; } - + /* * It seems that some calendar clients don't set a class... * RFC2445, 4.8.1.3: * Default is PUBLIC - */ + */ if ( !isset($class) || $class == '' ) { - $class = 'PUBLIC' + $class = 'PUBLIC'; } $sql .= <<