Index: openacs-4/packages/acs-subsite/sql/postgresql/application-groups-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/sql/postgresql/application-groups-create.sql,v diff -u -r1.12 -r1.13 --- openacs-4/packages/acs-subsite/sql/postgresql/application-groups-create.sql 10 Feb 2009 18:31:54 -0000 1.12 +++ openacs-4/packages/acs-subsite/sql/postgresql/application-groups-create.sql 30 Mar 2013 18:04:20 -0000 1.13 @@ -36,24 +36,34 @@ unique (package_id) ); -select define_function_args('application_group__new','group_id,object_type;application_group,creation_date;now(),creation_user,creation_ip,email,url,group_name,package_id,join_policy,context_id'); -create function application_group__new(integer,varchar,timestamptz,integer,varchar,varchar,varchar,varchar,integer,varchar,integer) -returns integer as ' -declare - new__group_id alias for $1; - new__object_type alias for $2; -- default ''application_group'', - new__creation_date alias for $3; -- default sysdate, - new__creation_user alias for $4; -- default null, - new__creation_ip alias for $5; -- default null, - new__email alias for $6; -- default null, - new__url alias for $7; -- default null, - new__group_name alias for $8; - new__package_id alias for $9; - new__join_policy alias for $10; - new__context_id alias for $11; -- default null +-- old define_function_args('application_group__new','group_id,object_type;application_group,creation_date;now(),creation_user,creation_ip,email,url,group_name,package_id,join_policy,context_id') +-- new +select define_function_args('application_group__new','group_id,object_type;application_group,creation_date;now(),creation_user;null,creation_ip;null,email;null,url;null,group_name,package_id,join_policy,context_id;null'); + + + + +-- +-- procedure application_group__new/11 +-- +CREATE OR REPLACE FUNCTION application_group__new( + new__group_id integer, + new__object_type varchar, -- default 'application_group', + new__creation_date timestamptz, -- default sysdate, -- default 'now()' + new__creation_user integer, -- default null, + new__creation_ip varchar, -- default null, + new__email varchar, -- default null, + new__url varchar, -- default null, + new__group_name varchar, + new__package_id integer, + new__join_policy varchar, + new__context_id integer -- default null + +) RETURNS integer AS $$ +DECLARE v_group_id application_groups.group_id%TYPE; -begin +BEGIN v_group_id := acs_group__new ( new__group_id, new__object_type, @@ -72,27 +82,46 @@ return v_group_id; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; -create function application_group__delete(integer) -returns integer as ' -declare - group_id alias for $1; -begin + + +-- added +select define_function_args('application_group__delete','group_id'); + +-- +-- procedure application_group__delete/1 +-- +CREATE OR REPLACE FUNCTION application_group__delete( + group_id integer +) RETURNS integer AS $$ +DECLARE +BEGIN PERFORM acs_group__delete(group_id); return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; -create function application_group__group_id_from_package_id(integer,boolean) -returns integer as ' -declare - group_id_from_package_id__package_id alias for $1; - group_id_from_package_id__no_complain_p alias for $2; -- default ''f'' + + +-- added +select define_function_args('application_group__group_id_from_package_id','package_id,no_complain_p;f'); + +-- +-- procedure application_group__group_id_from_package_id/2 +-- +CREATE OR REPLACE FUNCTION application_group__group_id_from_package_id( + group_id_from_package_id__package_id integer, + group_id_from_package_id__no_complain_p boolean -- default 'f' + +) RETURNS integer AS $$ +DECLARE v_group_id application_groups.group_id%TYPE; v_object_name varchar; -begin +BEGIN select group_id into v_group_id @@ -103,16 +132,17 @@ -- return v_group_id; if not found then - if group_id_from_package_id__no_complain_p != ''t'' then + if group_id_from_package_id__no_complain_p != 't' then v_object_name := acs_object__name(group_id_from_package_id__package_id); - raise EXCEPTION ''-20000: No group_id found for package % (%)'', group_id_from_package_id__package_id, v_object_name; + raise EXCEPTION '-20000: No group_id found for package % (%)', group_id_from_package_id__package_id, v_object_name; end if; return null; else return v_group_id; end if; -end;' language 'plpgsql' stable; +END; +$$ LANGUAGE plpgsql stable; insert into group_type_rels (group_rel_type_id, group_type, rel_type) Index: openacs-4/packages/acs-subsite/sql/postgresql/email-image.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/sql/postgresql/email-image.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-subsite/sql/postgresql/email-image.sql 25 Sep 2006 21:16:34 -0000 1.2 +++ openacs-4/packages/acs-subsite/sql/postgresql/email-image.sql 30 Mar 2013 18:04:20 -0000 1.3 @@ -10,31 +10,31 @@ primary key ); -create function inline_0 () -returns integer as ' -begin - PERFORM acs_rel_type__create_role(''email_image'', ''Email Image'', ''Email Images''); +CREATE OR REPLACE FUNCTION inline_0 () RETURNS integer AS $$ +BEGIN + PERFORM acs_rel_type__create_role('email_image', 'Email Image', 'Email Images'); PERFORM acs_rel_type__create_type ( - ''email_image_rel'', - ''Email Image'', - ''Email Images'', - ''relationship'', - ''email_images'', - ''user_id'', - ''email_image_rel'', - ''user'', - ''user'', + 'email_image_rel', + 'Email Image', + 'Email Images', + 'relationship', + 'email_images', + 'user_id', + 'email_image_rel', + 'user', + 'user', 1, 1, - ''content_item'', + 'content_item', null, 0, 1 ); return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select inline_0 (); Index: openacs-4/packages/acs-subsite/sql/postgresql/portraits.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/sql/postgresql/portraits.sql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-subsite/sql/postgresql/portraits.sql 25 Sep 2006 21:16:34 -0000 1.4 +++ openacs-4/packages/acs-subsite/sql/postgresql/portraits.sql 30 Mar 2013 18:04:20 -0000 1.5 @@ -37,32 +37,32 @@ -- / -- show errors -create function inline_0 () -returns integer as ' -begin - PERFORM acs_rel_type__create_role(''user'', ''User'', ''Users''); - PERFORM acs_rel_type__create_role(''portrait'', ''Portrait'', ''Portraits''); +CREATE OR REPLACE FUNCTION inline_0 () RETURNS integer AS $$ +BEGIN + PERFORM acs_rel_type__create_role('user', 'User', 'Users'); + PERFORM acs_rel_type__create_role('portrait', 'Portrait', 'Portraits'); PERFORM acs_rel_type__create_type ( - ''user_portrait_rel'', - ''#acs-subsite.User_Portrait#'', - ''#acs-subsite.User_Portraits#'', - ''relationship'', - ''user_portraits'', - ''user_id'', - ''user_portrait_rel'', - ''user'', - ''user'', + 'user_portrait_rel', + '#acs-subsite.User_Portrait#', + '#acs-subsite.User_Portraits#', + 'relationship', + 'user_portraits', + 'user_id', + 'user_portrait_rel', + 'user', + 'user', 1, 1, - ''content_item'', + 'content_item', null, 0, 1 ); return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select inline_0 (); Index: openacs-4/packages/acs-subsite/sql/postgresql/subsite-callbacks-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/sql/postgresql/subsite-callbacks-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-subsite/sql/postgresql/subsite-callbacks-create.sql 10 Feb 2009 18:31:54 -0000 1.3 +++ openacs-4/packages/acs-subsite/sql/postgresql/subsite-callbacks-create.sql 30 Mar 2013 18:04:20 -0000 1.4 @@ -163,21 +163,30 @@ -- END new; -create function subsite_callback__new(integer,varchar,varchar,varchar,varchar,integer) -returns integer as ' -declare - new__callback_id alias for $1; -- default null, - new__event_type alias for $2; - new__object_type alias for $3; - new__callback alias for $4; - new__callback_type alias for $5; - new__sort_order alias for $6; -- default null + + +-- added +select define_function_args('subsite_callback__new','callback_id;null,event_type,object_type,callback,callback_type,sort_order;null'); + +-- +-- procedure subsite_callback__new/6 +-- +CREATE OR REPLACE FUNCTION subsite_callback__new( + new__callback_id integer, -- default null, + new__event_type varchar, + new__object_type varchar, + new__callback varchar, + new__callback_type varchar, + new__sort_order integer -- default null + +) RETURNS integer AS $$ +DECLARE v_callback_id subsite_callbacks.callback_id%TYPE; v_sort_order subsite_callbacks.sort_order%TYPE; -begin +BEGIN if new__callback_id is null then - select nextval(''t_acs_object_id_seq'') into v_callback_id; + select nextval('t_acs_object_id_seq') into v_callback_id; else v_callback_id := new__callback_id; end if; @@ -210,7 +219,8 @@ -- end; return v_callback_id; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; -- procedure delete ( -- callback_id IN subsite_callbacks.callback_id%TYPE @@ -220,14 +230,23 @@ -- delete from subsite_callbacks where callback_id=subsite_callback.delete.callback_id; -- end delete; -create function subsite_callback__delete(integer) -returns integer as ' -declare - delete__callback_id alias for $1; -begin + + +-- added +select define_function_args('subsite_callback__delete','callback_id'); + +-- +-- procedure subsite_callback__delete/1 +-- +CREATE OR REPLACE FUNCTION subsite_callback__delete( + delete__callback_id integer +) RETURNS integer AS $$ +DECLARE +BEGIN delete from subsite_callbacks where callback_id = delete__callback_id; return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; -- end subsite_callback; -- / Index: openacs-4/packages/acs-subsite/sql/postgresql/user-profiles-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/sql/postgresql/user-profiles-create.sql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-subsite/sql/postgresql/user-profiles-create.sql 10 Feb 2009 18:31:54 -0000 1.6 +++ openacs-4/packages/acs-subsite/sql/postgresql/user-profiles-create.sql 30 Mar 2013 18:04:20 -0000 1.7 @@ -42,35 +42,35 @@ -- / -- show errors -create function inline_0 () -returns integer as ' -begin - -- the ''user'' role should already exist from the portraits stuff. - -- acs_rel_type.create_role(''user'', - -- ''Registered User'', ''Registered Users''); +CREATE OR REPLACE FUNCTION inline_0 () RETURNS integer AS $$ +BEGIN + -- the 'user' role should already exist from the portraits stuff. + -- acs_rel_type.create_role('user', + -- 'Registered User', 'Registered Users'); - PERFORM acs_rel_type__create_role(''application'', ''Application Group'', ''Application Group''); + PERFORM acs_rel_type__create_role('application', 'Application Group', 'Application Group'); PERFORM acs_rel_type__create_type ( - ''user_profile'', - ''#acs-subsite.User_Profile#'', - ''#acs-subsite.User_Profiles#'', - ''membership_rel'', - ''user_profiles'', - ''profile_id'', - ''user_profile'', - ''application_group'', - ''application'', + 'user_profile', + '#acs-subsite.User_Profile#', + '#acs-subsite.User_Profiles#', + 'membership_rel', + 'user_profiles', + 'profile_id', + 'user_profile', + 'application_group', + 'application', 0, null, - ''user'', - ''user'', + 'user', + 'user', 0, null ); return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select inline_0 (); @@ -137,20 +137,30 @@ -- return v_profile_id; -- end new; -select define_function_args('user_profile__new','profile_id,rel_type;user_profile,object_id_one,object_id_two,member_state,creation_user,creation_ip'); -create function user_profile__new(integer,varchar,integer,integer,varchar,integer,varchar) -returns integer as ' -declare - new__profile_id alias for $1; -- default null, - new__rel_type alias for $2; -- default ''user_profile'', - new__object_id_one alias for $3; - new__object_id_two alias for $4; - new__member_state alias for $5; -- default null, - new__creation_user alias for $6; -- default null, - new__creation_ip alias for $7; -- default null +-- old define_function_args('user_profile__new','profile_id,rel_type;user_profile,object_id_one,object_id_two,member_state,creation_user,creation_ip') +-- new +select define_function_args('user_profile__new','profile_id;null,rel_type;user_profile,object_id_one,object_id_two,member_state;null,creation_user;null,creation_ip;null'); + + + + +-- +-- procedure user_profile__new/7 +-- +CREATE OR REPLACE FUNCTION user_profile__new( + new__profile_id integer, -- default null, + new__rel_type varchar, -- default 'user_profile', + new__object_id_one integer, + new__object_id_two integer, + new__member_state varchar, -- default null, + new__creation_user integer, -- default null, + new__creation_ip varchar -- default null + +) RETURNS integer AS $$ +DECLARE v_profile_id integer; -begin +BEGIN v_profile_id := membership_rel__new ( new__profile_id, new__rel_type, @@ -164,7 +174,8 @@ insert into user_profiles (profile_id) values (v_profile_id); return v_profile_id; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; -- procedure delete ( -- profile_id in user_profiles.profile_id%TYPE @@ -176,16 +187,25 @@ -- end delete; -create function user_profile__delete(integer) -returns integer as ' -declare - profile_id alias for $1; -begin + +-- added +select define_function_args('user_profile__delete','profile_id'); + +-- +-- procedure user_profile__delete/1 +-- +CREATE OR REPLACE FUNCTION user_profile__delete( + profile_id integer +) RETURNS integer AS $$ +DECLARE +BEGIN + PERFORM membership_rel__delete(profile_id); return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; -- end user_profile; -- / Index: openacs-4/packages/acs-subsite/sql/postgresql/user-sc-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/sql/postgresql/user-sc-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-subsite/sql/postgresql/user-sc-create.sql 8 Jul 2002 16:42:44 -0000 1.1 +++ openacs-4/packages/acs-subsite/sql/postgresql/user-sc-create.sql 30 Mar 2013 18:04:20 -0000 1.2 @@ -13,134 +13,141 @@ -- ported by dan chak (chak@openforce.net) -- Jan 22, 2002 -create function inline_0() -returns integer as ' -declare + + +-- +-- procedure inline_0/0 +-- +CREATE OR REPLACE FUNCTION inline_0( + +) RETURNS integer AS $$ +DECLARE foo integer; -begin +BEGIN foo := acs_sc_contract__new( - ''UserData'', - ''User Data Updates'' + 'UserData', + 'User Data Updates' ); -- The UserNew operation foo := acs_sc_msg_type__new( - ''UserData.UserNew.InputType'', - ''user_id:integer'' + 'UserData.UserNew.InputType', + 'user_id:integer' ); foo := acs_sc_msg_type__new( - ''UserData.UserNew.OutputType'', - '''' + 'UserData.UserNew.OutputType', + '' ); foo := acs_sc_operation__new( - ''UserData'', - ''UserNew'', - ''Notify that a new user has been created'', - ''f'', + 'UserData', + 'UserNew', + 'Notify that a new user has been created', + 'f', 1, - ''UserData.UserNew.InputType'', - ''UserData.UserNew.OutputType'' + 'UserData.UserNew.InputType', + 'UserData.UserNew.OutputType' ); -- The UserApprove operation foo := acs_sc_msg_type__new( - ''UserData.UserApprove.InputType'', - ''user_id:integer'' + 'UserData.UserApprove.InputType', + 'user_id:integer' ); foo := acs_sc_msg_type__new( - ''UserData.UserApprove.OutputType'', - '''' + 'UserData.UserApprove.OutputType', + '' ); foo := acs_sc_operation__new( - ''UserData'', - ''UserApprove'', - ''Notify that a user has been approved'', - ''f'', + 'UserData', + 'UserApprove', + 'Notify that a user has been approved', + 'f', 1, - ''UserData.UserApprove.InputType'', - ''UserData.UserApprove.OutputType'' + 'UserData.UserApprove.InputType', + 'UserData.UserApprove.OutputType' ); -- The UserDeapprove operation foo := acs_sc_msg_type__new( - ''UserData.UserDeapprove.InputType'', - ''user_id:integer'' + 'UserData.UserDeapprove.InputType', + 'user_id:integer' ); foo := acs_sc_msg_type__new( - ''UserData.UserDeapprove.OutputType'', - '''' + 'UserData.UserDeapprove.OutputType', + '' ); foo := acs_sc_operation__new( - ''UserData'', - ''UserDeapprove'', - ''Notify that a user has been deapproved'', - ''f'', + 'UserData', + 'UserDeapprove', + 'Notify that a user has been deapproved', + 'f', 1, - ''UserData.UserDeapprove.InputType'', - ''UserData.UserDeapprove.OutputType'' + 'UserData.UserDeapprove.InputType', + 'UserData.UserDeapprove.OutputType' ); -- The UserModify operation foo := acs_sc_msg_type__new( - ''UserData.UserModify.InputType'', - ''user_id:integer'' + 'UserData.UserModify.InputType', + 'user_id:integer' ); foo := acs_sc_msg_type__new( - ''UserData.UserModify.OutputType'', - '''' + 'UserData.UserModify.OutputType', + '' ); foo := acs_sc_operation__new( - ''UserData'', - ''UserModify'', - ''Notify that a user has been modified'', - ''f'', + 'UserData', + 'UserModify', + 'Notify that a user has been modified', + 'f', 1, - ''UserData.UserModify.InputType'', - ''UserData.UserModify.OutputType'' + 'UserData.UserModify.InputType', + 'UserData.UserModify.OutputType' ); -- The UserDelete operation foo := acs_sc_msg_type__new( - ''UserData.UserDelete.InputType'', - ''user_id:integer'' + 'UserData.UserDelete.InputType', + 'user_id:integer' ); foo := acs_sc_msg_type__new( - ''UserData.UserDelete.OutputType'', - '''' + 'UserData.UserDelete.OutputType', + '' ); foo := acs_sc_operation__new ( - ''UserData'', - ''UserDelete'', - ''Notify that a user has been deleted'', - ''f'', + 'UserData', + 'UserDelete', + 'Notify that a user has been deleted', + 'f', 1, - ''UserData.UserDelete.InputType'', - ''UserData.UserDelete.OutputType'' + 'UserData.UserDelete.InputType', + 'UserData.UserDelete.OutputType' ); return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select inline_0(); drop function inline_0(); Index: openacs-4/packages/acs-subsite/sql/postgresql/upgrade/upgrade-5.5.0d5-5.5.0d6.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/sql/postgresql/upgrade/upgrade-5.5.0d5-5.5.0d6.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-subsite/sql/postgresql/upgrade/upgrade-5.5.0d5-5.5.0d6.sql 4 Feb 2009 18:52:38 -0000 1.2 +++ openacs-4/packages/acs-subsite/sql/postgresql/upgrade/upgrade-5.5.0d5-5.5.0d6.sql 30 Mar 2013 18:04:20 -0000 1.3 @@ -1,21 +1,31 @@ -select define_function_args('application_group__new','group_id,object_type;application_group,creation_date;now(),creation_user,creation_ip,email,url,group_name,package_id,join_policy,context_id'); -create or replace function application_group__new(integer,varchar,timestamptz,integer,varchar,varchar,varchar,varchar,integer,varchar,integer) -returns integer as ' -declare - new__group_id alias for $1; - new__object_type alias for $2; -- default ''application_group'', - new__creation_date alias for $3; -- default sysdate, - new__creation_user alias for $4; -- default null, - new__creation_ip alias for $5; -- default null, - new__email alias for $6; -- default null, - new__url alias for $7; -- default null, - new__group_name alias for $8; - new__package_id alias for $9; - new__join_policy alias for $10; - new__context_id alias for $11; -- default null +-- old define_function_args('application_group__new','group_id,object_type;application_group,creation_date;now(),creation_user,creation_ip,email,url,group_name,package_id,join_policy,context_id') +-- new +select define_function_args('application_group__new','group_id,object_type;application_group,creation_date;now(),creation_user;null,creation_ip;null,email;null,url;null,group_name,package_id,join_policy,context_id;null'); + + + + +-- +-- procedure application_group__new/11 +-- +CREATE OR REPLACE FUNCTION application_group__new( + new__group_id integer, + new__object_type varchar, -- default 'application_group', + new__creation_date timestamptz, -- default sysdate, -- default 'now()' + new__creation_user integer, -- default null, + new__creation_ip varchar, -- default null, + new__email varchar, -- default null, + new__url varchar, -- default null, + new__group_name varchar, + new__package_id integer, + new__join_policy varchar, + new__context_id integer -- default null + +) RETURNS integer AS $$ +DECLARE v_group_id application_groups.group_id%TYPE; -begin +BEGIN v_group_id := acs_group__new ( new__group_id, new__object_type, @@ -34,5 +44,6 @@ return v_group_id; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; Index: openacs-4/packages/acs-subsite/sql/postgresql/upgrade/upgrade-5.8.0d1-5.8.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/sql/postgresql/upgrade/upgrade-5.8.0d1-5.8.0d2.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-subsite/sql/postgresql/upgrade/upgrade-5.8.0d1-5.8.0d2.sql 6 Sep 2011 13:20:15 -0000 1.1 +++ openacs-4/packages/acs-subsite/sql/postgresql/upgrade/upgrade-5.8.0d1-5.8.0d2.sql 30 Mar 2013 18:04:20 -0000 1.2 @@ -1,20 +1,29 @@ -- providing upgrade script for subsite_callback__new -create or replace function subsite_callback__new(integer,varchar,varchar,varchar,varchar,integer) -returns integer as ' -declare - new__callback_id alias for $1; -- default null, - new__event_type alias for $2; - new__object_type alias for $3; - new__callback alias for $4; - new__callback_type alias for $5; - new__sort_order alias for $6; -- default null + + +-- added +select define_function_args('subsite_callback__new','callback_id;null,event_type,object_type,callback,callback_type,sort_order;null'); + +-- +-- procedure subsite_callback__new/6 +-- +CREATE OR REPLACE FUNCTION subsite_callback__new( + new__callback_id integer, -- default null, + new__event_type varchar, + new__object_type varchar, + new__callback varchar, + new__callback_type varchar, + new__sort_order integer -- default null + +) RETURNS integer AS $$ +DECLARE v_callback_id subsite_callbacks.callback_id%TYPE; v_sort_order subsite_callbacks.sort_order%TYPE; -begin +BEGIN if new__callback_id is null then - select nextval(''t_acs_object_id_seq'') into v_callback_id; + select nextval('t_acs_object_id_seq') into v_callback_id; else v_callback_id := new__callback_id; end if; @@ -47,4 +56,5 @@ -- end; return v_callback_id; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; Index: openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-create.sql,v diff -u -r1.7 -r1.8 --- openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-create.sql 13 Feb 2006 11:45:44 -0000 1.7 +++ openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-create.sql 30 Mar 2013 18:04:20 -0000 1.8 @@ -8,82 +8,82 @@ -- openacs port: vinod kurup vkurup@massmed.org -- -create function inline_0 () -returns integer as ' -begin +CREATE OR REPLACE FUNCTION inline_0 () RETURNS integer AS $$ +BEGIN PERFORM acs_object_type__create_type ( - ''template_demo_note'', -- object_type - ''Template Demo Note'', -- pretty_name - ''Template Demo Notes'', -- pretty_plural - ''acs_object'', -- supertype - ''template_demo_notes'', -- table_name - ''template_demo_note_id'', -- id_column + 'template_demo_note', -- object_type + 'Template Demo Note', -- pretty_name + 'Template Demo Notes', -- pretty_plural + 'acs_object', -- supertype + 'template_demo_notes', -- table_name + 'template_demo_note_id', -- id_column null, -- package_name - ''f'', -- abstract_p + 'f', -- abstract_p null, -- type_extension_table - ''template_demo_note.name'' -- name_method + 'template_demo_note.name' -- name_method ); return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select inline_0 (); drop function inline_0 (); -create function inline_1 () -returns integer as ' -begin +CREATE OR REPLACE FUNCTION inline_1 () RETURNS integer AS $$ +BEGIN PERFORM acs_attribute__create_attribute ( - ''template_demo_note'', -- object_type - ''title'', -- attribute_name - ''string'', -- datatype - ''Title'', -- pretty_name - ''Titles'', -- pretty_plural + 'template_demo_note', -- object_type + 'title', -- attribute_name + 'string', -- datatype + 'Title', -- pretty_name + 'Titles', -- pretty_plural null, -- table_name null, -- column_name null, -- default_value 1, -- min_n_values 1, -- max_n_values null, -- sort_order - ''type_specific'', -- storage - ''f'' -- static_p + 'type_specific', -- storage + 'f' -- static_p ); PERFORM acs_attribute__create_attribute ( - ''template_demo_note'', -- object_type - ''body'', -- attribute_name - ''string'', -- datatype - ''Body'', -- pretty_name - ''Bodies'', -- pretty_plural + 'template_demo_note', -- object_type + 'body', -- attribute_name + 'string', -- datatype + 'Body', -- pretty_name + 'Bodies', -- pretty_plural null, -- table_name null, -- column_name null, -- default_value 1, -- min_n_values 1, -- max_n_values null, -- sort_order - ''type_specific'', -- storage - ''f'' -- static_p + 'type_specific', -- storage + 'f' -- static_p ); PERFORM acs_attribute__create_attribute ( - ''template_demo_note'', -- object_type - ''color'', -- attribute_name - ''string'', -- datatype - ''Color'', -- pretty_name - ''Colors'', -- pretty_plural + 'template_demo_note', -- object_type + 'color', -- attribute_name + 'string', -- datatype + 'Color', -- pretty_name + 'Colors', -- pretty_plural null, -- table_name null, -- column_name null, -- default_value 1, -- min_n_values 1, -- max_n_values null, -- sort_order - ''type_specific'', -- storage - ''f'' -- static_p + 'type_specific', -- storage + 'f' -- static_p ); return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select inline_1 (); @@ -103,22 +103,32 @@ color text ); -select define_function_args('template_demo_note__new','template_demo_note_id,title,body,color,object_type;template_demo_note,creation_date;now,creation_user,creation_ip,context_id'); -create function template_demo_note__new (integer,varchar,varchar,varchar,varchar,timestamptz,integer,varchar,integer) -returns integer as ' -declare - p_template_demo_note_id alias for $1; -- default null - p_title alias for $2; - p_body alias for $3; - p_color alias for $4; - p_object_type alias for $5; -- default ''template_demo_note'' - p_creation_date alias for $6; -- default now() - p_creation_user alias for $7; -- default null - p_creation_ip alias for $8; -- default null - p_context_id alias for $9; -- default null +-- old define_function_args('template_demo_note__new','template_demo_note_id,title,body,color,object_type;template_demo_note,creation_date;now,creation_user,creation_ip,context_id') +-- new +select define_function_args('template_demo_note__new','template_demo_note_id;null,title,body,color,object_type;template_demo_note,creation_date;now,creation_user;null,creation_ip;null,context_id;null'); + + + + +-- +-- procedure template_demo_note__new/9 +-- +CREATE OR REPLACE FUNCTION template_demo_note__new( + p_template_demo_note_id integer, -- default null + p_title varchar, + p_body varchar, + p_color varchar, + p_object_type varchar, -- default 'template_demo_note' + p_creation_date timestamptz, -- default now() -- default 'now' + p_creation_user integer, -- default null + p_creation_ip varchar, -- default null + p_context_id integer -- default null + +) RETURNS integer AS $$ +DECLARE v_template_demo_note_id template_demo_notes.template_demo_note_id%TYPE; -begin +BEGIN v_template_demo_note_id := acs_object__new ( p_template_demo_note_id, p_object_type, @@ -137,48 +147,64 @@ PERFORM acs_permission__grant_permission( v_template_demo_note_id, p_creation_user, - ''admin'' + 'admin' ); end if; return v_template_demo_note_id; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select define_function_args('template_demo_note__del','template_demo_note_id'); -create function template_demo_note__del (integer) -returns integer as ' -declare - p_template_demo_note_id alias for $1; -begin + + +-- +-- procedure template_demo_note__del/1 +-- +CREATE OR REPLACE FUNCTION template_demo_note__del( + p_template_demo_note_id integer +) RETURNS integer AS $$ +DECLARE +BEGIN delete from acs_permissions where object_id = p_template_demo_note_id; delete from template_demo_notes where template_demo_note_id = p_template_demo_note_id; - raise NOTICE ''Deleting note...''; + raise NOTICE 'Deleting note...'; PERFORM acs_object__delete(p_template_demo_note_id); return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; -create function template_demo_note__name (integer) -returns varchar as ' -declare - p_template_demo_note_id alias for $1; + + +-- added +select define_function_args('template_demo_note__name','template_demo_note_id'); + +-- +-- procedure template_demo_note__name/1 +-- +CREATE OR REPLACE FUNCTION template_demo_note__name( + p_template_demo_note_id integer +) RETURNS varchar AS $$ +DECLARE v_template_demo_note_name template_demo_notes.title%TYPE; -begin +BEGIN select title into v_template_demo_note_name from template_demo_notes where template_demo_note_id = p_template_demo_note_id; return v_template_demo_note_name; -end; -' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; + -- neophytosd Index: openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-drop.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-drop.sql 6 Feb 2006 13:06:29 -0000 1.3 +++ openacs-4/packages/acs-templating/sql/postgresql/template-demo-notes-drop.sql 30 Mar 2013 18:04:20 -0000 1.4 @@ -14,18 +14,25 @@ delete from acs_permissions where object_id in (select template_demo_note_id from template_demo_notes); --drop objects -create function inline_0 () -returns integer as ' -declare + + +-- +-- procedure inline_0/0 +-- +CREATE OR REPLACE FUNCTION inline_0( + +) RETURNS integer AS $$ +DECLARE object_rec record; -begin - for object_rec in select object_id from acs_objects where object_type=''template_demo_note'' +BEGIN + for object_rec in select object_id from acs_objects where object_type='template_demo_note' loop perform acs_object__delete( object_rec.object_id ); end loop; return 0; -end;' language 'plpgsql'; +END; +$$ LANGUAGE plpgsql; select inline_0(); drop function inline_0();