Index: openacs-4/packages/acs-subsite/www/admin/site-map/allow-for-view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/admin/site-map/allow-for-view.tcl,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/acs-subsite/www/admin/site-map/allow-for-view.tcl 23 Nov 2004 18:49:51 -0000 1.1.2.1 +++ openacs-4/packages/acs-subsite/www/admin/site-map/allow-for-view.tcl 17 Dec 2004 22:49:26 -0000 1.1.2.2 @@ -5,7 +5,7 @@ } { checkbox:integer,multiple,optional - return_url + return_url } set user_id [ad_maybe_redirect_for_registration] @@ -14,10 +14,41 @@ set checkbox "" } +# Get the main site node_id from object_id +set main_node [site_node::get_node_id_from_object_id -object_id [subsite::main_site_id]] +set check_list [list] + +# Here we make shure that when a child node is checked all his parents +# in the tree are also checked as well + +foreach check_node $checkbox { + if { [string equal $main_node $check_node] } { + + # The main site node is always checked + lappend check_list $check_node + + } elseif {[string equal [site_node::get_parent_id -node_id $check_node] $main_node] } { + + # This node doesn't have a parent node, only the main site node + lappend check_list $check_node + + } else { + # The node has an inmediate parent, we put it on the list and all his parents until the + # node_id equals the main_site node_id and is already in the list + lappend check_list $check_node + while { [site_node::get_parent_id -node_id $check_node] != $main_node && \ + [lsearch -exact $check_list [site_node::get_parent_id -node_id $check_node]] == -1 } { + set check_node [site_node::get_parent_id -node_id $check_node] + lappend check_list $check_node + } + } +} + + db_transaction { db_dml delete_nodes { *SQL* } - foreach checkbox $checkbox { + foreach checkbox $check_list { db_dml insert_nodes { *SQL* } } }