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.29 -r1.30
--- openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl 29 Jun 2003 23:32:23 -0000 1.29
+++ openacs-4/packages/acs-tcl/tcl/site-nodes-procs.tcl 7 Jul 2003 12:00:01 -0000 1.30
@@ -537,7 +537,7 @@
ad_proc -public site_node_closest_ancestor_package {
{ -default "" }
{ -url "" }
- package_key
+ package_keys
} {
Finds the package id of a package of specified type that is
closest to the node id represented by url (or by ad_conn url).Note
@@ -558,50 +558,50 @@
@param default The value to return if no package can be found
@param current_node_id The node from which to start the search
- @param package_key The type of the package for which we are looking
+ @param package_keys The type(s) of the package(s) for which we are looking
@return package_id
of the nearest package of the
specified type (package_key
). Returns $default if no
such package can be found.
} {
if {[empty_string_p $url]} {
- set url [ad_conn url]
+ set url [ad_conn url]
}
# Try the URL as is.
if {[catch {nsv_get site_nodes $url} result] == 0} {
- array set node $result
- if { [string eq $node(package_key) $package_key] } {
- return $node(package_id)
- }
+ array set node $result
+ if { [lsearch -exact $package_keys $node(package_key)] != -1 } {
+ return $node(package_id)
+ }
}
-
+
# Add a trailing slash and try again.
if {[string index $url end] != "/"} {
- append url "/"
- if {[catch {nsv_get site_nodes $url} result] == 0} {
- array set node $result
- if { [string eq $node(package_key) $package_key] } {
- return $node(package_id)
- }
- }
+ append url "/"
+ if {[catch {nsv_get site_nodes $url} result] == 0} {
+ array set node $result
+ if { [lsearch -exact $package_keys $node(package_key)] != -1 } {
+ return $node(package_id)
+ }
+ }
}
-
+
# Try successively shorter prefixes.
while {$url != ""} {
- # Chop off last component and try again.
- set url [string trimright $url /]
- set url [string range $url 0 [string last / $url]]
+ # Chop off last component and try again.
+ set url [string trimright $url /]
+ set url [string range $url 0 [string last / $url]]
- if {[catch {nsv_get site_nodes $url} result] == 0} {
- array set node $result
- if {$node(pattern_p) == "t" && $node(object_id) != "" && [string eq $node(package_key) $package_key] } {
- return $node(package_id)
- }
- }
+ if {[catch {nsv_get site_nodes $url} result] == 0} {
+ array set node $result
+ if {$node(pattern_p) == "t" && $node(object_id) != "" && [lsearch -exact $package_keys $node(package_key)] != -1 } {
+ return $node(package_id)
+ }
+ }
}
-
+
return $default
}