Index: openacs-4/packages/forums/tcl/forums-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/forums-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/forums/tcl/forums-procs.tcl 2 Jul 2002 02:00:01 -0000 1.4 +++ openacs-4/packages/forums/tcl/forums-procs.tcl 2 Jul 2002 19:42:19 -0000 1.5 @@ -41,6 +41,10 @@ db_dml update_forum {} } + ad_proc -public attachments_enabled_p {} { + return [apm_package_registered_p attachments] + } + ad_proc -public list_forums { {-package_id:required} } { Index: openacs-4/packages/forums/tcl/messages-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/Attic/messages-procs-oracle.xql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/forums/tcl/messages-procs-oracle.xql 3 Jun 2002 06:51:25 -0000 1.5 +++ openacs-4/packages/forums/tcl/messages-procs-oracle.xql 2 Jul 2002 19:42:19 -0000 1.6 @@ -6,6 +6,7 @@ select forums_messages.*, + 0 as n_attachments, 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, @@ -19,6 +20,23 @@ + + + select forums_messages.*, + (select count(*) from attachments where object_id= message_id) as n_attachments, + 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, + forums_message.root_message_id(forums_messages.message_id) as root_message_id, + (select fm2.subject + from forums_messages fm2 + where fm2.message_id = forums_message.root_message_id(forums_messages.message_id)) as root_subject, + to_char(forums_messages.posting_date, 'Mon DD YYYY HH24:MI:SS') as posting_date + from forums_messages + where forums_messages.message_id = :message_id + + + select site_node.url(node_id) 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.3 -r1.4 --- openacs-4/packages/forums/tcl/messages-procs-postgresql.xql 3 Jun 2002 06:51:25 -0000 1.3 +++ openacs-4/packages/forums/tcl/messages-procs-postgresql.xql 2 Jul 2002 19:42:19 -0000 1.4 @@ -19,6 +19,23 @@ + + + select forums_messages.*, + (select count(*) from attachments where object_id= message_id) as n_attachments, + 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, + forums_message__root_message_id(forums_messages.message_id) as root_message_id, + (select fm2.subject + from forums_messages fm2 + where fm2.message_id = forums_message__root_message_id(forums_messages.message_id)) as root_subject, + to_char(forums_messages.posting_date, 'Mon DD YYYY HH24:MI:SS') as posting_date + from forums_messages + where forums_messages.message_id= :message_id + + + select site_node__url(node_id) Index: openacs-4/packages/forums/tcl/messages-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/messages-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/forums/tcl/messages-procs.tcl 3 Jun 2002 23:58:45 -0000 1.6 +++ openacs-4/packages/forums/tcl/messages-procs.tcl 2 Jul 2002 19:42:19 -0000 1.7 @@ -113,7 +113,12 @@ } { # Select the info into the upvar'ed Tcl Array upvar $array row - db_1row select_message {} -column_array row + + if {[forum::attachments_enabled_p]} { + db_1row select_message_with_attachment {} -column_array row + } else { + db_1row select_message {} -column_array row + } } ad_proc -private set_state { @@ -177,5 +182,18 @@ } { db_exec_plsql thread_open {} } + + ad_proc -public get_attachments { + {-message_id:required} + } { + get the attachments for a message + } { + # If attachments aren't enabled, then we stop + if {![forum::attachments_enabled_p]} { + return [list] + } + return [attachments::get_attachments -object_id $message_id] + } + } Index: openacs-4/packages/forums/www/message-attachment-chunk.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/Attic/message-attachment-chunk.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/message-attachment-chunk.adp 2 Jul 2002 19:42:19 -0000 1.1 @@ -0,0 +1,6 @@ +<% +foreach attachment $attachments { + template::adp_puts "$attachment_graphic  " +} +%> + Index: openacs-4/packages/forums/www/message-attachment-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/Attic/message-attachment-chunk.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/message-attachment-chunk.tcl 2 Jul 2002 19:42:19 -0000 1.1 @@ -0,0 +1,19 @@ + +ad_page_contract { + a message attachment chunk to be included to display attachments + + @author ben (ben@openforce) + @creation-date 2002-07-02 + @version $Id: message-attachment-chunk.tcl,v 1.1 2002/07/02 19:42:19 ben Exp $ +} + +if {![array exists message]} { + ad_return_complaint 1 "need to provide a message to display attachments!" +} + +# get the attachments +set attachments [attachments::get_attachments -object_id $message(message_id)] + +set attachment_graphic [attachments::graphic_url] + +ad_return_template Index: openacs-4/packages/forums/www/message-chunk.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/Attic/message-chunk.adp,v diff -u -r1.5 -r1.6 --- openacs-4/packages/forums/www/message-chunk.adp 5 Jun 2002 19:25:37 -0000 1.5 +++ openacs-4/packages/forums/www/message-chunk.adp 2 Jul 2002 19:42:19 -0000 1.6 @@ -1,5 +1,5 @@ - @message.subject@ + @message.subject@ @message.user_name@ @message.posting_date@ Index: openacs-4/packages/forums/www/message-post-confirm.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-post-confirm.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/forums/www/message-post-confirm.adp 3 Jun 2002 05:53:55 -0000 1.3 +++ openacs-4/packages/forums/www/message-post-confirm.adp 2 Jul 2002 19:42:19 -0000 1.4 @@ -24,5 +24,12 @@
+ + Would you like to attach a file to this message? + No + Yes +
+
+ Index: openacs-4/packages/forums/www/message-post.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-post.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/forums/www/message-post.tcl 3 Jun 2002 05:53:55 -0000 1.6 +++ openacs-4/packages/forums/www/message-post.tcl 2 Jul 2002 19:42:19 -0000 1.7 @@ -66,6 +66,19 @@ -widget hidden \ -optional +set attachments_enabled_p [forum::attachments_enabled_p] + +if {$attachments_enabled_p} { + ns_log Notice "FORUMS: attachments enabled" + element create message attach_p \ + -label "Attach?" \ + -datatype text \ + -widget hidden \ + -optional +} else { + ns_log Notice "FORUMS: attachments not enabled" +} + if {[form is_valid message]} { form get_values message \ message_id forum_id parent_id subject content html_p confirm_p subscribe_p @@ -111,26 +124,36 @@ -html_p $html_p if {[empty_string_p $parent_id]} { - set message_view_url "[ad_conn package_url]message-view?message_id=$message_id" + set redirect_url "[ad_conn package_url]message-view?message_id=$message_id" } else { - set message_view_url "[ad_conn package_url]message-view?message_id=$parent_id" + set redirect_url "[ad_conn package_url]message-view?message_id=$parent_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 $message_view_url \ + -url $redirect_url \ -user_id [ad_conn user_id] \ ] # redirect to notification stuff - ad_returnredirect $notification_url - } else { - # redirect to viewing the message - ad_returnredirect $message_view_url + set redirect_url $notification_url } + # 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\""] + } + } + + # Do the redirection + ad_returnredirect $redirect_url + ad_script_abort } Index: openacs-4/packages/forums/www/message-view-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-view-oracle.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/forums/www/message-view-oracle.xql 3 Jun 2002 04:39:05 -0000 1.2 +++ openacs-4/packages/forums/www/message-view-oracle.xql 2 Jul 2002 19:42:19 -0000 1.3 @@ -5,69 +5,38 @@ select message_id, + 0 as n_attachments, subject, content, person.name(user_id) as user_name, to_char(posting_date, 'Mon DD YYYY HH24:MI:SS') as posting_date, tree.tree_level(tree_sortkey) as tree_level, state, user_id - from forums_messages_approved + from $table_name where forum_id = :forum_id and tree_sortkey between tree.left(:tree_sortkey) and tree.right(:tree_sortkey) - order by tree_sortkey + order by $order_by - + select message_id, + (select count(*) from attachments where object_id = message_id) as n_attachments, subject, content, person.name(user_id) as user_name, to_char(posting_date, 'Mon DD YYYY HH24:MI:SS') as posting_date, tree.tree_level(tree_sortkey) as tree_level, state, user_id - from forums_messages_approved + from $table_name where forum_id = :forum_id and tree_sortkey between tree.left(:tree_sortkey) and tree.right(:tree_sortkey) - order by posting_date, tree_sortkey + order by $order_by - - - select message_id, - subject, - content, - person.name(user_id) as user_name, - to_char(posting_date, 'Mon DD YYYY HH24:MI:SS') as posting_date, - tree.tree_level(tree_sortkey) as tree_level, - state, - user_id - from forums_messages - where forum_id = :forum_id - and tree_sortkey between tree.left(:tree_sortkey) and tree.right(:tree_sortkey) - order by tree_sortkey - - - - - select message_id, - subject, - content, - person.name(user_id) as user_name, - to_char(posting_date, 'Mon DD YYYY HH24:MI:SS') as posting_date, - tree.tree_level(tree_sortkey) as tree_level, - state, - user_id - from forums_messages - where forum_id = :forum_id - and tree_sortkey between tree.left(:tree_sortkey) and tree.right(:tree_sortkey) - order by posting_date, tree_sortkey - - - Index: openacs-4/packages/forums/www/message-view-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-view-postgresql.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/forums/www/message-view-postgresql.xql 19 Jun 2002 15:11:46 -0000 1.3 +++ openacs-4/packages/forums/www/message-view-postgresql.xql 2 Jul 2002 19:42:19 -0000 1.4 @@ -6,69 +6,38 @@ select message_id, + 0 as n_attachments, subject, content, person__name(user_id) as user_name, to_char(posting_date, 'Mon DD YYYY HH24:MI:SS') as posting_date, tree_level(tree_sortkey) as tree_level, state, user_id - from forums_messages_approved + from $table_name where forum_id = :forum_id and tree_sortkey between tree_left(:tree_sortkey) and tree_right(:tree_sortkey) - order by tree_sortkey + order by $order_by - + select message_id, + (select count(*) from attachments where object_id = message_id) as n_attachments, subject, content, person__name(user_id) as user_name, to_char(posting_date, 'Mon DD YYYY HH24:MI:SS') as posting_date, tree_level(tree_sortkey) as tree_level, state, user_id - from forums_messages_approved + from $table_name where forum_id = :forum_id and tree_sortkey between tree_left(:tree_sortkey) and tree_right(:tree_sortkey) - order by posting_date, tree_sortkey + order by $order_by - - - select message_id, - subject, - content, - person__name(user_id) as user_name, - to_char(posting_date, 'Mon DD YYYY HH24:MI:SS') as posting_date, - tree_level(tree_sortkey) as tree_level, - state, - user_id - from forums_messages - where forum_id = :forum_id - and tree_sortkey between tree_left(:tree_sortkey) and tree_right(:tree_sortkey) - order by tree_sortkey - - - - - select message_id, - subject, - content, - person__name(user_id) as user_name, - to_char(posting_date, 'Mon DD YYYY HH24:MI:SS') as posting_date, - tree_level(tree_sortkey) as tree_level, - state, - user_id - from forums_messages - where forum_id = :forum_id - and tree_sortkey between tree_left(:tree_sortkey) and tree_right(:tree_sortkey) - order by posting_date, tree_sortkey - - - 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.6 -r1.7 --- openacs-4/packages/forums/www/message-view.tcl 2 Jul 2002 02:00:01 -0000 1.6 +++ openacs-4/packages/forums/www/message-view.tcl 2 Jul 2002 19:42:19 -0000 1.7 @@ -64,13 +64,24 @@ set forum_id $message(forum_id) set tree_sortkey $message(tree_sortkey) -set query select_message_responses +if {[forum::attachments_enabled_p]} { + set query select_message_responses_attachments +} else { + set query select_message_responses +} + +# We set a Tcl variable for moderation now (Ben) if {$moderate_p} { - set query select_message_responses_moderator + set table_name "forums_messages" +} else { + set table_name "forums_messages_approved" } +# More Tcl vars (we might as well use them - Ben) if {[string equal $forum(presentation_type) flat]} { - append query "_flat" + set order_by "posting_date, tree_sortkey" +} else { + set order_by "tree_sortkey" } db_multirow responses $query {}