Index: openacs-4/packages/dotlrn/www/subscribe-members.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/subscribe-members.tcl,v diff -u -r1.8 -r1.8.2.1 --- openacs-4/packages/dotlrn/www/subscribe-members.tcl 29 Jun 2018 17:27:19 -0000 1.8 +++ openacs-4/packages/dotlrn/www/subscribe-members.tcl 8 Jul 2022 14:36:55 -0000 1.8.2.1 @@ -29,7 +29,7 @@ # Precompute these items rather than repeat them for each user set type_id [notification::type::get_type_id -short_name forums_forum_notif] -set interval_id [notification::get_interval_id -name instant] +set interval_id [notification::interval::get_id_from_name -name instant] set delivery_method_id [notification::get_delivery_method_id -name email] db_transaction { Index: openacs-4/packages/dotlrn/www/weblog-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/weblog-new.tcl,v diff -u -r1.11 -r1.11.2.1 --- openacs-4/packages/dotlrn/www/weblog-new.tcl 29 Jun 2018 17:27:19 -0000 1.11 +++ openacs-4/packages/dotlrn/www/weblog-new.tcl 8 Jul 2022 14:36:55 -0000 1.11.2.1 @@ -60,7 +60,7 @@ notification::request::new -object_id $forum_id \ -type_id [notification::type::get_type_id -short_name "forums_forum_notif"] \ -user_id $user_id \ - -interval_id [notification::get_interval_id -name "instant"] \ + -interval_id [notification::interval::get_id_from_name -name "instant"] \ -delivery_method_id [notification::get_delivery_method_id -name "email"] } } else { Index: openacs-4/packages/dotlrn-forums/tcl/dotlrn-forums-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-forums/tcl/dotlrn-forums-procs.tcl,v diff -u -r1.16.2.7 -r1.16.2.8 --- openacs-4/packages/dotlrn-forums/tcl/dotlrn-forums-procs.tcl 23 Feb 2021 13:08:02 -0000 1.16.2.7 +++ openacs-4/packages/dotlrn-forums/tcl/dotlrn-forums-procs.tcl 8 Jul 2022 14:36:55 -0000 1.16.2.8 @@ -239,7 +239,7 @@ # Set up notifications for all the forums that have set for autosubscription set type_id [notification::type::get_type_id -short_name forums_forum_notif] - set interval_id [notification::get_interval_id -name instant] + set interval_id [notification::interval::get_id_from_name -name instant] set delivery_method_id [notification::get_delivery_method_id -name email] foreach forum_id [db_list select_forums {}] { Index: openacs-4/packages/notifications/tcl/notification-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/notification-procs.tcl,v diff -u -r1.23.2.4 -r1.23.2.5 --- openacs-4/packages/notifications/tcl/notification-procs.tcl 28 Dec 2021 11:40:24 -0000 1.23.2.4 +++ openacs-4/packages/notifications/tcl/notification-procs.tcl 8 Jul 2022 14:36:55 -0000 1.23.2.5 @@ -24,11 +24,16 @@ return "notifications" } - ad_proc -public get_interval_id { + ad_proc -deprecated get_interval_id { {-name:required} } { obtain the interval ID for an interval with the given name. Interval names are unique, but are not the primary key. + + DEPRECATED: an API doing the exact same thing was moved into + an own namespace + + @see notification::interval::get_id_from_name } { return [db_string select_interval_id {} -default ""] } @@ -214,7 +219,7 @@ if { $default_request_data eq "" } { set default_request_data [list \ - interval_id [get_interval_id -name "instant"] \ + interval_id [notification::interval::get_id_from_name -name "instant"] \ delivery_method_id [get_delivery_method_id -name "email"] \ format "text"] } Index: openacs-4/packages/notifications/tcl/test/notifications-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/test/Attic/notifications-test-procs.tcl,v diff -u -r1.1.2.4 -r1.1.2.5 --- openacs-4/packages/notifications/tcl/test/notifications-test-procs.tcl 8 Jul 2022 09:22:29 -0000 1.1.2.4 +++ openacs-4/packages/notifications/tcl/test/notifications-test-procs.tcl 8 Jul 2022 14:36:56 -0000 1.1.2.5 @@ -27,8 +27,13 @@ notification::package_key acs_sc::impl::new_from_spec notification::type::new + notification::type::get notification::type::get_type_id notification::type::get_impl_key + notification::type::delivery_method_enable + notification::type::delivery_method_disable + notification::type::interval_enable + notification::type::interval_disable notification::type::delete notification::request::new notification::request::delete @@ -44,7 +49,7 @@ notification::get_delivery_method_id notification::get_all_intervals notification::get_intervals - notification::get_interval_id + notification::interval::get_id_from_name notification::delete } \ notification_api_tests { @@ -92,12 +97,12 @@ aa_equals "Implementation key retrieval works as expected" \ "notifications_test_notif_type" $impl_key - aa_equals "Short name is correct" \ - $short_name [db_string q {select short_name from notification_types where type_id = :type_id}] - aa_equals "Description is correct" \ - $description [db_string q {select description from notification_types where type_id = :type_id}] - aa_equals "Service Contract Implementation id is correct" \ - $sc_impl_id [db_string q {select sc_impl_id from notification_types where type_id = :type_id}] + aa_log "Fetching the new type" + notification::type::get -short_name $short_name \ + -column_array notif + foreach {key value} [array get notif] { + aa_equals "'$key' is correct" [set $key] $notif($key) + } aa_equals "No delivery methods have been assigned to the new type" \ 0 [db_string q {select count(*) from notification_types_del_methods where type_id = :type_id}] @@ -122,7 +127,7 @@ -all_intervals \ -all_delivery_methods - aa_section "Some fun with the delivery methods and intervals API" + aa_section "Some fun with the delivery methods API" set all_delivery_methods [db_list_of_lists q { select delivery_method_id, short_name @@ -139,6 +144,18 @@ [notification::get_delivery_method_id -name $name] $id } + set one_delivery_method_id [lindex $delivery_methods 0 1] + aa_log "Disabling delivery method '$one_delivery_method_id' for type '$type_id'" + notification::type::delivery_method_disable -type_id $type_id -delivery_method_id $one_delivery_method_id + aa_equals "Delivery methods are one less for the type" \ + [llength [notification::get_delivery_methods -type_id $type_id]] [expr {[llength $delivery_methods] - 1}] + aa_log "Enabling delivery method '$one_delivery_method_id' for type '$type_id' again" + notification::type::delivery_method_enable -type_id $type_id -delivery_method_id $one_delivery_method_id + aa_equals "Delivery methods are back as before" \ + [lsort $delivery_methods] [lsort [notification::get_delivery_methods -type_id $type_id]] + + aa_section "Some fun with the intervals API" + set all_intervals [notification::get_all_intervals] set intervals [notification::get_intervals -localized -type_id $type_id] aa_equals "All intervals have been assigned to the new type" \ @@ -148,9 +165,19 @@ lassign $i name id seconds aa_true "Seconds '$seconds' is an integer" [string is integer -strict $seconds] aa_equals "Lookup interval '$name' returns the right id" \ - [notification::get_interval_id -name $name] $id + [notification::interval::get_id_from_name -name $name] $id } + set one_interval_id [lindex $intervals 0 1] + aa_log "Disabling interval '$one_interval_id' for type '$type_id'" + notification::type::interval_disable -type_id $type_id -interval_id $one_interval_id + aa_equals "Intervals are one less for the type" \ + [llength [notification::get_intervals -type_id $type_id]] [expr {[llength $intervals] - 1}] + aa_log "Enabling interval '$one_interval_id' for type '$type_id' again" + notification::type::interval_enable -type_id $type_id -interval_id $one_interval_id + aa_equals "Intervals are back as before" \ + [lsort $intervals] [lsort [notification::get_intervals -type_id $type_id]] + aa_section "Creating a notification with no subscriptions..." set object_id [db_string q {select object_id from acs_objects fetch first 1 rows only}] @@ -172,18 +199,8 @@ [db_0or1row q {select 1 from notifications where type_id = :type_id}] aa_section "Generating some subscriptions..." - set delivery_method_id [db_string q { - select delivery_method_id - from notification_types_del_methods - where type_id = :type_id - fetch first 1 rows only - }] - set interval_id [db_string q { - select interval_id - from notification_types_intervals - where type_id = :type_id - fetch first 1 rows only - }] + set delivery_method_id $one_delivery_method_id + set interval_id $one_interval_id aa_log "Creating a subscription for user_id '$user_id' on object_id '$object_id' and type_id '$type_id'" set request_id [notification::request::new \ Index: openacs-4/packages/notifications/www/request-notification.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/www/request-notification.tcl,v diff -u -r1.7 -r1.7.2.1 --- openacs-4/packages/notifications/www/request-notification.tcl 28 Jun 2018 10:39:36 -0000 1.7 +++ openacs-4/packages/notifications/www/request-notification.tcl 8 Jul 2022 14:36:56 -0000 1.7.2.1 @@ -28,7 +28,7 @@ #if group_id parameter exists then all users of this community are subscribed if they're not already subscribed if {$group_id ne ""} { - set interval_id [notification::get_interval_id -name instant] + set interval_id [notification::interval::get_id_from_name -name instant] set delivery_method_id [notification::get_delivery_method_id -name email] db_foreach get_member_id {} {