Index: openacs-4/packages/ams/www/attribute-option-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/attribute-option-delete.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/ams/www/attribute-option-delete.tcl 28 May 2005 15:37:27 -0000 1.3 +++ openacs-4/packages/ams/www/attribute-option-delete.tcl 7 Jun 2005 11:22:23 -0000 1.4 @@ -9,17 +9,29 @@ } { option_id:integer,notnull + {attribute_id ""} } -validate { option_has_no_entries -requires {option_id} { - if { ![string match [db_string get_count { select count(*) from ams_option_map where option_id = :option_id } -default {0}] {0}] } { - ad_complain {[_ ams.lt_You_cannot_delete_an_]} - } + if {[empty_string_p $attribute_id]} { + if { ![string match [db_string get_count { select count(*) from ams_option_types where option_id = :option_id } -default {0}] {0}] } { + ad_complain [_ ams.lt_You_cannot_delete_an_] + } + } } } -db_1row get_option_info { select * from ams_options where option_id = :option_id } +if {[empty_string_p $attribute_id]} { -db_dml delete_option { delete from ams_options where option_id = :option_id } + # Delete the option for good + + db_1row get_option_info { select * from ams_options where option_id = :option_id } + db_dml delete_option { delete from ams_options where option_id = :option_id } +} else { + + # Just unmap the option + + db_dml unmap_option { delete from ams_option_types where option_id = :option_id and attribute_id = :attribute_id } +} -ad_returnredirect -message "[_ ams.Option_Deleted]" "attribute?[export_vars -url {ams_attribute_id}]" +ad_returnredirect -message "[_ ams.Option_Deleted]" "attribute?[export_vars -url {attribute_id}]"