Index: openacs-4/packages/forums/lib/message/row2.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/lib/message/row2.adp,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/forums/lib/message/row2.adp 10 Jun 2015 12:45:27 -0000 1.3 +++ openacs-4/packages/forums/lib/message/row2.adp 6 Nov 2016 11:03:00 -0000 1.3.2.1 @@ -31,23 +31,21 @@ - -
- + + + - #forums.Expand_only_direct_reply_of_message# - #forums.Expand_all_messages# - #forums.Collapse_all_messages# + #forums.Expand_only_direct_reply_of_message# + #forums.Expand_all_messages# + #forums.Collapse_all_messages# -
+
-
- - -
+
+ + +
  @message.number@: @message.subject@ Index: openacs-4/packages/forums/lib/message/row2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/lib/message/row2.tcl,v diff -u -r1.3.2.1 -r1.3.2.2 --- openacs-4/packages/forums/lib/message/row2.tcl 12 Sep 2015 11:06:24 -0000 1.3.2.1 +++ openacs-4/packages/forums/lib/message/row2.tcl 6 Nov 2016 11:03:00 -0000 1.3.2.2 @@ -12,8 +12,7 @@ set viewer_id [ad_conn user_id] - -if {(![info exists rownum] || $rownum eq "")} { +if {![info exists rownum] || $rownum eq ""} { set rownum 1 } @@ -26,12 +25,13 @@ # JCD: display subject only if changed from the root subject if {![info exists root_subject]} { set display_subject_p 1 -} else {thr regsub {^(Response to |\s*Re:\s*)*} $message(subject) {} subject +} else { + regsub {^(Response to |\s*Re:\s*)*} $message(subject) {} subject set display_subject_p [expr {$subject ne $root_subject }] } -if {([info exists alt_template] && $alt_template ne "")} { - ad_return_template $alt_template +if {[info exists alt_template] && $alt_template ne ""} { + ad_return_template $alt_template } if {![info exists message(message_id)]} { set message(message_id) none @@ -40,45 +40,40 @@ set message(tree_level) 0 } - - - ## New ## set max_number_messages [parameter::get -parameter max_number_messages_with_effects -default 120] -set parent $message(message_id) -set direct_children_list [db_list children_list_name "select message_id from $table_name where message_id = $parent or parent_id = $parent order by message_id"] +set parent_message_id $message(message_id) +set direct_children_list [db_list children_list_name "select message_id from $table_name \ + where message_id = :parent_message_id or parent_id = :parent_message_id order by message_id"] set message_children_list [db_list select_message_children " SELECT fma.message_id \ FROM forums_messages_approved fma \ WHERE fma.forum_id = $forum_id \ - and fma.tree_sortkey between (select fm.tree_sortkey from forums_messages fm where fm.message_id = $parent) \ - and (select tree_right(fm.tree_sortkey) from forums_messages fm where fm.message_id = $parent) \ + and fma.tree_sortkey between (select fm.tree_sortkey from forums_messages fm where fm.message_id = :parent_message_id) \ + and (select tree_right(fm.tree_sortkey) from forums_messages fm where fm.message_id = :parent_message_id) \ ORDER BY fma.message_id "] # List of all the children given a message_id if {[llength $message_children_list] == 0 } { - - set children_string "null" + set children_string "null" +} else { + set children_string $message_children_list } - -set children_string $message_children_list # List of the direct children of a message - if {[llength $direct_children_list] == 0} { + set children_direct_list "null" +} else { + set children_direct_list "$direct_children_list" +} - set children_direct_list "null" - } - set children_direct_list "$direct_children_list" - # Gets all the direct children of the main message -set childs [db_list get_childs "select message_id from $table_name where parent_id = $main_message_id or message_id = $main_message_id order by message_id"] +set childs [db_list get_children "select message_id from $table_name \ + where parent_id = :parent_message_id or message_id = $parent_message_id order by message_id"] -set is_direct_child 0 - -set is_direct_children [lsearch $childs $parent] +set is_direct_children [lsearch $childs $parent_message_id] if {$is_direct_children == -1 } { set is_direct_child 0 } else { @@ -89,6 +84,23 @@ set allow_edit_own_p [parameter::get -parameter AllowUsersToEditOwnPostsP -default 0] set own_p [expr {$message(user_id) eq $viewer_id && $allow_edit_own_p}] +template::add_event_listener -id "toggle$message(message_id)" -script [subst { + dynamicExpand('$message(message_id)'); +}] +if {$total_number_messages <= $max_number_messages} { + + template::add_event_listener -id "expand-direct-$message(message_id)" -script [subst { + expandChilds('$message(message_id)','$children_direct_list'); + }] + template::add_event_listener -id "expand-all-$message(message_id)" -script [subst { + expandChilds('$message(message_id)','$children_string'); + }] + template::add_event_listener -id "collapse-all-$message(message_id)" -script [subst { + collapseChilds('$message(message_id)','$children_string'); + }] +} + + # Local variables: # mode: tcl # tcl-indent-level: 4