Index: openacs-4/packages/notifications/notifications.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/notifications.info,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/notifications.info 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,40 @@
+
+
+
+
+ Notifications
+ Notifications
+ f
+ t
+
+
+
+ oracle
+ postgresql
+
+ Ben Adida
+ Notification Management
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: openacs-4/packages/notifications/sql/oracle/notifications-core-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/oracle/notifications-core-create.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/sql/oracle/notifications-core-create.sql 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,201 @@
+
+--
+-- The Notifications Package
+--
+-- ben@openforce.net
+-- Copyright OpenForce, 2002.
+--
+-- GNU GPL v2
+--
+
+
+-- intervals should really be service contracts so other intervals can be
+-- taken into account. For now we're going to make them just intervals
+create table notification_intervals (
+ interval_id integer not null
+ constraint notif_interv_id_pk primary key
+ constraint notif_interv_id_fk references acs_objects(object_id),
+ name varchar(200) not null
+ constraint notif_interv_name_un unique,
+ -- how to schedule this
+ n_seconds integer not null
+);
+
+
+-- delivery methods should be service contracts, too.
+create table notification_delivery_methods (
+ delivery_method_id integer not null
+ constraint notif_deliv_meth_pk primary key
+ constraint notif_deliv_meth_fk references acs_objects(object_id),
+ short_name varchar(100) not null
+ constraint notif_deliv_short_name_un unique,
+ pretty_name varchar(200) not null
+);
+
+
+create table notification_types (
+ type_id integer not null
+ constraint notif_type_type_id_pk primary key
+ constraint notif_type_type_id_fk references acs_objects(object_id),
+ short_name varchar(100) not null
+ constraint notif_type_short_name_un unique,
+ pretty_name varchar(200) not null,
+ description varchar(2000)
+);
+
+
+-- what's allowed for a given notification type?
+create table notification_types_intervals (
+ type_id integer not null
+ constraint notif_type_int_type_id_fk
+ references notification_types(type_id),
+ interval_id integer not null
+ constraint notif_type_int_int_id_fk
+ references notification_intervals(interval_id),
+ constraint notif_type_int_pk
+ primary key (type_id, interval_id)
+);
+
+-- allowed delivery methods
+create table notification_types_del_methods (
+ type_id integer not null
+ constraint notif_type_del_type_id_fk
+ references notification_types(type_id),
+ delivery_method_id integer not null
+ constraint notif_type_del_meth_id_fk
+ references notification_delivery_methods(delivery_method_id),
+ constraint notif_type_deliv_pk
+ primary key (type_id, delivery_method_id)
+);
+
+
+-- Requests for Notifications
+create table notification_requests (
+ request_id integer not null
+ constraint notif_request_id_pk primary key
+ constraint notif_request_id_fk references acs_objects(object_id),
+ type_id integer not null
+ constraint notif_request_type_id_fk
+ references notification_types(type_id),
+ user_id integer not null
+ constraint notif_request_user_id_fk
+ references users(user_id),
+ -- The object this request pertains to
+ object_id integer not null
+ constraint notif_request_object_id_fk
+ references acs_objects(object_id),
+ -- the interval must be allowed for this type
+ interval_id integer not null,
+ constraint notif_request_interv_fk
+ foreign key (type_id, interval_id) references notification_types_intervals(type_id,interval_id),
+ -- the delivery method must be allowed for this type
+ delivery_method_id integer not null,
+ constraint notif_request_deliv_fk
+ foreign key (type_id, delivery_method_id) references notification_types_del_methods(type_id,delivery_method_id),
+ -- the format of the notification should be...
+ format varchar(100) default 'text'
+ constraint notif_request_format_ch
+ check (format in ('text','html'))
+);
+
+
+-- preferences
+--
+-- for preferences that apply to each request, we're using the
+-- notification_requests table. For preferences that are notification-wide,
+-- we use user-preferences
+
+
+-- the actual stuff that has to go out
+create table notifications (
+ notification_id integer not null
+ constraint notif_notif_id_pk primary key
+ constraint notif_notif_id_fk references acs_objects(object_id),
+ type_id integer not null
+ constraint notif_type_id_fk references notification_types(type_id),
+ -- the object this notification pertains to
+ object_id integer not null
+ constraint notif_object_id_fk references acs_objects(object_id),
+ notif_date date not null,
+ -- this is to allow responses to notifications
+ response_id integer
+ constraint notif_reponse_id_fk references acs_objects(object_id),
+ notif_text varchar(4000),
+ notif_html varchar(4000)
+);
+
+
+-- who has received this notification?
+create table notification_user_map (
+ notification_id integer not null
+ constraint notif_user_map_notif_id_fk references notifications(notification_id),
+ user_id integer not null
+ constraint notif_user_map_user_id_fk references users(user_id),
+ constraint notif_user_map_pk
+ primary key (notification_id, user_id),
+ sent_date date
+);
+
+
+
+--
+-- Object Types
+--
+
+declare
+begin
+
+ acs_object_type.create_type (
+ supertype => 'acs_object',
+ object_type => 'notification_interval',
+ pretty_name => 'Notification Interval',
+ pretty_plural => 'Notification Intervals',
+ table_name => 'notification_intervals',
+ id_column => 'interval_id',
+ package_name => 'notification_interval'
+ );
+
+ acs_object_type.create_type (
+ supertype => 'acs_object',
+ object_type => 'notification_delivery_method',
+ pretty_name => 'Notification Delivery Method',
+ pretty_plural => 'Notification Delivery Methods',
+ table_name => 'notification_delivery_methods',
+ id_column => 'delivery_method_id',
+ package_name => 'notification_delivery_method'
+ );
+
+ acs_object_type.create_type (
+ supertype => 'acs_object',
+ object_type => 'notification_type',
+ pretty_name => 'Notification Type',
+ pretty_plural => 'Notification Types',
+ table_name => 'notification_types',
+ id_column => 'type_id',
+ package_name => 'notification_type'
+ );
+
+ acs_object_type.create_type (
+ supertype => 'acs_object',
+ object_type => 'notification_request',
+ pretty_name => 'Notification Request',
+ pretty_plural => 'Notification Requests',
+ table_name => 'notification_requests',
+ id_column => 'request_id',
+ package_name => 'notification_request'
+ );
+
+ acs_object_type.create_type (
+ supertype => 'acs_object',
+ object_type => 'notification',
+ pretty_name => 'Notification',
+ pretty_plural => 'Notifications',
+ table_name => 'notifications',
+ id_column => 'notification_id',
+ package_name => 'notification'
+ );
+
+
+end;
+/
+show errors
Index: openacs-4/packages/notifications/sql/oracle/notifications-core-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/oracle/notifications-core-drop.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/sql/oracle/notifications-core-drop.sql 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,60 @@
+
+--
+-- The Notifications Package
+--
+-- ben@openforce.net
+-- Copyright OpenForce, 2002.
+--
+-- GNU GPL v2
+--
+
+-- drop script
+
+drop table notification_user_map;
+
+drop table notifications;
+
+drop table notification_requests;
+
+drop table notification_types_del_methods;
+
+drop table notification_types_intervals;
+
+drop table notification_types;
+
+drop table notification_intervals;
+
+drop table notification_delivery_methods;
+
+
+
+
+--
+-- Object Types
+--
+
+declare
+begin
+
+ acs_object_type.drop_type (
+ object_type => 'notification_interval'
+ );
+
+ acs_object_type.drop_type (
+ object_type => 'notification_delivery_method'
+ );
+
+ acs_object_type.drop_type (
+ object_type => 'notification_type'
+ );
+
+ acs_object_type.drop_type (
+ object_type => 'notification_request'
+ );
+
+ acs_object_type.drop_type (
+ object_type => 'notification'
+ );
+end;
+/
+show errors
Index: openacs-4/packages/notifications/sql/oracle/notifications-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/oracle/notifications-create.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/sql/oracle/notifications-create.sql 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,16 @@
+
+--
+-- The Notifications Package
+--
+-- ben@openforce.net
+-- Copyright OpenForce, 2002.
+--
+-- GNU GPL v2
+--
+
+@ notifications-core-create.sql
+@ notifications-package-create.sql
+
+-- the service contracts will eventually be created
+-- @ notifications-interval-sc-create.sql
+-- @ notifications-delivery-sc-create.sql
Index: openacs-4/packages/notifications/sql/oracle/notifications-package-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/oracle/notifications-package-create.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/sql/oracle/notifications-package-create.sql 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,366 @@
+
+--
+-- The Notifications Package
+--
+-- ben@openforce.net
+-- Copyright OpenForce, 2002.
+--
+-- GNU GPL v2
+--
+
+
+-- The Notification Interval Package
+
+create or replace package notification_interval
+as
+ function new (
+ interval_id in notification_intervals.interval_id%TYPE default null,
+ name in notification_intervals.name%TYPE,
+ n_seconds in notification_intervals.n_seconds%TYPE,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE,
+ creation_ip in acs_objects.creation_ip%TYPE,
+ context_id in acs_objects.context_id%TYPE default null
+ ) return notification_intervals.interval_id%TYPE;
+
+ procedure delete (
+ interval_id in notification_intervals.interval_id%TYPE
+ );
+
+end notification_interval;
+/
+show errors
+
+
+
+create or replace package body notification_interval
+as
+ function new (
+ interval_id in notification_intervals.interval_id%TYPE default null,
+ name in notification_intervals.name%TYPE,
+ n_seconds in notification_intervals.n_seconds%TYPE,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE,
+ creation_ip in acs_objects.creation_ip%TYPE,
+ context_id in acs_objects.context_id%TYPE default null
+ ) return notification_intervals.interval_id%TYPE
+ is
+ v_interval_id acs_objects.object_id%TYPE;
+ begin
+ v_interval_id:= acs_object.new (
+ object_id => interval_id,
+ object_type => 'notification_interval',
+ creation_date => creation_date,
+ creation_user => creation_user,
+ creation_ip => creation_ip,
+ context_id => context_id
+ );
+
+ insert into notification_intervals
+ (interval_id, name, n_seconds) values
+ (v_interval_id, name, n_seconds);
+
+ return v_interval_id;
+ end new;
+
+ procedure delete (
+ interval_id in notification_intervals.interval_id%TYPE
+ )
+ is
+ begin
+ acs_object.delete(interval_id);
+ end delete;
+
+end notification_interval;
+/
+show errors
+
+
+-- The notification delivery methods package
+
+create or replace package notification_delivery_method
+as
+ function new (
+ delivery_method_id in notification_delivery_methods.delivery_method_id%TYPE default null,
+ short_name in notification_delivery_methods.short_name%TYPE,
+ pretty_name in notification_delivery_methods.pretty_name%TYPE,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE,
+ creation_ip in acs_objects.creation_ip%TYPE,
+ context_id in acs_objects.context_id%TYPE default null
+ ) return notification_delivery_methods.delivery_method_id%TYPE;
+
+ procedure delete (
+ delivery_method_id in notification_delivery_methods.delivery_method_id%TYPE
+ );
+
+end notification_delivery_method;
+/
+show errors
+
+
+
+create or replace package body notification_delivery_method
+as
+ function new (
+ delivery_method_id in notification_delivery_methods.delivery_method_id%TYPE default null,
+ short_name in notification_delivery_methods.short_name%TYPE,
+ pretty_name in notification_delivery_methods.pretty_name%TYPE,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE,
+ creation_ip in acs_objects.creation_ip%TYPE,
+ context_id in acs_objects.context_id%TYPE default null
+ ) return notification_delivery_methods.delivery_method_id%TYPE
+ is
+ v_delivery_method_id acs_objects.object_id%TYPE;
+ begin
+ v_delivery_method_id := acs_object.new (
+ object_id => delivery_method_id,
+ object_type => 'notification_delivery_method',
+ creation_date => creation_date,
+ creation_user => creation_user,
+ creation_ip => creation_ip,
+ context_id => context_id
+ );
+
+ insert into notification_delivery_methods
+ (delivery_method_id, short_name, pretty_name) values
+ (v_delivery_method_id, short_name, pretty_name);
+
+ return v_delivery_method_id;
+ end new;
+
+ procedure delete (
+ delivery_method_id in notification_delivery_methods.delivery_method_id%TYPE
+ )
+ is
+ begin
+ acs_object.delete (delivery_method_id);
+ end delete;
+
+end notification_delivery_method;
+/
+show errors
+
+
+
+-- Notification Types Package
+create or replace package notification_type
+as
+ function new (
+ type_id in notification_types.type_id%TYPE default null,
+ short_name in notification_types.short_name%TYPE,
+ pretty_name in notification_types.pretty_name%TYPE,
+ description in notification_types.description%TYPE,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE,
+ creation_ip in acs_objects.creation_ip%TYPE,
+ context_id in acs_objects.context_id%TYPE default null
+ ) return notification_types.type_id%TYPE;
+
+ procedure delete (
+ type_id in notification_types.type_id%TYPE default null
+ );
+
+end notification_type;
+/
+show errors
+
+
+
+create or replace package body notification_type
+as
+ function new (
+ type_id in notification_types.type_id%TYPE default null,
+ short_name in notification_types.short_name%TYPE,
+ pretty_name in notification_types.pretty_name%TYPE,
+ description in notification_types.description%TYPE,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE,
+ creation_ip in acs_objects.creation_ip%TYPE,
+ context_id in acs_objects.context_id%TYPE default null
+ ) return notification_types.type_id%TYPE
+ is
+ v_type_id acs_objects.object_id%TYPE;
+ begin
+ v_type_id := acs_object.new (
+ object_id => type_id,
+ object_type => 'notification_type',
+ creation_date => creation_date,
+ creation_user => creation_user,
+ creation_ip => creation_ip,
+ context_id => context_id
+ );
+
+ insert into notification_types
+ (type_id, short_name, pretty_name, description) values
+ (v_type_id, short_name, pretty_name, description);
+
+ return v_type_id;
+ end new;
+
+ procedure delete (
+ type_id in notification_types.type_id%TYPE default null
+ )
+ is
+ begin
+ acs_object.delete(type_id);
+ end delete;
+
+end notification_type;
+/
+show errors
+
+
+
+-- the notification request package
+
+create or replace package notification_request
+as
+ function new (
+ request_id in notification_requests.request_id%TYPE default null,
+ object_type in acs_objects.object_type%TYPE default 'notification_request',
+ type_id in notification_requests.type_id%TYPE,
+ user_id in notification_requests.user_id%TYPE,
+ object_id in notification_requests.object_id%TYPE,
+ interval_id in notification_requests.interval_id%TYPE,
+ delivery_method_id in notification_requests.delivery_method_id%TYPE,
+ format in notification_requests.format%TYPE,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE,
+ creation_ip in acs_objects.creation_ip%TYPE,
+ context_id in acs_objects.context_id%TYPE default null
+ ) return notification_requests.request_id%TYPE;
+
+ procedure delete (
+ request_id in notification_requests.request_id%TYPE default null
+ );
+end notification_request;
+/
+show errors
+
+
+create or replace package body notification_request
+as
+ function new (
+ request_id in notification_requests.request_id%TYPE default null,
+ object_type in acs_objects.object_type%TYPE default 'notification_request',
+ type_id in notification_requests.type_id%TYPE,
+ user_id in notification_requests.user_id%TYPE,
+ object_id in notification_requests.object_id%TYPE,
+ interval_id in notification_requests.interval_id%TYPE,
+ delivery_method_id in notification_requests.delivery_method_id%TYPE,
+ format in notification_requests.format%TYPE,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE,
+ creation_ip in acs_objects.creation_ip%TYPE,
+ context_id in acs_objects.context_id%TYPE default null
+ ) return notification_requests.request_id%TYPE
+ is
+ v_request_id acs_objects.object_id%TYPE;
+ begin
+ v_request_id := acs_object.new (
+ object_id => request_id,
+ object_type => object_type,
+ creation_date => creation_date,
+ creation_user => creation_user,
+ creation_ip => creation_ip,
+ context_id => context_id
+ );
+
+ insert into notification_requests
+ (request_id, type_id, user_id, object_id, interval_id, delivery_method_id, format) values
+ (v_request_id, type_id, user_id, object_id, interval_id, delivery_method_id, format);
+
+ return v_request_id;
+ end new;
+
+ procedure delete (
+ request_id in notification_requests.request_id%TYPE default null
+ )
+ is
+ begin
+ acs_object.delete(request_id);
+ end delete;
+
+end notification_request;
+/
+show errors
+
+
+
+-- the notifications package
+create or replace package notification
+as
+
+ function new (
+ notification_id in notifications.notification_id%TYPE default null,
+ type_id in notifications.type_id%TYPE,
+ object_id in notifications.object_id%TYPE,
+ notif_date in notifications.notif_date%TYPE default sysdate,
+ response_id in notifications.response_id%TYPE default null,
+ notif_text in notifications.notif_text%TYPE default null,
+ notif_html in notifications.notif_html%TYPE default null,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE,
+ creation_ip in acs_objects.creation_ip%TYPE,
+ context_id in acs_objects.context_id%TYPE default null
+ ) return notifications.notification_id%TYPE;
+
+ procedure delete (
+ notification_id in notifications.notification_id%TYPE default null
+ );
+
+end notification;
+/
+show errors
+
+
+
+create or replace package body notification
+as
+
+ function new (
+ notification_id in notifications.notification_id%TYPE default null,
+ type_id in notifications.type_id%TYPE,
+ object_id in notifications.object_id%TYPE,
+ notif_date in notifications.notif_date%TYPE default sysdate,
+ response_id in notifications.response_id%TYPE default null,
+ notif_text in notifications.notif_text%TYPE default null,
+ notif_html in notifications.notif_html%TYPE default null,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE,
+ creation_ip in acs_objects.creation_ip%TYPE,
+ context_id in acs_objects.context_id%TYPE default null
+ ) return notifications.notification_id%TYPE
+ is
+ v_notification_id acs_objects.object_id%TYPE;
+ begin
+ v_notification_id := acs_object.new (
+ object_id => notification_id,
+ object_type => 'notification',
+ creation_date => creation_date,
+ creation_user => creation_user,
+ creation_ip => creation_ip,
+ context_id => context_id
+ );
+
+ insert into notifications
+ (notification_id, type_id, object_id, notif_date, response_id, notif_text, notif_html)
+ values
+ (v_notification_id, type_id, object_id, notif_date, response_id, notif_text, notif_html);
+
+ return v_notification_id;
+ end new;
+
+ procedure delete (
+ notification_id in notifications.notification_id%TYPE default null
+ )
+ is
+ begin
+ acs_object.delete (notification_id);
+ end delete;
+
+end notification;
+/
+show errors
Index: openacs-4/packages/notifications/sql/oracle/notifications-package-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/sql/oracle/notifications-package-drop.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/sql/oracle/notifications-package-drop.sql 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,22 @@
+
+--
+-- The Notifications Package
+--
+-- ben@openforce.net
+-- Copyright OpenForce, 2002.
+--
+-- GNU GPL v2
+--
+
+
+-- The Notification Interval Package
+
+drop package notification_interval;
+
+drop package notification_delivery_method;
+
+drop package notification_type;
+
+drop package notification_request;
+
+drop package notification;
Index: openacs-4/packages/notifications/tcl/delivery-method-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/delivery-method-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/tcl/delivery-method-procs.tcl 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,23 @@
+ad_library {
+
+ Notification Delivery Methods
+
+ @creation-date 2002-05-24
+ @author Ben Adida
+ @cvs-id $Id: delivery-method-procs.tcl,v 1.1 2002/05/24 20:42:42 ben Exp $
+
+}
+
+namespace eval notification::delivery {
+
+ ad_proc -public deliver {
+ {-delivery_method_id:required}
+ {-to:required}
+ {-content:required}
+ } {
+ do the delivery of certain content to a particular user
+ } {
+ # FIXME: implement
+ }
+
+}
Index: openacs-4/packages/notifications/tcl/interval-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/interval-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/tcl/interval-procs.tcl 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,26 @@
+ad_library {
+
+ Notification Intervals
+
+ @creation-date 2002-05-24
+ @author Ben Adida
+ @cvs-id $Id: interval-procs.tcl,v 1.1 2002/05/24 20:42:42 ben Exp $
+
+}
+
+namespace eval notification::interval {
+
+ ad_proc -public schedule_all {} {
+ This schedules all the notification procs
+ } {
+ }
+
+ ad_proc -public sweep_notifications {
+ {-interval_id:required}
+ } {
+ This sweeps for notifications in a particular interval
+ } {
+
+ }
+
+}
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 -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/tcl/notification-procs.tcl 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,46 @@
+ad_library {
+
+ Notifications
+
+ @creation-date 2002-05-24
+ @author Ben Adida
+ @cvs-id $Id: notification-procs.tcl,v 1.1 2002/05/24 20:42:42 ben Exp $
+
+}
+
+namespace eval notification {
+
+ ad_proc -public new {
+ } {
+ create a new notification
+ } {
+ # Set up the vars
+ set extra_vars [ns_set create]
+ oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {}
+
+ # Create the request
+ set notification_id [package_instantiate_object -extra_vars $extra_vars notification]
+
+ return $notification_id
+ }
+
+ ad_proc -public delete {
+ {-notification_id:required}
+ } {
+ delete a notification
+ } {
+ # do the delete
+ # FIXME: implement this
+ db_exec_plsql delete_notification {}
+ }
+
+ ad_proc -public mark_sent {
+ {-notification_id:required}
+ {-user_id:required}
+ } {
+ mark that a user has been sent a notification
+ } {
+ # Do the insert
+ db_dml insert_notification_user_map {}
+ }
+}
Index: openacs-4/packages/notifications/tcl/notification-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/notification-procs.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/tcl/notification-procs.xql 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,12 @@
+
+
+
+
+
+insert into notification_user_map
+(notification_id, user_id, sent_date) values
+(:notification_id, :user_id, sysdate())
+
+
+
+
Index: openacs-4/packages/notifications/tcl/notification-request-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/notification-request-procs-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/tcl/notification-request-procs-oracle.xql 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,13 @@
+
+
+ oracle8.1.6
+
+
+
+declare begin
+ notification_request.delete(request_id => :request_id);
+end;
+
+
+
+
Index: openacs-4/packages/notifications/tcl/notification-request-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/notification-request-procs-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/tcl/notification-request-procs-postgresql.xql 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,11 @@
+
+
+ postgresql7.1
+
+
+
+select notification_request__delete(:request_id);
+
+
+
+
Index: openacs-4/packages/notifications/tcl/notification-request-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/notification-request-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/tcl/notification-request-procs.tcl 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,43 @@
+ad_library {
+
+ Notification Requests
+
+ @creation-date 2002-05-24
+ @author Ben Adida
+ @cvs-id $Id: notification-request-procs.tcl,v 1.1 2002/05/24 20:42:42 ben Exp $
+
+}
+
+namespace eval notification::request {
+
+ ad_proc -public new {
+ {-request_id ""}
+ {-type_id:required}
+ {-user_id:required}
+ {-object_id:required}
+ {-interval_id:required}
+ {-delivery_method_id:required}
+ {-format "text"}
+ } {
+ create a new request
+ } {
+ # Set up the vars
+ set extra_vars [ns_set create]
+ oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {request_id type_id user_id object_id interval_id delivery_method_id format}
+
+ # Create the request
+ set request_id [package_instantiate_object -extra_vars $extra_vars notification_request]
+
+ return $request_id
+ }
+
+ ad_proc -public delete {
+ {-request_id:required}
+ } {
+ delete a request
+ } {
+ # do the delete
+ db_exec_plsql delete_request {}
+ }
+
+}
Index: openacs-4/packages/notifications/tcl/notification-type-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/notification-type-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/tcl/notification-type-procs.tcl 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,85 @@
+ad_library {
+
+ Notification Types
+
+ @creation-date 2002-05-24
+ @author Ben Adida
+ @cvs-id $Id: notification-type-procs.tcl,v 1.1 2002/05/24 20:42:42 ben Exp $
+
+}
+
+namespace eval notification::type {
+
+ ad_proc -public new {
+ {-type_id ""}
+ {-short_name:required}
+ {-pretty_name:required}
+ {-description ""}
+ } {
+ create a new notification type
+ } {
+ set extra_vars [ns_set create]
+ oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {type_id short_name pretty_name description}
+
+ set type_id [package_instantiate_object -extra_vars $extra_vars notification_type]
+
+ return $type_id
+ }
+
+ ad_proc -public get_type_id {
+ {-short_name:required}
+ } {
+ return [db_string select_type_id {} -default {}]
+ }
+
+ ad_proc -public delete {
+ {-short_name:required}
+ } {
+ set type_id [get_type_id -short_name $short_name]
+
+ # do the delete
+ # FIXME: implement
+ }
+
+ ad_proc -public get {
+ {-short_name:required}
+ {-column_array:required}
+ } {
+ # Select the data into the upvar'ed array
+ upvar $column_array row
+ db_1row select_notification_type {} -column_array row
+ }
+
+ ad_proc -public interval_enable {
+ {-type_id:required}
+ {-interval_id:required}
+ } {
+ # Perform the insert if necessary
+ db_dml insert_interval_map {}
+ }
+
+ ad_proc -public interval_disable {
+ {-type_id:required}
+ {-interval_id:required}
+ } {
+ # perform the delete if necessary
+ db_dml delete_interval_map {}
+ }
+
+ ad_proc -public delivery_method_enable {
+ {-type_id:required}
+ {-delivery_method_id:required}
+ } {
+ # perform the insert if necessary
+ db_dml insert_delivery_method_map {}
+ }
+
+ ad_proc -public delivery_method_disable {
+ {-type_id:required}
+ {-delivery_method_id:required}
+ } {
+ # perform the delete if necessary
+ db_dml delete_delivery_method_map {}
+ }
+
+}
Index: openacs-4/packages/notifications/tcl/notification-type-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/tcl/notification-type-procs.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/tcl/notification-type-procs.xql 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,55 @@
+
+
+
+
+
+select type_id from notification_types where short_name = :short_name
+
+
+
+
+
+select type_id, short_name, pretty_name, description from notification_types
+where short_name= :short_name
+
+
+
+
+
+insert into notification_types_intervals
+(type_id, interval_id) select :type_id, :interval_id
+from dual where not exists
+(select 1 from notification_types_intervals
+where type_id = :type_id
+and interval_id = :interval_id)
+
+
+
+
+
+delete from notification_types_intervals
+where type_id = :type_id
+and interval_id = :interval_id
+
+
+
+
+
+insert into notification_types_del_methods
+(type_id, delivery_method_id) select :type_id, :delivery_method_id
+from dual where not exists
+(select 1 from notification_types_del_methods
+where type_id = :type_id
+and delivery_method_id = :delivery_method_id)
+
+
+
+
+
+delete from notification_types_del_methods
+where type_id = :type_id
+and delivery_method_id = :delivery_method_id
+
+
+
+
Index: openacs-4/packages/notifications/www/test.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/notifications/www/test.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/notifications/www/test.tcl 24 May 2002 20:42:42 -0000 1.1
@@ -0,0 +1,24 @@
+
+# Create a notification type
+db_transaction {
+ set interval_id [db_exec_plsql new_interval "declare begin
+ :1 := notification_interval.new (name => 'hourly' , n_seconds => 3600, creation_user => NULL, creation_ip => NULL);
+ end;
+ "]
+
+ set delivery_method_id [db_exec_plsql new_deliv_method "declare begin
+ :1 := notification_delivery_method.new (short_name => 'email', pretty_name => 'Email', creation_user => NULL, creation_ip => NULL);
+ end;
+ "]
+
+ set type_id [notification::type::new -short_name "test" -pretty_name "Test Notification" -description "foobar"]
+
+ # enable both
+ notification::type::interval_enable -type_id $type_id -interval_id $interval_id
+ notification::type::delivery_method_enable -type_id $type_id -delivery_method_id $delivery_method_id
+
+ set request_id [notification::request::new -type_id $type_id -user_id 2394 -interval_id $interval_id -delivery_method_id $delivery_method_id -object_id 2394]
+}
+
+doc_body_append $request_id
+
Index: openacs-4/packages/user-preferences/user-preferences.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/user-preferences/user-preferences.info,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/user-preferences/user-preferences.info 24 May 2002 20:43:27 -0000 1.1
@@ -0,0 +1,35 @@
+
+
+
+
+ User Preferences
+ User Preferences
+ f
+ t
+
+
+
+ oracle
+ postgresql
+
+ Ben Adida
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: openacs-4/packages/user-preferences/sql/oracle/user-preferences-core-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/user-preferences/sql/oracle/user-preferences-core-create.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/user-preferences/sql/oracle/user-preferences-core-create.sql 24 May 2002 20:43:27 -0000 1.1
@@ -0,0 +1,86 @@
+
+--
+-- The User Preferences package
+--
+-- Copyright 2002, OpenForce
+-- ben@openforce
+--
+-- distributed under the GPL v2
+--
+-- May 21st 2002
+--
+
+-- we would use acs_attributes if it wasn't so braindead in tying
+-- everything to acs_object_types (ben)
+
+create table user_preference_types (
+ preference_type_id integer not null
+ constraint user_pref_type_id_pk primary key
+ constraint user_pref_type_id_fk references acs_objects(object_id),
+ package_key varchar(100)
+ constraint user_pref_type_pack_key_fk
+ references apm_package_types(package_key),
+ short_name varchar(100) not null,
+ constraint user_pref_un unique (package_key, short_name),
+ pretty_name varchar(250) not null,
+ datatype varchar(20) default 'text' not null
+ constraint user_pref_datatype_ch
+ check (datatype in ('text','number','enum')),
+ -- denormalized options if the datatype is choice
+ -- we really don't need a table of these. They are separated by "|"
+ options varchar(2000),
+ -- preference-type wide default value
+ default_value varchar(200)
+);
+
+
+-- These are the default values for package-instance specific stuff
+create table user_preference_default_values (
+ preference_type_id integer not null
+ constraint user_pref_def_val_type_id_fk
+ references user_preference_types(preference_type_id),
+ package_id integer not null
+ constraint user_pref_def_val_pack_id_fk
+ references apm_packages(package_id),
+ constraint user_pref_def_val_pk
+ primary key (preference_type_id, package_id),
+ default_value varchar(200) not null
+);
+
+
+-- These are the user preferences
+create table user_preference_values (
+ preference_type_id integer not null
+ constraint user_pref_val_type_id_fk
+ references user_preference_types(preference_type_id),
+ user_id integer not null
+ constraint user_pref_val_user_id_fk
+ references users(user_id),
+ package_id integer
+ constraint user_pref_val_pack_id_fk
+ references apm_packages(package_id),
+ constraint user_pref_val_pk
+ primary key (preference_type_id, user_id, package_id),
+ value varchar(200)
+);
+
+
+
+--
+-- Object Types
+--
+
+declare
+begin
+ acs_object_type.create_type (
+ supertype => 'acs_object',
+ object_type => 'user_pref_type',
+ pretty_name => 'User Preference Type',
+ pretty_plural => 'User Preference Types',
+ table_name => 'user_preference_types',
+ id_column => 'preference_type_id',
+ package_name => 'user_pref_type'
+ );
+end;
+/
+show errors
Index: openacs-4/packages/user-preferences/sql/oracle/user-preferences-core-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/user-preferences/sql/oracle/user-preferences-core-drop.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/user-preferences/sql/oracle/user-preferences-core-drop.sql 24 May 2002 20:43:27 -0000 1.1
@@ -0,0 +1,33 @@
+
+--
+-- The User Preferences package
+--
+-- Copyright 2002, OpenForce
+-- ben@openforce
+--
+-- distributed under the GPL v2
+--
+-- May 21st 2002
+--
+
+-- the drop scripts
+
+drop table user_preference_default_values;
+
+drop table user_preference_values;
+
+drop table user_preference_types;
+
+
+--
+-- Object Types
+--
+
+declare
+begin
+ acs_object_type.drop_type (
+ object_type => 'user_pref_type'
+ );
+end;
+/
+show errors
Index: openacs-4/packages/user-preferences/sql/oracle/user-preferences-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/user-preferences/sql/oracle/user-preferences-create.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/user-preferences/sql/oracle/user-preferences-create.sql 24 May 2002 20:43:27 -0000 1.1
@@ -0,0 +1,14 @@
+
+--
+-- The User Preferences package
+--
+-- Copyright 2002, OpenForce
+-- ben@openforce
+--
+-- distributed under the GPL v2
+--
+-- May 21st 2002
+--
+
+@ user-preferences-core-create.sql
+@ user-preferences-package-create.sql
Index: openacs-4/packages/user-preferences/sql/oracle/user-preferences-package-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/user-preferences/sql/oracle/user-preferences-package-create.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/user-preferences/sql/oracle/user-preferences-package-create.sql 24 May 2002 20:43:27 -0000 1.1
@@ -0,0 +1,203 @@
+
+--
+-- The User Preferences package
+--
+-- Copyright 2002, OpenForce
+-- ben@openforce
+--
+-- distributed under the GPL v2
+--
+-- May 21st 2002
+--
+
+-- package
+
+create or replace package user_pref_type
+as
+ function new (
+ preference_type_id in user_preference_types.preference_type_id%TYPE default null,
+ object_type in acs_objects.object_type%TYPE default 'user_pref_type',
+ package_key in user_preference_types.package_key%TYPE,
+ short_name in user_preference_types.short_name%TYPE,
+ pretty_name in user_preference_types.pretty_name%TYPE,
+ datatype in user_preference_types.datatype%TYPE default 'text',
+ options in user_preference_types.options%TYPE default null,
+ default_value in user_preference_types.default_value%TYPE default null,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE,
+ creation_ip in acs_objects.creation_ip%TYPE,
+ context_id in acs_objects.context_id%TYPE
+ ) return user_preference_types.preference_type_id%TYPE;
+
+ function get_user_pref (
+ preference_type in user_preference_types.short_name%TYPE,
+ package_id in user_preference_values.package_id%TYPE default null,
+ user_id in user_preference_values.user_id%TYPE
+ ) return user_preference_values.value%TYPE;
+
+ procedure set_package_default (
+ preference_type_id in user_preference_default_values.preference_type_id%TYPE,
+ package_id in user_preference_default_values.package_id%TYPE,
+ default_value in user_preference_default_values.default_value%TYPE
+ );
+
+ procedure set_user_pref (
+ preference_type_id in user_preference_default_values.preference_type_id%TYPE,
+ package_id in user_preference_default_values.package_id%TYPE,
+ user_id in user_preference_values.user_id%TYPE,
+ value in user_preference_default_values.default_value%TYPE
+ );
+
+ procedure delete (
+ preference_type_id in user_preference_types.preference_type_id%TYPE
+ );
+end user_pref_type;
+/
+show errors
+
+
+
+create or replace package body user_pref_type
+as
+ function new (
+ preference_type_id in user_preference_types.preference_type_id%TYPE default null,
+ object_type in acs_objects.object_type%TYPE default 'user_pref_type',
+ package_key in user_preference_types.package_key%TYPE,
+ short_name in user_preference_types.short_name%TYPE,
+ pretty_name in user_preference_types.pretty_name%TYPE,
+ datatype in user_preference_types.datatype%TYPE default 'text',
+ options in user_preference_types.options%TYPE default null,
+ default_value in user_preference_types.default_value%TYPE default null,
+ creation_date in acs_objects.creation_date%TYPE default sysdate,
+ creation_user in acs_objects.creation_user%TYPE,
+ creation_ip in acs_objects.creation_ip%TYPE,
+ context_id in acs_objects.context_id%TYPE
+ ) return user_preference_types.preference_type_id%TYPE
+ is
+ v_pref_type_id user_preference_types.preference_type_id%TYPE;
+ begin
+ v_pref_type_id := acs_object.new (
+ object_id => preference_type_id,
+ object_type => object_type,
+ creation_date => creation_date,
+ creation_user => creation_user,
+ creation_ip => creation_ip,
+ context_id => context_id
+ );
+
+ insert into user_preference_types
+ (preference_type_id, package_key, short_name, pretty_name, datatype, options, default_value)
+ values
+ (v_pref_type_id, package_key, short_name, pretty_name, datatype, options, default_value);
+
+ return v_pref_type_id;
+ end new;
+
+ function get_user_pref (
+ preference_type in user_preference_types.short_name%TYPE,
+ package_id in user_preference_values.package_id%TYPE,
+ user_id in user_preference_values.user_id%TYPE
+ ) return user_preference_values.value%TYPE
+ is
+ v_type_id user_preference_types.preference_type_id%TYPE;
+ v_pref user_preference_values.value%TYPE;
+ begin
+ select preference_type_id into v_type_id
+ from user_preference_types where short_name = preference_type;
+
+ -- if there is no such preference type
+ if SQL%NOTFOUND then return NULL; end if;
+
+ -- check direct user pref for package_id not null
+ select value into v_pref from user_preference_values
+ where preference_type_id = v_type_id
+ and package_id = get_user_pref.package_id
+ and user_id = get_user_pref.user_id;
+
+ if SQL%FOUND then return v_pref; end if;
+
+ -- check user pref with package_id NULL
+ select value into v_pref from user_preference_values
+ where preference_type_id = v_type_id
+ and package_id is NULL
+ and user_id = get_user_pref.user_id;
+
+ if SQL%FOUND then return v_pref; end if;
+
+ -- if not found, check package default
+ select default_value into v_pref from user_preference_default_values
+ where preference_type_id = v_type_id
+ and package_id = get_user_pref.package_id;
+
+ if SQL%FOUND then return v_pref; end if;
+
+ -- if not found check default value for preference type
+ select default_value into v_pref from user_preference_types
+ where preference_type_id = v_type_id;
+
+ return v_pref;
+
+ end get_user_pref;
+
+ procedure set_package_default (
+ preference_type_id in user_preference_default_values.preference_type_id%TYPE,
+ package_id in user_preference_default_values.package_id%TYPE,
+ default_value in user_preference_default_values.default_value%TYPE
+ )
+ is
+ v_count integer;
+ begin
+ update user_preference_default_values
+ set default_value= set_package_default.default_value
+ where preference_type_id= set_package_default.preference_type_id
+ and package_id= set_package_default.package_id;
+
+ v_count:= SQL%ROWCOUNT;
+
+ if v_count = 0
+ then
+ insert into user_preference_default_values
+ (preference_type_id, package_id, default_value) values
+ (preference_type_id, package_id, default_value);
+ end if;
+
+ end set_package_default;
+
+ procedure set_user_pref (
+ preference_type_id in user_preference_default_values.preference_type_id%TYPE,
+ package_id in user_preference_default_values.package_id%TYPE,
+ user_id in user_preference_values.user_id%TYPE,
+ value in user_preference_default_values.default_value%TYPE
+ )
+ is
+ v_count integer;
+ begin
+ update user_preference_values
+ set value= set_user_pref.value
+ where preference_type_id= set_user_pref.preference_type_id
+ and package_id= set_user_pref.package_id
+ and user_id= set_user_pref.user_id;
+
+ v_count:= SQL%ROWCOUNT;
+
+ if v_count = 0
+ then
+ insert into user_preference_values
+ (preference_type_id, package_id, user_id, value) values
+ (preference_type_id, package_id, user_id, value);
+ end if;
+
+ end set_user_pref;
+
+ procedure delete (
+ preference_type_id in user_preference_types.preference_type_id%TYPE
+ )
+ is
+ begin
+ acs_object.delete(preference_type_id);
+ end delete;
+
+end user_pref_type;
+/
+show errors
+
Index: openacs-4/packages/user-preferences/tcl/preference-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/user-preferences/tcl/preference-procs-oracle.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/user-preferences/tcl/preference-procs-oracle.xql 24 May 2002 20:43:27 -0000 1.1
@@ -0,0 +1,42 @@
+
+
+ oracle8.1.6
+
+
+
+declare begin
+ user_pref_type.set_package_default(
+ preference_type_id => :preference_type_id,
+ package_id => :package_id,
+ default_value => :default_value
+ );
+end;
+
+
+
+
+
+declare begin
+ user_pref_type.set_user_pref(
+ preference_type_id => :preference_type_id,
+ package_id => :package_id,
+ user_id => :user_id,
+ value => :value
+ );
+end;
+
+
+
+
+
+declare begin
+:1 := user_pref_type.get_user_pref (
+ preference_type_id => :preference_type_id,
+ package_id => :package_id,
+ user_id => :user_id
+ );
+end;
+
+
+
+
Index: openacs-4/packages/user-preferences/tcl/preference-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/user-preferences/tcl/preference-procs-postgresql.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/user-preferences/tcl/preference-procs-postgresql.xql 24 May 2002 20:43:27 -0000 1.1
@@ -0,0 +1,36 @@
+
+
+ postgresql7.1
+
+
+
+select user_pref_type__set_package_default(
+ :preference_type_id,
+ :package_id,
+ :default_value
+);
+
+
+
+
+
+select user_pref_type.set_user_pref(
+ :preference_type_id,
+ :package_id,
+ :user_id,
+ :value
+);
+
+
+
+
+
+select user_pref_type__get_user_pref (
+ :preference_type_id,
+ :package_id,
+ :user_id
+ );
+
+
+
+
Index: openacs-4/packages/user-preferences/tcl/preference-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/user-preferences/tcl/preference-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/user-preferences/tcl/preference-procs.tcl 24 May 2002 20:43:27 -0000 1.1
@@ -0,0 +1,66 @@
+ad_library {
+
+ User Preferences
+
+ @creation-date 2002-05-24
+ @author Ben Adida
+ @cvs-id $Id: preference-procs.tcl,v 1.1 2002/05/24 20:43:27 ben Exp $
+
+}
+
+namespace eval preference {
+
+ ad_proc -public get_preference_type_id {
+ {-preference_type:required}
+ } {
+ get the ID from the short name
+ } {
+ # This will eventually be cached
+ return [db_string select_preference_type_id {} -default {}]
+ }
+
+ ad_proc -public set_package_default {
+ {-preference_type:required}
+ {-package_id:required}
+ {-default_value:required}
+ } {
+ sets the default value for a package ID
+ } {
+ # get the preference type id
+ set preference_type_id [get_preference_type_id -preference_type $preference_type]
+
+ # simply exec the PL/SQL
+ db_exec_plsql set_package_default {}
+ }
+
+ ad_proc -public set_user_pref {
+ {-preference_type:required}
+ {-package_id ""}
+ {-user_id:required}
+ {-value:required}
+ } {
+ set a user pref
+ } {
+ # get the preference type id
+ set preference_type_id [get_preference_type_id -preference_type $preference_type]
+
+ # exec the PL/SQL
+ db_exec_plsql set_user_pref {}
+ }
+
+ ad_proc -public get_user_pref {
+ {-preference_type:required}
+ {-package_id:required}
+ {-user_id:required}
+ } {
+ get a user pref
+ } {
+ # get the preference type id
+ set preference_type_id [get_preference_type_id -preference_type $preference_type]
+
+ # exec the PL/SQL
+ set pref [db_exec_plsql get_user_pref {}]
+
+ return $pref
+ }
+}
Index: openacs-4/packages/user-preferences/tcl/preference-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/user-preferences/tcl/preference-procs.xql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/user-preferences/tcl/preference-procs.xql 24 May 2002 20:43:27 -0000 1.1
@@ -0,0 +1,11 @@
+
+
+
+
+
+select preference_type_id from user_preference_types
+where short_name= :preference_type
+
+
+
+
Index: openacs-4/packages/user-preferences/tcl/preference-types-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/user-preferences/tcl/preference-types-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/user-preferences/tcl/preference-types-procs.tcl 24 May 2002 20:43:27 -0000 1.1
@@ -0,0 +1,44 @@
+ad_library {
+
+ User Preferences Types
+
+ @creation-date 2002-05-24
+ @author Ben Adida
+ @cvs-id $Id: preference-types-procs.tcl,v 1.1 2002/05/24 20:43:27 ben Exp $
+
+}
+
+namespace eval preference::type {
+
+ ad_proc -public new {
+ {-preference_type_id ""}
+ {-package_key:required}
+ {-short_name:required}
+ {-pretty_name:required}
+ {-datatype "text"}
+ {-options ""}
+ {-default_value ""}
+ } {
+ create a new preference type
+ } {
+ # Set up the vars
+ set extra_vars [ns_set create]
+ oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {preference_type_id package_key short_name pretty_name datatype options default_value}
+
+ # Instantiate the pref
+ set preference_type_id [package_instantiate_object -extra_vars $extra_vars user_preference_type]
+
+ return $preference_type_id
+ }
+
+ ad_proc -public delete {
+ {-preference_type:required}
+ } {
+ this deletes a preference type
+ } {
+ # FIXME: implement
+ }
+
+
+
+}