From e72559061228a57b18d17c15b1a7e2cfe6530680 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Fri, 26 Oct 2007 11:35:19 +1300 Subject: [PATCH] Rewrite force events to public logic to be PUBLIC only, not general. --- dba/patches/1.1.10.sql | 6 ++++-- inc/caldav-PUT-functions.php | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/dba/patches/1.1.10.sql b/dba/patches/1.1.10.sql index d7cce76a..532a3bb0 100644 --- a/dba/patches/1.1.10.sql +++ b/dba/patches/1.1.10.sql @@ -8,8 +8,10 @@ SELECT check_db_revision(1,1,9); -- According to RFC2445, 4.8.1.3. UPDATE calendar_item SET class = 'PUBLIC' WHERE class IS NULL; --- Allow forcing all events in a calendar to a specific class -ALTER TABLE collection ADD COLUMN force_class TEXT; +-- Allow forcing all events in a calendar to be public +ALTER TABLE collection ADD COLUMN public_events_only BOOLEAN; +ALTER TABLE collection ALTER public_events_only SET NOT NULL; +ALTER TABLE collection ALTER public_events_only SET DEFAULT 'f'; SELECT new_db_revision(1,1,10, 'October' ); COMMIT; diff --git a/inc/caldav-PUT-functions.php b/inc/caldav-PUT-functions.php index fbe4383c..8bea00a2 100644 --- a/inc/caldav-PUT-functions.php +++ b/inc/caldav-PUT-functions.php @@ -84,12 +84,13 @@ function controlRequestContainer( $username, $user_no, $path, $caldav_context ) } /** -* Check if there is a class that new events should be forced to. +* Check if this collection sould force all events to be PUBLIC. * @param string $user_no the user that owns the collection * @param string $dav_name the collection to check +* @return boolean Return true if public events only are allowed. */ -function find_forced_class( $user_no, $dav_name ) { - $sql = "SELECT force_class "; +function public_events_only( $user_no, $dav_name ) { + $sql = "SELECT public_events_only "; $sql .= "FROM collection "; $sql .= "WHERE user_no=? AND dav_name=?"); @@ -98,10 +99,13 @@ function find_forced_class( $user_no, $dav_name ) { if( $qry->Exec($user_no, $dav_name) && $qry->rows == 1 ) { $collection = $qry->Fetch(); - if ( ( isset($collection->force_class) && $collection->force_class != '' ) { - return $collection->force_class; + if ($collection->public_events_only == 't') { + return true; } } + + // Something went wrong, must be false. + return false; } @@ -208,9 +212,8 @@ function import_collection( $ics_content, $user_no, $path, $caldav_context ) { $class = $ic->Get("class"); /* Check and see if we should over ride the class. */ - $force_class = find_forced_class($user_no, $path); - if ( isset($force_class) ) { - $class = $force_class; + if ( public_events_only($user_no, $path) ) { + $class = 'PUBLIC'; } /* @@ -354,9 +357,8 @@ function putCalendarResource( &$request, $author, $caldav_context ) { $class = $ic->Get("class"); /* Check and see if we should over ride the class. */ - $force_class = find_forced_class($user_no, $path); - if ( isset($force_class) ) { - $class = $force_class; + if ( public_events_only($user_no, $path) ) { + $class = 'PUBLIC'; } /*