Index: openacs-4/packages/curriculum/tcl/element-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/tcl/element-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/curriculum/tcl/element-procs.tcl 10 Jun 2003 09:29:49 -0000 1.2 +++ openacs-4/packages/curriculum/tcl/element-procs.tcl 25 Jun 2003 17:34:17 -0000 1.3 @@ -38,26 +38,49 @@ } { # Check for external URLs. + set external_p [external_p -url $url] + + # Prepare the variables for instantiation. + set extra_vars [ns_set create] + oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {element_id curriculum_id name description desc_format url external_p enabled_p sort_key} + + # Instantiate the curriculum element. + return [package_instantiate_object -extra_vars $extra_vars cu_element] +} + + +ad_proc -public curriculum::element::external_p { + {-url:required} +} { + + Determine whether or not a curriculum element is external. + + @param url The url to check. + + @return t or f + + @author Ola Hansson (ola@polyxena.net) + +} { + # Check for external URLs. if { [string equal -length 7 "http://" $url] } { set external_p t } else { # Try to determine if the URL belongs to another subsite. - array set node [site_node::get_from_url -url $url] + #array set node [site_node::get_from_url -url $url] # FIXME. This condition does not tell the whole truth ... - if { [string equal -length [string length $node(url)] $node(url) $url] } { + + set subsite_id [site_node_closest_ancestor_package -url $url [curriculum::package_keys]] + + if { $subsite_id == [curriculum::conn subsite_id] } { set external_p f } else { set external_p t } } - - # Prepare the variables for instantiation. - set extra_vars [ns_set create] - oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {element_id curriculum_id name description desc_format url external_p enabled_p sort_key} - - # Instantiate the curriculum element. - return [package_instantiate_object -extra_vars $extra_vars cu_element] + + return $external_p } @@ -82,6 +105,9 @@ @author Ola Hansson (ola@polyxena.net) } { + # Check for external URLs. + set external_p [external_p -url $url] + db_dml update_curriculum_element {*SQL*} } Index: openacs-4/packages/curriculum/tcl/element-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/tcl/element-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/curriculum/tcl/element-procs.xql 3 Jun 2003 10:28:20 -0000 1.1 +++ openacs-4/packages/curriculum/tcl/element-procs.xql 25 Jun 2003 17:34:17 -0000 1.2 @@ -7,7 +7,8 @@ set name = :name, description = :description, desc_format = :desc_format, - url = :url + url = :url, + external_p = :external_p where element_id = :element_id Index: openacs-4/packages/curriculum/tcl/misc-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/tcl/misc-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/curriculum/tcl/misc-procs.tcl 18 Jun 2003 15:21:51 -0000 1.6 +++ openacs-4/packages/curriculum/tcl/misc-procs.tcl 25 Jun 2003 17:34:17 -0000 1.7 @@ -11,7 +11,25 @@ namespace eval curriculum {} + +ad_proc -public curriculum::package_keys { +} { + Builds a list that will be used as an argument to "site_node_closest_ancestor_package". + If .LRN is not installed it will be ste to "acs_subsite" and if it is installed, + "dotlrn" will be prepended to the list. The Underlying reason we do this is because + we want to allow one Curriculum instance under each dotLRN instance, if dotLRN is + installed. And if it is installed it should take precedence over acs_subsite. +} { + set package_keys [list acs-subsite] + if { [apm_package_installed_p dotlrn] } { + set package_keys [concat dotlrn $package_keys] + } + + return $package_keys +} + + ad_proc -public curriculum::conn { args } { @@ -49,13 +67,7 @@ # "ad_conn subsite_id" does not work when called from within a filter # (which we do for the curriculum bar), so we use the following instead. - set package_keys [list acs-subsite] - - if { [apm_package_installed_p dotlrn] } { - set package_keys [concat dotlrn $package_keys] - } - - return [site_node_closest_ancestor_package $package_keys] + return [site_node_closest_ancestor_package [package_keys]] } package_id - package_url -