Index: openacs-4/contrib/packages/cop-base/tcl/cop-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/tcl/cop-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/cop-base/tcl/cop-procs.tcl 7 May 2004 16:43:21 -0000 1.6 +++ openacs-4/contrib/packages/cop-base/tcl/cop-procs.tcl 23 Jun 2004 14:22:50 -0000 1.7 @@ -1,4 +1,4 @@ -# /packages/cop-base/tcl/clipboard-procs.tcl +# /packages/cop-base/tcl/cop-procs.tcl ad_library { TCL library for the COP package @@ -33,7 +33,8 @@ ad_proc -public cop::util::package_id { {-node_id {}} } { - Returns the first cop-ui package under node_id, node_id defaults to the nearest + Returns the first cop-ui package under node_id, + node_id defaults to the nearest acs-subsite. @param subsite_id the subsite for which to find the cop-ui package_id @@ -42,7 +43,7 @@ @author Jeff Davis davis@xarg.net @creation-date 2003-10-30 } { - if {[empty_string_p $node_id]} { + if {[empty_string_p $node_id]} { set node_id [site_node::closest_ancestor_package -package_key acs-subsite -node_id [ad_conn node_id] -include_self -element node_id] } @@ -76,14 +77,14 @@ set __the_body__ [read $file] close $file # Interpolate the vars. - if {![empty_string_p binds]} { + if {![empty_string_p $binds]} { foreach {var val} $binds { set $var [ad_quotehtml $val] } - if {![info exists Id]} { + if {![info exists Id]} { set Id {$Id} } - if {[catch {set __the_body__ [subst -nobackslashes -nocommands ${__the_body__}]} err]} { + if {[catch {set __the_body__ [subst -nobackslashes -nocommands ${__the_body__}]} err]} { error $err } } @@ -92,7 +93,7 @@ return $root_node } -ad_proc -private cop::install {filename binds} { +ad_proc -private cop::install {filename binds} { set root_node [cop::load_install_xml $filename $binds] install a CoP subsite from an xml definition. @parameter filename path to the xml file defining the CoP relative to serverroot. @@ -248,8 +249,8 @@ } { # need to strip nodes which have no mounted package... set packages [list] - foreach package [site_node::get_children -all -node_id $node_id -element package_id] { - if {![empty_string_p $package]} { + foreach package [site_node::get_children -all -node_id $node_id -element package_id] { + if {![empty_string_p $package]} { lappend packages $package } } @@ -276,3 +277,64 @@ return [util_memoize [list cop::util::packages_no_mem -node_id $subsite_node_id] 1200] } + +ad_proc -private cop::util::catmap { + -name + -description + -context_id + -cats +} { + set tree_id [category_tree::add -name $name -description $description -context_id $context_id] + + set parent(0) {} + set parent(1) {} + set parent(2) {} + + foreach {cat key} $cats { + set parent([expr $cat + 1]) [category::add -noflush -name $key -description $key -tree_id $tree_id -parent_id $parent($cat)] + } + + category_tree::flush_cache $tree_id + category_tree::map -tree_id $tree_id -object_id $context_id + + ns_log Notice "cop::util::catmap $name tree id $tree_id created and mapped to $context_id" + + return $tree_id +} + +ad_proc -private cop::util::after_mount { + -package_id + -node_id +} { + Create the KM categories and map them to mainsite +} { + set cats { + 0 KM + 1 {Urgent question} + 1 {Key document} + 1 {Unanswered question} + 1 {Answered question} + 1 {Discussion} + } + + set tree_id [cop::util::catmap -name KM -description "KM categories" -context_id [subsite::main_site_id] -cats $cats] + + parameter::set_value -package_id $package_id -parameter KMCategoryTreeID -value $tree_id +} + +ad_proc -private cop::util::after_ui_mount { + -package_id + -node_id +} { + Map the KM categories for the cop-base instance to the subsite containing the cop-ui package + + WARNING: This is a callback in cop-ui not cop-base. +} { + set subsite_id [site_node::closest_ancestor_package -package_key acs-subsite -node_id $node_id -element package_id] + + set base_id [apm_package_id_from_key cop-base] + + set tree_id [parameter::get -package_id $base_id -parameter KMCategoryTreeID] + + category_tree::map -tree_id $tree_id -object_id $subsite_id +}