Index: openacs-4/packages/forums/lib/message/row.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/lib/message/row.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/forums/lib/message/row.adp 13 Jan 2005 13:58:15 -0000 1.2 +++ openacs-4/packages/forums/lib/message/row.adp 27 Jan 2005 16:08:31 -0000 1.3 @@ -1,86 +1,115 @@ + - - - - - - @message.number@: - @message.subject@ - - - @message.subject@ - - - + <%# ----------------------------------------------------------- %> + <%# Non-preview %> + <%# ----------------------------------------------------------- %> + + + - - - - @message.number@ - - + - - - - In response to @message.parent_number@ - - - @message.posting_date_pretty@ - - - -
- [ - - #forums.reply# | - - #forums.forward# - ] - -
- [ #forums.edit# - | #forums.delete# - - - - | #forums.approve# + + +
+ + + <%# ----------------------------------------------------------- %> + <%# Expanded Message %> + <%# ----------------------------------------------------------- %> + +
+ + +
+ @message.content;noquote@ +
+ #forums.Attachments# + +
+
#forums.Posted_by# @message.user_name@ on
+ + + + - + + [open parent] + - ] - +
- +
- + - + <%# ----------------------------------------------------------- %> + <%# Collapsed Message %> + <%# ----------------------------------------------------------- %> - - - - - - - + + #forums.Posted_by# @message.user_name@ on + + (response to @message.parent_number@) + +
+ -
- @message.content;noquote@ -

- #forums.Posted_by# @message.user_name@ -

-
- - - - - - #forums.Attachments# - - - +
+ + + + + <%# ----------------------------------------------------------- %> + <%# Preview %> + <%# ----------------------------------------------------------- %> + +
+ @message.subject@ +
#forums.Posted_by# @message.user_name@ on
+
+
+ @message.content;noquote@ +
+
Index: openacs-4/packages/forums/lib/message/row.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/lib/message/row.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/forums/lib/message/row.tcl 13 Jan 2005 13:58:15 -0000 1.3 +++ openacs-4/packages/forums/lib/message/row.tcl 27 Jan 2005 16:08:31 -0000 1.4 @@ -1,26 +1,21 @@ ad_page_contract { - a message chunk to be included in a table listing of messages + a message chunk to be included in a listing of messages - _so that has to be wrapped in a _ - @author yon (yon@openforce.net) @author arjun (arjun@openforce.net) @creation-date 2002-06-02 @cvs-id $Id$ } -if {![exists_and_not_null bgcolor]} { - set table_bgcolor [parameter::get -parameter table_bgcolor] -} else { - set table_bgcolor $bgcolor +set viewer_id [ad_conn user_id] + +if {![exists_and_not_null rownum]} { + set rownum 1 } - -#if { [string compare $message(format) "text/plain"] == 0 } { set message(content) [ad_html_text_convert -from $message(format) -to text/html -- $message(content)] -#} # convert emoticons to images if the parameter is set if { [string is true [parameter::get -parameter DisplayEmoticonsAsImagesP -default 0]] } { @@ -38,3 +33,61 @@ if {[exists_and_not_null alt_template]} { ad_return_template $alt_template } + + +if {![info exists message(message_id)]} { + set message(message_id) none +} +if {![info exists message(tree_level)]} { + set message(tree_level) 0 +} + +if {![exists_and_not_null level_exp]} { + set level_exp 0 +} + +if {![exists_and_not_null moderate_p]} { + set moderate_p 0 +} + +if {![exists_and_not_null message(reply_p)]} { + set message(reply_p) 0 +} + +if {![exists_and_not_null display_mode]} { + set display_mode dynamic_minimal +} + +if { $moderate_p } { + set table_name "forums_messages" +} else { + set table_name "forums_messages_approved" +} + +set links "" + +set allow_edit_own_p [parameter::get -parameter AllowUsersToEditOwnPostsP -default 0] +set own_p [expr [string equal $message(user_id) $viewer_id] && $allow_edit_own_p] + +switch -exact $display_mode { + flat { + ad_return_template "../lib/message/row-flat" + return + } + nested { + ad_return_template "../lib/message/row-nested" + return + } + threaded { + ad_return_template "../lib/message/row-threaded" + return + } + minimal { + ad_return_template "../lib/message/row-minimal" + return + } + default { + ad_return_template "../lib/message/row" + return + } +} Index: openacs-4/packages/forums/lib/message/thread-chunk-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/lib/message/thread-chunk-oracle.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/forums/lib/message/thread-chunk-oracle.xql 29 Jun 2004 10:18:28 -0000 1.2 +++ openacs-4/packages/forums/lib/message/thread-chunk-oracle.xql 27 Jan 2005 16:08:31 -0000 1.3 @@ -21,7 +21,7 @@ 0 as n_attachments, subject, content, - format, + html_p, person.name(user_id) as user_name, to_char(posting_date, 'YYYY-MM-DD HH24:MI:SS') as posting_date_ansi, tree.tree_level(tree_sortkey) as tree_level, @@ -41,7 +41,7 @@ (select count(*) from attachments where object_id = message_id) as n_attachments, subject, content, - format, + html_p, person.name(user_id) as user_name, to_char(posting_date, 'YYYY-MM-DD HH24:MI:SS') as posting_date_ansi, tree.tree_level(tree_sortkey) as tree_level, Index: openacs-4/packages/forums/lib/message/thread-chunk-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/lib/message/thread-chunk-postgresql.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/forums/lib/message/thread-chunk-postgresql.xql 29 Jun 2004 10:18:28 -0000 1.2 +++ openacs-4/packages/forums/lib/message/thread-chunk-postgresql.xql 27 Jan 2005 16:08:31 -0000 1.3 @@ -27,7 +27,9 @@ tree_level(tree_sortkey) as tree_level, state, user_id, - parent_id + parent_id, + open_p, + max_child_sortkey from $table_name where forum_id = :forum_id and tree_sortkey between tree_left(:tree_sortkey) and tree_right(:tree_sortkey) @@ -41,13 +43,15 @@ (select count(*) from attachments where object_id = message_id) as n_attachments, subject, content, - format, + html_p, person__name(user_id) as user_name, to_char(posting_date, 'YYYY-MM-DD HH24:MI:SS') as posting_date_ansi, tree_level(tree_sortkey) as tree_level, state, user_id, - parent_id + parent_id, + open_p, + max_child_sortkey from $table_name where forum_id = :forum_id and tree_sortkey between tree_left(:tree_sortkey) and tree_right(:tree_sortkey) Index: openacs-4/packages/forums/lib/message/thread-chunk.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/lib/message/thread-chunk.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/forums/lib/message/thread-chunk.adp 13 Jan 2005 13:58:15 -0000 1.3 +++ openacs-4/packages/forums/lib/message/thread-chunk.adp 27 Jan 2005 16:08:31 -0000 1.4 @@ -1,56 +1,23 @@ - -
- - -
- - -
+
+ - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - -
-
+ + +
+
+@response_arrays_stub;noquote@ Index: openacs-4/packages/forums/lib/message/thread-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/lib/message/thread-chunk.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/forums/lib/message/thread-chunk.tcl 13 Jan 2005 13:58:15 -0000 1.3 +++ openacs-4/packages/forums/lib/message/thread-chunk.tcl 27 Jan 2005 16:08:31 -0000 1.4 @@ -58,11 +58,15 @@ set message(number) [expr [lsearch $message_id_list $message(message_id)] + 1] set message(parent_number) {} +set message(parent_direct_url) "" if { [exists_and_not_null message(parent_id)] } { set message(parent_number) [expr [lsearch $message_id_list $message(parent_id)] + 1] set message(parent_direct_url) "$direct_url_base\#$message(parent_id)" + set message(parent_root_url) [export_vars -base [ad_conn url] { { message_id $message(parent_id) } }] } +set message(reply_p) [expr [string equal $message(open_p) "t"] || [string equal $message(user_id) [ad_conn user_id]]] + ##### # # Find responses @@ -76,15 +80,69 @@ set order_by "tree_sortkey" } -db_multirow -extend { width posting_date_pretty direct_url number parent_number parent_direct_url } responses $query {} { +set old_tree_level 0 +set old_message_id 0 +set message_ids {} + +db_multirow -extend { posting_date_pretty direct_url number parent_number parent_direct_url reply_p viewed_p} responses $query {} { + set tree_level [min [expr {$tree_level - $message(tree_level)}] 10] set posting_date_pretty [lc_time_fmt $posting_date_ansi "%x %X"] set direct_url "$direct_url_base\#$message_id" set number [expr [lsearch $message_id_list $message_id] + 1] set parent_number [expr [lsearch $message_id_list $parent_id] + 1] set parent_direct_url "$direct_url_base\#$parent_id" - set width [expr 100 - ($tree_level - 1) * 1] + set parent_root_url [export_vars -base [ad_conn url] {{message_id $parent_id}}] + set reply_p [expr [string equal $open_p "t"] || [string equal $user_id [ad_conn user_id]]] + + # DEDS: get the response ids the tcl way or else we need to hit + # the db for each response to count its children + if {$tree_level == 1} { + # leftmost so this is a new parent. truncate the list of ids. + set message_ids {} + } else { + if {$tree_level > $old_tree_level} { + # increase in level. previous id is a parent too. + lappend message_ids $old_message_id + foreach one_parent_id $message_ids { + lappend parent_message($one_parent_id) $message_id + } + } elseif {$tree_level < $old_tree_level} { + # decrease in level. let us pop the last id. + set message_ids_last [expr [llength $message_ids] - 1] + set message_ids [lreplace $message_ids $message_ids_last $message_ids_last] + } else { + foreach one_parent_id $message_ids { + lappend parent_message($one_parent_id) $message_id + } + } + } + # keep track of what level and message we are in + set old_tree_level $tree_level + set old_message_id $message_id + + # make sure we also populate the original message id + lappend parent_message($message(message_id)) $message_id } +set message(tree_level) 0 + if {[exists_and_not_null alt_template]} { ad_return_template $alt_template } + +set response_arrays_stub " +" + +set return_url [ad_return_url] Index: openacs-4/packages/forums/tcl/messages-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/Attic/messages-procs-postgresql.xql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/forums/tcl/messages-procs-postgresql.xql 13 Jan 2005 13:58:16 -0000 1.8 +++ openacs-4/packages/forums/tcl/messages-procs-postgresql.xql 27 Jan 2005 16:08:31 -0000 1.9 @@ -6,6 +6,7 @@ select forums_messages.*, + tree_level(forums_messages.tree_sortkey) as tree_level, person__name(forums_messages.user_id) as user_name, party__email(forums_messages.user_id) as user_email, forums_forum__name(forums_messages.forum_id) as forum_name, Index: openacs-4/packages/forums/www/message-view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-view.adp,v diff -u -r1.25 -r1.26 --- openacs-4/packages/forums/www/message-view.adp 1 Apr 2004 16:14:30 -0000 1.25 +++ openacs-4/packages/forums/www/message-view.adp 27 Jan 2005 16:08:32 -0000 1.26 @@ -1,8 +1,18 @@ #forums.Forum# @forum.name;noquote@: @message.subject;noquote@ @context;noquote@ + + + +@alternate_style_sheet;noquote@ +@dynamic_script;noquote@ + @message_id@ + + + +
@@ -16,26 +26,27 @@
  • #forums.Back_to_thread_label#
  • -

    @notification_chunk;noquote@

    + + &permissions="permissions" + display_mode="@display_mode@"> - - - -
    +
    -
    - -
    - #forums.Back_to_thread_link# -
    + +
  • #forums.Back_to_thread_link#
  • + Index: openacs-4/packages/forums/www/message-view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-view.tcl,v diff -u -r1.28 -r1.29 --- openacs-4/packages/forums/www/message-view.tcl 1 Apr 2004 16:14:30 -0000 1.28 +++ openacs-4/packages/forums/www/message-view.tcl 27 Jan 2005 16:08:32 -0000 1.29 @@ -8,6 +8,7 @@ } { message_id:integer,notnull + {display_mode ""} } ####################### @@ -77,14 +78,75 @@ set context [list [list "./forum-view?forum_id=$message(forum_id)" "$message(forum_name)"]] if {![empty_string_p $message(parent_id)]} { - lappend context [list "./message-view?message_id=$message(root_message_id)" "[_ forums.Entire_Thread]"] + lappend context [list "./message-view?message_id=$message(root_message_id)" "$message(subject)"] lappend context [_ forums.One_Message] } else { - lappend context [_ forums.One_Thread] + lappend context "$message(subject)" } if { $permissions(post_p) || [ad_conn user_id] == 0 } { set reply_url [export_vars -base message-post { { parent_id $message(message_id) } }] } set thread_url [export_vars -base forum-view { { forum_id $message(forum_id) } }] + +if {[empty_string_p $display_mode]} { + # user doesn't set display so let's get cookie + set display_mode [ad_get_cookie forums_display_mode dynamic_minimal] +} else { + # user desires a new look so store it too + # half a year should be fine for now + ad_set_cookie -replace t -max_age 15768000 forums_display_mode $display_mode +} + +set alternate_style_p 0 + +if {[string equal $display_mode flat]} { + set alternate_style_p 1 + set display_stylesheet "flat.css" +} elseif {[string equal $display_mode nested] || [string equal $display_mode minimal] || [string equal $display_mode threaded]} { +} else { + set display_mode dynamic_minimal +} + +if {$alternate_style_p} { + set alternate_style_sheet "" +} else { + set alternate_style_sheet "" +} + +if {[string equal $display_mode "dynamic_minimal"]} { + set dynamic_script " + + +" +} else { + set dynamic_script "" +} + +set display_options_list {{Flat flat} {Nested nested} {Threaded threaded} {Minimal minimal} {"Dynamic Minimal" dynamic_minimal}} +#set display_options_list {{Flat flat} {Nested nested} {"Dynamic" dynamic_minimal}} +ad_form \ + -name display_form \ + -method post \ + -has_submit 1 \ + -form { + {message_id:text(hidden) {value $message_id}} + {display_mode:text(radio),optional + {label "Display:"} + {options $display_options_list} + {value $display_mode} + {html {onChange "this.form.submit();"}} + } + } \ + -after_submit { + }