Index: openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl 19 Jul 2003 01:48:45 -0000 1.3 +++ openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl 21 Jul 2003 05:23:56 -0000 1.4 @@ -50,6 +50,8 @@ @param form_id The ID of the form that contains the name/value pairs @param item_id_element The name of the form element that should be used as the item id + @see classified-ads::edit_ca_item + } { return [classified-ads::edit_ca_item -item_id_element $item_id_element \ -form_id $form_id \ @@ -91,6 +93,7 @@ # Get extra widgets that we need to display # set package_id [ad_conn package_id] + set content_type "ca_ad" set widget_list [db_list_of_ns_sets select_widgets {}] if {[empty_string_p $revision_id]} { @@ -104,11 +107,11 @@ db_1row select_data {} -column_array row - set row(pretty_publish_date) [util_AnsiDatetoPrettyDate $publish_date] + set row(pretty_publish_date) [util_AnsiDatetoPrettyDate $row(publish_date)] set row(data) [classified-ads::get_content -revision_id $revision_id] return 0 - } +} ad_proc -public get_assigned_ads_by_category { @@ -164,4 +167,44 @@ return [db_list_of_ns_sets select_ads {}] } +ad_proc -public get_category_id { + {-ad_id:required} +} { + Return the keyword_id of the category the passed ad belongs to. + + @author Roberto Mello +} { + return [db_0or1row get_category_id {}] } + +ad_proc -public generate_trail { + {-ad_id:required} + {-append_element} +} { + Generates a cookie trail for a particular ad. + + @param ad_id The id of the ad. + @author Roberto Mello +} { + set keyword_id [classified-ads::ads::get_category_id -ad_id $ad_id] + + if { [exists_and_not_null append_element] } { + set to_append $append_element + } else { + set to_append "Ad $ad_id" + } + + # + # We call categories::generate_trail with "-append_element foo" so we + # can cache its results effectively. + # + + set trail_list [util_memoize "classified-ads::categories::generate_trail -keyword_id $keyword_id -append_element foo"] + + set last_element_index [expr [llength $trail_list] - 1] + set trail_list [lreplace $trail_list $last_element_index $last_element_index $to_append] + + return $trail_list +} + +}