Index: openacs-4/packages/forums/lib/message/post.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/lib/message/post.tcl,v diff -u -r1.17 -r1.18 --- openacs-4/packages/forums/lib/message/post.tcl 7 Oct 2007 22:37:01 -0000 1.17 +++ openacs-4/packages/forums/lib/message/post.tcl 13 Jan 2008 12:06:33 -0000 1.18 @@ -33,12 +33,12 @@ set form_elements { {message_id:key} {subject:text(text) - {html {size 60}} - {label "[_ forums.Subject]"} + {html {size 60}} + {label "[_ forums.Subject]"} } {message_body:richtext(richtext) - {html {rows 20 cols 60}} - {label "[_ forums.Body]"} + {html {rows 20 cols 60}} + {label "[_ forums.Body]"} } {forum_id:integer(hidden) } @@ -53,30 +53,30 @@ # Deal with anonymous postings if {[expr {$user_id != 0 && $anonymous_allowed_p}]} { append form_elements { - {anonymous_p:integer(checkbox),optional - {options {{"[_ forums.post_anonymously]" 1}}} - {label "[_ forums.Anonymous]"} - } + {anonymous_p:integer(checkbox),optional + {options {{"[_ forums.post_anonymously]" 1}}} + {label "[_ forums.Anonymous]"} + } } } else { append form_elements { - {anonymous_p:integer(hidden),optional - } + {anonymous_p:integer(hidden),optional + } } } # Attachments if {$user_id != 0} { append form_elements { - {attach_p:integer(radio),optional - {options {{[_ acs-kernel.common_No] 0} {[_ acs-kernel.common_Yes] 1}}} - {label "[_ forums.Attach]"} - } + {attach_p:integer(radio),optional + {options {{[_ acs-kernel.common_No] 0} {[_ acs-kernel.common_Yes] 1}}} + {label "[_ forums.Attach]"} + } } } else { append form_elements { - {attach_p:integer(hidden),optional - } + {attach_p:integer(hidden),optional + } } } @@ -85,129 +85,129 @@ -edit_buttons $edit_buttons \ -form $form_elements \ -new_request { - ############################## - # Form initialisation - # - set message_id [db_nextval acs_object_id_seq] - if {[empty_string_p $parent_id]} { - set parent_id "" - } else { - set forum_id $parent_message(forum_id) - set subject [forum::format::reply_subject $parent_message(subject)] - } - - set confirm_p 0 - set subscribe_p 0 - set anonymous_p 0 - set attach_p 0 + ############################## + # Form initialisation + # + set message_id [db_nextval acs_object_id_seq] + if {[empty_string_p $parent_id]} { + set parent_id "" + } else { + set forum_id $parent_message(forum_id) + set subject [forum::format::reply_subject $parent_message(subject)] + } + + set confirm_p 0 + set subscribe_p 0 + set anonymous_p 0 + set attach_p 0 } -on_submit { - ############################## - # Form processing - # - - if { [empty_string_p $anonymous_p] } { set anonymous_p 0 } - + ############################## + # Form processing + # + + if { [empty_string_p $anonymous_p] } { set anonymous_p 0 } + - set action [template::form::get_button message] + set action [template::form::get_button message] - # Make post the default action - if {$action eq ""} { - set action preview - } + # Make post the default action + if {$action eq ""} { + set action preview + } - set displayed_user_id [ad_decode \ - [expr {$anonymous_allowed_p && $anonymous_p}] \ - 0 $user_id \ - 0] + set displayed_user_id [ad_decode \ + [expr {$anonymous_allowed_p && $anonymous_p}] \ + 0 $user_id \ + 0] - if { [string equal $action "preview"] } { - - set confirm_p 1 - set subject.spellcheck ":nospell:" - set content.spellcheck ":nospell:" - set content [template::util::richtext::get_property content $message_body] - set format [template::util::richtext::get_property format $message_body] - - set exported_vars [export_vars -form {message_id forum_id parent_id subject {message_body $content} {message_body.format $format} confirm_p subject.spellcheck content.spellcheck anonymous_p attach_p}] - - set message(format) $format - set message(subject) $subject - set message(content) $content - set message(user_id) $displayed_user_id - set message(user_name) [db_string select_name {}] - set message(screen_name) $screen_name - set message(posting_date_ansi) [db_string select_date {}] - set message(posting_date_pretty) [lc_time_fmt $message(posting_date_ansi) "%x %X"] - - # Let's check if this person is subscribed to the forum - # in case we might want to subscribe them to the thread - if {[empty_string_p $parent_id]} { - if {![empty_string_p [notification::request::get_request_id \ - -type_id [notification::type::get_type_id -short_name forums_forum_notif] \ - -object_id $forum_id \ - -user_id [ad_conn user_id]]]} { - set forum_notification_p 1 - } else { - set forum_notification_p 0 - } - } - - ad_return_template "/packages/forums/lib/message/post-confirm" - } + if { [string equal $action "preview"] } { + + set confirm_p 1 + set subject.spellcheck ":nospell:" + set content.spellcheck ":nospell:" + set content [template::util::richtext::get_property content $message_body] + set format [template::util::richtext::get_property format $message_body] + + set exported_vars [export_vars -form {message_id forum_id parent_id subject {message_body $content} {message_body.format $format} confirm_p subject.spellcheck content.spellcheck anonymous_p attach_p}] + + set message(format) $format + set message(subject) $subject + set message(content) $content + set message(user_id) $displayed_user_id + set message(user_name) [db_string select_name {}] + set message(screen_name) $screen_name + set message(posting_date_ansi) [db_string select_date {}] + set message(posting_date_pretty) [lc_time_fmt $message(posting_date_ansi) "%x %X"] + + # Let's check if this person is subscribed to the forum + # in case we might want to subscribe them to the thread + if {[empty_string_p $parent_id]} { + if {![empty_string_p [notification::request::get_request_id \ + -type_id [notification::type::get_type_id -short_name forums_forum_notif] \ + -object_id $forum_id \ + -user_id [ad_conn user_id]]]} { + set forum_notification_p 1 + } else { + set forum_notification_p 0 + } + } + + ad_return_template "/packages/forums/lib/message/post-confirm" + } # DRB: Malte: this redirect_url var isn't used as it is reset in the code below. Please # review and either discard this line or fix the stuff below ... -# set redirect_url "[ad_conn package_url]message-view?message_id=[set redirect_message_id]&\#$message_id" +# set redirect_url "[ad_conn package_url]message-view?message_id=[set redirect_message_id]&\#$message_id" - if { [string equal $action "post"] } { - set content [template::util::richtext::get_property content $message_body] - set format [template::util::richtext::get_property format $message_body] - - forum::message::new \ - -forum_id $forum_id \ - -message_id $message_id \ - -parent_id $parent_id \ - -subject $subject \ - -content $content \ - -format $format \ - -user_id $displayed_user_id - - # DRB: Black magic cache flush call which will disappear when list builder is - # rewritten to paginate internally rather than use the template paginator. - cache flush "messages,forum_id=$forum_id*" + if { [string equal $action "post"] } { + set content [template::util::richtext::get_property content $message_body] + set format [template::util::richtext::get_property format $message_body] + + forum::message::new \ + -forum_id $forum_id \ + -message_id $message_id \ + -parent_id $parent_id \ + -subject $subject \ + -content $content \ + -format $format \ + -user_id $displayed_user_id + + # DRB: Black magic cache flush call which will disappear when list builder is + # rewritten to paginate internally rather than use the template paginator. + cache flush "messages,forum_id=$forum_id*" if { [forum::use_ReadingInfo_p] } { - # remove reading info for this thread for all users (mark it unread) + # remove reading info for this thread for all users (mark it unread) set db_antwort [db_exec_plsql forums_reading_info__remove_msg {}] } # VGUERRA Redirecting to the first message ALWAYS forum::message::get -message_id $message_id -array msg set redirect_url "[ad_conn package_url]message-view?message_id=$msg(root_message_id)" - - # Wrap the notifications URL - if {![empty_string_p $subscribe_p] && $subscribe_p && [empty_string_p $parent_id]} { - set notification_url [notification::display::subscribe_url \ - -type forums_message_notif \ - -object_id $message_id \ - -url $redirect_url \ - -user_id $user_id] - - # redirect to notification stuff - set redirect_url $notification_url - } - - # Wrap the attachments URL - if {$attachments_enabled_p} { - if { ![empty_string_p $attach_p] && $attach_p} { - set redirect_url [attachments::add_attachment_url -object_id $message_id -return_url $redirect_url -pretty_name "[_ forums.Forum_Posting] \"$subject\""] - } - } - - # Do the redirection - ad_returnredirect $redirect_url - ad_script_abort - } + + # Wrap the notifications URL + if {![empty_string_p $subscribe_p] && $subscribe_p && [empty_string_p $parent_id]} { + set notification_url [notification::display::subscribe_url \ + -type forums_message_notif \ + -object_id $message_id \ + -url $redirect_url \ + -user_id $user_id] + + # redirect to notification stuff + set redirect_url $notification_url + } + + # Wrap the attachments URL + if {$attachments_enabled_p} { + if { ![empty_string_p $attach_p] && $attach_p} { + set redirect_url [attachments::add_attachment_url -object_id $message_id -return_url $redirect_url -pretty_name "[_ forums.Forum_Posting] \"$subject\""] + } + } + + # Do the redirection + ad_returnredirect $redirect_url + ad_script_abort + } }