Allow forcing all events in a collection to a specified class.

This commit is contained in:
Andrew Ruthven 2007-10-26 11:05:32 +13:00 committed by Andrew Ruthven
parent bbcd6a82ac
commit e0746e058e
2 changed files with 41 additions and 4 deletions

View File

@ -1,12 +1,16 @@
-- Make sure that class is set to something, by default PUBLIC.
-- According to RFC2445, 4.8.1.3.
-- Sort out accessing calendar entries.
BEGIN;
SELECT check_db_revision(1,1,9);
-- Make sure that class is set to something, by default PUBLIC.
-- 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;
SELECT new_db_revision(1,1,10, 'October' );
COMMIT;
ROLLBACK;

View File

@ -83,6 +83,27 @@ function controlRequestContainer( $username, $user_no, $path, $caldav_context )
return $is_collection;
}
/**
* Check if there is a class that new events should be forced to.
* @param string $user_no the user that owns the collection
* @param string $dav_name the collection to check
*/
function find_forced_class( $user_no, $dav_name ) {
$sql = "SELECT force_class ";
$sql .= "FROM collection ";
$sql .= "WHERE user_no=? AND dav_name=?");
$qry = new PgQuery($sql);
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;
}
}
}
/**
* This function will import a whole calendar
@ -185,12 +206,18 @@ function import_collection( $ics_content, $user_no, $path, $caldav_context ) {
$dtstamp = $last_modified;
}
$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;
}
/*
* It seems that some calendar clients don't set a class...
* RFC2445, 4.8.1.3:
* Default is PUBLIC
*/
$class = $ic->Get("class");
if ( !isset($class) || $class == '' ) {
$class = 'PUBLIC'
}
@ -325,12 +352,18 @@ function putCalendarResource( &$request, $author, $caldav_context ) {
$dtstamp = $last_modified;
}
$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;
}
/*
* It seems that some calendar clients don't set a class...
* RFC2445, 4.8.1.3:
* Default is PUBLIC
*/
$class = $ic->Get("class");
if ( !isset($class) || $class == '' ) {
$class = 'PUBLIC'
}