Index: openacs-4/packages/cms/tcl/rel-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/cms/tcl/rel-procs.xql,v diff -u -r1.2.8.1 -r1.2.8.2 --- openacs-4/packages/cms/tcl/rel-procs.xql 31 Aug 2006 19:59:05 -0000 1.2.8.1 +++ openacs-4/packages/cms/tcl/rel-procs.xql 19 Feb 2007 22:17:42 -0000 1.2.8.2 @@ -49,4 +49,52 @@ + + + select 1 + from cr_type_relations tr + where tr.content_type = :content_type + and tr.target_type = :target_type + and (tr.max_n is null + or (select count(*) from cr_item_rels + where item_id = :item_id + and relation_tag = tr.relation_tag) < tr.max_n) + and not exists (select 1 from cr_item_rels ir + where related_object_id = :object_id + and item_id = :item_id) + + + + + + select 1 + from cr_type_children tc + where tc.parent_type = :parent_type + and tc.child_type = :child_type + and (tc.max_n is null + or (select count(*) from cr_child_rels + where parent_id = :item_id + and relation_tag = tc.relation_tag) < tc.max_n) + and not exists (select 1 from cr_child_rels cr + where child_id = :object_id + and parent_id = :item_id) + + + + + + insert into cr_child_rels ( + rel_id, parent_id, child_id, relation_tag, order_n + ) values ( + :rel_id, :item_id, :object_id, :relation_tag, :order_n + ) + + + + + + delete from cr_child_rels where rel_id = :rel_id + + +