Index: openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl,v diff -u -r1.44 -r1.45 --- openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl 16 Oct 2003 13:01:50 -0000 1.44 +++ openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl 20 Oct 2003 22:05:55 -0000 1.45 @@ -535,7 +535,8 @@ @param url The url of the node to start from. You must provide either url or node_id. An empty url is taken to mean the main site. @param node_id The id of the node to start from. Takes precedence over any provided url. - @param package_key Restrict search to objects of this package type. + @param package_key Restrict search to objects of this package type. You may + supply a list of package_keys. @return The id of the first object found and an empty string if no object is found. Throws an error if no node with given url can be found. @@ -551,28 +552,27 @@ set node_id [site_node::get_node_id -url $url] } - # Climb up the site map starting with node_id and stop when we have - # an object to use as context or when we have reached the root node - set loop_node_id $node_id - set main_node_id [site_node::get_node_id -url "/"] - set context_id "" - set context_package_key "___${package_key}" - while { [empty_string_p $context_id] && \ - [expr [empty_string_p $package_key] || [string equal $package_key $context_package_key]]} { + set object_id "" + while { [empty_string_p $object_id] } { + # move up a level + set node_id [site_node::get_parent_id -node_id $node_id] - set loop_node_id [site_node::get_parent_id -node_id $loop_node_id] - - if { [string equal $loop_node_id ""] } { + if { [empty_string_p $node_id] } { # There is no parent node - we reached the root of the site map break } - array set node_array [site_node::get -node_id $loop_node_id] - set context_id $node_array(object_id) - set context_package_key $node_array(package_key) - } + array set node_array [site_node::get -node_id $node_id] - return $context_id + # are we looking for a specific package_key? + if { [empty_string_p $package_key] || \ + [lsearch -exact $package_key $node_array(package_key)] != -1 } { + set object_id $node_array(object_id) + } + } + + return $object_id + }