Index: openacs-4/packages/acs-core-docs/www/tutorial-notifications.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/tutorial-notifications.html,v diff -u -r1.20 -r1.20.2.1 --- openacs-4/packages/acs-core-docs/www/tutorial-notifications.html 25 Apr 2018 08:38:28 -0000 1.20 +++ openacs-4/packages/acs-core-docs/www/tutorial-notifications.html 2 Mar 2019 19:30:06 -0000 1.20.2.1 @@ -1,24 +1,16 @@ -Notifications

Notifications

- - <authorblurb> -

by David Bell and Simon Carstensen

- </authorblurb>
- -

The notifications package allows you to send notifications through any +Notifications

Notifications

by David Bell and Simon Carstensen

+ OpenACS docs are written by the named authors, and may be edited + by OpenACS documentation staff. +

The notifications package allows you to send notifications through any defined communications medium (e.g. email, sms) upon some event occurring within - the system.

-

This tutorial steps through the process of integrating the notifications - package with your package.

- -

First step is to create the notification types. To do this a script similar + the system.

This tutorial steps through the process of integrating the notifications + package with your package.

First step is to create the notification types. To do this a script similar to the one below needs to be loaded into Postgresql. I create this script in a package-name/sql/postgresql/package-name-notifications-init.sql file. I then load this file from my create sql file. The following code snippet is taken from Weblogger. It creates a lars_blogger_notif notification type (which was created - above).

- -
+    above).

     create function inline_0() returns integer as $$
     declare
             impl_id integer;
@@ -81,11 +73,8 @@
 
     select inline_0();
     drop function inline_0();
-    
- -

You also need a drop script. This is untested for - compatibility with the above script.

-
+    

You also need a drop script. This is untested for + compatibility with the above script.

       -- @author gwong@orchardlabs.com,ben@openforce.biz
       -- @creation-date 2002-05-16
       --
@@ -174,23 +163,17 @@
 
 select inline_0();
 drop function inline_0();
-    
- -

The next step is to setup our notification creation. A new notification must +

The next step is to setup our notification creation. A new notification must be added to the notification table for each blog entry added. We do this using the - notification::new procedure

- -
+    notification::new procedure

         notification::new \
             -type_id [notification::type::get_type_id \
             -short_name lars_blogger_notif] \
             -object_id $blog(package_id) \
             -response_id $blog(entry_id) \
             -notif_subject $blog(title) \
             -notif_text $new_content
-    
- -

This code is placed in the Tcl procedure that creates blog +

This code is placed in the Tcl procedure that creates blog entries, right after the entry gets created in the code. The $blog(package_id) is the OpenACS object_id of the Weblogger instance to which the entry has been @@ -200,34 +183,24 @@ changes for blogger entries in this package. However, if you instead used the blog_entry_id or something like that, you could set up per-item notifications. The forums packages does this -- - you can look at it for an example.

- -

The final step is to setup the notification subscription process. In this + you can look at it for an example.

The final step is to setup the notification subscription process. In this example we want to let a user find out when a new entry has been posted to the blog. To do this we put a link on the blog that allows them to subscribe to notifications of new - entries. The notifications/requests-new page is very handy in this situation.

- -

Such a link can be created using the notification::display::request_widget - proc:

-
+    entries. The notifications/requests-new page is very handy in this situation.

Such a link can be created using the notification::display::request_widget + proc:

     set notification_chunk [notification::display::request_widget \
         -type lars_blogger_notif \
         -object_id $package_id \
         -pretty_name [lars_blog_name] \
         -url [lars_blog_public_package_url] \
     ]
-    
+

which will return something like -

which will return something like -

     You may <a href="/notifications/request-new?...">request notification</a> for Weblogger.

which can be readily put on the blog index page. The pretty_name parameter is what appears at the end of the text returned (i.e. "... request notification</a> for pretty_name"), The url parameter should be set to the address we want the user - to be redirected to after they have finished the subscription process.

- -

This should be all you need to implement a notification system. For more examples - look at the forums package.

-
+ to be redirected to after they have finished the subscription process.

This should be all you need to implement a notification system. For more examples + look at the forums package.