Index: openacs-4/contrib/packages/project-manager/tcl/project-manager-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/tcl/Attic/project-manager-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/project-manager/tcl/project-manager-procs.tcl 10 Jun 2004 20:23:11 -0000 1.6 +++ openacs-4/contrib/packages/project-manager/tcl/project-manager-procs.tcl 11 Jun 2004 20:58:13 -0000 1.7 @@ -402,3 +402,95 @@ -body "$nice_text" } + + +ad_proc -public pm::util::category_selects { + {-export_vars ""} + {-category_id ""} + {-package_id ""} +} { + Returns an HTML fragment of forms, one for each + category tree, suitable for use on a page. + + @author Jade Rubick (jader@bread.com) + @creation-date 2004-06-11 + + @param export_vars Variables already exported with export_vars -form + + @param category_id If set, the currently selected category + + @return + + @error +} { + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + + # caches results for 5 minutes. + return [util_memoize [list pm::util::category_selects_helper -export_vars $export_vars -category_id $category_id -package_id $package_id] 300] +} + + + +ad_proc -public pm::util::category_selects_helper { + {-export_vars ""} + {-category_id ""} + -package_id:required +} { + Returns an HTML fragment of forms, one for each + category tree, suitable for use on a page. This proc + is used so that pm::util::category_selects can cache + the categories + + @author Jade Rubick (jader@bread.com) + @creation-date 2004-06-11 + + @param export_vars Variables already exported with export_vars -form + + @param category_id If set, the currently selected category + + @return + + @error +} { + # Categories are arranged into category trees. + # Set up an array for each tree. The array contains the category for each tree + + db_foreach get_categories { } { + lappend category_choices($tree_id) [list $cat_name $cat_id] + } + + + set category_select "" + + foreach tree_list [db_list_of_lists get_category_trees { }] { + + set tree_name [lindex $tree_list 0] + set tree_id [lindex $tree_list 1] + + if {![exists_and_not_null category_choices($tree_id)]} { + set category_choices($tree_id) [list] + } + + + append category_select "
$export_vars $tree_name:
" + + return $category_select +}