mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-19 01:34:26 +00:00
Allow forcing all events in a collection to a specified class.
This commit is contained in:
parent
bbcd6a82ac
commit
e0746e058e
@ -1,12 +1,16 @@
|
|||||||
|
|
||||||
-- Make sure that class is set to something, by default PUBLIC.
|
-- Sort out accessing calendar entries.
|
||||||
-- According to RFC2445, 4.8.1.3.
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT check_db_revision(1,1,9);
|
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;
|
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' );
|
SELECT new_db_revision(1,1,10, 'October' );
|
||||||
COMMIT;
|
COMMIT;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|||||||
@ -83,6 +83,27 @@ function controlRequestContainer( $username, $user_no, $path, $caldav_context )
|
|||||||
return $is_collection;
|
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
|
* This function will import a whole calendar
|
||||||
@ -185,12 +206,18 @@ function import_collection( $ics_content, $user_no, $path, $caldav_context ) {
|
|||||||
$dtstamp = $last_modified;
|
$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...
|
* It seems that some calendar clients don't set a class...
|
||||||
* RFC2445, 4.8.1.3:
|
* RFC2445, 4.8.1.3:
|
||||||
* Default is PUBLIC
|
* Default is PUBLIC
|
||||||
*/
|
*/
|
||||||
$class = $ic->Get("class");
|
|
||||||
if ( !isset($class) || $class == '' ) {
|
if ( !isset($class) || $class == '' ) {
|
||||||
$class = 'PUBLIC'
|
$class = 'PUBLIC'
|
||||||
}
|
}
|
||||||
@ -325,12 +352,18 @@ function putCalendarResource( &$request, $author, $caldav_context ) {
|
|||||||
$dtstamp = $last_modified;
|
$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...
|
* It seems that some calendar clients don't set a class...
|
||||||
* RFC2445, 4.8.1.3:
|
* RFC2445, 4.8.1.3:
|
||||||
* Default is PUBLIC
|
* Default is PUBLIC
|
||||||
*/
|
*/
|
||||||
$class = $ic->Get("class");
|
|
||||||
if ( !isset($class) || $class == '' ) {
|
if ( !isset($class) || $class == '' ) {
|
||||||
$class = 'PUBLIC'
|
$class = 'PUBLIC'
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user