Index: openacs-4/packages/notifications/notifications.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/notifications.info,v diff -u -r1.29 -r1.30 --- openacs-4/packages/notifications/notifications.info 24 Feb 2005 13:33:24 -0000 1.29 +++ openacs-4/packages/notifications/notifications.info 24 May 2005 21:10:46 -0000 1.30 @@ -8,14 +8,14 @@ t notifications - + OpenACS Email notifications management 2003-11-07 OpenACS Provides an API for packages to provide subscription based email notifications and handle replies. Used by forums, bug-tracker, etc. The currently prefered package for email notifications. - + Index: openacs-4/packages/notifications/catalog/notifications.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/catalog/notifications.en_US.ISO-8859-1.xml,v diff -u -r1.13 -r1.14 --- openacs-4/packages/notifications/catalog/notifications.en_US.ISO-8859-1.xml 13 Jan 2005 13:58:32 -0000 1.13 +++ openacs-4/packages/notifications/catalog/notifications.en_US.ISO-8859-1.xml 24 May 2005 21:10:47 -0000 1.14 @@ -1,14 +1,16 @@ - + Action Change Contents: Delivery Method + for the object type Frequency Item Getting too much email? Manage your notifications at: %manage_notifications_url% Notification Interval + Notifications Interval Request Notification for %pretty_name% [%system_name% - Batched Notification] You have no notifications. @@ -18,5 +20,13 @@ Notification type Request Notification SUBJECT: + Subscribe notification + Subscribe to notification: + Subscribed User + There are no users Unsubscribe + Unsubscribe notifications + Unsubscribe of notification: + Unsubscribe selected users + User Index: openacs-4/packages/notifications/catalog/notifications.es_ES.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/catalog/notifications.es_ES.ISO-8859-1.xml,v diff -u -r1.10 -r1.11 --- openacs-4/packages/notifications/catalog/notifications.es_ES.ISO-8859-1.xml 13 Jan 2005 13:58:32 -0000 1.10 +++ openacs-4/packages/notifications/catalog/notifications.es_ES.ISO-8859-1.xml 24 May 2005 21:10:47 -0000 1.11 @@ -1,14 +1,16 @@ - + Acci�n Cambiar Contenido: M�todo de entrega + para el objeto de tipo Frecuencia Elemento �Recibe demasiados correos? Administre sus notificaciones en: %manage_notifications_url% Intervalo de notificaci�n + Intervalo de notificaci�n Pedir notificaci�n para %pretty_name% [%system_name% - Notificaci�n en Batch] No tiene avisos. @@ -18,5 +20,13 @@ Tipo de Aviso Pedir Notificaci�n Asunto: + Subscribir notificaci�n + Subscribir a notificaci�n: + Usuario subscrito + Ning�n usuario est� subscrito para recibir notificaciones de ese tipo para ese objeto. Darse de baja + Desubscribir notificaciones + Desubscribir de notificaci�n: + Desuscribir Usuarios seleccionados + Usuario Index: openacs-4/packages/notifications/catalog/notifications.es_GT.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/catalog/notifications.es_GT.ISO-8859-1.xml,v diff -u -r1.3 -r1.4 --- openacs-4/packages/notifications/catalog/notifications.es_GT.ISO-8859-1.xml 13 Jan 2005 13:58:32 -0000 1.3 +++ openacs-4/packages/notifications/catalog/notifications.es_GT.ISO-8859-1.xml 24 May 2005 21:10:47 -0000 1.4 @@ -4,10 +4,12 @@ Acci�n Cambiar M�todo de entrega + para el objeto de tipo Frecuencia Elemento �Recibe demasiados correos? Administre sus notificaciones en: %manage_notifications_url% Intervalo de notificaci�n + Intervalo de notificaci�n Pedir notificaci�n para %pretty_name% [%system_name% - Notificaci�nes Programadas] No tiene notificaciones. @@ -17,5 +19,13 @@ Tipo de Notificaci�n Pedir Notificaci�n Asunto: + Subscribir notificaci�n + Subscribir a notificaci�n: + Usuario subscrito + Ning�n usuario est� subscrito para recibir notificaciones de ese tipo para ese objeto. Darse de baja + Desubscribir notificaciones + Desubscribir de notificaci�n: + Desuscribir Usuarios seleccionados + Usuario Index: openacs-4/packages/notifications/www/request-notification.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/www/request-notification.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/notifications/www/request-notification.adp 24 May 2005 21:10:47 -0000 1.1 @@ -0,0 +1,6 @@ + +@title@ +@context;noquote@ +

#notifications.Subscribe_to_notification# @pretty_name@ #notifications.for_the_object_type# @object_type@

+ + \ No newline at end of file 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/notifications/www/request-notification.tcl 24 May 2005 21:10:47 -0000 1.1 @@ -0,0 +1,127 @@ +ad_page_contract { + + Subscribe a person or a group to a notification of an object and a type. + + @author Natalia P�rez (nperper@it.uc3m.es) + @create-date 2005-03-28 + +} { + object_id:integer,notnull + type_id + {group_id ""} +} + +set package_id [ad_conn package_id] +permission::require_permission -object_id $package_id -privilege create + +set title "[_ notifications.Subscribe_notification]" +set context "[_ notifications.Subscribe_notification]" + +db_0or1row get_type_object {} +db_0or1row get_name_notification {} + +set return_url "request-notification?object_id=$object_id&type_id=$type_id" + +form create notify +set intervals [notification::get_intervals -type_id $type_id] +set delivery_methods [notification::get_delivery_methods -type_id $type_id] + +#if group_id parameter exists then all users of this community are subscribed if they're not already subscribed +if {$group_id != ""} { + set interval_id [notification::get_interval_id -name instant] + set delivery_method_id [notification::get_delivery_method_id -name email] + + db_foreach get_member_id {} { + # Add notification for this user if they're not already subscribed for an instant alert + if {[string equal [notification::request::get_request_id -user_id $user_id -type_id $type_id -object_id $object_id] ""] } { + notification::request::new -type_id $type_id -user_id $user_id -object_id $object_id -interval_id $interval_id \ + -delivery_method_id $delivery_method_id + } + } +} + + +element create notify type_id\ + -widget hidden\ + -value $type_id +element create notify object_id\ + -widget hidden\ + -value $object_id +element create notify party_id \ + -widget party_search \ + -datatype party_search \ + -label "[_ notifications.User]" +element create notify interval_id\ + -widget select\ + -datatype text\ + -label "[_ notifications.lt_Notification_Interval]"\ + -options $intervals +element create notify delivery_method_id\ + -datatype integer \ + -widget select\ + -label "[_ notifications.Delivery_Method]"\ + -options $delivery_methods\ + -value [lindex [lindex $delivery_methods 0] 1] + + +set username "" +if {[template::form is_valid notify]} { + template::form get_values notify party_id interval_id type_id delivery_method_id + + db_foreach get_user {} { + if {[string equal [notification::request::get_request_id -user_id $user_id -type_id $type_id -object_id $object_id] ""] } { + notification::request::new -type_id $type_id -user_id $user_id -object_id $object_id -interval_id $interval_id \ + -delivery_method_id $delivery_method_id + } + } + + #if party_id is a group of users then returnredirect, else we get an error + db_0or1row get_user_name {} + if {$username == ""} { + ad_returnredirect $return_url + } + + + # Add the subscribe + notification::request::new \ + -type_id $type_id \ + -user_id $party_id \ + -object_id $object_id \ + -interval_id $interval_id \ + -delivery_method_id $delivery_method_id + + + ad_returnredirect $return_url +} + +#delete subscribed users +template::list::create \ + -name notify_users\ + -multirow notify_users\ + -key request_id\ + -bulk_actions\ + { + "\#notifications.Unsubscribe\#" "unsubscribe" "\#notifications.unsubscribe_user\#" + }\ + -bulk_action_method post -bulk_action_export_vars { + object_id + type_id + return_url + }\ + -no_data "\#notifications.there_are_no_users\#"\ + -row_pretty_plural "notify_users"\ + -elements { + name { + label "[_ notifications.Subscribed_User_ID]" + } + interval_name { + label "[_ notifications.lt_Notification_Interval]" + } + delivery_name { + label "[_ notifications.Delivery_Method]" + } + } + +db_multirow notify_users notify_users { *SQL* } + + Index: openacs-4/packages/notifications/www/request-notification.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/www/request-notification.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/notifications/www/request-notification.xql 24 May 2005 21:10:47 -0000 1.1 @@ -0,0 +1,59 @@ + + + + + + select p.first_names || ' ' || p.last_name as name,nr.request_id, + (select name from notification_intervals where interval_id= + nr.interval_id) as interval_name ,(select short_name from + notification_delivery_methods where + delivery_method_id=nr.delivery_method_id) as delivery_name + from persons p, notification_requests nr + where p.person_id = nr.user_id and + nr.object_id = :object_id and + nr.type_id = :type_id + + + + + + + select party_approved_member_map.member_id as user_id + from party_approved_member_map, group_member_map + where group_member_map.member_id = party_approved_member_map.member_id + and party_id = :party_id + + + + + + select object_type + from acs_objects + where object_id = :object_id + + + + + + select pretty_name + from notification_types + where type_id = :type_id + + + + + + select member_id as user_id + from group_member_map + where group_id = :group_id + + + + + + select username + from users + where user_id = :party_id + + + Index: openacs-4/packages/notifications/www/request-unsubscribe-notification.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/www/request-unsubscribe-notification.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/notifications/www/request-unsubscribe-notification.adp 24 May 2005 21:10:47 -0000 1.1 @@ -0,0 +1,6 @@ + +@title@ +@context;noquote@ +

#notifications.Unsubscribe_of_notification# @pretty_name@

+ + Index: openacs-4/packages/notifications/www/request-unsubscribe-notification.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/www/request-unsubscribe-notification.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/notifications/www/request-unsubscribe-notification.tcl 24 May 2005 21:10:47 -0000 1.1 @@ -0,0 +1,50 @@ +ad_page_contract { + + Unsubscribe users. + + @author Natalia P�rez (nperper@it.uc3m.es) + @create-date 2005-03-28 + +} { + object_id:integer,notnull + type_id +} + +set package_id [ad_conn package_id] +permission::require_permission -object_id $package_id -privilege create + +set title "[_ notifications.Unsubscribe_Notifications]" + +set context "[_ notifications.Unsubscribe_Notifications]" + +db_0or1row get_name_notification {} +set return_url "request-unsubscribe-notification?object_id=$object_id&type_id=$type_id" + +#get all users subscribed to notification of type_id +template::list::create -name notify_users\ +-multirow notify_users\ +-key request_id\ +-bulk_actions\ + { + "\#notifications.unsubscribe\#" "unsubscribe" "\#notifications.unsubscribe_user\#" + }\ + -bulk_action_method post -bulk_action_export_vars { + object_id + type_id + return_url + }\ + -no_data "\#notifications.there_are_no_users\#"\ + -row_pretty_plural "notify_users"\ + -elements { + name { + label "[_ notifications.User]" + } + interval_name { + label "[_ notifications.lt_Notifications_Interval]" + } + delivery_name { + label "[_ notifications.Delivery_Method]" + } + } + + db_multirow notify_users notify_users { *SQL* } \ No newline at end of file Index: openacs-4/packages/notifications/www/request-unsubscribe-notification.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/www/request-unsubscribe-notification.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/notifications/www/request-unsubscribe-notification.xql 24 May 2005 21:10:47 -0000 1.1 @@ -0,0 +1,28 @@ + + + + + + select p.first_names || ' ' || p.last_name as name,nr.request_id, + (select name from notification_intervals where interval_id= + nr.interval_id) as interval_name ,(select short_name from + notification_delivery_methods where + delivery_method_id=nr.delivery_method_id) as delivery_name, + (select pretty_name from notification_types + where type_id = :type_id) as pretty_name + from persons p, notification_requests nr + where p.person_id = nr.user_id and + nr.object_id = :object_id and + nr.type_id = :type_id + + + + + + select pretty_name + from notification_types + where type_id = :type_id + + + + \ No newline at end of file Index: openacs-4/packages/notifications/www/unsubscribe.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/www/unsubscribe.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/notifications/www/unsubscribe.tcl 24 May 2005 21:10:47 -0000 1.1 @@ -0,0 +1,21 @@ +ad_page_contract { + + @author Natalia P�rez (nperper@it.uc3m.es) + @creation_date 2005-03-28 + +} { + object_id:notnull + request_id:multiple + type_id + return_url +} + +set request_count [llength $request_id] +for { set i 0} { $i < $request_count } { incr i } { + db_transaction { + set r_id [lindex $request_id $i] + db_dml remove_notify { *SQL* } + } +} + +ad_returnredirect $return_url Index: openacs-4/packages/notifications/www/unsubscribe.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/www/Attic/unsubscribe.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/notifications/www/unsubscribe.xql 24 May 2005 21:10:47 -0000 1.1 @@ -0,0 +1,9 @@ + + + + + + delete from notification_requests where request_id=:r_id + + +