Index: openacs.org-dev/packages/forums/tcl/messages-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/tcl/messages-procs.tcl,v diff -u -r1.1.1.3 -r1.1.1.4 --- openacs.org-dev/packages/forums/tcl/messages-procs.tcl 25 Jul 2002 19:59:28 -0000 1.1.1.3 +++ openacs.org-dev/packages/forums/tcl/messages-procs.tcl 8 Oct 2002 15:47:12 -0000 1.1.1.4 @@ -18,7 +18,6 @@ {-content:required} {-html_p "f"} {-user_id ""} - {-posting_date ""} } { create a new message } { @@ -28,9 +27,10 @@ set user_id [ad_conn user_id] } + set original_message_id $message_id # Prepare the variables for instantiation set extra_vars [ns_set create] - oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {forum_id message_id parent_id subject content html_p user_id posting_date} + oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {forum_id message_id parent_id subject content html_p user_id} db_transaction { set message_id [package_instantiate_object -extra_vars $extra_vars forums_message] @@ -39,6 +39,26 @@ if {[info exists message(state)] && [string equal $message(state) approved]} { do_notifications -message_id $message_id } + } on_error { + + db_abort_transaction + + # Check to see if the message with a message_id matching the + # message_id arguement was in the database before calling + # this procedure. If so, the error is due to a double click + # and we should continue without returning an error. + + if {![empty_string_p $original_message_id]} { + # The was a non-null message_id arguement + if {[db_string message_exists_p " + select count(message_id) + from forums_messages + where message_id = :message_id"]} { + + return $message_id + + } + } } return $message_id @@ -60,10 +80,34 @@ append new_content "Posted: $message(posting_date)
" append new_content "\n
\n" append new_content $message(content) + append new_content "

-------------------
" # send text for now. set new_content [ad_html_to_text $new_content] + set html_version $new_content + set text_version "" + append text_version " +Forum: $message(forum_name) +Thread: $message(root_message_id) +Author: $message(user_name) ($message(user_email)) +Posted: $message(posting_date) +---------------------------------- +[ad_html_to_text $message(content)] +--------------------------------- +To post a reply to this email or view this message go to: +${url}message-view?message_id=$message(root_message_id) + +To view Forum $message(forum_name) go to: +${url}forum-view?forum_id=$message(forum_id) + +To email the author($message(user_name)) privately: +mailto:$message(user_email) +" + set new_content $text_version + ns_log notice "requesting a notification with subject $message(forum_name) $message(subject)" + + # Do the notification for the forum notification::new \ -type_id [notification::type::get_type_id \