Index: openacs-4/packages/categories/categories.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/categories.info,v diff -u -r1.14 -r1.15 --- openacs-4/packages/categories/categories.info 1 Oct 2007 09:46:56 -0000 1.14 +++ openacs-4/packages/categories/categories.info 6 Nov 2008 15:39:47 -0000 1.15 @@ -8,20 +8,20 @@ f categories - + timo@timohentschel.de Manage categories in category trees and let users map objects to categories. - 2006-02-12 + 2008-11-06 Datamodel for category trees with supporting API and management pages. Provides a widget for general categorization of arbitrary objects and tracks which package instances use which category trees. Also supports localization. 0 - + - + Index: openacs-4/packages/categories/sql/postgresql/category-tree-package.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/sql/postgresql/category-tree-package.sql,v diff -u -r1.10 -r1.11 --- openacs-4/packages/categories/sql/postgresql/category-tree-package.sql 16 Sep 2007 10:35:35 -0000 1.10 +++ openacs-4/packages/categories/sql/postgresql/category-tree-package.sql 6 Nov 2008 15:39:47 -0000 1.11 @@ -199,6 +199,7 @@ for source in (select category_id, parent_id, left_ind, right_ind from categories where tree_id = p_source_tree) loop v_category_id := acs_object__new ( + null, ''category'', -- object_type now(), -- creation_date p_creation_user, -- creation_user @@ -213,11 +214,11 @@ end loop; -- correct parent_ids - update categories + update categories c set parent_id = (select t.category_id from categories s, categories t where s.category_id = c.parent_id - and t.tree_id = copy.dest_tree + and t.tree_id = p_dest_tree and s.left_ind + v_new_left_ind = t.left_ind) where tree_id = p_dest_tree; Index: openacs-4/packages/categories/sql/postgresql/upgrade/upgrade-1.1.2d3-1.1.2d4.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/sql/postgresql/upgrade/upgrade-1.1.2d3-1.1.2d4.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/sql/postgresql/upgrade/upgrade-1.1.2d3-1.1.2d4.sql 6 Nov 2008 15:39:47 -0000 1.1 @@ -0,0 +1,63 @@ +create or replace function category_tree__copy ( + integer, -- source_tree + integer, -- dest_tree + integer, -- creation_user + varchar -- creation_ip +) +returns integer as ' +declare + p_source_tree alias for $1; + p_dest_tree alias for $2; + p_creation_user alias for $3; + p_creation_ip alias for $4; + + v_new_left_ind integer; + v_category_id integer; + source record; +begin + select coalesce(max(right_ind),0) into v_new_left_ind + from categories + where tree_id = p_dest_tree; + + for source in (select category_id, parent_id, left_ind, right_ind from categories where tree_id = p_source_tree) loop + + v_category_id := acs_object__new ( + null, + ''category'', -- object_type + now(), -- creation_date + p_creation_user, -- creation_user + p_creation_ip, -- creation_ip + p_dest_tree -- context_id + ); + + insert into categories + (category_id, tree_id, parent_id, left_ind, right_ind) + values + (v_category_id, p_dest_tree, source.parent_id, source.left_ind + v_new_left_ind, source.right_ind + v_new_left_ind); + end loop; + + -- correct parent_ids + update categories c + set parent_id = (select t.category_id + from categories s, categories t + where s.category_id = c.parent_id + and t.tree_id = p_dest_tree + and s.left_ind + v_new_left_ind = t.left_ind) + where tree_id = p_dest_tree; + + -- copy all translations + insert into category_translations + (category_id, locale, name, description) + (select ct.category_id, t.locale, t.name, t.description + from category_translations t, categories cs, categories ct + where ct.tree_id = p_dest_tree + and cs.tree_id = p_source_tree + and cs.left_ind + v_new_left_ind = ct.left_ind + and t.category_id = cs.category_id); + + -- for debugging reasons + perform category_tree__check_nested_ind(p_dest_tree); + + return 0; +end; +' language 'plpgsql'; \ No newline at end of file