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 -r1.8 -r1.9 --- openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl 25 Jul 2003 23:53:19 -0000 1.8 +++ openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl 27 Jul 2003 00:46:16 -0000 1.9 @@ -72,19 +72,52 @@ } { set main_keyword_id [classified-ads::main_keyword_exists_p] set attributes [list type expires_on] - set attributes_query [join attributes ","] - set count [db_1row count_attributes {}] + foreach attrib $attributes { + set count [db_1row count_attributes {}] - if { $count != [llength $attributes] } { - # - # Site-wide attributes have not been created. Create them. - # + if { $count != 1 } { + # + # This site-wide attribute has not been created. Create them. + # - db_transaction { - db_exec_plsql create_function {} - db_exec_plsql run_function {} - db_exec_plsql drop_function {} + db_transaction { + switch $attrib { + "type" { + set attribute_name "type" + set datatype "integer" + set pretty_name "Type" + set pretty_plural "Types" + set default_value 0 + set column_spec "integer" + set widget "radio" + set html_options "" + set extra_options "" + set select_options "{{\"For Sale\" 0} {\"Wanted to Buy\" 1}}" + set validate "" + set optional_p "f" + set enabled_p "t" + } + "expires_on" { + set attribute_name "expires_on" + set datatype "date" + set pretty_name "Expires On" + set pretty_plural "Expires On" + set default_value "" + set column_spec "timestamp" + set widget "date" + set html_options "" + set extra_options " -format \"MONTH DD YYYY\" -help" + set select_options "" + set validate "" + set optional_p "t" + set enabled_p "t" + } + } + + set attribute_id [db_exec_plsql create_attribute {}] + db_exec_plsql register_widget {} + } } return 1