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.7 -r1.8 --- openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl 24 Jul 2003 01:14:44 -0000 1.7 +++ openacs-4/contrib/packages/classified-ads/tcl/ads-procs.tcl 24 Jul 2003 20:20:10 -0000 1.8 @@ -53,8 +53,10 @@ @see classified-ads::edit_ca_item } { - return [classified-ads::edit_ca_item -item_id_element $item_id_element \ - -form_id $form_id \ + ns_log notice "RBM: item_id = $item_id_element, form_id = $form_id, isbn exists? [template::element::exists $form_id isbn]" + return [classified-ads::edit_ca_item \ + -item_id_element $item_id_element \ + -form_id $form_id \ ] } 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.5 -r1.6 --- openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl 23 Jul 2003 22:39:16 -0000 1.5 +++ openacs-4/contrib/packages/classified-ads/tcl/classified-ads-procs.tcl 24 Jul 2003 20:20:10 -0000 1.6 @@ -331,7 +331,7 @@ if {[template::element::exists $form_id $item_id_element]} { set item_id [template::element::get_value $form_id $item_id_element] } else { - ad_return_complaint 1 "
  • passed in item id not found" + ad_return_error "Passed item_id not found" "
  • Passed in item id not found." ad_script_abort } @@ -359,6 +359,10 @@ set name "$content_type -- $item_id" set title [template::element::get_value $form_id $title_column] + # + # RBM: FIXME? This doesn't look like what should be done to me. + # + if {[empty_string_p $title]} { # make sure there is always a title set title $name @@ -373,6 +377,7 @@ # do everything in a transaction db_transaction { + # # DEDS: FIXME - this only supports one table # fix it so that it can span multiple tables @@ -387,6 +392,7 @@ # Get the type specific attributes set type_specific_attr_list [get_attributes -content_type $content_type -storage "type_specific"] + ns_log notice "RBM: type_specific = $type_specific_attr_list" if {[llength $type_specific_attr_list]} { # @@ -403,7 +409,11 @@ set table_name [ns_set get $one_attribute table_name] set datatype [ns_set get $one_attribute datatype] + ns_log notice "RBM: column = $column_name, table = $table_name, datatype = $datatype" + if {[template::element::exists $form_id $column_name]} { + ns_log notice "RBM: Exists in the form" + lappend name_list $column_name lappend value_list ":$column_name" lappend update_list "$column_name = :$column_name" @@ -428,13 +438,15 @@ # update the type specific data + ns_log notice "RBM: plsql_query: $plsql_query" db_dml update_data {} -bind $type_specific_bind_vars ns_set free $type_specific_bind_vars } # get the generic attributes set generic_attr_list [get_attributes -content_type $content_type -storage "generic"] + ns_log notice "RBM: generic = $generic_attr_list" if {[llength $generic_attr_list]} { foreach one_attribute $generic_attr_list { Index: openacs-4/contrib/packages/classified-ads/tcl/widget-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/tcl/widget-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/classified-ads/tcl/widget-procs.tcl 24 Jul 2003 01:04:48 -0000 1.3 +++ openacs-4/contrib/packages/classified-ads/tcl/widget-procs.tcl 24 Jul 2003 20:20:10 -0000 1.4 @@ -30,6 +30,8 @@ } { set package_id [ad_conn package_id] + set ad_form_spec "ad_form -extend -name $form_id -form {" + set validate_block "" if { [empty_string_p $keyword_id] } { # @@ -44,63 +46,80 @@ set widget_list [db_list_of_ns_sets select_widgets {}] foreach one_widget $widget_list { - set extra_ops "" + set element_name [ns_set get $one_widget attribute_name] + set element_label [ns_set get $one_widget label] + set element_datatype [ns_set get $one_widget datatype] + set element_widget [ns_set get $one_widget widget] + set element_options [ns_set get $one_widget select_options] + set element_line "\n{$element_name:$element_datatype\($element_widget\)" + # Is it optional? + + if {[string equal [ns_set get $one_widget optional_p] "t"]} { + append element_line ",optional {label \"$element_label\"}" + } else { + append element_line "\t{label \"$element_label\"}" + } + # Were html options passed? set html_options [ns_set get $one_widget html_options] if {![empty_string_p $html_options]} { - append extra_ops " -html $html_options" + append element_line "\n\t{html $html_options}" } # Is there a default value? set default_value [ns_set get $one_widget default_value] if {![empty_string_p $default_value]} { - append extra_ops " -value $default_value" + append element_line "\n\t{value \"$default_value\"}" } - # Is there a validate clause? - - set validate_clause [ns_set get $one_widget validate] - - if {![empty_string_p $validate_clause]} { - append extra_ops " -validate $validate_clause" - } - - # Is it optional? - - if {[string equal [ns_set get $one_widget optional_p] "t"]} { - append extra_ops " -optional" - } - # # RBM: Did the user pass extra form builder options? # # This is somewhat dangerous, but the admin must know what # s/he is doing when entering extra options. It was the only # way I could think of to allow for different options like - # -format, -help_text, -help, etc. to be added on a - # per-field basis. + # format, help_text, help, etc. to be added on a per-field basis. # set extra_clause [ns_set get $one_widget extra_options] if { ![empty_string_p $extra_clause] } { - append extra_ops " $extra_clause" + append element_line "\n\t$extra_clause" } - set widget_command "template::element::create $form_id [ns_set get $one_widget attribute_name] \ - -label \"[ns_set get $one_widget label]\" \ - -datatype \"[ns_set get $one_widget datatype]\" \ - -options \"[ns_set get $one_widget select_options]\" \ - -widget \"[ns_set get $one_widget widget]\" $extra_ops" + # Now end the element list - eval $widget_command + append element_line "}" + + # Is there a validate clause? + + set validate_clause [ns_set get $one_widget validate] + + if {![empty_string_p $validate_clause]} { + append validate_block "{$element_name {$validate_clause}}" + } + + # Add this element to the ad_form spec + + append ad_form_spec $element_line } + # Close the ad_form spec and then add a validate block if not empty + + append ad_form_spec "}" + + if { ![empty_string_p $validate_block] } { + append ad_form_spec " -validate { $validate_block }" + } + + ns_log notice "RBM: ad_form: $ad_form_spec" + eval $ad_form_spec + return 0 } Index: openacs-4/contrib/packages/classified-ads/www/admin/ad-one.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/classified-ads/www/admin/ad-one.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/classified-ads/www/admin/ad-one.tcl 24 Jul 2003 01:04:48 -0000 1.3 +++ openacs-4/contrib/packages/classified-ads/www/admin/ad-one.tcl 24 Jul 2003 20:20:10 -0000 1.4 @@ -40,7 +40,10 @@ {optional} {html {cols 60 rows 10 wrap soft}} } -} -on_request { +} + +if {[template::form is_request ad]} { + ns_log notice "RBM: Executed on_request. Action = $action." classified-ads::ads::get -ad_id $ad_id -revision_id $revision_id -array adinfo # Get extra custom widgets, if any @@ -54,12 +57,16 @@ classified-ads::widgets::set_widget_values -form_id ad -form_values $form_values - element set_properties ad ad_id -value $ad_id - element set_properties ad title -value $adinfo(title) - element set_properties ad description -value $adinfo(description) - element set_properties ad data -value $adinfo(data) + template::element::set_value ad title $adinfo(title) + template::element::set_value ad description $adinfo(description) + template::element::set_value ad data $adinfo(data) -} -edit_data { + ns_log notice "RBM: on_request: isbn exists? [template::element::exists ad isbn] , [info exists isbn]" +} + +ad_form -extend -name ad -edit_data { + ns_log notice "RBM: Executed edit_data. Action = $action" + ns_log notice "RBM: isbn_exists? [template::element::exists ad isbn], OK? [info exists isbn]. description exists? [template::element::exists ad description]" set ad_id [classified-ads::ads::edit \ -item_id_element ad_id \ -form_id ad] @@ -70,6 +77,7 @@ ad_script_abort } -edit_request { + ns_log notice "RBM: Executed edit_request. Action = $action. isbn_exists? [template::element::exists ad isbn] OK? [info exists isbn]" if { [string equal $action "delete"] } { # # If the delete button was pressed