Fisheye: Tag 1.5 refers to a dead (removed) revision in file `openacs.org-dev/packages/forums/www/message-post-confirm.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs.org-dev/packages/forums/www/message-post.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs.org-dev/packages/forums/www/message-post.tcl,v diff -u -r1.8 -r1.9 --- openacs.org-dev/packages/forums/www/message-post.tcl 4 Sep 2002 03:23:44 -0000 1.8 +++ openacs.org-dev/packages/forums/www/message-post.tcl 21 Oct 2002 18:42:42 -0000 1.9 @@ -4,10 +4,9 @@ @author Ben Adida (ben@openforce.net) @creation-date 2002-05-25 - @version $Id$ + @cvs-id $Id$ } -query { - message_id:optional {forum_id ""} {parent_id ""} } -validate { @@ -17,80 +16,89 @@ } } } + set user_id [ad_verify_and_get_user_id] -if { $user_id == 0 } { - ad_returnredirect "/register/?return_url=[ad_urlencode [ad_conn url]?[ad_conn query]]" -} +# get the colors from the params +set table_border_color [parameter::get -parameter table_border_color] +set table_bgcolor [parameter::get -parameter table_bgcolor] +form create message -if {![empty_string_p $parent_id]} { - # get the parent message information - forum::message::get -message_id $parent_id -array parent_message - set forum_id $parent_message(forum_id) - set subject "Re: $parent_message(subject)" +element create message message_id \ + -label "Message ID" \ + -datatype integer \ + -widget hidden -} +element create message subject \ + -label Subject \ + -datatype text \ + -widget text \ + -html {size 60} \ + -validate { {expr ![empty_string_p [string trim $value]]} {Please enter a subject} } -forum::security::require_post_forum -forum_id $forum_id +# we use ns_queryget to get the value of html_p because it won't be defined +# until the next element -DaveB -forum::get -forum_id $forum_id -array forum +element create message content \ + -label Body \ + -datatype text \ + -widget textarea \ + -html {rows 20 cols 60 wrap soft} \ + -validate { + empty {expr ![empty_string_p [string trim $value]]} {Please enter a message} + html { expr {( [string match [set l_html_p [ns_queryget html_p f]] "t"] && [empty_string_p [set v_message [ad_html_security_check $value]]] ) || [string match $l_html_p "f"] } } + {} + } -set attachments_enabled_p [forum::attachments_enabled_p] +element create message html_p \ + -label Format \ + -datatype text \ + -widget select \ + -options {{text f} {html t}} -# get the colors from the params -set table_border_color [parameter::get -parameter table_border_color] -set table_bgcolor [parameter::get -parameter table_bgcolor] +element create message parent_id \ + -label "parent ID" \ + -datatype integer \ + -widget hidden \ + -optional -# switchover to using ad_form -# this allows simpler state management of the form --DaveB -# -# message_id:key -# this generates a message_id from acs_objects_sequence useful for -# double-click protection and inserting a new message in the database -# -# -validate section runs the message content through ad_html_security_check -# to check for tags that can cause trouble -# -# -confirm_template sends to message-post-confirm -# with magic hidden variables to maintain ad_form state when we get back here -# The confirm template reproduces all the data in hidden variables -# so that they can be returned for processing -# -# -new_data section runs after confirm_template to actually insert the -# message into the database +element create message forum_id \ + -label "forum ID" \ + -datatype integer \ + -widget hidden -ad_form -name message -confirm_template message-post-confirm -form { +element create message confirm_p \ + -label "Confirm?" \ + -datatype text \ + -widget hidden - message_id:key +element create message subscribe_p \ + -label "Subscribe?" \ + -datatype text \ + -widget hidden \ + -optional - {subject:text(text) - {label Subject} - {html {size 60}} - } +set attachments_enabled_p [forum::attachments_enabled_p] - {content:text(textarea) - {label Body} - {html {rows 20 cols 60 wrap soft}} - } +if {$attachments_enabled_p} { + element create message attach_p \ + -label "Attach?" \ + -datatype text \ + -widget hidden \ + -optional +} - {parent_id:text(hidden) {value $parent_id}} +if {[form is_valid message]} { + form get_values message \ + message_id forum_id parent_id subject content html_p confirm_p subscribe_p - {forum_id:text(hidden) {value $forum_id}} - {attachments_enabled_p:text(hidden) {value $attachments_enabled_p}} - {html_p:text(select) - {label Format} - {options {{text f} {html t}}} - } - {subscribe_p:text(hidden),optional} - -} -validate { {content - {[expr { [string equal [set error_message [ad_html_security_check $content]] ""]}]} "$error_message" } - } -new_data { - + if {!$confirm_p} { forum::get -forum_id $forum_id -array forum + set confirm_p 1 set content [string trimright $content] + set exported_vars [export_form_vars message_id forum_id parent_id subject content html_p confirm_p] set message(html_p) $html_p set message(subject) $subject @@ -112,6 +120,13 @@ } } + set context [list [list "./forum-view?forum_id=$forum_id" "$forum(name)"]] + lappend context {Post a Message} + + ad_return_template message-post-confirm + return + } + forum::message::new \ -forum_id $forum_id \ -message_id $message_id \ @@ -141,6 +156,7 @@ # Wrap the attachments URL if {$attachments_enabled_p} { + form get_values message attach_p if {$attach_p} { set redirect_url [attachments::add_attachment_url -object_id $message_id -return_url $redirect_url -pretty_name "Forum Posting \"$subject\""] @@ -151,30 +167,37 @@ ad_returnredirect $redirect_url ad_script_abort -} +} +set message_id [db_nextval acs_object_id_seq] +set subject "" -if {$attachments_enabled_p} { +if {![empty_string_p $parent_id]} { + # get the parent message information + forum::message::get -message_id $parent_id -array parent_message + set forum_id $parent_message(forum_id) + set subject "Re: $parent_message(subject)" - ad_form -extend -name message -form { - {attach_p:text(hidden)} - } -} else { - ns_log Notice "FORUMS: attachments not enabled" } +forum::security::require_post_forum -forum_id $forum_id -#set message_id [db_nextval acs_object_id_seq] -set subject "" +forum::get -forum_id $forum_id -array forum # Prepare the other data +element set_properties message forum_id -value $forum_id +element set_properties message parent_id -value $parent_id +element set_properties message message_id -value $message_id +element set_properties message subject -value $subject +element set_properties message confirm_p -value 0 +element set_properties message subscribe_p -value 0 -set context_bar [list [list "./forum-view?forum_id=$forum_id" "$forum(name)"]] +set context [list [list "./forum-view?forum_id=$forum_id" "$forum(name)"]] if {![empty_string_p $parent_id]} { - lappend context_bar [list "./message-view?message_id=$parent_message(message_id)" "$parent_message(subject)"] - lappend context_bar {Post a Reply} + lappend context [list "./message-view?message_id=$parent_message(message_id)" "$parent_message(subject)"] + lappend context {Post a Reply} } else { - lappend context_bar {Post a Message} + lappend context {Post a Message} } ad_return_template