Index: openacs-4/packages/bm-portlet/bm-portlet.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bm-portlet/bm-portlet.info,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bm-portlet/bm-portlet.info 15 May 2002 22:11:37 -0000 1.1 @@ -0,0 +1,35 @@ + + + + + Bulk Mail Portlet + Bulk Mail Portlet + f + t + + + + oracle + postgresql + + Yonatan Feldman + OpenForce, Inc. + + + + + + + + + + + + + + + + + + + Index: openacs-4/packages/bm-portlet/sql/oracle/bm-portlet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bm-portlet/sql/oracle/bm-portlet-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bm-portlet/sql/oracle/bm-portlet-create.sql 15 May 2002 22:11:37 -0000 1.1 @@ -0,0 +1,162 @@ +-- +-- Copyright (C) 2001, 2002 OpenForce, Inc. +-- +-- This file is part of dotLRN. +-- +-- dotLRN is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 2 of the License, or (at your option) any later +-- version. +-- +-- dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- + +-- +-- Creates the bulk-mail portlet +-- +-- @author yon (yon@openforce.net) +-- @creation-date 2002-05-13 +-- @version $Id: bm-portlet-create.sql,v 1.1 2002/05/15 22:11:37 yon Exp $ +-- + +declare + ds_id portal_datasources.datasource_id%TYPE; + foo integer; +begin + + ds_id := portal_datasource.new( + name => 'bm_portlet', + description => 'Displays spam info for the given package' + ); + + portal_datasource.set_def_param( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shadeable_p', + value => 't' + ); + + portal_datasource.set_def_param( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'hideable_p', + value => 't' + ); + + portal_datasource.set_def_param( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'user_editable_p', + value => 'f' + ); + + portal_datasource.set_def_param( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shaded_p', + value => 'f' + ); + + portal_datasource.set_def_param( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'link_hideable_p', + value => 't' + ); + + portal_datasource.set_def_param( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'package_id', + value => '' + ); + + portal_datasource.set_def_param( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'scoped_p', + value => 't' + ); + + -- create the implementation + foo := acs_sc_impl.new( + 'portal_datasource', + 'bm_portlet', + 'bm_portlet' + ); + + -- add all the hooks + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'bm_portlet', + 'GetMyName', + 'bm_portlet::get_my_name', + 'TCL' + ); + + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'bm_portlet', + 'GetPrettyName', + 'bm_portlet::get_pretty_name', + 'TCL' + ); + + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'bm_portlet', + 'Link', + 'bm_portlet::link', + 'TCL' + ); + + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'bm_portlet', + 'AddSelfToPage', + 'bm_portlet::add_self_to_page', + 'TCL' + ); + + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'bm_portlet', + 'Show', + 'bm_portlet::show', + 'TCL' + ); + + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'bm_portlet', + 'Edit', + 'bm_portlet::edit', + 'TCL' + ); + + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'bm_portlet', + 'RemoveSelfFromPage', + 'bm_portlet::remove_self_from_page', + 'TCL' + ); + + acs_sc_binding.new( + contract_name => 'portal_datasource', + impl_name => 'bm_portlet' + ); + +end; +/ +show errors Index: openacs-4/packages/bm-portlet/sql/oracle/bm-portlet-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bm-portlet/sql/oracle/bm-portlet-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bm-portlet/sql/oracle/bm-portlet-drop.sql 15 May 2002 22:11:37 -0000 1.1 @@ -0,0 +1,96 @@ +-- +-- Copyright (C) 2001, 2002 OpenForce, Inc. +-- +-- This file is part of dotLRN. +-- +-- dotLRN is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 2 of the License, or (at your option) any later +-- version. +-- +-- dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- + +-- +-- Drops the bulk-mail portlet +-- +-- @author yon (yon@openforce.net) +-- @creation-date 2002-05-13 +-- @version $Id: bm-portlet-drop.sql,v 1.1 2002/05/15 22:11:37 yon Exp $ +-- + +declare + ds_id portal_datasources.datasource_id%TYPE; + foo integer; +begin + + begin + select datasource_id into ds_id + from portal_datasources + where name = 'bm_portlet'; + exception when no_data_found then + ds_id := null; + end; + + if ds_id is not null then + portal_datasource.delete(ds_id); + end if; + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'bm_portlet', + 'GetMyName' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'bm_portlet', + 'GetPrettyName' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'bm_portlet', + 'Link' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'bm_portlet', + 'AddSelfToPage' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'bm_portlet', + 'Show' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'bm_portlet', + 'Edit' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'bm_portlet', + 'RemoveSelfFromPage' + ); + + acs_sc_binding.delete ( + contract_name => 'portal_datasource', + impl_name => 'bm_portlet' + ); + + acs_sc_impl.delete ( + 'portal_datasource', + 'bm_portlet' + ); + +end; +/ +show errors Index: openacs-4/packages/bm-portlet/tcl/bm-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bm-portlet/tcl/bm-portlet-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bm-portlet/tcl/bm-portlet-procs.tcl 15 May 2002 22:11:37 -0000 1.1 @@ -0,0 +1,93 @@ +# +# Copyright (C) 2001, 2002 OpenForce, Inc. +# +# This file is part of dotLRN. +# +# dotLRN is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# + +ad_library { + + Procedures to support the bulk-mail portlet + + @author yon (yon@openforce.net) + @creation-date 2002-05-13 + @version $Id: bm-portlet-procs.tcl,v 1.1 2002/05/15 22:11:37 yon Exp $ + +} + +namespace eval bm_portlet { + + ad_proc -private my_package_key { + } { + return "bm-portlet" + } + + ad_proc -private get_my_name { + } { + return "bm_portlet" + } + + ad_proc -public get_pretty_name { + } { + return [parameter::get -parameter pretty_name -default "Bulk Mail"] + } + + ad_proc -public link { + } { + return "" + } + + ad_proc -public add_self_to_page { + {-portal_id:required} + {-page_name ""} + {-package_id:required} + {-extra_params ""} + {-force_region ""} + } { + add the portlet element to the given portal + } { + return [portal::add_element_or_append_id \ + -portal_id $portal_id \ + -page_name $page_name \ + -pretty_name [get_pretty_name] \ + -portlet_name [get_my_name] \ + -key package_id \ + -value_id $package_id \ + -force_region $force_region \ + -extra_params $extra_params + ] + } + + ad_proc -public remove_self_from_page { + {-portal_id:required} + {-package_id:required} + } { + remove the portal element from the given portal + } { + portal::remove_element_or_remove_id \ + -portal_id $portal_id \ + -portlet_name [get_my_name] \ + -key package_id \ + -extra_params $extra_params + } + + ad_proc -public show { + cf + } { + shoe the portal element + } { + portal::show_proc_helper \ + -package_key [my_package_key] \ + -config_list $cf + } + +} Index: openacs-4/packages/bm-portlet/www/bm-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bm-portlet/www/bm-portlet.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bm-portlet/www/bm-portlet.adp 15 May 2002 22:11:37 -0000 1.1 @@ -0,0 +1,24 @@ +<% + + # + # Copyright (C) 2001, 2002 OpenForce, Inc. + # + # This file is part of dotLRN. + # + # dotLRN is free software; you can redistribute it and/or modify it under the + # terms of the GNU General Public License as published by the Free Software + # Foundation; either version 2 of the License, or (at your option) any later + # version. + # + # dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY + # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + # details. + # + +%> + + Index: openacs-4/packages/bm-portlet/www/bm-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bm-portlet/www/bm-portlet.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bm-portlet/www/bm-portlet.tcl 15 May 2002 22:11:37 -0000 1.1 @@ -0,0 +1,43 @@ +# +# Copyright (C) 2001, 2002 OpenForce, Inc. +# +# This file is part of dotLRN. +# +# dotLRN is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# + +ad_page_contract { + + The display logic for the bulk-mail portlet + + @author yon (yon@openforce.net) + @creation-date 2002-05-13 + @version $Id: bm-portlet.tcl,v 1.1 2002/05/15 22:11:37 yon Exp $ + +} -query { +} -properties { + user_id:onevalue + admin_p:onevalue + package_id:onevalue + scoped_p:onevalue +} + +array set config $cf + +set user_id [ad_conn user_id] +set package_id $config(package_id) +set scoped_p [ad_decode $config(scoped_p) t 1 0] +set admin_p [permission::permission_p -object_id $package_id -privilege "admin"] + +set spam_name [bulk_mail::parameter -parameter PrettyName -default Spam] +set spam_url [portal::mapping::get_url -object_id $package_id] + +ad_return_template Index: openacs-4/packages/bulk-mail/bulk-mail.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/bulk-mail.info,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/bulk-mail.info 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,51 @@ + + + + + Bulk Mail + Bulk Mail + f + f + + + + oracle + postgresql + + Yonatan Feldman + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-create.sql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,58 @@ +-- +-- bulk_mail model create +-- +-- @author yon@openforce.net +-- @version $Id: bulk-mail-create.sql,v 1.1 2002/05/15 22:07:52 yon Exp $ +-- + +create table bulk_mail_messages ( + bulk_mail_id constraint bm_messages_bulk_mail_id_fk + references acs_objects (object_id) + constraint bm_messages_bulk_mail_id_pk + primary key, + package_id constraint bm_messages_package_id_fk + references apm_packages (package_id) + constraint bm_messages_package_id_nn + not null, + send_date date + default sysdate + constraint bm_messages_send_date_nn + not null, + sent_p char(1) + default 'f' + constraint bm_messages_sent_p_ck + check (sent_p in ('t', 'f')) + constraint bm_messages_sent_p_nn + not null, + from_addr varchar(4000) + constraint bm_messages_from_addr_nn + not null, + subject varchar(4000), + reply_to varchar(4000), + extra_headers varchar(4000), + message clob + constraint bm_messages_message_nn + not null, + query varchar(4000) + constraint bm_messages_query_nn + not null +); + +-- create a new object type +begin + acs_object_type.create_type( + supertype => 'acs_object', + object_type => 'bulk_mail_message', + pretty_name => 'Bulk Mail Message', + pretty_plural => 'Bulk Mail Messages', + table_name => 'bulk_mail_messages', + id_column => 'bulk_mail_id', + package_name => 'bulk_mail', + name_method => 'acs_object.default_name' + ); +end; +/ +show errors + +@@ bulk-mail-views-create.sql +@@ bulk-mail-package-create.sql Index: openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-drop.sql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,25 @@ +-- +-- bulk_mail model drop +-- +-- @author yon@openforce.net +-- @version $Id: bulk-mail-drop.sql,v 1.1 2002/05/15 22:07:52 yon Exp $ +-- + +begin + for row in (select bulk_mail_id from bulk_mail_messages) loop + bulk_mail.delete(row.bulk_mail_id); + end loop; +end; +/ +show errors + +begin + acs_object_type.drop_type('bulk_mail_message', 'f'); +end; +/ +show errors + +@@ bulk-mail-package-drop.sql +@@ bulk-mail-views-drop.sql + +drop table bulk_mail_messages; Index: openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-package-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-package-create.sql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,110 @@ +-- +-- bulk_mail logic +-- +-- @author yon@openforce.net +-- @version $Id: bulk-mail-package-create.sql,v 1.1 2002/05/15 22:07:52 yon Exp $ +-- + +create or replace package bulk_mail +as + + function new ( + bulk_mail_id in bulk_mail_messages.bulk_mail_id%TYPE default null, + package_id in bulk_mail_messages.package_id%TYPE, + send_date in varchar default null, + date_format in varchar default 'YYYY MM DD HH24 MI SS', + sent_p in bulk_mail_messages.sent_p%TYPE default 'f', + from_addr in bulk_mail_messages.from_addr%TYPE, + subject in bulk_mail_messages.subject%TYPE default null, + reply_to in bulk_mail_messages.reply_to%TYPE default null, + extra_headers in bulk_mail_messages.extra_headers%TYPE default null, + message in varchar, + query in bulk_mail_messages.query%TYPE, + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE default null, + creation_ip in acs_objects.creation_ip%TYPE default null, + context_id in acs_objects.context_id%TYPE default null + ) return bulk_mail_messages.bulk_mail_id%TYPE; + + procedure delete ( + bulk_mail_id in bulk_mail_messages.bulk_mail_id%TYPE + ); + +end bulk_mail; +/ +show errors + +create or replace package body bulk_mail +as + + function new ( + bulk_mail_id in bulk_mail_messages.bulk_mail_id%TYPE default null, + package_id in bulk_mail_messages.package_id%TYPE, + send_date in varchar default null, + date_format in varchar default 'YYYY MM DD HH24 MI SS', + sent_p in bulk_mail_messages.sent_p%TYPE default 'f', + from_addr in bulk_mail_messages.from_addr%TYPE, + subject in bulk_mail_messages.subject%TYPE default null, + reply_to in bulk_mail_messages.reply_to%TYPE default null, + extra_headers in bulk_mail_messages.extra_headers%TYPE default null, + message in varchar, + query in bulk_mail_messages.query%TYPE, + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE default null, + creation_ip in acs_objects.creation_ip%TYPE default null, + context_id in acs_objects.context_id%TYPE default null + ) return bulk_mail_messages.bulk_mail_id%TYPE + is + v_bulk_mail_id bulk_mail_messages.bulk_mail_id%TYPE; + v_send_date varchar(4000); + begin + + v_bulk_mail_id := acs_object.new( + object_id => bulk_mail.new.bulk_mail_id, + object_type => 'bulk_mail_message', + creation_date => bulk_mail.new.creation_date, + creation_user => bulk_mail.new.creation_user, + creation_ip => bulk_mail.new.creation_ip, + context_id => bulk_mail.new.context_id + ); + + v_send_date := bulk_mail.new.send_date; + if v_send_date is null then + select to_char(sysdate, bulk_mail.new.date_format) + into v_send_date + from dual; + end if; + + insert + into bulk_mail_messages + (bulk_mail_id, package_id, + send_date, sent_p, + from_addr, subject, reply_to, + extra_headers, message, query) + values + (v_bulk_mail_id, bulk_mail.new.package_id, + to_date(bulk_mail.new.send_date, bulk_mail.new.date_format), bulk_mail.new.sent_p, + bulk_mail.new.from_addr, bulk_mail.new.subject, bulk_mail.new.reply_to, + bulk_mail.new.extra_headers, bulk_mail.new.message, bulk_mail.new.query); + + return v_bulk_mail_id; + + end new; + + procedure delete ( + bulk_mail_id in bulk_mail_messages.bulk_mail_id%TYPE + ) + is + begin + + delete + from bulk_mail_messages + where bulk_mail_messages.bulk_mail_id = bulk_mail.delete.bulk_mail_id; + + acs_object.delete(bulk_mail.delete.bulk_mail_id); + + end delete; + +end bulk_mail; +/ +show errors Index: openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-package-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-package-drop.sql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,8 @@ +-- +-- bulk_mail logic +-- +-- @author yon@openforce.net +-- @version $Id: bulk-mail-package-drop.sql,v 1.1 2002/05/15 22:07:52 yon Exp $ +-- + +drop package bulk_mail; Index: openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-views-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-views-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-views-create.sql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,18 @@ +-- +-- bulk_mail views +-- +-- @author yon@openforce.net +-- @version $Id: bulk-mail-views-create.sql,v 1.1 2002/05/15 22:07:52 yon Exp $ +-- + +create or replace view bulk_mail_messages_unsent +as + select bulk_mail_messages.* + from bulk_mail_messages + where sent_p = 'f'; + +create or replace view bulk_mail_messages_sent +as + select bulk_mail_messages.* + from bulk_mail_messages + where sent_p = 't'; Index: openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-views-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-views-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/sql/oracle/bulk-mail-views-drop.sql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,9 @@ +-- +-- bulk_mail views +-- +-- @author yon@openforce.net +-- @version $Id: bulk-mail-views-drop.sql,v 1.1 2002/05/15 22:07:52 yon Exp $ +-- + +drop view bulk_mail_messages_sent; +drop view bulk_mail_messages_unsent; Index: openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-create.sql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,56 @@ +-- +-- bulk_mail model create +-- +-- @author yon@openforce.net +-- @version $Id: bulk-mail-create.sql,v 1.1 2002/05/15 22:07:52 yon Exp $ +-- + +create table bulk_mail_messages ( + bulk_mail_id constraint bm_messages_bulk_mail_id_fk + references acs_objects (object_id) + constraint bm_messages_bulk_mail_id_pk + primary key, + package_id constraint bm_messages_package_id_fk + references apm_packages (package_id) + constraint bm_messages_package_id_nn + not null, + send_date date + default now() + constraint bm_messages_send_date_nn + not null, + sent_p boolean + default 'f' + constraint bm_messages_sent_p_nn + not null, + from_addr varchar(4000) + constraint bm_messages_from_addr_nn + not null, + subject varchar(4000), + reply_to varchar(4000), + extra_headers varchar(4000), + message clob + constraint bm_messages_message_nn + not null, + query varchar(4000) + constraint bm_messages_query_nn + not null +); + +-- create a new object type +begin + acs_object_type__create_type( + 'acs_object', + 'bulk_mail_message', + 'Bulk Mail Message', + 'Bulk Mail Messages', + 'bulk_mail_messages', + 'bulk_mail_id', + 'bulk_mail', + 'acs_object__default_name' + ); +end; +/ +show errors + +\i bulk-mail-views-create.sql +\i bulk-mail-package-create.sql Index: openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-drop.sql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,25 @@ +-- +-- bulk_mail model drop +-- +-- @author yon@openforce.net +-- @version $Id: bulk-mail-drop.sql,v 1.1 2002/05/15 22:07:52 yon Exp $ +-- + +begin + for row in (select bulk_mail_id from bulk_mail_messages) loop + bulk_mail__delete(row.bulk_mail_id); + end loop; +end; +/ +show errors + +begin + acs_object_type__drop_type('bulk_mail_message', 'f'); +end; +/ +show errors + +\i bulk-mail-package-drop.sql +\i bulk-mail-views-drop.sql + +drop table bulk_mail_messages; Index: openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-create.sql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,85 @@ +-- +-- bulk_mail logic +-- +-- @author yon@openforce.net +-- @version $Id: bulk-mail-package-create.sql,v 1.1 2002/05/15 22:07:52 yon Exp $ +-- + +drop function bulk_mail__new; +create function bulk_mail__new (integer, integer, varchar, varchar, varchar, varchar, varchar, varchar, varchar, text, varchar, timestamp, integer, varchar, integer) +returns integer as ' +declare + bulk_mail__new__bulk_mail_id alias for $1; -- default to null + bulk_mail__new__package_id alias for $2; + bulk_mail__new__send_date alias for $3; -- default to null + bulk_mail__new__date_format alias for $4; -- default to "YYYY MM DD HH24 MI SS" + bulk_mail__new__sent_p alias for $5; -- default to "f" + bulk_mail__new__from_addr alias for $6; + bulk_mail__new__subject alias for $7; -- default to null + bulk_mail__new__reply_to alias for $8; -- default to null + bulk_mail__new__extra_headers alias for $9; -- default to null + bulk_mail__new__message alias for $10; + bulk_mail__new__query alias for $11; + bulk_mail__new__creation_date alias for $12; -- default to now() + bulk_mail__new__creation_user alias for $13; -- default to null + bulk_mail__new__creation_ip alias for $14; -- default to null + bulk_mail__new__context_id alias for $15; -- default to null + v_bulk_mail_id integer; + v_send_date varchar(4000); +begin + + v_bulk_mail_id := acs_object__new( + bulk_mail__new__bulk_mail_id, + ''bulk_mail_message'', + bulk_mail__new__creation_date, + bulk_mail__new__creation_user, + bulk_mail__new__creation_ip, + bulk_mail__new__context_id + ); + + if bulk_mail__new__date_format is null then + bulk_mail__new__date_format := ''YYYY MM DD HH24 MI SS''; + end if; + + v_send_date := bulk_mail__new__send_date; + if v_send_date is null then + select to_char(now(), bulk_mail__new__date_format) + into v_send_date; + end if; + + if bulk_mail__new__sent_p is null then + bulk_mail__new__sent_p := ''f''; + end if; + + insert + into bulk_mail_messages + (bulk_mail_id, package_id, + send_date, sent_p, + from_addr, subject, reply_to, + extra_headers, message, query) + values + (v_bulk_mail_id, bulk_mail__new__package_id, + to_date(bulk_mail__new__send_date, bulk_mail__new__date_format), bulk_mail__new__sent_p, + bulk_mail__new__from_addr, bulk_mail__new__subject, bulk_mail__new__reply_to, + bulk_mail__new__extra_headers, bulk_mail__new__message, bulk_mail__new__query); + + return v_bulk_mail_id; + +end; +' language 'plpgsql'; + +drop function bulk_mail__delete; +create function bulk_mail__delete (integer) +returns integer as ' +declare + bulk_mail__delete__bulk_mail_id alias for $1; +begin + + delete + from bulk_mail_messages + where bulk_mail_messages.bulk_mail_id = bulk_mail__delete__bulk_mail_id; + + acs_object__delete(bulk_mail__delete__bulk_mail_id); + +end; +' language 'plpgsql'; Index: openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-package-drop.sql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,9 @@ +-- +-- bulk_mail logic +-- +-- @author yon@openforce.net +-- @version $Id: bulk-mail-package-drop.sql,v 1.1 2002/05/15 22:07:52 yon Exp $ +-- + +drop function bulk_mail__new; +drop function bulk_mail__delete; Index: openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-views-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-views-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-views-create.sql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,18 @@ +-- +-- bulk_mail views +-- +-- @author yon@openforce.net +-- @version $Id: bulk-mail-views-create.sql,v 1.1 2002/05/15 22:07:52 yon Exp $ +-- + +create view bulk_mail_messages_unsent +as + select bulk_mail_messages.* + from bulk_mail_messages + where sent_p = 'f'; + +create view bulk_mail_messages_sent +as + select bulk_mail_messages.* + from bulk_mail_messages + where sent_p = 't'; Index: openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-views-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-views-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/sql/postgresql/bulk-mail-views-drop.sql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,9 @@ +-- +-- bulk_mail views +-- +-- @author yon@openforce.net +-- @version $Id: bulk-mail-views-drop.sql,v 1.1 2002/05/15 22:07:52 yon Exp $ +-- + +drop view bulk_mail_messages_sent; +drop view bulk_mail_messages_unsent; Index: openacs-4/packages/bulk-mail/tcl/bulk-mail-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/tcl/bulk-mail-init.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/tcl/bulk-mail-init.tcl 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,12 @@ +ad_library { + + initialization for bulk-mail module + + @author yon (yon@openforce.net) + @creation-date 2002-05-07 + @version $Id: bulk-mail-init.tcl,v 1.1 2002/05/15 22:07:52 yon Exp $ + +} + +# default interval is 1 minute +ad_schedule_proc -thread t 60 bulk_mail::sweep Index: openacs-4/packages/bulk-mail/tcl/bulk-mail-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/tcl/bulk-mail-procs-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/tcl/bulk-mail-procs-oracle.xql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,31 @@ + + + + oracle8.1.6 + + + + select site_node.url(site_nodes.node_id) + from site_nodes + where site_nodes.object_id = :package_id + + + + + + select to_char(sysdate, :date_format) + from dual + + + + + + select bulk_mail_messages.* + from bulk_mail_messages + where bulk_mail_messages.sent_p = 'f' + and bulk_mail_messages.send_date <= sysdate + for update + + + + Index: openacs-4/packages/bulk-mail/tcl/bulk-mail-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/tcl/bulk-mail-procs-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/tcl/bulk-mail-procs-postgresql.xql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,30 @@ + + + + postgresql7.1 + + + + select site_node__url(site_nodes.node_id) + from site_nodes + where site_nodes.object_id = :package_id + + + + + + select to_char(now(), :date_format) + + + + + + select bulk_mail_messages.* + from bulk_mail_messages + where bulk_mail_messages.sent_p = 'f' + and bulk_mail_messages.send_date <= now() + for update + + + + Index: openacs-4/packages/bulk-mail/tcl/bulk-mail-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/tcl/bulk-mail-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/tcl/bulk-mail-procs.tcl 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,261 @@ +ad_library { + + bulk_mail procedure library + + @author yon (yon@openforce.net) + @creation-date 2002-05-07 + @version $Id: bulk-mail-procs.tcl,v 1.1 2002/05/15 22:07:52 yon Exp $ + +} + +namespace eval bulk_mail { + + ad_proc -public package_key {} { + returns the package key of the bulk_mail package + } { + return "bulk-mail" + } + + ad_proc -public pretty_name { + {package_id ""} + } { + return the pretty name of this instance + } { + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + + return [parameter -package_id $package_id -parameter PrettyName -default "Bulk Mail"] + } + + ad_proc -public parameter { + {-package_id ""} + {-parameter:required} + {-default ""} + } { + returns the bulk_mail parameter value for the given parameter + } { + if {[empty_string_p $package_id]} { + set package_id [package_id] + } + + return [parameter::get -package_id $package_id -parameter $parameter -default $default] + } + + ad_proc -public package_id { + } { + returns the top most bulk_mail package_id + } { + return [util_memoize {bulk_mail::package_id_not_cached}] + } + + ad_proc -private package_id_not_cached { + } { + returns the top most bulk_mail package_id + } { + set package_key [package_key] + + return [db_string select_bulk_mail_package_id {}] + } + + ad_proc -public url { + } { + returns the base url of the top most bulk_mail package + } { + return [util_memoize {bulk_mail::url_not_cached}] + } + + ad_proc -private url_not_cached { + } { + returns the base url of the top most bulk_mail package + } { + set package_id [package_id] + + return [db_string select_bulk_mail_url {}] + } + + ad_proc -public new { + {-package_id ""} + {-send_date ""} + {-date_format "YYYY MM DD HH24 MI SS"} + {-from_addr:required} + {-subject ""} + {-reply_to ""} + {-extra_headers ""} + {-message:required} + {-query:required} + } { + create a new bulk_mail message + + @param package_id which instance does this bulk_mail belong to + @param send_date expects a date in the date_format format. if no date + is passed it will use the current date and time + @param date_format how to parse send_date, defaults to + "YYYY MM DD HH24 MI SS" + @param from_addr from email address to bulk_mail from, can be + overridden by a value from the query + @param subject subject of the bulk_mail message, can be overridden + by a value from the query. will be interpolated + with values from the query. + @param reply_to reply_to email address for the bulk_mail, defaults to + the value of the from_addr parameter, can be + overridden by a value from the query. + @param extra_headers a list of key, value pairs of extra headers to + stick in the email, such as 'X-Mailer' or + 'Content-type' + @param message the body of the email, can be overridden by a value + selected in the query. will be interpolated with values + from the query. + @param query a query that must select the email address to send to as + 'email' and can select any other values that will be + interpolated into the subject and message of the bulk_mail for + each recipient. if column 'foo' is selected it's value + will be interpolated anywhere that '{foo}' appears in the + subject or message of the bulk_mail. if columns 'from_addr', + 'reply_to', 'subject', or 'message' are selected, their + respective values will also become the 'from_addr', + 'reply_to', 'subject', and 'message' on a per recipient + basis. + + @return bulk_mail_id the id of the newly created bulk_mail message + } { + # run the query here to make sure that the required columns are + # present, if they are not all present then we error out. + db_with_handle db { + set selection [ns_db select $db $query] + ns_db flush $db + } + + # column email is required + if {[ns_set find $selection email] == -1} { + error "Invalid query, column \"email\" is required" + } + + # default the package_id to the appropriate value + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + + # set a reasonable default for send_date + if {[empty_string_p $send_date]} { + set send_date [db_string select_current_date {}] + } + + # set a reasonable default for the reply_to header + if {[empty_string_p $reply_to]} { + set reply_to $from_addr + } + + # prepare the data + set extra_vars [ns_set create] + ns_set put $extra_vars package_id $package_id + ns_set put $extra_vars send_date $send_date + ns_set put $extra_vars date_format $date_format + ns_set put $extra_vars from_addr $from_addr + ns_set put $extra_vars subject $subject + ns_set put $extra_vars reply_to $reply_to + ns_set put $extra_vars extra_headers $extra_headers + ns_set put $extra_vars message $message + ns_set put $extra_vars query $query + ns_set put $extra_vars context_id $package_id + + # create the new bulk_mail message + return [package_instantiate_object -extra_vars $extra_vars "bulk_mail_message"] + } + + ad_proc -private sweep { + } { + process any bulk_mails that are ready to send + } { + ns_log notice "bulk_mail::sweep starting" + + db_transaction { + foreach bulk_mail [db_list_of_ns_sets select_bulk_mails_to_send {}] { + foreach recipient [db_list_of_ns_sets select_bulk_mail_recipients [ns_set get $bulk_mail query]] { + + # create a list of key, value pairs that will be used to + # interpolate the subject and the message. we will search + # for strings of the format {column_name} in the subject + # and message and replace them witht the value of that + # column as returned by the query + set pairs [list] + for {set i 0} {$i < [ns_set size $recipient]} {incr i} { + lappend pairs [list \{[ns_set key $recipient $i]\} [ns_set value $recipient $i]] + } + + # it's possible that someone may want to override the from + # address on a per recepient basis + set from_addr [ns_set get $bulk_mail from_addr] + if {[ns_set find $recipient from_addr] > -1} { + set from_addr [ns_set get $recipient from_addr] + } + + # it's possible that someone may want to override the + # reply_to address on a per recepient basis + set reply_to [ns_set get $bulk_mail reply_to] + if {[ns_set find $recipient reply_to] > -1} { + set reply_to [ns_set get $recipient reply_to] + } + + # it's possible that someone may want to override the + # subject on a per recepient basis + # create the new bulk_mail message + set subject [ns_set get $bulk_mail subject] + if {[ns_set find $recipient subject] > -1} { + set subject [ns_set get $recipient subject] + } + + # interpolate the key, value pairs (as described above) + # into the subject + set subject [interpolate -values $pairs -text $subject] + + # it's possible that someone may want to override the + # message on a per recepient basis + set message [ns_set get $bulk_mail message] + if {[ns_set find $recipient message] > -1} { + set message [ns_set get $recipient message] + } + + # interpolate the key, value pairs (as described above) + # into the message body + set message [interpolate -values $pairs -text $message] + + # send the message reliably + acs_mail_lite::send \ + -to_addr [ns_set get $recipient email] \ + -from_addr $from_addr \ + -subject $subject \ + -body $message \ + -extraheaders [util_list_to_ns_set [ns_set get $bulk_mail extra_headers]] + + } + + # mark the bulk_mail as sent so that we don't process it again + set bulk_mail_id [ns_set get $bulk_mail bulk_mail_id] + db_dml mark_message_sent {} + } + } + + ns_log notice "bulk_mail::sweep ending" + } + + ad_proc -private interpolate { + {-values:required} + {-text:required} + } { + Interpolates a set of values into a string. + + @param values a list of key, value pairs, each one consisting of a + target string and the value it is to be replaced with. + @param text the string that is to be interpolated + + @return the interpolated string + } { + foreach pair $values { + regsub -all [lindex $pair 0] $text [lindex $pair 1] text + } + + return $text + } + +} Index: openacs-4/packages/bulk-mail/tcl/bulk-mail-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/tcl/bulk-mail-procs.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/tcl/bulk-mail-procs.xql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,20 @@ + + + + + + select min(apm_packages.package_id) + from apm_packages + where apm_packages.package_key = :package_key + + + + + + update bulk_mail_messages + set sent_p = 't' + where bulk_mail_id = :bulk_mail_id + + + + Index: openacs-4/packages/bulk-mail/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/www/index.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/www/index.adp 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,7 @@ + +@title@ +@context_bar@ + +
+ @table@ +
Index: openacs-4/packages/bulk-mail/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/www/index.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/www/index.tcl 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,42 @@ +ad_page_contract { + + @author yon (yon@openforce.net) + @creation-date 2002-05-13 + @version $Id: index.tcl,v 1.1 2002/05/15 22:07:52 yon Exp $ + +} -query { + {orderby "send_date*,subject"} +} -properties { + title:onevalue + context_bar:onevalue + table:onevalue +} + +set package_id [ad_conn package_id] +set title [bulk_mail::pretty_name] +set context_bar {All} + +set table_def { + {send_date {Send Date} {bulk_mail_messages.send_date $order} {[util_AnsiDatetoPrettyDate $send_date]}} + {from_addr From {bulk_mail_messages.from_addr $order} {$from_addr}} + {subject Subject {bulk_mail_messages.subject $order} {$subject}} + {sent_p {Sent?} {bulk_mail_messages.sent_p $order} {[ad_decode $sent_p t Yes No]}} +} + +set sql " + select bulk_mail_messages.* + from bulk_mail_messages + where bulk_mail_messages.package_id = :package_id + [ad_order_by_from_sort_spec $orderby $table_def] +" + +set table [ad_table \ + -Tmissing_text {
No bulk mail messages to display.
} \ + -Torderby $orderby \ + -Ttable_extra_html {width="95%"} \ + select_bulk_mail_messages \ + $sql \ + $table_def \ +] + +ad_return_template Index: openacs-4/packages/bulk-mail/www/master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/www/Attic/master.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/www/master.adp 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,12 @@ + +@title@ + +

@title@

+ + + <%= [eval ad_context_bar $context_bar] %> + + +
+ + Index: openacs-4/packages/bulk-mail/www/one.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/www/one.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/www/one.adp 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,41 @@ + +@title@ +@context_bar@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Send Date@send_date@
From@from_addr@
Subject@subject@
Reply To@reply_to@
Extra Headers@extra_headers@
Message
@message@
Query
@query@
Sent?YesNo
+
Index: openacs-4/packages/bulk-mail/www/one.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/www/one.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/www/one.tcl 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,21 @@ +ad_page_contract { + + @author yon (yon@openforce.net) + @creation-date 2002-05-13 + @version $Id: one.tcl,v 1.1 2002/05/15 22:07:52 yon Exp $ + +} -query { + bulk_mail_id:integer,notnull +} -properties { + bulk_mail_name:onevalue + context_bar:onevalue +} + +set package_id [ad_conn package_id] + +db_1row select_message_info {} + +set title $subject +set context_bar [list $subject] + +ad_return_template Index: openacs-4/packages/bulk-mail/www/one.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bulk-mail/www/one.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/bulk-mail/www/one.xql 15 May 2002 22:07:52 -0000 1.1 @@ -0,0 +1,21 @@ + + + + + + + select bulk_mail_messages.bulk_mail_id, + to_char(bulk_mail_messages.send_date, 'Mon DD YYYY HH24:MI') as send_date, + bulk_mail_messages.sent_p, + bulk_mail_messages.from_addr, + bulk_mail_messages.subject, + bulk_mail_messages.reply_to, + bulk_mail_messages.extra_headers, + bulk_mail_messages.message, + bulk_mail_messages.query + from bulk_mail_messages + where bulk_mail_messages.bulk_mail_id = :bulk_mail_id + + + + Index: openacs-4/packages/dotlrn-bm/dotlrn-bm.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-bm/dotlrn-bm.info,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-bm/dotlrn-bm.info 15 May 2002 22:12:16 -0000 1.1 @@ -0,0 +1,31 @@ + + + + + dotLRN Bulk Mail Applet + dotLRN Bulk Mail Applets + f + t + + + + oracle + postgresql + + Yonatan Feldman + + + + + + + + + + + + + + + + Index: openacs-4/packages/dotlrn-bm/sql/oracle/dotlrn-bm-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-bm/sql/oracle/dotlrn-bm-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-bm/sql/oracle/dotlrn-bm-create.sql 15 May 2002 22:12:16 -0000 1.1 @@ -0,0 +1,138 @@ +-- +-- Copyright(C) 2001, 2002 OpenForce, Inc. +-- +-- This file is part of dotLRN. +-- +-- dotLRN is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 2 of the License, or(at your option) any later +-- version. +-- +-- dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- + +-- +-- Creates the bulk-mail portlet +-- +-- @author yon (yon@openforce.net) +-- @creation-date 2002-05-13 +-- @version $Id: dotlrn-bm-create.sql,v 1.1 2002/05/15 22:12:16 yon Exp $ +-- + +declare + foo integer; +begin + + foo := acs_sc_impl.new( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_owner_name => 'dotlrn_bm' + ); + + foo := acs_sc_impl.new_alias( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_operation_name => 'GetPrettyName', + impl_alias => 'dotlrn_bm::get_pretty_name', + impl_pl => 'TCL' + ); + + foo := acs_sc_impl.new_alias( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_operation_name => 'AddApplet', + impl_alias => 'dotlrn_bm::add_applet', + impl_pl => 'TCL' + ); + + foo := acs_sc_impl.new_alias( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_operation_name => 'RemoveApplet', + impl_alias => 'dotlrn_bm::remove_applet', + impl_pl => 'TCL' + ); + + foo := acs_sc_impl.new_alias( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_operation_name => 'AddAppletToCommunity', + impl_alias => 'dotlrn_bm::add_applet_to_community', + impl_pl => 'TCL' + ); + + foo := acs_sc_impl.new_alias( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_operation_name => 'RemoveAppletFromCommunity', + impl_alias => 'dotlrn_bm::remove_applet_from_community', + impl_pl => 'TCL' + ); + + foo := acs_sc_impl.new_alias( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_operation_name => 'AddUser', + impl_alias => 'dotlrn_bm::add_user', + impl_pl => 'TCL' + ); + + foo := acs_sc_impl.new_alias( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_operation_name => 'RemoveUser', + impl_alias => 'dotlrn_bm::remove_user', + impl_pl => 'TCL' + ); + + foo := acs_sc_impl.new_alias( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_operation_name => 'AddUserToCommunity', + impl_alias => 'dotlrn_bm::add_user_to_community', + impl_pl => 'TCL' + ); + + foo := acs_sc_impl.new_alias( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_operation_name => 'RemoveUserFromCommunity', + impl_alias => 'dotlrn_bm::remove_user_from_community', + impl_pl => 'TCL' + ); + + foo := acs_sc_impl.new_alias( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_operation_name => 'AddPortlet', + impl_alias => 'dotlrn_bm::add_portlet', + impl_pl => 'TCL' + ); + + foo := acs_sc_impl.new_alias( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_operation_name => 'RemovePortlet', + impl_alias => 'dotlrn_bm::remove_portlet', + impl_pl => 'TCL' + ); + + foo := acs_sc_impl.new_alias( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm', + impl_operation_name => 'Clone', + impl_alias => 'dotlrn_bm::clone', + impl_pl => 'TCL' + ); + + acs_sc_binding.new( + contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_bm' + ); + +end; +/ +show errors Index: openacs-4/packages/dotlrn-bm/tcl/dotlrn-bm-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-bm/tcl/dotlrn-bm-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-bm/tcl/dotlrn-bm-procs.tcl 15 May 2002 22:12:16 -0000 1.1 @@ -0,0 +1,210 @@ +# +# Copyright (C) 2001, 2002 OpenForce, Inc. +# +# This file is part of dotLRN. +# +# dotLRN is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# + +ad_library { + + proc library for dotlrn bulk-mail applet + + @author yon (yon@openforce.net) + @creation-date 2002-05-13 + @version $Id: dotlrn-bm-procs.tcl,v 1.1 2002/05/15 22:12:16 yon Exp $ + +} + +namespace eval dotlrn_bm { + + ad_proc -public applet_key { + } { + get the applet_key + } { + return "dotlrn_bm" + } + + ad_proc -public package_key { + } { + get the package_key this applet deals with + } { + return "bulk-mail" + } + + ad_proc portal_element_key { + } { + return the portal element key + } { + return "bm-portlet" + } + + ad_proc -public get_pretty_name { + } { + returns the pretty name + } { + return "dotLRN Bulk Mail Applet" + } + + ad_proc -public get_user_default_page {} { + return the user default page to add the portlet to + } { + return "" + } + + ad_proc -public get_community_default_page {} { + return the user default page to add the portlet to + } { + return "" + } + + ad_proc -public get_subcomm_default_page {} { + return the user default page to add the portlet to + } { + return "" + } + + ad_proc -public add_applet { + } { + used for one-time init - must be repeatable! + } { + if {![dotlrn::is_package_mounted -package_key [package_key]]} { + set package_id [dotlrn::mount_package \ + -package_key [package_key] \ + -url [package_key] \ + -directory_p "t"] + + portal::mapping::new \ + -object_id $package_id \ + -node_id [site_nodes::get_node_id_from_package_id -package_id $package_id] + + dotlrn_applet::add_applet_to_dotlrn -applet_key [applet_key] + + dotlrn_applet::mount -package_key "dotlrn-bm" -url "bm" -pretty_name "Bulk Mail" + } + } + + ad_proc -public remove_applet { + } { + remove the applet from dotlrn + } { + } + + ad_proc -public add_applet_to_community { + community_id + } { + Add the bulk-mail applet to a dotlrn community + } { + if {[dotlrn_community::dummy_comm_p -community_id $community_id]} { + return + } + + set portal_id [dotlrn_community::get_admin_portal_id -community_id $community_id] + set package_id [dotlrn::instantiate_and_mount $community_id [package_key]] + + bm_portlet::add_self_to_page -portal_id $portal_id -package_id $package_id + + return $package_id + } + + ad_proc -public remove_applet_from_community { + community_id + } { + remove the bulk-mail applet from a dotlrn community + } { + set portal_id [dotlrn_community::get_admin_portal_id -community_id $community_id] + set package_id [dotlrn::get_community_applet_package_id \ + -community_id $community_id \ + -package_key [package_key] + ] + + bm_portlet::remove_self_from_page -portal_id $portal_id -package_id $package_id + } + + ad_proc -public add_user { + user_id + } { + one time user-specfic init + } { + } + + ad_proc -public remove_user { + user_id + } { + one time user-specific removal + } { + } + + ad_proc -public add_user_to_community { + community_id + user_id + } { + add a user to a community + } { + } + + ad_proc -public remove_user_from_community { + community_id + user_id + } { + remove a user from a community + } { + } + + ad_proc -public add_portlet { + portal_id + args + } { + a helper proc to add the underlying portlet to the given portal. + } { + ns_log notice "** Error in [get_pretty_name]: 'add_portlet' not implemented!" + ad_return_complaint 1 "Please notifiy the administrator of this error: ** Error in [get_pretty_name]: 'add_portlet' not implemented!" + } + + ad_proc -public remove_portlet { + portal_id + args + } { + a helper proc to remove the underlying portlet from the given portal. + } { + ns_log notice "** Error in [get_pretty_name]: 'remove_portlet' not implemented!" + ad_return_complaint 1 "Please notifiy the administrator of this error: ** Error in [get_pretty_name]: 'remove_portlet' not implemented!" + } + + ad_proc -public clone { + old_community_id + new_community_id + } { + clone this applet's content from the old community to the new one + } { + ns_log notice "** Error in [get_pretty_name] 'clone' not implemented!" + ad_return_complaint 1 "Please notifiy the administrator of this error: ** Error in [get_pretty_name]: 'clone' not implemented!" + } + + ad_proc -public get_package_id { + } { + returns the package_id of the dotlrn-bm package + } { + return [db_string select_package_id { + select min(package_id) + from apm_packages + where package_key = 'dotlrn-bm' + }] + } + + ad_proc -public get_url { + } { + returns the URL for the dotlrn-bm package + } { + return [site_nodes::get_url_from_package_id -package_id [get_package_id]] + } + +}