OpenACS
Online discussion forums.
2017-08-06
@@ -19,7 +19,7 @@
2
#forums.Forums#
-
+
Index: openacs-4/packages/forums/tcl/forums-install-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/forums-install-procs.tcl,v
diff -u -r1.10.2.2 -r1.10.2.3
--- openacs-4/packages/forums/tcl/forums-install-procs.tcl 7 May 2020 14:43:08 -0000 1.10.2.2
+++ openacs-4/packages/forums/tcl/forums-install-procs.tcl 13 May 2020 14:31:33 -0000 1.10.2.3
@@ -51,6 +51,10 @@
# and rely on callbacks from now on.
forum::sc::unregister_implementations
}
+ 1.3.1d18 1.4.0d1 {
+ ## Forum moderator notifications
+ forum::install::create_moderator_notification_types
+ }
}
}
@@ -59,7 +63,16 @@
changes.
} {
## Forum user notifications
+ forum::install::create_user_notification_types
+ ## Forum moderator notifications
+ forum::install::create_moderator_notification_types
+}
+
+ad_proc -private forum::install::create_user_notification_types {} {
+ Create the Forum Notification types used to notify users of forum
+ changes.
+} {
# Entire forum
set spec {
contract_name "NotificationType"
@@ -127,12 +140,85 @@
}
}
+ad_proc -private forum::install::create_moderator_notification_types {} {
+ Create the Forum Notification types used to notify usersmoderators
+ of forum changes.
+} {
+ # Entire forum
+ set spec {
+ contract_name "NotificationType"
+ owner "forums"
+ name "forums_forum_moderator_notif_type"
+ pretty_name "forums_forum_moderator_notif_type"
+ aliases {
+ GetURL forum::notification::get_url
+ ProcessReply forum::notification::process_reply
+ }
+ }
+ set sc_impl_id [acs_sc::impl::new_from_spec -spec $spec]
+
+ set type_id [notification::type::new \
+ -sc_impl_id $sc_impl_id \
+ -short_name "forums_forum_moderator_notif" \
+ -pretty_name "Forum Moderator Notification" \
+ -description "Moderator notifications for Entire Forums"]
+
+ # Enable the various intervals and delivery methods
+ db_dml insert_intervals {
+ insert into notification_types_intervals
+ (type_id, interval_id)
+ select :type_id, interval_id
+ from notification_intervals where name in ('instant','hourly','daily')
+ }
+ db_dml insert_del_method {
+ insert into notification_types_del_methods
+ (type_id, delivery_method_id)
+ select :type_id, delivery_method_id
+ from notification_delivery_methods where short_name in ('email')
+ }
+
+ # Message
+ set spec {
+ contract_name "NotificationType"
+ owner "forums"
+ name "forums_message_moderator_notif_type"
+ pretty_name "forums_message_moderator_notif_type"
+ aliases {
+ GetURL forum::notification::get_url
+ ProcessReply forum::notification::process_reply
+ }
+ }
+ set sc_impl_id [acs_sc::impl::new_from_spec -spec $spec]
+
+ set type_id [notification::type::new \
+ -sc_impl_id $sc_impl_id \
+ -short_name "forums_message_moderator_notif" \
+ -pretty_name "Message Moderator Notification" \
+ -description "Moderator notifications for Message Thread"]
+
+ # Enable the various intervals and delivery methods
+ db_dml insert_intervals {
+ insert into notification_types_intervals
+ (type_id, interval_id)
+ select :type_id, interval_id
+ from notification_intervals where name in ('instant','hourly','daily')
+ }
+ db_dml insert_del_method {
+ insert into notification_types_del_methods
+ (type_id, delivery_method_id)
+ select :type_id, delivery_method_id
+ from notification_delivery_methods where short_name in ('email')
+ }
+}
+
ad_proc -private forum::install::delete_notification_types {} {
Delete notification types on uninstall
} {
foreach {short_name impl_name} {
"forums_forum_notif" "forums_forum_notif_type"
"forums_message_notif" "forums_message_notif_type"
+ "forums_forum_moderator_notif" "forums_forum_moderator_notif_type"
+ "forums_message_moderator_notif" "forums_message_moderator_notif_type"
} {
notification::type::delete -short_name $short_name
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.59.2.18 -r1.59.2.19
--- openacs-4/packages/forums/tcl/messages-procs.tcl 12 May 2020 15:33:23 -0000 1.59.2.18
+++ openacs-4/packages/forums/tcl/messages-procs.tcl 13 May 2020 14:31:33 -0000 1.59.2.19
@@ -102,8 +102,10 @@
-message_url $message_url
}
- # TODO: implement a moderator notification type that triggers also
- # on unapproved messages.
+ forum::message::notify_moderators \
+ -message_array message \
+ -forum_url $forum_url \
+ -message_url $message_url
# This computations are not used... just commented for now.
# if {$useScreenNameP eq 0 && $user_id ne 0} {
@@ -219,6 +221,89 @@
-notif_html $html_version
}
+ad_proc -private forum::message::notify_moderators {
+ -message_array:required
+ -forum_url:required
+ -message_url:required
+} {
+ Notify moderators of a new forum message
+
+ @param message_array name of message array of forum info in the caller scope
+} {
+ upvar 1 $message_array message
+
+ set useScreenNameP [parameter::get -parameter "UseScreenNameP" -default 0]
+
+ # Moderated messages are never notified in full, as they might
+ # contain unsuitable content by definition.
+ set href [ns_quotehtml $message_url]
+ set message_html "#forums.Message_content_withheld# #forums.To_view_message_follow_link# $href
"
+ set message_text [ad_html_text_convert -from text/html -to text/plain -- $message_html]
+
+ set html_version ""
+ append html_version "#forums.Forum#: $message(forum_name)
\n"
+ append html_version "#forums.Thread#: $message(root_subject)
\n"
+ if {$useScreenNameP == 0} {
+ append html_version "#forums.Author#: $message(user_name)
\n"
+ } else {
+ append html_version "#forums.Author#: $message(screen_name)
\n"
+ }
+ append html_version "#forums.Posted#: $message(posting_date)
"
+ append html_version "\n
\n"
+ #
+ # The resulting HTML messages is sent in total by
+ # notifications::send through [lang::util::localize...]. In case
+ # a forums message contains something looking like a localized
+ # message key, it will be substituted. One rough attempt is to add
+ # a zero width space after the "#" signs to make the regular
+ # expression searching for the message keys fail....
+ #
+ regsub -all "#" $message_html "#\\" message_html
+
+ append html_version $message_html
+ append html_version " "
+
+ set text_version ""
+ append text_version "
+#forums.Forum#: $message(forum_name)
+#forums.Thread#: $message(root_subject)\n"
+ if {$useScreenNameP == 0} {
+ append text_version "#forums.Author#: $message(user_name)"
+ } else {
+ append text_version "#forums.Author#: $message(screen_name)"
+ }
+ append text_version "
+#forums.Posted#: $message(posting_date)
+-----------------------------------------
+$message_text
+-----------------------------------------
+#forums.To_post_a_reply_to_this_email_or_view_this_message_go_to#
+$message_url
+
+#forums.To_view_Forum_forum_name_go_to#
+$forum_url
+"
+ # Do the notification for the forum
+ notification::new \
+ -type_id [notification::type::get_type_id \
+ -short_name forums_forum_moderator_notif] \
+ -object_id $message(forum_id) \
+ -response_id $message(message_id) \
+ -notif_subject "\[$message(forum_name)\] $message(subject) (#forums.moderated#)" \
+ -notif_text $text_version \
+ -notif_html $html_version
+
+ # Eventually we need notification for the root message too
+ notification::new \
+ -type_id [notification::type::get_type_id \
+ -short_name forums_message_moderator_notif] \
+ -object_id $message(root_message_id) \
+ -response_id $message(message_id) \
+ -notif_subject "\[$message(forum_name)\] $message(subject) (#forums.moderated#)" \
+ -notif_text $text_version \
+ -notif_html $html_version
+}
+
ad_proc -public forum::message::edit {
{-message_id:required}
{-subject:required}
Index: openacs-4/packages/forums/www/forum-view.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/forum-view.adp,v
diff -u -r1.42.2.1 -r1.42.2.2
--- openacs-4/packages/forums/www/forum-view.adp 13 May 2020 08:00:59 -0000 1.42.2.1
+++ openacs-4/packages/forums/www/forum-view.adp 13 May 2020 14:31:33 -0000 1.42.2.2
@@ -9,6 +9,13 @@
+
+
+
+
+
+
-
+