Index: openacs-4/packages/forums/sql/oracle/forums-notifications-init.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-notifications-init.sql,v diff -u -N --- openacs-4/packages/forums/sql/oracle/forums-notifications-init.sql 30 Sep 2003 12:10:07 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,118 +0,0 @@ - --- --- The Forums Package --- --- @author gwong@orchardlabs.com,ben@openforce.biz --- @creation-date 2002-05-16 --- --- This code is newly concocted by Ben, but with significant concepts and code --- lifted from Gilbert's UBB forums. Thanks Orchard Labs. --- - --- the integration with Notifications - -declare - impl_id integer; - v_foo integer; -begin - -- the notification type impl - impl_id := acs_sc_impl.new ( - impl_contract_name => 'NotificationType', - impl_name => 'forums_forum_notif_type', - impl_pretty_name => 'forums_forum_notif_type', - impl_owner_name => 'forums' - ); - - v_foo := acs_sc_impl.new_alias ( - 'NotificationType', - 'forums_forum_notif_type', - 'GetURL', - 'forum::notification::get_url', - 'TCL' - ); - - v_foo := acs_sc_impl.new_alias ( - 'NotificationType', - 'forums_forum_notif_type', - 'ProcessReply', - 'forum::notification::process_reply', - 'TCL' - ); - - acs_sc_binding.new ( - contract_name => 'NotificationType', - impl_name => 'forums_forum_notif_type' - ); - - v_foo:= notification_type.new ( - short_name => 'forums_forum_notif', - sc_impl_id => impl_id, - pretty_name => 'Forum Notification', - description => 'Notifications for Entire Forums', - creation_user => NULL, - creation_ip => NULL - ); - - -- enable the various intervals and delivery methods - insert into notification_types_intervals - (type_id, interval_id) - select v_foo, interval_id - from notification_intervals where name in ('instant','hourly','daily'); - - insert into notification_types_del_methods - (type_id, delivery_method_id) - select v_foo, delivery_method_id - from notification_delivery_methods where short_name in ('email'); - - -- the notification type impl - impl_id := acs_sc_impl.new ( - impl_contract_name => 'NotificationType', - impl_name => 'forums_message_notif_type', - impl_pretty_name => 'forums_message_notif_type', - impl_owner_name => 'forums' - ); - - v_foo := acs_sc_impl.new_alias ( - 'NotificationType', - 'forums_message_notif_type', - 'GetURL', - 'forum::notification::get_url', - 'TCL' - ); - - v_foo := acs_sc_impl.new_alias ( - 'NotificationType', - 'forums_message_notif_type', - 'ProcessReply', - 'forum::notification::process_reply', - 'TCL' - ); - - acs_sc_binding.new ( - contract_name => 'NotificationType', - impl_name => 'forums_message_notif_type' - ); - - v_foo:= notification_type.new ( - short_name => 'forums_message_notif', - sc_impl_id => impl_id, - pretty_name => 'Message Notification', - description => 'Notifications for Message Thread', - creation_user => NULL, - creation_ip => NULL - ); - - -- enable the various intervals and delivery methods - insert into notification_types_intervals - (type_id, interval_id) - select v_foo, interval_id - from notification_intervals where name in ('instant','hourly','daily'); - - insert into notification_types_del_methods - (type_id, delivery_method_id) - select v_foo, delivery_method_id - from notification_delivery_methods where short_name in ('email'); - -end; -/ -show errors Index: openacs-4/packages/forums/sql/oracle/forums-notifications-sanitize.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-notifications-sanitize.sql,v diff -u -N --- openacs-4/packages/forums/sql/oracle/forums-notifications-sanitize.sql 30 Sep 2003 12:10:07 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,128 +0,0 @@ --- --- The Forums Package --- --- @author gwong@orchardlabs.com,ben@openforce.biz --- @creation-date 2002-05-16 --- --- This code is newly concocted by Ben, but with significant concepts and code --- lifted from Gilbert's UBB forums. Thanks Orchard Labs. --- - -declare - v_foo integer; - v_impl_id integer; -begin - -- forums_forum - v_impl_id := acs_sc_impl.get_id ( - 'NotificationType', -- impl_contract_name - 'forums_forum_notif_type' -- impl_name - ); - - select type_id into v_foo from notification_types - where sc_impl_id = v_impl_id and short_name = 'forums_forum_notif'; - - delete from notification_types_intervals - where type_id = v_foo - and interval_id in ( - select interval_id - from notification_intervals - where name in ('instant','hourly','daily') - ); - - delete from notification_types_del_methods - where type_id = v_foo - and delivery_method_id in ( - select delivery_method_id - from notification_delivery_methods - where short_name in ('email') - ); - - for row in (select type_id - from notification_types - where short_name in ('forums_forum_notif')) - loop - notification_type.del(row.type_id); - end loop; - - acs_sc_binding.del( - contract_name => 'NotificationType', - impl_name => 'forums_forum_notif_type' - ); - - v_foo := acs_sc_impl.delete_alias( - 'NotificationType', - 'forums_forum_notif_type', - 'GetURL' - ); - - v_foo := acs_sc_impl.delete_alias( - 'NotificationType', - 'forums_forum_notif_type', - 'ProcessReply' - ); - - acs_sc_impl.del( - 'NotificationType', - 'forums_forum_notif_type' - ); - - -- forums_message - v_impl_id := acs_sc_impl.get_id ( - 'NotificationType', -- impl_contract_name - 'forums_message_notif_type' -- impl_name - ); - - select type_id into v_foo from notification_types - where sc_impl_id = v_impl_id and short_name = 'forums_message_notif'; - - delete from notification_types_intervals - where type_id = v_foo - and interval_id in ( - select interval_id - from notification_intervals - where name in ('instant','hourly','daily') - ); - - delete from notification_types_del_methods - where type_id = v_foo - and delivery_method_id in ( - select delivery_method_id - from notification_delivery_methods - where short_name in ('email') - ); - - for row in (select type_id - from notification_types - where short_name in ('forums_message_notif')) - loop - notification_type.del(row.type_id); - end loop; - - acs_sc_binding.del( - contract_name => 'NotificationType', - impl_name => 'forums_message_notif_type' - ); - - v_foo := acs_sc_impl.delete_alias( - 'NotificationType', - 'forums_message_notif_type', - 'GetURL' - ); - - v_foo := acs_sc_impl.delete_alias( - 'NotificationType', - 'forums_message_notif_type', - 'ProcessReply' - ); - - acs_sc_impl.del( - 'NotificationType', - 'forums_message_notif_type' - ); -end; -/ -show errors - - - - Index: openacs-4/packages/forums/sql/postgresql/forums-notifications-init.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/postgresql/forums-notifications-init.sql,v diff -u -N --- openacs-4/packages/forums/sql/postgresql/forums-notifications-init.sql 12 Aug 2013 09:34:30 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,134 +0,0 @@ - --- --- The Forums Package --- --- @author gwong@orchardlabs.com,ben@openforce.biz --- @creation-date 2002-05-16 --- --- This code is newly concocted by Ben, but with significant concepts and code --- lifted from Gilbert's UBB forums. Thanks Orchard Labs. --- - --- the integration with Notifications - - - --- --- procedure inline_0/0 --- -CREATE OR REPLACE FUNCTION inline_0( - -) RETURNS integer AS $$ -DECLARE - impl_id integer; - v_foo integer; -BEGIN - -- the notification type impl - impl_id := acs_sc_impl__new ( - 'NotificationType', - 'forums_forum_notif_type', - 'forums' - ); - - v_foo := acs_sc_impl_alias__new ( - 'NotificationType', - 'forums_forum_notif_type', - 'GetURL', - 'forum::notification::get_url', - 'TCL' - ); - - v_foo := acs_sc_impl_alias__new ( - 'NotificationType', - 'forums_forum_notif_type', - 'ProcessReply', - 'forum::notification::process_reply', - 'TCL' - ); - - PERFORM acs_sc_binding__new ( - 'NotificationType', - 'forums_forum_notif_type' - ); - - v_foo:= notification_type__new ( - NULL, - impl_id, - 'forums_forum_notif', - 'Forum Notification', - 'Notifications for Entire Forums', - now(), - NULL, - NULL, - NULL - ); - - -- enable the various intervals and delivery methods - insert into notification_types_intervals - (type_id, interval_id) - select v_foo, interval_id - from notification_intervals where name in ('instant','hourly','daily'); - - insert into notification_types_del_methods - (type_id, delivery_method_id) - select v_foo, delivery_method_id - from notification_delivery_methods where short_name in ('email'); - - -- the notification type impl - impl_id := acs_sc_impl__new ( - 'NotificationType', - 'forums_message_notif_type', - 'forums' - ); - - v_foo := acs_sc_impl_alias__new ( - 'NotificationType', - 'forums_message_notif_type', - 'GetURL', - 'forum::notification::get_url', - 'TCL' - ); - - v_foo := acs_sc_impl_alias__new ( - 'NotificationType', - 'forums_message_notif_type', - 'ProcessReply', - 'forum::notification::process_reply', - 'TCL' - ); - - PERFORM acs_sc_binding__new ( - 'NotificationType', - 'forums_message_notif_type' - ); - - v_foo:= notification_type__new ( - NULL, - impl_id, - 'forums_message_notif', - 'Message Notification', - 'Notifications for Message Thread', - now(), - NULL, - NULL, - NULL - ); - - -- enable the various intervals and delivery methods - insert into notification_types_intervals - (type_id, interval_id) - select v_foo, interval_id - from notification_intervals where name in ('instant','hourly','daily'); - - insert into notification_types_del_methods - (type_id, delivery_method_id) - select v_foo, delivery_method_id - from notification_delivery_methods where short_name in ('email'); - - return (0); -END; - -$$ LANGUAGE plpgsql; - -select inline_0(); -drop function inline_0(); \ No newline at end of file Index: openacs-4/packages/forums/sql/postgresql/forums-notifications-sanitize.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/postgresql/forums-notifications-sanitize.sql,v diff -u -N --- openacs-4/packages/forums/sql/postgresql/forums-notifications-sanitize.sql 12 Aug 2013 09:34:30 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,151 +0,0 @@ --- --- The Forums Package --- --- @author gwong@orchardlabs.com,ben@openforce.biz --- @creation-date 2002-05-16 --- --- This code is newly concocted by Ben, but with significant concepts and code --- lifted from Gilbert's UBB forums. Thanks Orchard Labs. --- - - - --- --- procedure inline_0/0 --- -CREATE OR REPLACE FUNCTION inline_0( - -) RETURNS integer AS $$ -DECLARE - row record; -BEGIN - for row in select nt.type_id - from notification_types nt - where nt.short_name in ('forums_forum_notif', 'forums_message_notif') - loop - perform notification_type__delete(row.type_id); - end loop; - - return null; -END; -$$ LANGUAGE plpgsql; - -select inline_0(); -drop function inline_0 (); - --- --- Service contract drop stuff was missing - Roberto Mello --- - - - --- --- procedure inline_0/0 --- -CREATE OR REPLACE FUNCTION inline_0( - -) RETURNS integer AS $$ -DECLARE - impl_id integer; - v_foo integer; -BEGIN - - -- the notification type impl - impl_id := acs_sc_impl__get_id ( - 'NotificationType', -- impl_contract_name - 'forums_forum_notif_type' -- impl_name - ); - - PERFORM acs_sc_binding__delete ( - 'NotificationType', - 'forums_forum_notif_type' - ); - - v_foo := acs_sc_impl_alias__delete ( - 'NotificationType', -- impl_contract_name - 'forums_forum_notif_type', -- impl_name - 'GetURL' -- impl_operation_name - ); - - v_foo := acs_sc_impl_alias__delete ( - 'NotificationType', -- impl_contract_name - 'forums_forum_notif_type', -- impl_name - 'ProcessReply' -- impl_operation_name - ); - - select into v_foo type_id - from notification_types - where sc_impl_id = impl_id - and short_name = 'forums_forum_notif'; - - perform notification_type__delete (v_foo); - - delete from notification_types_intervals - where type_id = v_foo - and interval_id in ( - select interval_id - from notification_intervals - where name in ('instant','hourly','daily') - ); - - delete from notification_types_del_methods - where type_id = v_foo - and delivery_method_id in ( - select delivery_method_id - from notification_delivery_methods - where short_name in ('email') - ); - - -- the notification type impl - impl_id := acs_sc_impl__get_id ( - 'NotificationType', - 'forums_message_notif_type' - ); - - PERFORM acs_sc_binding__delete ( - 'NotificationType', - 'forums_message_notif_type' - ); - - v_foo := acs_sc_impl_alias__delete ( - 'NotificationType', - 'forums_message_notif_type', - 'GetURL' - ); - - v_foo := acs_sc_impl_alias__delete ( - 'NotificationType', - 'forums_message_notif_type', - 'ProcessReply' - ); - - select into v_foo type_id - from notification_types - where sc_impl_id = impl_id - and short_name = 'forums_message_notif'; - - perform notification_type__delete (v_foo); - - delete from notification_types_intervals - where type_id = v_foo - and interval_id in ( - select interval_id - from notification_intervals - where name in ('instant','hourly','daily') - ); - - delete from notification_types_del_methods - where type_id = v_foo - and delivery_method_id in ( - select delivery_method_id - from notification_delivery_methods - where short_name in ('email') - ); - - return (0); -END; - -$$ LANGUAGE plpgsql; - -select inline_0(); -drop function inline_0(); 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 -N -r1.10.2.1 -r1.10.2.2 --- openacs-4/packages/forums/tcl/forums-install-procs.tcl 7 May 2020 08:34:04 -0000 1.10.2.1 +++ openacs-4/packages/forums/tcl/forums-install-procs.tcl 7 May 2020 14:43:08 -0000 1.10.2.2 @@ -15,6 +15,9 @@ # installations will not register search service contract # implementations. See forums-callback-procs. # forum::sc::register_implementations + + # Create notification types + forum::install::create_notification_types } ad_proc -private forum::install::package_uninstall {} { @@ -24,6 +27,9 @@ # installations will not register search service contract # implementations. See forums-callback-procs. # forum::sc::unregister_implementations + + # Delete notification types + forum::install::delete_notification_types } ad_proc -private forum::install::package_upgrade { @@ -48,6 +54,94 @@ } } +ad_proc -private forum::install::create_notification_types {} { + Create the Forum Notification types used to notify users of forum + changes. +} { + ## Forum user notifications + + # Entire forum + set spec { + contract_name "NotificationType" + owner "forums" + name "forums_forum_notif_type" + pretty_name "forums_forum_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_notif" \ + -pretty_name "Forum Notification" \ + -description "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_notif_type" + pretty_name "forums_message_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_notif" \ + -pretty_name "Message Notification" \ + -description "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" + } { + notification::type::delete -short_name $short_name + + acs_sc::impl::delete \ + -contract_name "NotificationType" \ + -impl_name $impl_name + } +} + ad_proc -private ::install::xml::action::forum-create { node } { Create a forum instance from an install.xml file } {