Index: openacs.org-dev/packages/notifications/sql/oracle/notifications-core-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/notifications/sql/oracle/notifications-core-create.sql,v
diff -u -r1.1 -r1.2
--- openacs.org-dev/packages/notifications/sql/oracle/notifications-core-create.sql 9 Jul 2002 17:35:10 -0000 1.1
+++ openacs.org-dev/packages/notifications/sql/oracle/notifications-core-create.sql 12 Feb 2003 13:16:53 -0000 1.2
@@ -4,7 +4,7 @@
-- @author Ben Adida (ben@openforce.net)
-- @version $Id$
--
--- Copyright OpenForce, 2002.
+-- Copyright (C) 2000 MIT
--
-- GNU GPL v2
--
@@ -120,6 +120,8 @@
check (format in ('text', 'html'))
);
+create index notification_requests_t_o_idx on notification_requests(type_id, object_id);
+
-- preferences
--
-- for preferences that apply to each request, we're using the
@@ -144,7 +146,7 @@
-- this is to allow responses to notifications
response_id constraint notif_reponse_id_fk
references acs_objects (object_id),
- notif_subject varchar(100),
+ notif_subject varchar(1000),
notif_text clob,
notif_html clob
);
Index: openacs.org-dev/packages/notifications/sql/postgresql/notifications-core-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/notifications/sql/postgresql/notifications-core-create.sql,v
diff -u -r1.1 -r1.2
--- openacs.org-dev/packages/notifications/sql/postgresql/notifications-core-create.sql 9 Jul 2002 17:35:10 -0000 1.1
+++ openacs.org-dev/packages/notifications/sql/postgresql/notifications-core-create.sql 12 Feb 2003 13:17:35 -0000 1.2
@@ -4,7 +4,7 @@
-- @author Ben Adida (ben@openforce.net)
-- @version $Id$
--
--- Copyright OpenForce, 2002.
+-- Copyright (C) 2000 MIT
--
-- GNU GPL v2
--
@@ -53,10 +53,10 @@
references acs_objects (object_id)
constraint notif_type_type_id_pk
primary key,
- sc_impl_id integer not null
+ sc_impl_id integer not null
constraint notif_deliv_meth_impl_id_fk
references acs_sc_impls(impl_id),
- short_name varchar(100)
+ short_name varchar(100)
constraint notif_type_short_name_nn
not null
constraint notif_type_short_name_un
@@ -136,6 +136,8 @@
check (format in ('text', 'html'))
);
+create index notification_requests_t_o_idx on notification_requests(type_id, object_id);
+
-- preferences
--
-- for preferences that apply to each request, we're using the
@@ -164,7 +166,7 @@
response_id integer
constraint notif_reponse_id_fk
references acs_objects (object_id),
- notif_subject varchar(100),
+ notif_subject varchar(1000),
notif_text text,
notif_html text
);
Index: openacs.org-dev/packages/notifications/tcl/notification-display-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/notifications/tcl/notification-display-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs.org-dev/packages/notifications/tcl/notification-display-procs.tcl 9 Jul 2002 17:35:10 -0000 1.1
+++ openacs.org-dev/packages/notifications/tcl/notification-display-procs.tcl 12 Feb 2003 13:18:06 -0000 1.2
@@ -17,7 +17,8 @@
{-url:required}
{-user_id ""}
} {
- Produce a widget for requesting notifications
+ Produce a widget for requesting notifications of a given type. If the notifications package has not been
+ mounted then return the empty string.
} {
if {[empty_string_p $user_id]} {
set user_id [ad_conn user_id]
@@ -33,10 +34,14 @@
set sub_url [unsubscribe_url -request_id $request_id -url $url]
set sub_chunk "You have requested notification for $pretty_name. You may unsubscribe."
} else {
- set sub_url [subscribe_url -type $type -object_id $object_id -url $url -user_id $user_id]
+ set sub_url [subscribe_url -type $type -object_id $object_id -url $url -user_id $user_id -pretty_name $pretty_name]
set sub_chunk "You may request notification for $pretty_name."
}
+ if { [empty_string_p $sub_url] } {
+ return ""
+ }
+
return "\[ $sub_chunk \]"
}
@@ -45,12 +50,21 @@
{-object_id:required}
{-url:required}
{-user_id:required}
+ {-pretty_name}
} {
+ Returns the URL that allows one to subscribe to a notification type on a particular object. If the
+ notifications package has not been mounted return the empty string.
+ } {
set type_id [notification::type::get_type_id -short_name $type]
set root_path [apm_package_url_from_key [notification::package_key]]
- set subscribe_url "${root_path}request-new?type_id=$type_id&user_id=$user_id&object_id=$object_id&return_url=[ns_urlencode $url]"
+ if { [empty_string_p $root_path] } {
+ return ""
+ }
+
+ set subscribe_url "${root_path}request-new?[export_vars { type_id user_id object_id pretty_name {return_url $url} }]"
+
return $subscribe_url
}
@@ -59,6 +73,11 @@
{-url:required}
} {
set root_path [apm_package_url_from_key [notification::package_key]]
+
+ if { [empty_string_p $root_path] } {
+ return ""
+ }
+
set unsubscribe_url "${root_path}request-delete?request_id=$request_id&return_url=[ns_urlencode $url]"
return $unsubscribe_url
Index: openacs.org-dev/packages/notifications/tcl/notification-email-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/notifications/tcl/notification-email-procs.tcl,v
diff -u -r1.5 -r1.6
--- openacs.org-dev/packages/notifications/tcl/notification-email-procs.tcl 12 Feb 2003 01:22:50 -0000 1.5
+++ openacs.org-dev/packages/notifications/tcl/notification-email-procs.tcl 12 Feb 2003 13:18:07 -0000 1.6
@@ -97,6 +97,8 @@
# Set the reply to address to the address of the mailer.
set extra_headers [ns_set new]
ns_set put $extra_headers Reply-To [reply_address -object_id $reply_object_id -type_id $notification_type_id]
+ ns_set put $extra_headers Precedence bulk
+ ns_set put $extra_headers Sender "notifications-admin@openacs.org"
acs_mail_lite::send \
-to_addr $email \
Index: openacs.org-dev/packages/notifications/tcl/notification-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/notifications/tcl/notification-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs.org-dev/packages/notifications/tcl/notification-procs.tcl 9 Jul 2002 17:35:10 -0000 1.1
+++ openacs.org-dev/packages/notifications/tcl/notification-procs.tcl 12 Feb 2003 13:18:07 -0000 1.2
@@ -51,16 +51,16 @@
{-notif_text ""}
{-notif_html ""}
} {
- create a new notification
+ create a new notification if any notification requests exist for the object and type
} {
- # Set up the vars
- set extra_vars [ns_set create]
- oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {notification_id type_id object_id response_id notif_subject notif_text notif_html}
+ if { [notification::request::request_exists -object_id $object_id -type_id $type_id] } {
+ # Set up the vars
+ set extra_vars [ns_set create]
+ oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {notification_id type_id object_id response_id notif_subject notif_text notif_html}
- # Create the request
- set notification_id [package_instantiate_object -extra_vars $extra_vars notification]
-
- return $notification_id
+ # Create the request
+ package_instantiate_object -extra_vars $extra_vars notification
+ }
}
ad_proc -public delete {
@@ -84,6 +84,7 @@
mark that a user has been sent a notification
} {
# Do the insert
+ns_log Notice "DRB: marking notification $notification_id sent for user $user_id"
db_dml insert_notification_user_map {}
}
}
Index: openacs.org-dev/packages/notifications/tcl/notification-request-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/notifications/tcl/notification-request-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs.org-dev/packages/notifications/tcl/notification-request-procs.tcl 9 Jul 2002 17:35:10 -0000 1.1
+++ openacs.org-dev/packages/notifications/tcl/notification-request-procs.tcl 12 Feb 2003 13:18:07 -0000 1.2
@@ -45,6 +45,15 @@
return [db_string select_request_id {} -default {}]
}
+ ad_proc -public request_exists {
+ {-type_id:required}
+ {-object_id:required}
+ } {
+ returns true if at least one request exists for this object and type
+ } {
+ return [expr { [db_string request_count {}] > 0 }]
+ }
+
ad_proc -public delete {
{-request_id:required}
} {
Index: openacs.org-dev/packages/notifications/tcl/notification-request-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/notifications/tcl/notification-request-procs.xql,v
diff -u -r1.1 -r1.2
--- openacs.org-dev/packages/notifications/tcl/notification-request-procs.xql 9 Jul 2002 17:35:10 -0000 1.1
+++ openacs.org-dev/packages/notifications/tcl/notification-request-procs.xql 12 Feb 2003 13:18:07 -0000 1.2
@@ -12,4 +12,13 @@
+