Index: openacs-4/packages/calendar/sql/oracle/calendar-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/sql/oracle/calendar-create.sql,v diff -u -r1.11 -r1.12 --- openacs-4/packages/calendar/sql/oracle/calendar-create.sql 29 Mar 2018 20:23:43 -0000 1.11 +++ openacs-4/packages/calendar/sql/oracle/calendar-create.sql 22 Apr 2018 18:05:23 -0000 1.12 @@ -6,108 +6,108 @@ -- ------------------------------------------------------------------ --- calendar system permissions +-- calendar system permissions ------------------------------------------------------------------ - + -- creating the basic set of permissions for cal_item -- - -- 1 create: create an new item + -- 1 create: create an new item -- 2. read: can view the cal_item -- 3. write: edit an existing cal_item -- 4. delete: can delete the cal_item -- 5. invite: can allow other parties to view or edit the cal_item begin - acs_privilege.create_privilege('cal_item_create', 'Add an new item'); - acs_privilege.create_privilege('cal_item_read', 'view an cal_item'); - acs_privilege.create_privilege('cal_item_write', 'Edit an existing cal_item'); - acs_privilege.create_privilege('cal_item_delete', 'Delete cal_item' ); - acs_privilege.create_privilege('cal_item_invite', 'Allow others to view cal_item'); + acs_privilege.create_privilege('cal_item_create', 'Add an new item'); + acs_privilege.create_privilege('cal_item_read', 'view an cal_item'); + acs_privilege.create_privilege('cal_item_write', 'Edit an existing cal_item'); + acs_privilege.create_privilege('cal_item_delete', 'Delete cal_item' ); + acs_privilege.create_privilege('cal_item_invite', 'Allow others to view cal_item'); - -- bind the calendar permissions to the golbal names + -- bind the calendar permissions to the golbal names - acs_privilege.add_child('create', 'cal_item_create'); - acs_privilege.add_child('read', 'cal_item_read'); - acs_privilege.add_child('write', 'cal_item_write'); - acs_privilege.add_child('delete', 'cal_item_delete'); + acs_privilege.add_child('create', 'cal_item_create'); + acs_privilege.add_child('read', 'cal_item_read'); + acs_privilege.add_child('write', 'cal_item_write'); + acs_privilege.add_child('delete', 'cal_item_delete'); end; / show errors - -- creating the addition set of permissions for calendar. + -- creating the addition set of permissions for calendar. -- these are going to be used as status markers for the calendar - -- + -- -- 1. calendar_on: calendar has been selected -- 2. calendar_show: user wants to view events from the calendar -- 3. calendar_hide: user does not want to view events from the calendar begin - acs_privilege.create_privilege('calendar_on', 'Implies that a calendar is selected'); - acs_privilege.create_privilege('calendar_show', 'Show a calendar'); + acs_privilege.create_privilege('calendar_on', 'Implies that a calendar is selected'); + acs_privilege.create_privilege('calendar_show', 'Show a calendar'); - -- bind the calendar permissions to the golbal names + -- bind the calendar permissions to the golbal names - acs_privilege.add_child('read', 'calendar_on'); - acs_privilege.add_child('read', 'calendar_show'); + acs_privilege.add_child('read', 'calendar_on'); + acs_privilege.add_child('read', 'calendar_show'); end; / show errors - -- creating the basic set of permissions for calendar. + -- creating the basic set of permissions for calendar. -- - -- 1. calendar_create: make a new calendar + -- 1. calendar_create: make a new calendar -- 2. calendar_read: can view all items on an existing calendar - -- 3. calendar_write: can edit all items on an existing calendar - -- 4. calendar_delete: delete an existing calendar + -- 3. calendar_write: can edit all items on an existing calendar + -- 4. calendar_delete: delete an existing calendar begin - acs_privilege.create_privilege('calendar_create', 'Create a new calendar'); - acs_privilege.create_privilege('calendar_read', 'View items on an existing calendar'); - acs_privilege.create_privilege('calendar_write', 'Edit items of an existing calendar'); - acs_privilege.create_privilege('calendar_delete','Delete an calendar' ); + acs_privilege.create_privilege('calendar_create', 'Create a new calendar'); + acs_privilege.create_privilege('calendar_read', 'View items on an existing calendar'); + acs_privilege.create_privilege('calendar_write', 'Edit items of an existing calendar'); + acs_privilege.create_privilege('calendar_delete','Delete an calendar' ); - -- bind the calendar permissions to the golbal names + -- bind the calendar permissions to the golbal names - acs_privilege.add_child('create', 'calendar_create'); - acs_privilege.add_child('read', 'calendar_read'); - acs_privilege.add_child('write', 'calendar_write'); - acs_privilege.add_child('delete', 'calendar_delete'); + acs_privilege.add_child('create', 'calendar_create'); + acs_privilege.add_child('read', 'calendar_read'); + acs_privilege.add_child('write', 'calendar_write'); + acs_privilege.add_child('delete', 'calendar_delete'); - -- bind the cal_item permissions to the calendar permissions + -- bind the cal_item permissions to the calendar permissions - -- When a calendar has the permission of public, - -- it implies that all the default permission to magic group 'public' - -- have the permissions of "calendar_read" - - -- When a calendar has the permission of private - -- it implies that the only group that will have the permission - -- "calendar_read" would the group that the calendar belong to. + -- When a calendar has the permission of public, + -- it implies that all the default permission to magic group 'public' + -- have the permissions of "calendar_read" - acs_privilege.add_child('calendar_create', 'cal_item_create'); - acs_privilege.add_child('calendar_read', 'cal_item_read'); - acs_privilege.add_child('calendar_write', 'cal_item_write'); - acs_privilege.add_child('calendar_delete', 'cal_item_delete'); - + -- When a calendar has the permission of private + -- it implies that the only group that will have the permission + -- "calendar_read" would the group that the calendar belong to. + + acs_privilege.add_child('calendar_create', 'cal_item_create'); + acs_privilege.add_child('calendar_read', 'cal_item_read'); + acs_privilege.add_child('calendar_write', 'cal_item_write'); + acs_privilege.add_child('calendar_delete', 'cal_item_delete'); + end; / show errors -- Assign the four basic permissions to more specific roles and conditions -- -- calendar_admin is assigned by the owner when the calendar - -- is created. A calendar_admin can grant any combinations + -- is created. A calendar_admin can grant any combinations -- or read, write, delete and invite to any member of the party - -- on a cal_item basis or on a calendar basis(all items). + -- on a cal_item basis or on a calendar basis(all items). begin - acs_privilege.create_privilege('calendar_admin', 'calendar administrator'); - acs_privilege.add_child('admin', 'calendar_admin'); - acs_privilege.add_child('calendar_admin', 'calendar_read'); - acs_privilege.add_child('calendar_admin', 'calendar_write'); - acs_privilege.add_child('calendar_admin', 'calendar_delete'); - acs_privilege.add_child('calendar_admin', 'calendar_create'); - acs_privilege.add_child('calendar_admin', 'cal_item_invite'); + acs_privilege.create_privilege('calendar_admin', 'calendar administrator'); + acs_privilege.add_child('admin', 'calendar_admin'); + acs_privilege.add_child('calendar_admin', 'calendar_read'); + acs_privilege.add_child('calendar_admin', 'calendar_write'); + acs_privilege.add_child('calendar_admin', 'calendar_delete'); + acs_privilege.add_child('calendar_admin', 'calendar_create'); + acs_privilege.add_child('calendar_admin', 'cal_item_invite'); end; / @@ -116,51 +116,51 @@ ----------------------------------------------------------- +---------------------------------------------------------- -- calendar_object ------------------------------------------------------------ - +----------------------------------------------------------- + begin - -- create the calendar object + -- create the calendar object - acs_object_type.create_type ( - supertype => 'acs_object', - object_type => 'calendar', - pretty_name => 'Calendar', - pretty_plural => 'Calendars', - table_name => 'calendars', - id_column => 'calendar_id' - ); + acs_object_type.create_type ( + supertype => 'acs_object', + object_type => 'calendar', + pretty_name => 'Calendar', + pretty_plural => 'Calendars', + table_name => 'calendars', + id_column => 'calendar_id' + ); end; / show errors - -declare - attr_id acs_attributes.attribute_id%TYPE; + +declare + attr_id acs_attributes.attribute_id%TYPE; begin - attr_id := acs_attribute.create_attribute ( - object_type => 'calendar', - attribute_name => 'owner_id', - pretty_name => 'Owner', - pretty_plural => 'Owners', - datatype => 'integer' - ); - - attr_id := acs_attribute.create_attribute ( - object_type => 'calendar', - attribute_name => 'private_p', - pretty_name => 'Private Calendar', - pretty_plural => 'Private Calendars', - datatype => 'string' - ); + attr_id := acs_attribute.create_attribute ( + object_type => 'calendar', + attribute_name => 'owner_id', + pretty_name => 'Owner', + pretty_plural => 'Owners', + datatype => 'integer' + ); - attr_id := acs_attribute.create_attribute ( - object_type => 'calendar', - attribute_name => 'calendar_name', - pretty_name => 'Calendar Name', - pretty_plural => 'Calendar Names', - datatype => 'string' - ); + attr_id := acs_attribute.create_attribute ( + object_type => 'calendar', + attribute_name => 'private_p', + pretty_name => 'Private Calendar', + pretty_plural => 'Private Calendars', + datatype => 'string' + ); + + attr_id := acs_attribute.create_attribute ( + object_type => 'calendar', + attribute_name => 'calendar_name', + pretty_name => 'Calendar Name', + pretty_plural => 'Calendar Names', + datatype => 'string' + ); end; / show errors @@ -169,55 +169,55 @@ -- Calendar is a collection of events. Each calendar must -- belong to somebody (a party). create table calendars ( - -- primary key - calendar_id integer - constraint calendars_calendar_id_fk - references acs_objects - constraint calendars_calendar_id_pk - primary key, - -- the name of the calendar - calendar_name varchar2(200), - -- the individual or party that owns the calendar - owner_id integer - constraint calendars_calendar_owner_id_fk - references parties - on delete cascade, - -- keep track of package instances - package_id integer - constraint calendars_package_id_fk - references apm_packages(package_id) - on delete cascade, - -- whether or not the calendar is a private personal calendar or a - -- public calendar. - private_p varchar2(1) - default 'f' - constraint calendars_private_p_ck - check (private_p in ( - 't', - 'f' - ) - ) + -- primary key + calendar_id integer + constraint calendars_calendar_id_fk + references acs_objects + constraint calendars_calendar_id_pk + primary key, + -- the name of the calendar + calendar_name varchar2(200), + -- the individual or party that owns the calendar + owner_id integer + constraint calendars_calendar_owner_id_fk + references parties + on delete cascade, + -- keep track of package instances + package_id integer + constraint calendars_package_id_fk + references apm_packages(package_id) + on delete cascade, + -- whether or not the calendar is a private personal calendar or a + -- public calendar. + private_p varchar2(1) + default 'f' + constraint calendars_private_p_ck + check (private_p in ( + 't', + 'f' + ) + ) ); comment on table calendars is ' - Table calendars maps the many to many relationship betweens - calendar and its owners. + Table calendars maps the many to many relationship betweens + calendar and its owners. '; comment on column calendars.calendar_id is ' - Primary Key + Primary Key '; comment on column calendars.calendar_name is ' - the name of the calendar. This would be unique to avoid confusion + the name of the calendar. This would be unique to avoid confusion '; comment on column calendars.owner_id is ' - the individual or party that owns the calendar + the individual or party that owns the calendar '; comment on column calendars.package_id is ' - keep track of package instances + keep track of package instances '; @@ -229,11 +229,11 @@ create table cal_item_types ( item_type_id integer not null - constraint cal_item_type_id_pk - primary key, + constraint cal_item_type_id_pk + primary key, calendar_id integer not null - constraint cal_item_type_cal_id_fk - references calendars(calendar_id), + constraint cal_item_type_cal_id_fk + references calendars(calendar_id), type varchar(100) not null, -- this constraint is obvious given that item_type_id -- is unique, but it's necessary to allow strong @@ -250,142 +250,133 @@ ------------------------------------------------------------- -- create package calendar ------------------------------------------------------------- - + create or replace package calendar as - function new ( - calendar_id in acs_objects.object_id%TYPE default null, - calendar_name in calendars.calendar_name%TYPE default null, - object_type in acs_objects.object_type%TYPE default 'calendar', - owner_id in calendars.owner_id%TYPE , - private_p in calendars.private_p%TYPE default 'f', - package_id in calendars.package_id%TYPE default null, - context_id in acs_objects.context_id%TYPE default null, - creation_date in acs_objects.creation_date%TYPE default sysdate, - creation_user in acs_objects.creation_user%TYPE default null, - creation_ip in acs_objects.creation_ip%TYPE default null + function new ( + calendar_id in acs_objects.object_id%TYPE default null, + calendar_name in calendars.calendar_name%TYPE default null, + object_type in acs_objects.object_type%TYPE default 'calendar', + owner_id in calendars.owner_id%TYPE , + private_p in calendars.private_p%TYPE default 'f', + package_id in calendars.package_id%TYPE default null, + context_id in acs_objects.context_id%TYPE default null, + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE default null, + creation_ip in acs_objects.creation_ip%TYPE default null - ) return calendars.calendar_id%TYPE; - - procedure del ( - calendar_id in calendars.calendar_id%TYPE - ); + ) return calendars.calendar_id%TYPE; + procedure del ( + calendar_id in calendars.calendar_id%TYPE + ); + end calendar; / show errors; - - + + create or replace package body calendar -as +as - function new ( - calendar_id in acs_objects.object_id%TYPE default null, - calendar_name in calendars.calendar_name%TYPE default null, - object_type in acs_objects.object_type%TYPE default 'calendar', - owner_id in calendars.owner_id%TYPE , - private_p in calendars.private_p%TYPE default 'f', - package_id in calendars.package_id%TYPE default null, - context_id in acs_objects.context_id%TYPE default null, - creation_date in acs_objects.creation_date%TYPE default sysdate, - creation_user in acs_objects.creation_user%TYPE default null, - creation_ip in acs_objects.creation_ip%TYPE default null + function new ( + calendar_id in acs_objects.object_id%TYPE default null, + calendar_name in calendars.calendar_name%TYPE default null, + object_type in acs_objects.object_type%TYPE default 'calendar', + owner_id in calendars.owner_id%TYPE , + private_p in calendars.private_p%TYPE default 'f', + package_id in calendars.package_id%TYPE default null, + context_id in acs_objects.context_id%TYPE default null, + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE default null, + creation_ip in acs_objects.creation_ip%TYPE default null - ) - return calendars.calendar_id%TYPE - - is - v_calendar_id calendars.calendar_id%TYPE; + ) + return calendars.calendar_id%TYPE - begin - v_calendar_id := acs_object.new ( - object_id => calendar_id, - object_type => object_type, - creation_date => creation_date, - creation_user => creation_user, - creation_ip => creation_ip, - context_id => context_id - ); - - insert into calendars - (calendar_id, calendar_name, owner_id, package_id, private_p) - values (v_calendar_id, calendar_name, owner_id, package_id, private_p); + is + v_calendar_id calendars.calendar_id%TYPE; + begin + v_calendar_id := acs_object.new ( + object_id => calendar_id, + object_type => object_type, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => context_id + ); - -- each calendar has three default conditions - -- 1. all items are public - -- 2. all items are private - -- 3. no default conditions - -- - -- calendar being public implies granting permission - -- calendar_read to the group 'the_public' and 'registered users' - -- - -- calendar being private implies granting permission - -- calendar_read to the owner party/group of the party - -- - -- by default, we grant "calendar_admin" to - -- the owner of the calendar - acs_permission.grant_permission ( - object_id => v_calendar_id, - grantee_id => owner_id, - privilege => 'calendar_admin' - ); - - - return v_calendar_id; - end new; - + insert into calendars + (calendar_id, calendar_name, owner_id, package_id, private_p) + values (v_calendar_id, calendar_name, owner_id, package_id, private_p); - -- body for procedure delete - procedure del ( - calendar_id in calendars.calendar_id%TYPE - ) - is - - begin - -- First erase all the item relate to this calendar. - delete from calendars - where calendar_id = calendar.del.calendar_id; - - -- Delete all privileges associate with this calendar - delete from acs_permissions - where object_id = calendar.del.calendar_id; + -- each calendar has three default conditions + -- 1. all items are public + -- 2. all items are private + -- 3. no default conditions + -- + -- calendar being public implies granting permission + -- calendar_read to the group 'the_public' and 'registered users' + -- + -- calendar being private implies granting permission + -- calendar_read to the owner party/group of the party + -- + -- by default, we grant "calendar_admin" to + -- the owner of the calendar + acs_permission.grant_permission ( + object_id => v_calendar_id, + grantee_id => owner_id, + privilege => 'calendar_admin' + ); - -- Delete all privilges of the cal_items that's associated - -- with this calendar - delete from acs_permissions - where object_id in ( - select cal_item_id - from cal_items - where on_which_calendar = calendar.del.calendar_id - ); - - - acs_object.del(calendar_id); - end del; - + return v_calendar_id; + end new; -end calendar; -/ -show errors - ------------------------------------------------------------------ --- load related sql files ------------------------------------------------------------------ --- -@@cal-table-create + -- body for procedure delete + procedure del ( + calendar_id in calendars.calendar_id%TYPE + ) + is -@@calendar-notifications-init + begin + -- First erase all the item relate to this calendar. + delete from calendars + where calendar_id = calendar.del.calendar_id; + -- Delete all privileges associate with this calendar + delete from acs_permissions + where object_id = calendar.del.calendar_id; + -- Delete all privilges of the cal_items that's associated + -- with this calendar + delete from acs_permissions + where object_id in ( + select cal_item_id + from cal_items + where on_which_calendar = calendar.del.calendar_id + ); + acs_object.del(calendar_id); + end del; +end calendar; +/ +show errors + +----------------------------------------------------------------- +-- load related sql files +----------------------------------------------------------------- +-- +@@cal-table-create + +@@calendar-notifications-init Index: openacs-4/packages/calendar/sql/postgresql/calendar-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/sql/postgresql/calendar-create.sql,v diff -u -r1.18 -r1.19 --- openacs-4/packages/calendar/sql/postgresql/calendar-create.sql 29 Mar 2018 20:23:43 -0000 1.18 +++ openacs-4/packages/calendar/sql/postgresql/calendar-create.sql 22 Apr 2018 18:05:23 -0000 1.19 @@ -7,39 +7,39 @@ -- ported by Charles Mok (mok_cl@eelab.usyd.edu.au) ------------------------------------------------------------------ --- calendar system permissions +-- calendar system permissions ------------------------------------------------------------------ - + -- creating the basic set of permissions for cal_item -- - -- 1 create: create an new item + -- 1 create: create an new item -- 2. read: can view the cal_item -- 3. write: edit an existing cal_item -- 4. delete: can delete the cal_item -- 5. invite: can allow other parties to view or edit the cal_item - select acs_privilege__create_privilege('cal_item_create', 'Add an new item', null); + select acs_privilege__create_privilege('cal_item_create', 'Add an new item', null); select acs_privilege__create_privilege('cal_item_read', 'view an cal_item', null); select acs_privilege__create_privilege('cal_item_write', 'Edit an existing cal_item', null); select acs_privilege__create_privilege('cal_item_delete', 'Delete cal_item', null ); - select acs_privilege__create_privilege('cal_item_invite', 'Allow others to view cal_item', null); + select acs_privilege__create_privilege('cal_item_invite', 'Allow others to view cal_item', null); - select acs_privilege__add_child('create', 'cal_item_create'); - select acs_privilege__add_child('read', 'cal_item_read'); - select acs_privilege__add_child('write', 'cal_item_write'); + select acs_privilege__add_child('create', 'cal_item_create'); + select acs_privilege__add_child('read', 'cal_item_read'); + select acs_privilege__add_child('write', 'cal_item_write'); - select acs_privilege__add_child('delete', 'cal_item_delete'); - - select acs_privilege__create_privilege('calendar_on', 'Implies that a calendar is selected', null); + select acs_privilege__add_child('delete', 'cal_item_delete'); + + select acs_privilege__create_privilege('calendar_on', 'Implies that a calendar is selected', null); select acs_privilege__create_privilege('calendar_show', 'Show a calendar', null); - select acs_privilege__add_child('read', 'calendar_on'); - select acs_privilege__add_child('read', 'calendar_show'); - + select acs_privilege__add_child('read', 'calendar_on'); + select acs_privilege__add_child('read', 'calendar_show'); + select acs_privilege__create_privilege('calendar_create', 'Create a new calendar', null); - select acs_privilege__create_privilege('calendar_read', 'View items on an existing calendar', null); + select acs_privilege__create_privilege('calendar_read', 'View items on an existing calendar', null); select acs_privilege__create_privilege('calendar_write', 'Edit items of an existing calendar', null); select acs_privilege__create_privilege('calendar_delete','Delete an calendar', null); @@ -52,7 +52,7 @@ select acs_privilege__add_child('calendar_read', 'cal_item_read'); select acs_privilege__add_child('calendar_write', 'cal_item_write'); select acs_privilege__add_child('calendar_delete', 'cal_item_delete'); - + select acs_privilege__create_privilege('calendar_admin', 'calendar administrator', null); select acs_privilege__add_child('admin', 'calendar_admin'); select acs_privilege__add_child('calendar_admin', 'calendar_read'); @@ -61,16 +61,16 @@ select acs_privilege__add_child('calendar_admin', 'calendar_create'); select acs_privilege__add_child('calendar_admin', 'cal_item_invite'); ----------------------------------------------------------- +---------------------------------------------------------- -- calendar_object ------------------------------------------------------------ +----------------------------------------------------------- create or replace function inline_0( ) returns integer AS $$ declare attr_id acs_attributes.attribute_id%TYPE; begin - PERFORM + PERFORM acs_object_type__create_type( 'calendar', -- object_type 'Calendar', -- pretty_name @@ -83,53 +83,53 @@ null, -- type_extension_table null -- name_method ); - + attr_id := acs_attribute__create_attribute ( 'calendar', -- object_type - 'owner_id', -- attribute_name - 'integer', -- datatype - 'Owner', -- pretty_name - 'Owners', -- pretty_plural - null, -- table_name (default) - null, -- column_name (default) - null, -- default_value (default) - 1, -- min_n_values (default) - 1, -- max_n_values (default) - null, -- sort_order (default) - 'type_specific', -- storage (default) - 'f' -- static_p (default) + 'owner_id', -- attribute_name + 'integer', -- datatype + 'Owner', -- pretty_name + 'Owners', -- pretty_plural + null, -- table_name (default) + null, -- column_name (default) + null, -- default_value (default) + 1, -- min_n_values (default) + 1, -- max_n_values (default) + null, -- sort_order (default) + 'type_specific', -- storage (default) + 'f' -- static_p (default) ); attr_id := acs_attribute__create_attribute ( 'calendar', -- object_type - 'private_p', -- attribute_name - 'string', -- datatype - 'Private Calendar', -- pretty_name - 'Private Calendars', -- pretty_plural - null, -- table_name (default) - null, -- column_name (default) - null, -- default_value (default) - 1, -- min_n_values (default) - 1, -- max_n_values (default) - null, -- sort_order (default) - 'type_specific', -- storage (default) - 'f' -- static_p (default) + 'private_p', -- attribute_name + 'string', -- datatype + 'Private Calendar', -- pretty_name + 'Private Calendars', -- pretty_plural + null, -- table_name (default) + null, -- column_name (default) + null, -- default_value (default) + 1, -- min_n_values (default) + 1, -- max_n_values (default) + null, -- sort_order (default) + 'type_specific', -- storage (default) + 'f' -- static_p (default) ); attr_id := acs_attribute__create_attribute ( 'calendar', -- object_type - 'calendar_name', -- attribute_name - 'string', -- datatype - 'Calendar Name', -- pretty_name - 'Calendar Names', -- pretty_plural - null, -- table_name (default) - null, -- column_name (default) - null, -- default_value (default) - 1, -- min_n_values (default) - 1, -- max_n_values (default) - null, -- sort_order (default) - 'type_specific', -- storage (default) - 'f' -- static_p (default) + 'calendar_name', -- attribute_name + 'string', -- datatype + 'Calendar Name', -- pretty_name + 'Calendar Names', -- pretty_plural + null, -- table_name (default) + null, -- column_name (default) + null, -- default_value (default) + 1, -- min_n_values (default) + 1, -- max_n_values (default) + null, -- sort_order (default) + 'type_specific', -- storage (default) + 'f' -- static_p (default) ); return 0; @@ -143,55 +143,55 @@ -- Calendar is a collection of events. Each calendar must -- belong to somebody (a party). create table calendars ( - -- primary key - calendar_id integer - constraint calendars_calendar_id_fk - references acs_objects - constraint calendars_calendar_id_pk - primary key, - -- the name of the calendar - calendar_name varchar(200), - -- the individual or party that owns the calendar - owner_id integer - constraint calendars_calendar_owner_id_fk - references parties - on delete cascade, - -- keep track of package instances - package_id integer - constraint calendars_package_id_fk - references apm_packages(package_id) - on delete cascade, - -- whether or not the calendar is a private personal calendar or a - -- public calendar. - private_p boolean - default 'f' - constraint calendars_private_p_ck - check (private_p in ( - 't', - 'f' - ) - ) + -- primary key + calendar_id integer + constraint calendars_calendar_id_fk + references acs_objects + constraint calendars_calendar_id_pk + primary key, + -- the name of the calendar + calendar_name varchar(200), + -- the individual or party that owns the calendar + owner_id integer + constraint calendars_calendar_owner_id_fk + references parties + on delete cascade, + -- keep track of package instances + package_id integer + constraint calendars_package_id_fk + references apm_packages(package_id) + on delete cascade, + -- whether or not the calendar is a private personal calendar or a + -- public calendar. + private_p boolean + default 'f' + constraint calendars_private_p_ck + check (private_p in ( + 't', + 'f' + ) + ) ); comment on table calendars is ' - Table calendars maps the many to many relationship betweens - calendar and its owners. + Table calendars maps the many to many relationship betweens + calendar and its owners. '; comment on column calendars.calendar_id is ' - Primary Key + Primary Key '; comment on column calendars.calendar_name is ' - the name of the calendar. This would be unique to avoid confusion + the name of the calendar. This would be unique to avoid confusion '; comment on column calendars.owner_id is ' - the individual or party that owns the calendar + the individual or party that owns the calendar '; comment on column calendars.package_id is ' - keep track of package instances + keep track of package instances '; @@ -201,11 +201,11 @@ create table cal_item_types ( item_type_id integer not null - constraint cal_item_type_id_pk - primary key, + constraint cal_item_type_id_pk + primary key, calendar_id integer not null - constraint cal_item_type_cal_id_fk - references calendars(calendar_id), + constraint cal_item_type_cal_id_fk + references calendars(calendar_id), type varchar(100) not null, -- this constraint is obvious given that item_type_id -- is unique, but it's necessary to allow strong @@ -244,24 +244,24 @@ declare v_calendar_id calendars.calendar_id%TYPE; begin - v_calendar_id := acs_object__new( + v_calendar_id := acs_object__new( new__calendar_id, new__object_type, new__creation_date, new__creation_user, new__creation_ip, new__context_id ); - + insert into calendars - (calendar_id, calendar_name, owner_id, package_id, private_p) + (calendar_id, calendar_name, owner_id, package_id, private_p) values (v_calendar_id, new__calendar_name, new__owner_id, new__package_id, new__private_p); - + PERFORM acs_permission__grant_permission ( - v_calendar_id, - new__owner_id, - 'calendar_admin' - ); + v_calendar_id, + new__owner_id, + 'calendar_admin' + ); return v_calendar_id; @@ -285,30 +285,30 @@ where calendar_id = delete__calendar_id; -- Delete all privileges associate with this calendar - - delete from acs_permissions - where object_id = delete__calendar_id; - delete from acs_permissions - where object_id in ( + delete from acs_permissions + where object_id = delete__calendar_id; + + delete from acs_permissions + where object_id in ( select cal_item_id - from cal_items - where on_which_calendar = delete__calendar_id + from cal_items + where on_which_calendar = delete__calendar_id ); - + PERFORM acs_object__delete(delete__calendar_id); return 0; end; $$ LANGUAGE plpgsql; - + ----------------------------------------------------------------- -- load related sql files ----------------------------------------------------------------- --\i cal-item-create.sql --- +-- \i cal-table-create.sql \i calendar-notifications-init.sql Index: openacs-4/packages/calendar/tcl/cal-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/cal-item-procs.tcl,v diff -u -r1.29 -r1.30 --- openacs-4/packages/calendar/tcl/cal-item-procs.tcl 22 Apr 2018 18:02:52 -0000 1.29 +++ openacs-4/packages/calendar/tcl/cal-item-procs.tcl 22 Apr 2018 18:05:23 -0000 1.30 @@ -19,7 +19,7 @@ {-start_date:required} {-end_date:required} } { - A sanity check that the start time is before the end time. + A sanity check that the start time is before the end time. } { return [db_string dates_valid_p_select {}] } @@ -31,10 +31,10 @@ {-description:required} {-calendar_id ""} {-item_type_id ""} - {-package_id ""} + {-package_id ""} {-location ""} {-cal_uid ""} - {-ical_vars ""} + {-ical_vars ""} } { Insert a new calendar item into the database } { @@ -52,32 +52,32 @@ # together with the ical_vars. # if {$cal_uid ne ""} { - db_dml insert_cal_uid {} + db_dml insert_cal_uid {} } - + # Convert from user timezone to system timezone if { $start_date ne $end_date } { # Convert to server timezone only if it's not an all-day event # otherwise, keep the start and end time as 00:00 set start_date [lc_time_conn_to_system $start_date] - set end_date [lc_time_conn_to_system $end_date] + set end_date [lc_time_conn_to_system $end_date] } set timespan_id [db_exec_plsql insert_timespan {}] - + # create the cal_item # we are leaving the name and description fields in acs_event # blank to abide by the definition that an acs_event is an acs_activity # with added on temporal information - - # by default, the cal_item permissions + + # by default, the cal_item permissions # are going to be inherited from the calendar permissions set cal_item_id [db_exec_plsql cal_item_add {}] - - db_dml set_item_type_id "update cal_items set item_type_id=:item_type_id where cal_item_id=:cal_item_id" + db_dml set_item_type_id "update cal_items set item_type_id=:item_type_id where cal_item_id=:cal_item_id" + # removing inherited permissions if { $calendar_id ne "" && [calendar::personal_p -calendar_id $calendar_id] } { permission::set_not_inherit -object_id $cal_item_id @@ -120,11 +120,11 @@ db_1row $query_name {} -column_array row if {$normalize_time_to_utc} { - set row(start_date_ansi) [lc_time_local_to_utc $row(start_date_ansi)] - set row(end_date_ansi) [lc_time_local_to_utc $row(end_date_ansi)] + set row(start_date_ansi) [lc_time_local_to_utc $row(start_date_ansi)] + set row(end_date_ansi) [lc_time_local_to_utc $row(end_date_ansi)] } else { - set row(start_date_ansi) [lc_time_system_to_conn $row(start_date_ansi)] - set row(end_date_ansi) [lc_time_system_to_conn $row(end_date_ansi)] + set row(start_date_ansi) [lc_time_system_to_conn $row(start_date_ansi)] + set row(end_date_ansi) [lc_time_system_to_conn $row(end_date_ansi)] } if { $row(start_date_ansi) eq $row(end_date_ansi) } { @@ -148,7 +148,7 @@ set row(full_end_date) [lc_time_fmt $row(end_date_ansi) "%x"] set row(end_time) [lc_time_fmt $row(end_date_ansi) "%X"] - + return [array get row] } @@ -166,7 +166,7 @@ db_dml update_event {} db_exec_plsql insert_instances {} - + # Make sure they're all in the calendar! db_dml insert_cal_items {} } @@ -219,7 +219,7 @@ # otherwise, keep the start and end time as 00:00 set start_date [lc_time_conn_to_system $start_date] - set end_date [lc_time_conn_to_system $end_date] + set end_date [lc_time_conn_to_system $end_date] } db_dml update_event {} @@ -247,7 +247,7 @@ # call edit procedure db_exec_plsql update_interval {} - + # Update the item_type_id and calendar_id set colspecs [list] lappend colspecs "item_type_id = :item_type_id" @@ -260,7 +260,7 @@ where object_id = :cal_item_id } } - + db_dml update_item_type_id [subst { update cal_items set [join $colspecs ", "] @@ -283,18 +283,18 @@ db_exec_plsql delete_cal_item {} } -ad_proc calendar::item::assign_permission { cal_item_id +ad_proc calendar::item::assign_permission { cal_item_id party_id - permission + permission {revoke ""} } { update the permission of the specific cal_item if revoke is set to revoke, then we revoke all permissions } { if { $revoke ne "revoke" } { - if { $permission ne "cal_item_read" } { + if { $permission ne "cal_item_read" } { permission::grant -object_id $cal_item_id -party_id $party_id -privilege cal_item_read - } + } permission::grant -object_id $cal_item_id -party_id $party_id -privilege $permission } elseif {$revoke eq "revoke"} { permission::revoke -object_id $cal_item_id -party_id $party_id -privilege $permission @@ -332,7 +332,7 @@ calendar::item::get \ -cal_item_id $event_id \ -array orig_event - + set colspecs [list] foreach col {name description} { if {$orig_event($col) ne [set $col]} { @@ -342,7 +342,7 @@ if {[llength $colspecs]} { db_dml recurrence_events_update {} } - set colspecs [list] + set colspecs [list] lappend colspecs {item_type_id = :item_type_id} if { $calendar_id ne "" } { lappend colspecs {on_which_calendar = :calendar_id}