Index: openacs-4/packages/acs-admin/www/apm/parameter-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/parameter-add.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-admin/www/apm/parameter-add.tcl 30 Mar 2010 22:19:45 -0000 1.8 +++ openacs-4/packages/acs-admin/www/apm/parameter-add.tcl 4 Oct 2010 21:59:20 -0000 1.9 @@ -11,11 +11,7 @@ set user_id [ad_get_user_id] set parameter_id [db_nextval acs_object_id_seq] -db_1row apm_get_name { - select package_key, pretty_name, version_name - from apm_package_version_info - where version_id = :version_id -} +db_1row apm_get_name {} db_release_unused_handles set page_title "Add Parameter" Index: openacs-4/packages/acs-admin/www/apm/parameter-add.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/parameter-add.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-admin/www/apm/parameter-add.xql 27 Apr 2001 01:41:12 -0000 1.1 +++ openacs-4/packages/acs-admin/www/apm/parameter-add.xql 4 Oct 2010 21:59:20 -0000 1.2 @@ -4,7 +4,7 @@ - select package_key, pretty_name, version_name, acs_object_id_seq.nextval as parameter_id + select package_key, pretty_name, version_name from apm_package_version_info where version_id = :version_id Index: openacs-4/packages/acs-content-repository/acs-content-repository.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/acs-content-repository.info,v diff -u -r1.91 -r1.92 --- openacs-4/packages/acs-content-repository/acs-content-repository.info 9 Mar 2010 11:49:46 -0000 1.91 +++ openacs-4/packages/acs-content-repository/acs-content-repository.info 4 Oct 2010 21:59:20 -0000 1.92 @@ -7,7 +7,7 @@ t t - + OpenACS The canonical repository for OpenACS content. 2009-06-19 @@ -20,8 +20,8 @@ GPL 3 - - + + Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-template.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-template.sql,v diff -u -r1.23 -r1.24 --- openacs-4/packages/acs-content-repository/sql/postgresql/content-template.sql 17 Sep 2007 09:43:56 -0000 1.23 +++ openacs-4/packages/acs-content-repository/sql/postgresql/content-template.sql 4 Oct 2010 21:59:20 -0000 1.24 @@ -53,7 +53,7 @@ begin if new__parent_id is null then - v_parent_id := content_template_globals.c_root_folder_id; + select c_root_folder_id into v_parent_id from content_template_globals; else v_parent_id := new__parent_id; end if; @@ -133,7 +133,7 @@ begin if new__parent_id is null then - v_parent_id := content_template_globals.c_root_folder_id; + select c_root_folder_id into v_parent_id from content_template_globals; else v_parent_id := new__parent_id; end if; Index: openacs-4/packages/acs-content-repository/sql/postgresql/upgrade/upgrade-5.7.0d1-5.7.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/upgrade/upgrade-5.7.0d1-5.7.0d2.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-content-repository/sql/postgresql/upgrade/upgrade-5.7.0d1-5.7.0d2.sql 4 Oct 2010 21:59:20 -0000 1.1 @@ -0,0 +1,147 @@ +-- @author Victor Guerra (vguerra@gmail.com) +-- @creation-date 2010-09-29 +-- + + +-- The following function get's rid of the foreign key constraint between cr_folders(folder_id) and cr_items(item_id), +-- at somepoint ( upgrade-5.4.2d1-5.42d2 ) it was added using the statement "alter table add foreign key .. " +-- which will add a constraint with name $1, since this is not for sure ( could have also other name assigned), we better look for the right constraint name +-- to be deleted using pg_constraint and pg_class table + +create function inline_0 () +returns integer as ' +declare + constraints RECORD; +begin + for constraints in select conname + from pg_constraint con ,pg_class cla1, pg_class cla2 + where con.contype = ''f'' and con.conrelid = cla1.oid and cla1.relname = ''cr_folders'' + and con.confrelid = cla2.oid and cla2.relname = ''cr_items'' + loop + EXECUTE ''alter table cr_folders drop constraint '' || constraints.conname; + end loop; + return null; +end;' language 'plpgsql'; + +select inline_0(); +drop function inline_0(); + +-- Now we create the foreign key constraint with the right name +alter table cr_folders add constraint cr_folders_folder_id_fk foreign key (folder_id) references cr_items(item_id) on delete cascade; + + +create or replace function content_template__new (varchar,integer,integer,timestamptz,integer,varchar) +returns integer as ' +declare + new__name alias for $1; + new__parent_id alias for $2; -- default null + new__template_id alias for $3; -- default null + new__creation_date alias for $4; -- default now() + new__creation_user alias for $5; -- default null + new__creation_ip alias for $6; -- default null + v_template_id cr_templates.template_id%TYPE; + v_parent_id cr_items.parent_id%TYPE; +begin + + if new__parent_id is null then + select c_root_folder_id into v_parent_id from content_template_globals; + else + v_parent_id := new__parent_id; + end if; + + -- make sure we''re allowed to create a template in this folder + if content_folder__is_folder(new__parent_id) = ''t'' and + content_folder__is_registered(new__parent_id,''content_template'',''f'') = ''f'' then + + raise EXCEPTION ''-20000: This folder does not allow templates to be created''; + + else + v_template_id := content_item__new ( + new__name, + v_parent_id, + new__template_id, + null, + new__creation_date, + new__creation_user, + null, + new__creation_ip, + ''content_item'', + ''content_template'', + null, + null, + ''text/plain'', + null, + null, + ''text'' + ); + + insert into cr_templates ( + template_id + ) values ( + v_template_id + ); + + return v_template_id; + + end if; + +end;' language 'plpgsql'; + +create or replace function content_template__new (varchar,integer,integer,timestamptz,integer,varchar,text,bool) +returns integer as ' +declare + new__name alias for $1; + new__parent_id alias for $2; -- default null + new__template_id alias for $3; -- default null + new__creation_date alias for $4; -- default now() + new__creation_user alias for $5; -- default null + new__creation_ip alias for $6; -- default null + new__text alias for $7; -- default null + new__is_live alias for $8; -- default ''f'' + v_template_id cr_templates.template_id%TYPE; + v_parent_id cr_items.parent_id%TYPE; +begin + + if new__parent_id is null then + select c_root_folder_id into v_parent_id from content_template_globals; + else + v_parent_id := new__parent_id; + end if; + + -- make sure we''re allowed to create a template in this folder + if content_folder__is_folder(new__parent_id) = ''t'' and + content_folder__is_registered(new__parent_id,''content_template'',''f'') = ''f'' then + + raise EXCEPTION ''-20000: This folder does not allow templates to be created''; + + else + v_template_id := content_item__new ( + new__template_id, -- new__item_id + new__name, -- new__name + v_parent_id, -- new__parent_id + null, -- new__title + new__creation_date, -- new__creation_date + new__creation_user, -- new__creation_user + null, -- new__context_id + new__creation_ip, -- new__creation_ip + new__is_live, -- new__is_live + ''text/plain'', -- new__mime_type + new__text, -- new__text + ''text'', -- new__storage_type + ''t'', -- new__security_inherit_p + ''CR_FILES'', -- new__storage_area_key + ''content_item'', -- new__item_subtype + ''content_template'' -- new__content_type + ); + + insert into cr_templates ( + template_id + ) values ( + v_template_id + ); + + return v_template_id; + + end if; + +end;' language 'plpgsql'; Index: openacs-4/packages/acs-kernel/acs-kernel.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/acs-kernel.info,v diff -u -r1.112 -r1.113 --- openacs-4/packages/acs-kernel/acs-kernel.info 31 Mar 2010 00:46:16 -0000 1.112 +++ openacs-4/packages/acs-kernel/acs-kernel.info 4 Oct 2010 21:59:19 -0000 1.113 @@ -7,15 +7,15 @@ t t - + OpenACS Core Team Routines and data models providing the foundation for OpenACS-based Web services. 2009-06-19 OpenACS The OpenACS kernel contains the core datamodel create and drop scripts for such things as objects, groups, partiies and the supporting PL/SQL and PL/pgSQL procedures. 3 - + Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql,v diff -u -r1.61 -r1.62 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 10 Mar 2010 00:44:03 -0000 1.61 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql 4 Oct 2010 21:59:20 -0000 1.62 @@ -475,8 +475,8 @@ create or replace function acs_objects_context_id_up_tr () returns trigger as ' declare pair record; - outer record; - inner record; + outer_record record; + inner_record record; security_context_root integer; begin if new.object_id = old.object_id @@ -487,13 +487,13 @@ end if; -- Remove my old ancestors from my descendants. - for outer in select object_id from acs_object_context_index where + for outer_record in select object_id from acs_object_context_index where ancestor_id = old.object_id and object_id <> old.object_id loop - for inner in select ancestor_id from acs_object_context_index where + for inner_record in select ancestor_id from acs_object_context_index where object_id = old.object_id and ancestor_id <> old.object_id loop delete from acs_object_context_index - where object_id = outer.object_id - and ancestor_id = inner.ancestor_id; + where object_id = outer_record.object_id + and ancestor_id = inner_record.ancestor_id; end loop; end loop; @@ -1197,9 +1197,9 @@ v_table_name := acs_object__get_attr_storage_table(v_storage); v_key_sql := acs_object__get_attr_storage_sql(v_storage); - for v_rec in execute ''select '' || quote_ident(v_column) || ''::text as return from '' || quote_ident(v_table_name) || '' where '' || v_key_sql + for v_rec in execute ''select '' || quote_ident(v_column) || ''::text as column_return from '' || quote_ident(v_table_name) || '' where '' || v_key_sql LOOP - v_return := v_rec.return; + v_return := v_rec.column_return; exit; end loop; if not FOUND then Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.7.0d1-5.7.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.7.0d1-5.7.0d2.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.7.0d1-5.7.0d2.sql 4 Oct 2010 21:59:20 -0000 1.1 @@ -0,0 +1,103 @@ +-- Support for postgresql 9.x +-- @author Victor Guerra (vguerra@gmail.com) + +create or replace function acs_objects_context_id_up_tr () returns trigger as ' +declare + pair record; + outer_record record; + inner_record record; + security_context_root integer; +begin + if new.object_id = old.object_id + and ((new.context_id = old.context_id) + or (new.context_id is null and old.context_id is null)) + and new.security_inherit_p = old.security_inherit_p then + return new; + end if; + + -- Remove my old ancestors from my descendants. + for outer_record in select object_id from acs_object_context_index where + ancestor_id = old.object_id and object_id <> old.object_id loop + for inner_record in select ancestor_id from acs_object_context_index where + object_id = old.object_id and ancestor_id <> old.object_id loop + delete from acs_object_context_index + where object_id = outer_record.object_id + and ancestor_id = inner_record.ancestor_id; + end loop; + end loop; + + -- Kill all my old ancestors. + delete from acs_object_context_index + where object_id = old.object_id; + + insert into acs_object_context_index + (object_id, ancestor_id, n_generations) + values + (new.object_id, new.object_id, 0); + + if new.context_id is not null and new.security_inherit_p = ''t'' then + -- Now insert my new ancestors for my descendants. + for pair in select * + from acs_object_context_index + where ancestor_id = new.object_id + LOOP + insert into acs_object_context_index + (object_id, ancestor_id, n_generations) + select + pair.object_id, ancestor_id, + n_generations + pair.n_generations + 1 as n_generations + from acs_object_context_index + where object_id = new.context_id; + end loop; + else + security_context_root = acs__magic_object_id(''security_context_root''); + if new.object_id != security_context_root then + -- We need to make sure that new.OBJECT_ID and all of its + -- children have security_context_root as an ancestor. + for pair in select * + from acs_object_context_index + where ancestor_id = new.object_id + LOOP + insert into acs_object_context_index + (object_id, ancestor_id, n_generations) + values + (pair.object_id, security_context_root, pair.n_generations + 1); + end loop; + end if; + end if; + + return new; + +end;' language 'plpgsql'; + +create or replace function acs_object__get_attribute (integer,varchar) +returns text as ' +declare + object_id_in alias for $1; + attribute_name_in alias for $2; + v_table_name varchar(200); + v_column varchar(200); + v_key_sql text; + v_return text; + v_storage text; + v_rec record; +begin + + v_storage := acs_object__get_attribute_storage(object_id_in, attribute_name_in); + + v_column := acs_object__get_attr_storage_column(v_storage); + v_table_name := acs_object__get_attr_storage_table(v_storage); + v_key_sql := acs_object__get_attr_storage_sql(v_storage); + + for v_rec in execute ''select '' || quote_ident(v_column) || ''::text as column_return from '' || quote_ident(v_table_name) || '' where '' || v_key_sql + LOOP + v_return := v_rec.column_return; + exit; + end loop; + if not FOUND then + return null; + end if; + + return v_return; + +end;' language 'plpgsql' stable; Index: openacs-4/packages/acs-subsite/acs-subsite.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/acs-subsite.info,v diff -u -r1.107 -r1.108 --- openacs-4/packages/acs-subsite/acs-subsite.info 5 Jan 2010 11:09:26 -0000 1.107 +++ openacs-4/packages/acs-subsite/acs-subsite.info 4 Oct 2010 21:59:20 -0000 1.108 @@ -8,7 +8,7 @@ f t - + OpenACS Subsite 2009-06-19 @@ -17,7 +17,7 @@ GPL 3 - + Index: openacs-4/packages/acs-subsite/sql/oracle/themes-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/sql/oracle/themes-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-subsite/sql/oracle/themes-create.sql 30 May 2009 20:18:41 -0000 1.3 +++ openacs-4/packages/acs-subsite/sql/oracle/themes-create.sql 4 Oct 2010 21:59:20 -0000 1.4 @@ -13,10 +13,10 @@ constraint subsite_themes_key_pk primary key, name varchar(100) - constraint subsite_theme_name_nn + constraint subsite_themes_name_nn not null, template varchar(200) - constraint subsite_theme_template_nn + constraint subsite_themes_template_nn not null, css varchar(2000), form_template varchar(200), Index: openacs-4/packages/acs-subsite/sql/oracle/upgrade/upgrade-5.7.0d1-5.7.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/sql/oracle/upgrade/upgrade-5.7.0d1-5.7.0d2.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-subsite/sql/oracle/upgrade/upgrade-5.7.0d1-5.7.0d2.sql 4 Oct 2010 21:59:20 -0000 1.1 @@ -0,0 +1,9 @@ +-- Getting right constraint names on subsite_themes this dont matter for PG since +-- +-- +-- @author Victor Guerra (vguerra@gmail.com) +-- @creation-date 2010-09-29 +-- + +alter table subsite_themes rename constraint subsite_theme_name_nn to subsite_themes_nn; +alter table subsite_themes rename constraint subsite_theme_template_nn to subsite_themes_template_nn; Index: openacs-4/packages/acs-subsite/sql/postgresql/themes-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/sql/postgresql/themes-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-subsite/sql/postgresql/themes-create.sql 7 Jun 2008 20:42:37 -0000 1.2 +++ openacs-4/packages/acs-subsite/sql/postgresql/themes-create.sql 4 Oct 2010 21:59:20 -0000 1.3 @@ -13,10 +13,10 @@ constraint subsite_themes_key_pk primary key, name text - constraint subsite_theme_name_nn + constraint subsite_themes_name_nn not null, template text - constraint subsite_theme_template_nn + constraint subsite_themes_template_nn not null, css text, form_template text, Index: openacs-4/packages/acs-subsite/sql/postgresql/upgrade/upgrade-5.5.0d1-5.5.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/sql/postgresql/upgrade/upgrade-5.5.0d1-5.5.0d2.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-subsite/sql/postgresql/upgrade/upgrade-5.5.0d1-5.5.0d2.sql 8 May 2008 01:52:32 -0000 1.1 +++ openacs-4/packages/acs-subsite/sql/postgresql/upgrade/upgrade-5.5.0d1-5.5.0d2.sql 4 Oct 2010 21:59:20 -0000 1.2 @@ -13,10 +13,10 @@ constraint subsite_theme_key_pk primary key, name text - constraint subsite_theme_name_nn + constraint subsite_themes_name_nn not null, template text - constraint subsite_theme_template_nn + constraint subsite_themes_template_nn not null, css text, form_template text, Index: openacs-4/packages/acs-subsite/tcl/rel-types-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/rel-types-procs.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/acs-subsite/tcl/rel-types-procs.tcl 10 Jan 2007 21:22:06 -0000 1.9 +++ openacs-4/packages/acs-subsite/tcl/rel-types-procs.tcl 4 Oct 2010 21:59:20 -0000 1.10 @@ -218,6 +218,7 @@ Add a permissible relationship for a given group type } { if {[catch { + set group_rel_type_id [db_nextval acs_object_id_seq] db_dml insert_rel_type {} } errmsg]} { } Index: openacs-4/packages/acs-subsite/tcl/rel-types-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/rel-types-procs.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-subsite/tcl/rel-types-procs.xql 4 Jun 2005 12:38:26 -0000 1.4 +++ openacs-4/packages/acs-subsite/tcl/rel-types-procs.xql 4 Oct 2010 21:59:20 -0000 1.5 @@ -23,7 +23,7 @@ insert into group_type_rels (group_rel_type_id, group_type, rel_type) values -(acs_object_id_seq.nextval, :group_type, :rel_type) +(:group_rel_type_id, :group_type, :rel_type) Index: openacs-4/packages/acs-subsite/www/admin/group-types/rel-type-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/group-types/rel-type-add-2.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-subsite/www/admin/group-types/rel-type-add-2.tcl 10 Jan 2007 21:22:06 -0000 1.2 +++ openacs-4/packages/acs-subsite/www/admin/group-types/rel-type-add-2.tcl 4 Oct 2010 21:59:20 -0000 1.3 @@ -31,11 +31,13 @@ } -if { [catch {db_dml insert_rel_type { +if { [catch { + set group_rel_type_id [db_nextval acs_object_id_seq] + db_dml insert_rel_type { insert into group_type_rels (group_rel_type_id, group_type, rel_type) values - (acs_object_id_seq.nextval, :group_type, :rel_type) + (:group_rel_type_id, :group_type, :rel_type) } } err_msg] } { # Does this pair already exists? if { ![db_string exists_p {select count(*) from group_type_rels where group_type = :group_type and rel_type = :rel_type}] } { Index: openacs-4/packages/acs-subsite/www/admin/groups/rel-type-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/groups/rel-type-add-2.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-subsite/www/admin/groups/rel-type-add-2.tcl 10 Jan 2007 21:22:07 -0000 1.3 +++ openacs-4/packages/acs-subsite/www/admin/groups/rel-type-add-2.tcl 4 Oct 2010 21:59:20 -0000 1.4 @@ -35,11 +35,13 @@ } } -if { [catch {db_dml insert_rel_type { +if { [catch { + set group_rel_id [db_nextval acs_object_id_seq] + db_dml insert_rel_type { insert into group_rels (group_rel_id, group_id, rel_type) values - (acs_object_id_seq.nextval, :group_id, :rel_type) + (:group_rel_id, :group_id, :rel_type) } } err_msg] } { # Does this pair already exists? if { ![db_string exists_p {