Index: openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl,v diff -u -N -r1.12 -r1.13 --- openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl 31 Jul 2003 01:33:13 -0000 1.12 +++ openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl 31 Jul 2003 09:31:00 -0000 1.13 @@ -124,7 +124,7 @@ set html_options "" set extra_options "" set select_options "" - set validate "" + set validate "{ price { [expr \$value < 0] } { \"Price has to be positive.\" }}" set optional_p "f" set enabled_p "t" } @@ -567,25 +567,24 @@ ad_proc -public classified-ads::get_attributes { {-content_type "ca_ad"} - {-package_id} + {-keyword_id} {-storage "all"} } { Returns a list of ns_sets of the attributes for one content type @param content_type This is the content type whose attributes we get - @param package_id Only the attributes belonging to this package are retrieved. - Defaults to current package. + @param keyword_id Only the attributes belonging to this category are retrieved. + Defaults to current package's main category. @param storage Only the attributes who belong to this storage type are retrieved. Can be "type_specific", "generic", or "all". } { - if {![exists_and_not_null package_id]} { + if {![exists_and_not_null keyword_id]} { set package_id [ad_conn package_id] + set keyword_id [util_memoize "classified-ads::categories::get_package_keyword_id -package_id $package_id"] } - set keyword_id [classified-ads::categories::get_package_keyword_id -package_id $package_id] - if {![string equal $storage "all"]} { set storage_stub "and storage = '$storage'" } else { @@ -595,14 +594,21 @@ return [db_list_of_ns_sets select_attributes {}] } -ad_proc -public classified-ads::get_attribute_names { +ad_proc -public -deprecated classified-ads::get_attribute_names { {-item_id} {-storage "all"} } { - Returns a list of lists of the attribute names for one item + Returns a list of lists of the attribute names for one item. @param package_id The item id whose attribute names we get } { + # + # RBM: I don't understand why we need to support more than one + # content_type and all the associated complications. + # This proc was only used in one place, and I didn't see + # a reason to not deprecate it until I figure out why. + # + if {![exists_and_not_null package_id]} { set package_id [ad_conn package_id] } @@ -624,13 +630,17 @@ {-storage "all"} {-revision_id} } { + Returns a list of lists of the attribute values for one item. - Returns a list of lists of the attribute values for one item - @param item_id The ID of the object whose values we retrieve @param storage Only the attribute values who belong to this storage type are retrieved. Can be "type_specific", "generic", or "all". } { + # + # RBM: FIXME: This looks too messy. Find out reason for all this + # and try to simplify. + # + set values_list [list] set cr_subclass_p [is_subclass -content_type [get_content_type \ @@ -643,7 +653,10 @@ if {[string match $storage "type_specific"] || [string match $storage "all"]} { set table_name [get_table_name -content_type [get_content_type -item_id $item_id]] - set names_value_list [get_attribute_names -item_id $item_id -storage type_specific] + # set names_value_list [get_attribute_names -item_id $item_id -storage type_specific] + set keyword_id [classified-ads::ads::get_category_id -ad_id $item_id] + set names_value_list \ + [classified-ads::categories::get_custom_fields_and_datatypes -keyword_id $keyword_id] set names_list [list] foreach one_name_value $names_value_list {