Index: openacs-4/packages/static-pages/static-pages.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/static-pages.info,v diff -u -r1.17 -r1.18 --- openacs-4/packages/static-pages/static-pages.info 11 Jan 2004 23:30:23 -0000 1.17 +++ openacs-4/packages/static-pages/static-pages.info 25 Mar 2004 10:52:47 -0000 1.18 @@ -7,7 +7,7 @@ f f - + oracle postgresql @@ -19,11 +19,11 @@ OpenACS Static Pages loads the static pages of a site into the database so that their contents are available to other packages, such as site-wide-search. It also allows users to make comments on static pages. - - - - - + + + + + Index: openacs-4/packages/static-pages/sql/oracle/static-page-pb.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/sql/oracle/static-page-pb.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/static-pages/sql/oracle/static-page-pb.sql 30 Sep 2003 12:10:11 -0000 1.3 +++ openacs-4/packages/static-pages/sql/oracle/static-page-pb.sql 25 Mar 2004 10:52:48 -0000 1.4 @@ -125,7 +125,8 @@ folder_id := static_page.new_folder ( -- name NEEDS to be unique, label does not name => 'sp_root_package_id_' || package_id, - label => 'sp_root_package_id_' || package_id + label => 'sp_root_package_id_' || package_id, + package_id => package_id ); update sp_folders @@ -168,7 +169,9 @@ creation_ip in acs_objects.creation_ip%TYPE default null, context_id in acs_objects.context_id%TYPE - default null + default null, + package_id in apm_packages.package_id%TYPE + default null ) return sp_folders.folder_id%TYPE is v_folder_id sp_folders.folder_id%TYPE; v_parent_id cr_items.parent_id%TYPE; Index: openacs-4/packages/static-pages/sql/oracle/static-page-ph.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/sql/oracle/static-page-ph.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/static-pages/sql/oracle/static-page-ph.sql 30 Sep 2003 12:10:11 -0000 1.3 +++ openacs-4/packages/static-pages/sql/oracle/static-page-ph.sql 25 Mar 2004 10:52:48 -0000 1.4 @@ -73,7 +73,9 @@ creation_ip in acs_objects.creation_ip%TYPE default null, context_id in acs_objects.context_id%TYPE - default null + default null, + package_id in apm_packages.package_id%TYPE + default null ) return sp_folders.folder_id%TYPE; procedure delete_folder ( Index: openacs-4/packages/static-pages/sql/oracle/upgrade/upgrade-5.2.0d1-5.2.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/sql/oracle/upgrade/upgrade-5.2.0d1-5.2.0d2.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/static-pages/sql/oracle/upgrade/upgrade-5.2.0d1-5.2.0d2.sql 25 Mar 2004 10:52:48 -0000 1.1 @@ -0,0 +1,4 @@ +-- Need to replace the funtions which should propigate package_id +-- .new_folder, .get_root_folder +@@ ../static-page-ph.sql +@@ ../static-page-pb.sql Index: openacs-4/packages/static-pages/sql/postgresql/static-page-pb.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/sql/postgresql/static-page-pb.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/static-pages/sql/postgresql/static-page-pb.sql 17 May 2003 12:25:00 -0000 1.3 +++ openacs-4/packages/static-pages/sql/postgresql/static-page-pb.sql 25 Mar 2004 10:52:49 -0000 1.4 @@ -6,7 +6,7 @@ -- create or replace package body static_page as -create or replace function static_page__new ( +create or replace function static_page__new ( integer, -- static_page_id in static_pages.static_page_id%TYPE -- default null, integer, -- folder_id in sp_folders.folder_id%TYPE, @@ -220,7 +220,8 @@ null, null, null, - null + null, + p_package_id ); update sp_folders @@ -249,7 +250,7 @@ end;' language 'plpgsql'; -create or replace function static_page__new_folder ( +create or replace function static_page__new_folder ( integer, -- folder_id in sp_folders.folder_id%TYPE -- default null, varchar, -- name in cr_items.name%TYPE, @@ -262,8 +263,9 @@ -- default null, varchar, -- creation_ip in acs_objects.creation_ip%TYPE -- default null, - integer -- context_id in acs_objects.context_id%TYPE + integer, -- context_id in acs_objects.context_id%TYPE -- default null + integer -- package_id ) returns integer as ' declare p_folder_id alias for $1; @@ -275,6 +277,7 @@ p_creation_user alias for $7; p_creation_ip alias for $8; p_context_id alias for $9; + p_package_id alias for $10; v_folder_id sp_folders.folder_id%TYPE; v_parent_id cr_items.parent_id%TYPE; @@ -294,6 +297,19 @@ v_parent_id := p_parent_id; end if; + + if p_parent_id is not null then + if p_package_id is null then + -- Get the package_id from the parent: + select package_id into v_package_id from sp_folders + where folder_id = p_parent_id; + else + v_package_id := p_package_id; + end if; + else + v_package_id := p_package_id; + end if; + v_folder_id := content_folder__new ( p_name, -- name p_label, -- label @@ -304,16 +320,13 @@ v_creation_date, -- creation_date p_creation_user, -- creation_user p_creation_ip, -- creation_ip - ''f'' -- secuity_inherit_p - + ''f'', -- secuity_inherit_p + v_package_id ); - if p_parent_id is not null then - -- Get the package_id from the parent: - select package_id into v_package_id from sp_folders - where folder_id = p_parent_id; - insert into sp_folders (folder_id, parent_id, package_id) + if p_parent_id is not null then + insert into sp_folders (folder_id, parent_id, package_id) values (v_folder_id, p_parent_id, v_package_id); -- update acs_objects set security_inherit_p = ''f'' @@ -331,26 +344,26 @@ ); end loop; else - insert into sp_folders (folder_id, parent_id) - values (v_folder_id, p_parent_id); + insert into sp_folders (folder_id, parent_id, package_id) + values (v_folder_id, p_parent_id, p_package_id); - -- if it''s a root folder, allow it to contain static pages and - -- other folders (subfolders will inherit these properties) - PERFORM content_folder__register_content_type ( - v_folder_id, -- folder_id - ''static_page'', -- content_type - ''f'' - ); - PERFORM content_folder__register_content_type ( - v_folder_id, -- folder_id - ''content_revision'', -- content_type - ''f'' - ); - PERFORM content_folder__register_content_type ( - v_folder_id, -- folder_id - ''content_folder'', -- content_type - ''f'' - ); + -- if it''s a root folder, allow it to contain static pages and + -- other folders (subfolders will inherit these properties) + PERFORM content_folder__register_content_type ( + v_folder_id, -- folder_id + ''static_page'', -- content_type + ''f'' + ); + PERFORM content_folder__register_content_type ( + v_folder_id, -- folder_id + ''content_revision'', -- content_type + ''f'' + ); + PERFORM content_folder__register_content_type ( + v_folder_id, -- folder_id + ''content_folder'', -- content_type + ''f'' + ); end if; return v_folder_id; Index: openacs-4/packages/static-pages/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/static-pages/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql 25 Mar 2004 10:52:49 -0000 1.1 @@ -0,0 +1,180 @@ +create or replace function static_page__get_root_folder ( + integer -- package_id in apm_packages.package_id%TYPE + ) returns integer as ' +declare + p_package_id alias for $1; + v_folder_exists_p integer; + v_folder_id sp_folders.folder_id%TYPE; + v_rows integer; +begin + -- If there isn''t a root folder for this package, create one. + -- Otherwise, just return its id. + select count(*) into v_folder_exists_p where exists ( + select 1 from sp_folders + where package_id = p_package_id + and parent_id is null + ); + + if v_folder_exists_p = 0 then + -- name NEEDS to be unique, label does not + v_folder_id := static_page__new_folder ( + null, + ''sp_root_package_id_'' || p_package_id, -- name + ''sp_root_package_id_'' || p_package_id, -- label + null, + null, + null, + null, + null, + null, + p_package_id + ); + + update sp_folders + set package_id = p_package_id + where folder_id = v_folder_id; + + PERFORM acs_permission__grant_permission ( + v_folder_id, -- object_id + acs__magic_object_id(''the_public''), -- grantee_id + ''general_comments_create'' -- privilege + ); + -- The comments will inherit read permission from the pages, + -- so the public should be able to read the static pages. + PERFORM acs_permission__grant_permission ( + v_folder_id, -- object_id + acs__magic_object_id(''the_public''), -- grantee_id + ''read'' -- privilege + ); + else + select folder_id into v_folder_id from sp_folders + where package_id = p_package_id + and parent_id is null; + end if; + + return v_folder_id; +end;' language 'plpgsql'; + + +-- The one that does not take package_id should just go away. +drop function static_page__new_folder (integer, character varying, character varying, text, integer, timestamp with time zone, integer, character varying, integer); + +create or replace function static_page__new_folder ( + integer, -- folder_id in sp_folders.folder_id%TYPE + -- default null, + varchar, -- name in cr_items.name%TYPE, + varchar, -- label in cr_folders.label%TYPE, + text, -- description in cr_folders.description%TYPE default null, + integer, -- parent_id in cr_items.parent_id%TYPE default null, + timestamptz, -- creation_date in acs_objects.creation_date%TYPE + -- default sysdate, + integer, -- creation_user in acs_objects.creation_user%TYPE + -- default null, + varchar, -- creation_ip in acs_objects.creation_ip%TYPE + -- default null, + integer, -- context_id in acs_objects.context_id%TYPE + -- default null + integer -- package_id + ) returns integer as ' + declare + p_folder_id alias for $1; + p_name alias for $2; + p_label alias for $3; + p_description alias for $4; + p_parent_id alias for $5; + p_creation_date alias for $6; + p_creation_user alias for $7; + p_creation_ip alias for $8; + p_context_id alias for $9; + p_package_id alias for $10; + + v_folder_id sp_folders.folder_id%TYPE; + v_parent_id cr_items.parent_id%TYPE; + v_package_id apm_packages.package_id%TYPE; + v_creation_date acs_objects.creation_date%TYPE; + v_permission_row RECORD; + begin + if p_creation_date is null then + v_creation_date := now(); + else + v_creation_date := p_creation_date; + end if; + + if p_parent_id is null then + v_parent_id := 0; + else + v_parent_id := p_parent_id; + end if; + + + if p_parent_id is not null then + if p_package_id is null then + -- Get the package_id from the parent: + select package_id into v_package_id from sp_folders + where folder_id = p_parent_id; + else + v_package_id := p_package_id; + end if; + else + v_package_id := p_package_id; + end if; + + v_folder_id := content_folder__new ( + p_name, -- name + p_label, -- label + p_description, -- description + v_parent_id, -- parent_id + p_context_id, -- context_id + p_folder_id, -- folder_id + v_creation_date, -- creation_date + p_creation_user, -- creation_user + p_creation_ip, -- creation_ip + ''f'', -- secuity_inherit_p + v_package_id + ); + + + if p_parent_id is not null then + insert into sp_folders (folder_id, parent_id, package_id) + values (v_folder_id, p_parent_id, v_package_id); + +-- update acs_objects set security_inherit_p = ''f'' +-- where object_id = v_folder_id; + + -- Copy permissions from the parent: + for v_permission_row in + select * from acs_permissions + where object_id = p_parent_id + loop + perform acs_permission__grant_permission( + v_folder_id, -- object_id + v_permission_row.grantee_id, -- grantee_id + v_permission_row.privilege -- privilege + ); + end loop; + else + insert into sp_folders (folder_id, parent_id, package_id) + values (v_folder_id, p_parent_id, p_package_id); + + -- if it''s a root folder, allow it to contain static pages and + -- other folders (subfolders will inherit these properties) + PERFORM content_folder__register_content_type ( + v_folder_id, -- folder_id + ''static_page'', -- content_type + ''f'' + ); + PERFORM content_folder__register_content_type ( + v_folder_id, -- folder_id + ''content_revision'', -- content_type + ''f'' + ); + PERFORM content_folder__register_content_type ( + v_folder_id, -- folder_id + ''content_folder'', -- content_type + ''f'' + ); + end if; + + return v_folder_id; +end;' language 'plpgsql'; + Index: openacs-4/packages/static-pages/tcl/static-pages-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/tcl/static-pages-procs-oracle.xql,v diff -u -r1.10 -r1.11 --- openacs-4/packages/static-pages/tcl/static-pages-procs-oracle.xql 16 Jan 2003 14:01:59 -0000 1.10 +++ openacs-4/packages/static-pages/tcl/static-pages-procs-oracle.xql 25 Mar 2004 10:52:49 -0000 1.11 @@ -11,7 +11,8 @@ name => :cumulative_path, label => :cumulative_path, parent_id => :parent_folder_id, - description => 'Static pages folder' + description => 'Static pages folder', + package_id => :package_id ); end; Index: openacs-4/packages/static-pages/tcl/static-pages-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/static-pages/tcl/static-pages-procs-postgresql.xql,v diff -u -r1.19 -r1.20 --- openacs-4/packages/static-pages/tcl/static-pages-procs-postgresql.xql 17 May 2003 12:26:29 -0000 1.19 +++ openacs-4/packages/static-pages/tcl/static-pages-procs-postgresql.xql 25 Mar 2004 10:52:49 -0000 1.20 @@ -33,7 +33,8 @@ current_timestamp, -- creation_date NULL, -- creation_user NULL, -- creation_ip - NULL -- context_id + NULL, -- context_id + :package_id );