Index: openacs-4/packages/calendar/sql/postgresql/cal-item-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/sql/postgresql/cal-item-create.sql,v diff -u -N -r1.15 -r1.16 --- openacs-4/packages/calendar/sql/postgresql/cal-item-create.sql 7 Aug 2017 23:48:05 -0000 1.15 +++ openacs-4/packages/calendar/sql/postgresql/cal-item-create.sql 4 Sep 2017 08:10:38 -0000 1.16 @@ -11,8 +11,8 @@ -- cal_item_ojbect ---------------------------------------------------------- -CREATE OR REPLACE FUNCTION inline_0 () RETURNS integer AS $$ -BEGIN +create or replace function inline_0 () returns integer AS $$ +begin PERFORM acs_object_type__create_type ( 'cal_item', -- object_type 'Calendar Item', -- pretty_name @@ -26,15 +26,15 @@ null -- name_method ); return 0; -END; +end; $$ LANGUAGE plpgsql; SELECT inline_0 (); DROP FUNCTION inline_0 (); -CREATE OR REPLACE FUNCTION inline_1 () RETURNS integer AS $$ -BEGIN +create or replace function inline_1 () returns integer AS $$ +begin PERFORM acs_attribute__create_attribute ( 'cal_item', -- object_type 'on_which_calendar', -- attribute_name @@ -51,7 +51,7 @@ 'f' -- static_p (default) ); return 0; -END; +end; $$ LANGUAGE plpgsql; SELECT inline_1 (); @@ -109,7 +109,7 @@ select define_function_args('cal_item__new','cal_item_id;null,on_which_calendar;null,name,description,html_p;null,status_summary;null,timespan_id;null,activity_id;null,recurrence_id;null,object_type;"cal_item",context_id;null,creation_date;now(),creation_user;null,creation_ip;null'); -CREATE OR REPLACE FUNCTION cal_item__new( +create or replace function cal_item__new( new__cal_item_id integer, -- default null new__on_which_calendar integer, -- default null new__name varchar, @@ -126,11 +126,11 @@ integer, -- default null new__creation_ip varchar -- default null -) RETURNS integer AS $$ -DECLARE +) returns integer AS $$ +declare v_cal_item_id cal_items.cal_item_id%TYPE; -BEGIN +begin v_cal_item_id := acs_event__new( new__cal_item_id, -- event_id new__name, -- name @@ -154,7 +154,7 @@ return v_cal_item_id; -END; +end; $$ LANGUAGE plpgsql; @@ -167,11 +167,11 @@ -- select define_function_args('cal_item__delete','cal_item_id'); -CREATE OR REPLACE FUNCTION cal_item__delete( +create or replace function cal_item__delete( delete__cal_item_id integer -) RETURNS integer AS $$ -DECLARE -BEGIN +) returns integer AS $$ +declare +begin -- Erase the cal_item associated with the id delete from cal_items where cal_item_id = delete__cal_item_id; @@ -183,7 +183,7 @@ PERFORM acs_event__delete(delete__cal_item_id); return 0; -END; +end; $$ LANGUAGE plpgsql; @@ -193,12 +193,12 @@ -- select define_function_args('cal_item__delete_all','recurrence_id'); -CREATE OR REPLACE FUNCTION cal_item__delete_all( +create or replace function cal_item__delete_all( delete__recurrence_id integer -) RETURNS integer AS $$ -DECLARE +) returns integer AS $$ +declare v_event RECORD; -BEGIN +begin for v_event in select event_id from acs_events where recurrence_id= delete__recurrence_id @@ -210,5 +210,5 @@ return 0; -END; +end; $$ LANGUAGE plpgsql; 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 -N -r1.15 -r1.16 --- openacs-4/packages/calendar/sql/postgresql/calendar-create.sql 7 Aug 2017 23:48:05 -0000 1.15 +++ openacs-4/packages/calendar/sql/postgresql/calendar-create.sql 4 Sep 2017 08:10:38 -0000 1.16 @@ -65,76 +65,76 @@ -- calendar_ojbect ----------------------------------------------------------- -CREATE FUNCTION inline_0() -RETURNS integer -AS 'declare +create or replace function inline_0( +) returns integer AS $$ +declare attr_id acs_attributes.attribute_id%TYPE; - begin +begin PERFORM acs_object_type__create_type( - ''calendar'', -- object_type - ''Calendar'', -- pretty_name - ''Calendar'', -- pretty_plural - ''acs_object'', -- supertype - ''calendars'', -- table_name - ''calendar_id'',-- id_column + 'calendar', -- object_type + 'Calendar', -- pretty_name + 'Calendar', -- pretty_plural + 'acs_object', -- supertype + 'calendars', -- table_name + 'calendar_id', -- id_column null, -- package_name - ''f'', -- abstract_p + 'f', -- abstract_p 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) + '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) ); attr_id := acs_attribute__create_attribute ( - ''calendar'', -- object_type - ''private_p'', -- attribute_name - ''string'', -- datatype - ''Private Calendar'', -- pretty_name - ''Private Calendars'', -- pretty_plural + '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) + '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 + '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) + 'type_specific', -- storage (default) + 'f' -- static_p (default) ); return 0; - end;' -LANGUAGE 'plpgsql'; +end; +$$ LANGUAGE plpgsql; SELECT inline_0(); @@ -224,33 +224,26 @@ select define_function_args ('calendar__new', 'calendar_id,calendar_name,object_type;calendar,owner_id,private_p,package_id,context_id,creation_date,creation_user,creation_ip'); -CREATE FUNCTION calendar__new ( - integer, -- calendar.calendar_id%TYPE - varchar(200), -- calendar.calendar_name%TYPE - varchar, -- acs_objects.object_type%TYPE - integer, -- calendar.owner_id%TYPE - boolean, -- calendar.private_p - integer, -- calendar.package_id - integer, -- acs_objects.context_id%TYPE - timestamptz, -- acs_objects.creation_date%TYPE - integer, -- acs_objects.creation_user%TYPE - varchar -- acs_objects.creation_ip%TYPE -) -RETURNS integer -AS 'declare - v_calendar_id calendars.calendar_id%TYPE; - new__calendar_id alias for $1; - new__calendar_name alias for $2; - new__object_type alias for $3; - new__owner_id alias for $4; - new__private_p alias for $5; - new__package_id alias for $6; - new__context_id alias for $7; - new__creation_date alias for $8; - new__creation_user alias for $9; - new__creation_ip alias for $10; +-- +-- procedure calendar__new/10 +-- - begin +create or replace function calendar__new( + new__calendar_id integer, + new__calendar_name varchar(200), + new__object_type varchar, -- default 'calendar' + new__owner_id integer, + new__private_p boolean, + new__package_id integer, + new__context_id integer, + new__creation_date timestamptz, + new__creation_user integer, + new__creation_ip varchar + +) returns integer AS $$ +declare + v_calendar_id calendars.calendar_id%TYPE; +begin v_calendar_id := acs_object__new( new__calendar_id, new__object_type, @@ -267,23 +260,27 @@ PERFORM acs_permission__grant_permission ( v_calendar_id, new__owner_id, - ''calendar_admin'' + 'calendar_admin' ); return v_calendar_id; - end;' -LANGUAGE 'plpgsql'; +end; +$$ LANGUAGE plpgsql; + +-- +-- procedure calendar__delete/1 +-- + select define_function_args('calendar__delete','calendar_id'); -CREATE FUNCTION calendar__delete( +create or replace function calendar__delete( integer -- calendar.calendar_id%TYPE -) -RETURNS integer -AS 'declare +) returns integer AS $$ +declare delete__calendar_id alias for $1; - begin +begin delete from calendars where calendar_id = delete__calendar_id; @@ -302,8 +299,8 @@ PERFORM acs_object__delete(delete__calendar_id); return 0; - end;' -LANGUAGE 'plpgsql'; +end; +$$ LANGUAGE plpgsql; Index: openacs-4/packages/calendar/sql/postgresql/calendar-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/sql/postgresql/calendar-drop.sql,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/calendar/sql/postgresql/calendar-drop.sql 10 Jan 2004 18:57:24 -0000 1.7 +++ openacs-4/packages/calendar/sql/postgresql/calendar-drop.sql 4 Sep 2017 08:10:38 -0000 1.8 @@ -113,24 +113,23 @@ ------------------------------------------------ DROP TABLE calendars; -CREATE FUNCTION inline_0 () -RETURNS integer -AS 'begin - PERFORM acs_attribute__drop_attribute (''calendar'',''owner_id''); - PERFORM acs_attribute__drop_attribute (''calendar'',''private_p''); - DELETE FROM acs_objects WHERE object_type = ''calendar''; - PERFORM acs_object_type__drop_type (''calendar'', ''f''); +CREATE OR REPLACE FUNCTION inline_0 () RETURNS integer AS $$ +BEGIN + PERFORM acs_attribute__drop_attribute ('calendar','owner_id'); + PERFORM acs_attribute__drop_attribute ('calendar','private_p'); + DELETE FROM acs_objects WHERE object_type = 'calendar'; + PERFORM acs_object_type__drop_type ('calendar', 'f'); + return 0; - end;' -LANGUAGE 'plpgsql'; +END; +$$ LANGUAGE plpgsql; SELECT inline_0 (); - DROP FUNCTION inline_0 (); -DELETE FROM acs_objects WHERE object_type='calendar'; +DELETE FROM acs_objects WHERE object_type = 'calendar'; DROP FUNCTION calendar__new ( integer, -- calendar.calendar_id%TYPE Index: openacs-4/packages/calendar/sql/postgresql/calendar-notifications-init.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/sql/postgresql/calendar-notifications-init.sql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/calendar/sql/postgresql/calendar-notifications-init.sql 12 Aug 2013 09:34:30 -0000 1.2 +++ openacs-4/packages/calendar/sql/postgresql/calendar-notifications-init.sql 4 Sep 2017 08:10:38 -0000 1.3 @@ -5,13 +5,12 @@ -- -- procedure inline_0/0 -- -CREATE OR REPLACE FUNCTION inline_0( - -) RETURNS integer AS $$ -DECLARE +create or replace function inline_0( +) returns integer AS $$ +declare impl_id integer; v_notification_id integer; -BEGIN +begin -- the notification type impl impl_id := acs_sc_impl__new ( 'NotificationType', @@ -64,9 +63,9 @@ from notification_delivery_methods where short_name in ('email'); return (0); -END; +end; $$ LANGUAGE plpgsql; select inline_0(); -drop function inline_0(); \ No newline at end of file +drop function inline_0();