Index: openacs-4/packages/forums/forums.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/forums.info,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/forums.info 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,88 @@ + + + + + Forums + Forums + f + f + + + + oracle + postgresql + + Ben Adida + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: openacs-4/packages/forums/sql/oracle/forums-alerts-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/Attic/forums-alerts-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/forums-alerts-create.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,25 @@ + +-- +-- The Forums Package - Alerts +-- +-- @author gwong@orchardlabs.com,ben@openforce.biz +-- @creation-date 2002-05-16 +-- +-- This code is newly concocted by Ben, but with significant concepts and code +-- lifted from Gilbert. Thanks Orchard Labs! +-- + +-- +-- the problem in the original bboard code was the scoping of the alerts +-- technically, alerts are scoped given which forum they refer to. +-- That's great if everyone follows the convention of checking alerts +-- with a subquery on forums. I'm toying with the idea of directly scoping +-- the alerts. It's a denormalization that is cheap and probably will +-- lead to better developer behavior. +-- +-- Ben +-- + +create table forums_alerts ( + alert_id integer not null + constraint forums_forum Index: openacs-4/packages/forums/sql/oracle/forums-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/forums-create.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,25 @@ + +-- +-- The Forums Package +-- +-- @author gwong@orchardlabs.com,ben@openforce.biz +-- @creation-date 2002-05-16 +-- +-- This code is newly concocted by Ben, but with significant concepts and code +-- lifted from Gilbert's UBB forums. Thanks Orchard Labs. +-- + +-- The basic forum constructs +@ forums-forums-create.sql +@ forums-forums-package-create.sql + +-- The messages +@ tree-create.sql +@ forums-messages-create.sql +@ forums-messages-package-create.sql + +-- tree stuff +@ forums-tree-create.sql + +-- notifications +@ forums-notifications-init.sql Index: openacs-4/packages/forums/sql/oracle/forums-forums-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-forums-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/forums-forums-create.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,90 @@ + +-- +-- The Forums Package +-- +-- @author gwong@orchardlabs.com,ben@openforce.biz +-- @creation-date 2002-05-16 +-- +-- This code is newly concocted by Ben, but with heavy concepts and heavy code +-- chunks lifted from Gilbert. Thanks Orchard Labs. +-- + +-- privileges +declare +begin + -- moderate and post are new privileges + -- the rest are obvious inheritance + -- forum creation on a package allows a user to create forums + -- forum creation on a forum allows a user to create new threads + acs_privilege.create_privilege('forum_create',null,null); + acs_privilege.create_privilege('forum_write',null,null); + acs_privilege.create_privilege('forum_delete',null,null); + acs_privilege.create_privilege('forum_read',null,null); + acs_privilege.create_privilege('forum_post',null,null); + acs_privilege.create_privilege('forum_moderate',null,null); + + -- add children + acs_privilege.add_child('create','forum_create'); + acs_privilege.add_child('write','forum_write'); + acs_privilege.add_child('delete','forum_delete'); + acs_privilege.add_child('admin','forum_moderate'); + acs_privilege.add_child('forum_moderate','forum_read'); + acs_privilege.add_child('forum_moderate','forum_post'); + acs_privilege.add_child('forum_write','forum_read'); + acs_privilege.add_child('forum_write','forum_post'); + + -- the last one that will cause all the updates + acs_privilege.add_child('read','forum_read'); +end; +/ +show errors + + +-- +-- The Data Model +-- + +create table forums_forums ( + forum_id integer not null + constraint forums_forum_id_fk + references acs_objects(object_id) + constraint forums_forum_id_pk + primary key, + name varchar(200) constraint forum_name_nn not null, + charter varchar(2000), + presentation_type varchar(100) + constraint forum_type_nn not null + constraint forum_type_ch + check (presentation_type in ('flat','threaded')), + posting_policy varchar(100) + constraint forum_policy_nn not null + constraint forum_policy_ch + check (posting_policy in ('open','moderated','closed')), + max_child_sortkey raw(100), + enabled_p char(1) default 't' not null + constraint forum_enabled_p_ch check + (enabled_p in ('t','f')), + package_id integer constraint forum_package_id_nn not null +); + +create view forums_forums_enabled +as select * from forums_forums where enabled_p='t'; + +-- +-- Object Type +-- + +declare +begin + acs_object_type.create_type ( + supertype => 'acs_object', + object_type => 'forums_forum', + pretty_name => 'Forums Forum', + pretty_plural => 'Forums Forums', + table_name => 'forums_forums', + id_column => 'forum_id', + package_name => 'forums_forum' + ); +end; +/ +show errors Index: openacs-4/packages/forums/sql/oracle/forums-forums-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-forums-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/forums-forums-drop.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,54 @@ + +-- +-- The Forums Package +-- +-- @author gwong@orchardlabs.com,ben@openforce.biz +-- @creation-date 2002-05-16 +-- +-- This code is newly concocted by Ben, but with heavy concepts and heavy code +-- chunks lifted from Gilbert. Thanks Orchard Labs. +-- + +-- privileges +declare +begin + -- remove children + acs_privilege.remove_child('read','forum_read'); + acs_privilege.remove_child('create','forum_create'); + acs_privilege.remove_child('write','forum_write'); + acs_privilege.remove_child('delete','forum_delete'); + acs_privilege.remove_child('admin','forum_moderate'); + acs_privilege.remove_child('forum_moderate','forum_read'); + acs_privilege.remove_child('forum_moderate','forum_post'); + acs_privilege.remove_child('forum_write','forum_read'); + acs_privilege.remove_child('forum_write','forum_post'); + + acs_privilege.drop_privilege('forum_moderate'); + acs_privilege.drop_privilege('forum_post'); + acs_privilege.drop_privilege('forum_read'); + acs_privilege.drop_privilege('forum_create'); + acs_privilege.drop_privilege('forum_write'); + acs_privilege.drop_privilege('forum_delete'); +end; +/ +show errors + + +-- +-- The Data Model +-- + +drop table forums_forums; + +-- +-- Object Type +-- + +declare +begin + acs_object_type.drop_type ( + object_type => 'forums_forum' + ); +end; +/ +show errors Index: openacs-4/packages/forums/sql/oracle/forums-forums-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-forums-package-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/forums-forums-package-create.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,97 @@ + +-- +-- The Forums Package +-- +-- @author gwong@orchardlabs.com,ben@openforce.biz +-- @creation-date 2002-05-16 +-- +-- The Package +-- +-- This code is newly concocted by Ben, but with heavy concepts and heavy code +-- chunks lifted from Gilbert. Thanks Orchard Labs! +-- + +create or replace package forums_forum +as + function new ( + forum_id in forums_forums.forum_id%TYPE default null, + object_type in acs_objects.object_type%TYPE default 'forums_forum', + name in forums_forums.name%TYPE, + charter in forums_forums.charter%TYPE default null, + presentation_type in forums_forums.presentation_type%TYPE, + posting_policy in forums_forums.posting_policy%TYPE, + package_id in forums_forums.package_id%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 forums_forums.forum_id%TYPE; + + function name ( + forum_id in forums_forums.forum_id%TYPE + ) return varchar; + + procedure delete ( + forum_id in forums_forums.forum_id%TYPE + ); +end forums_forum; +/ +show errors + + +create or replace package body forums_forum +as + function new ( + forum_id in forums_forums.forum_id%TYPE default null, + object_type in acs_objects.object_type%TYPE default 'forums_forum', + name in forums_forums.name%TYPE, + charter in forums_forums.charter%TYPE default null, + presentation_type in forums_forums.presentation_type%TYPE, + posting_policy in forums_forums.posting_policy%TYPE, + package_id in forums_forums.package_id%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 forums_forums.forum_id%TYPE + is + v_forum_id forums_forums.forum_id%TYPE; + begin + v_forum_id := acs_object.new ( + object_id => forum_id, + object_type => object_type, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => nvl(context_id, package_id) + ); + + insert into forums_forums + (forum_id, name, charter, presentation_type, posting_policy, package_id) values + (v_forum_id, name, charter, presentation_type, posting_policy, package_id); + + return v_forum_id; + end new; + + function name ( + forum_id in forums_forums.forum_id%TYPE + ) return varchar + is + v_name forums_forums.name%TYPE; + begin + select name into v_name from forums_forums where forum_id= name.forum_id; + + return v_name; + end name; + + procedure delete ( + forum_id in forums_forums.forum_id%TYPE + ) + is + begin + acs_object.delete(forum_id); + end delete; + +end forums_forum; +/ +show errors Index: openacs-4/packages/forums/sql/oracle/forums-forums-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-forums-package-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/forums-forums-package-drop.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,15 @@ + +-- +-- The Forums Package +-- +-- @author gwong@orchardlabs.com,ben@openforce.biz +-- @creation-date 2002-05-16 +-- +-- The Package +-- +-- This code is newly concocted by Ben, but with heavy concepts and heavy code +-- chunks lifted from Gilbert. Thanks Orchard Labs! +-- +-- drop script + +drop package forums_forum; Index: openacs-4/packages/forums/sql/oracle/forums-messages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-messages-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/forums-messages-create.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,82 @@ + +-- +-- The Forums Package +-- +-- @author gwong@orchardlabs.com,ben@openforce.biz +-- @creation-date 2002-05-16 +-- +-- This code is newly concocted by Ben, but with significant concepts and code +-- lifted from Gilbert. Thanks Orchard Labs! +-- + +-- privileges +-- NO PRIVILEGES FOR MESSAGES +-- we don't individually permission messages + +-- +-- The Data Model +-- + +create table forums_messages ( + message_id integer not null + constraint forums_message_id_fk + references acs_objects(object_id) + constraint forums_message_id_pk + primary key, + forum_id integer + constraint forums_mess_forum_id_fk + references forums_forums(forum_id), + subject varchar(200), + content clob, + -- html_p only applies to the body. The subject is plaintext. + html_p char(1) default 'f' + constraint forums_mess_html_p_ch + check (html_p in ('t','f')) + constraint forums_mess_html_p_nn not null, + user_id integer + constraint forums_mess_user_id_fk + references users(user_id) + constraint forums_mess_user_id_nn + not null, + posting_date date + constraint forum_mess_post_date_nn not null, + state varchar(100) + constraint forum_mess_state_ch check (state in ('pending','approved','rejected')), + -- Hierarchy of messages + parent_id integer + constraint forum_mess_parent_id_fk + references forums_messages(message_id), + open_p char(1) default 't' not null + constraint forum_mess_open_p_ch check (open_p in ('t','f')), + tree_sortkey raw(240), + max_child_sortkey raw(100), + constraint forums_mess_sk_forum_un + unique (tree_sortkey,forum_id) +); + +-- views + +create view forums_messages_approved as +select * from forums_messages where state='approved'; + +create view forums_messages_pending as +select * from forums_messages where state='pending'; + +-- +-- Object Type +-- + +declare +begin + acs_object_type.create_type ( + supertype => 'acs_object', + object_type => 'forums_message', + pretty_name => 'Forums Message', + pretty_plural => 'Forums Messages', + table_name => 'forums_messages', + id_column => 'message_id', + package_name => 'forums_message' + ); +end; +/ +show errors Index: openacs-4/packages/forums/sql/oracle/forums-messages-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-messages-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/forums-messages-drop.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,33 @@ + +-- +-- The Forums Package +-- +-- @author gwong@orchardlabs.com,ben@openforce.biz +-- @creation-date 2002-05-16 +-- +-- This code is newly concocted by Ben, but with significant concepts and code +-- lifted from Gilbert. Thanks Orchard Labs! +-- + +-- privileges +-- NO PRIVILEGES FOR MESSAGES +-- we don't individually permission messages + +-- +-- The Data Model +-- + +drop table forums_messages; + +-- +-- Object Type +-- + +declare +begin + acs_object_type.drop_type ( + object_type => 'forums_message' + ); +end; +/ +show errors Index: openacs-4/packages/forums/sql/oracle/forums-messages-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-messages-package-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/forums-messages-package-create.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,208 @@ + +-- +-- The Forums Package +-- +-- @author gwong@orchardlabs.com,ben@openforce.biz +-- @creation-date 2002-05-16 +-- +-- The Package for Messages +-- +-- This code is newly concocted by Ben, but with heavy concepts and heavy code +-- chunks lifted from Gilbert. Thanks Orchard Labs! +-- + +create or replace package forums_message +as + function new ( + message_id in forums_messages.message_id%TYPE default null, + object_type in acs_objects.object_type%TYPE default 'forums_message', + forum_id in forums_messages.forum_id%TYPE, + subject in forums_messages.subject%TYPE, + content in varchar, + html_p in forums_messages.html_p%TYPE default 'f', + user_id in forums_messages.user_id%TYPE, + posting_date in forums_messages.posting_date%TYPE default sysdate, + state in forums_messages.state%TYPE default null, + parent_id in forums_messages.parent_id%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 forums_messages.message_id%TYPE; + + function root_message_id ( + message_id in forums_messages.message_id%TYPE + ) return forums_messages.message_id%TYPE; + + procedure thread_open ( + message_id in forums_messages.message_id%TYPE + ); + + procedure thread_close ( + message_id in forums_messages.message_id%TYPE + ); + + procedure delete ( + message_id in forums_messages.message_id%TYPE + ); + + procedure delete_thread ( + message_id in forums_messages.message_id%TYPE + ); +end forums_message; +/ +show errors + + + +create or replace package body forums_message +as + function new ( + message_id in forums_messages.message_id%TYPE default null, + object_type in acs_objects.object_type%TYPE default 'forums_message', + forum_id in forums_messages.forum_id%TYPE, + subject in forums_messages.subject%TYPE, + content in varchar, + html_p in forums_messages.html_p%TYPE default 'f', + user_id in forums_messages.user_id%TYPE, + posting_date in forums_messages.posting_date%TYPE default sysdate, + state in forums_messages.state%TYPE default null, + parent_id in forums_messages.parent_id%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 forums_messages.message_id%TYPE + is + v_message_id acs_objects.object_id%TYPE; + v_forum_policy forums_forums.posting_policy%TYPE; + v_state forums_messages.state%TYPE; + begin + v_message_id := acs_object.new ( + object_id => message_id, + object_type => object_type, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => nvl(context_id,forum_id) + ); + + IF state is NULL + then + select posting_policy into v_forum_policy from forums_forums + where forum_id= new.forum_id; + + if v_forum_policy = 'moderated' + then v_state := 'pending'; + else v_state := 'approved'; + end if; + else + v_state := state; + end if; + + insert into forums_messages + (message_id, forum_id, subject, content, html_p, user_id, posting_date, parent_id, state) + values + (v_message_id, forum_id, subject, content, html_p, user_id, posting_date, parent_id, v_state); + + return v_message_id; + end new; + + function root_message_id ( + message_id in forums_messages.message_id%TYPE + ) return forums_messages.message_id%TYPE + is + v_message_id forums_messages.message_id%TYPE; + v_forum_id forums_messages.forum_id%TYPE; + v_sortkey forums_messages.tree_sortkey%TYPE; + begin + select forum_id, tree_sortkey into v_forum_id, v_sortkey + from forums_messages where message_id= root_message_id.message_id; + + select message_id into v_message_id from forums_messages where forum_id= v_forum_id + and tree_sortkey= tree.ancestor_key(v_sortkey, 1); + + return v_message_id; + end root_message_id; + + procedure thread_open ( + message_id in forums_messages.message_id%TYPE + ) + is + v_forum_id forums_messages.forum_id%TYPE; + v_sortkey forums_messages.tree_sortkey%TYPE; + begin + select forum_id, tree_sortkey into v_forum_id, v_sortkey + from forums_messages where message_id= thread_open.message_id; + + update forums_messages set open_p='t' + where tree_sortkey between tree.left(v_sortkey) and tree.right(v_sortkey) + and forum_id = v_forum_id; + + update forums_messages set open_p='t' + where message_id= thread_open.message_id; + end thread_open; + + procedure thread_close ( + message_id in forums_messages.message_id%TYPE + ) + is + v_forum_id forums_messages.forum_id%TYPE; + v_sortkey forums_messages.tree_sortkey%TYPE; + begin + select forum_id, tree_sortkey into v_forum_id, v_sortkey + from forums_messages where message_id= thread_close.message_id; + + update forums_messages set open_p='f' + where tree_sortkey between tree.left(v_sortkey) and tree.right(v_sortkey) + and forum_id = v_forum_id; + + update forums_messages set open_p='f' + where message_id= thread_close.message_id; + end thread_close; + + procedure delete ( + message_id in forums_messages.message_id%TYPE + ) + is + begin + acs_object.delete(message_id); + end delete; + + procedure delete_thread ( + message_id in forums_messages.message_id%TYPE + ) + is + v_forum_id forums_messages.forum_id%TYPE; + v_sortkey forums_messages.tree_sortkey%TYPE; + v_message forums_messages%ROWTYPE; + begin + select forum_id, tree_sortkey into v_forum_id, v_sortkey + from forums_messages where message_id= delete_thread.message_id; + + -- if it's already deleted + if SQL%NOTFOUND + then return; + end if; + + -- delete all children + -- order by tree_sortkey desc to guarantee + -- that we never delete a parent before its child + -- sortkeys are beautiful + FOR v_message in + (select * from forums_messages + where forum_id = v_forum_id and + tree_sortkey between tree.left(v_sortkey) + and tree.right(v_sortkey) order by tree_sortkey desc) + LOOP + forums_message.delete(v_message.message_id); + END LOOP; + + -- delete the message itself + forums_message.delete(delete_thread.message_id); + end delete_thread; + +end forums_message; +/ +show errors + Index: openacs-4/packages/forums/sql/oracle/forums-messages-package-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-messages-package-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/forums-messages-package-drop.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,14 @@ + +-- +-- The Forums Package +-- +-- @author gwong@orchardlabs.com,ben@openforce.biz +-- @creation-date 2002-05-16 +-- +-- The Package for Messages +-- +-- This code is newly concocted by Ben, but with heavy concepts and heavy code +-- chunks lifted from Gilbert. Thanks Orchard Labs! +-- + +drop package forums_message; Index: openacs-4/packages/forums/sql/oracle/forums-notifications-init.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-notifications-init.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/forums-notifications-init.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,57 @@ + +-- +-- The Forums Package +-- +-- @author gwong@orchardlabs.com,ben@openforce.biz +-- @creation-date 2002-05-16 +-- +-- This code is newly concocted by Ben, but with significant concepts and code +-- lifted from Gilbert's UBB forums. Thanks Orchard Labs. +-- + +-- the integration with Notifications + +declare + v_foo integer; +begin + v_foo:= notification_type.new ( + short_name => 'forums_forum_notif', + pretty_name => 'Forum Notification', + description => 'Notifications for Entire Forums', + creation_user => NULL, + creation_ip => NULL + ); + + -- enable the various intervals and delivery methods + insert into notification_types_intervals + (type_id, interval_id) + select v_foo, interval_id + from notification_intervals where name in ('instant','hourly','daily'); + + insert into notification_types_del_methods + (type_id, delivery_method_id) + select v_foo, delivery_method_id + from notification_delivery_methods where short_name in ('email'); + + v_foo:= notification_type.new ( + short_name => 'forums_message_notif', + pretty_name => 'Message Notification', + description => 'Notifications for Message Thread', + creation_user => NULL, + creation_ip => NULL + ); + + -- enable the various intervals and delivery methods + insert into notification_types_intervals + (type_id, interval_id) + select v_foo, interval_id + from notification_intervals where name in ('instant','hourly','daily'); + + insert into notification_types_del_methods + (type_id, delivery_method_id) + select v_foo, delivery_method_id + from notification_delivery_methods where short_name in ('email'); + +end; +/ +show errors Index: openacs-4/packages/forums/sql/oracle/forums-tree-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/forums-tree-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/forums-tree-create.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,60 @@ + +-- +-- The Forums Package +-- +-- @author gwong@orchardlabs.com,ben@openforce.biz +-- @creation-date 2002-05-16 +-- +-- This code is newly concocted by Ben, but with significant concepts and code +-- lifted from Gilbert. Thanks Orchard Labs! +-- + +-- +-- This is the sortkey code +-- + + +create or replace trigger forums_mess_insert_tr +before insert on forums_messages +for each row +declare + v_max_child_sortkey forums_messages.max_child_sortkey%TYPE; + v_parent_sortkey forums_messages.tree_sortkey%TYPE; +begin + if :new.parent_id is NULL + then + -- get the max from the forum + select max_child_sortkey into v_max_child_sortkey + from forums_forums where forum_id= :new.forum_id + for update of max_child_sortkey; + + v_parent_sortkey:= NULL; + else + -- get the max child sortkey from parent + -- grab the lock + select tree_sortkey, max_child_sortkey + into v_parent_sortkey, v_max_child_sortkey + from forums_messages + where message_id= :new.parent_id + for update of max_child_sortkey; + end if; + + -- increment the sortkey + v_max_child_sortkey:= lpad(tree.increment_key(v_max_child_sortkey),6,'0'); + + if :new.parent_id is null + then + update forums_forums set max_child_sortkey= v_max_child_sortkey + where forum_id= :new.forum_id; + else + -- update the parent + update forums_messages set max_child_sortkey= v_max_child_sortkey + where message_id= :new.parent_id; + end if; + + -- generate the current sortkey + :new.tree_sortkey:= v_parent_sortkey || v_max_child_sortkey; + +end forums_mess_insert_tr; +/ +show errors Index: openacs-4/packages/forums/sql/oracle/tree-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/sql/oracle/Attic/tree-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/sql/oracle/tree-create.sql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,201 @@ + +-- +-- The Tree Package +-- +-- @author ben@openforce +-- @creation-date 2002-05-17 +-- +-- The Package +-- +-- This does funky sortkey stuff in Oracle, +-- similar to DonB's PG varbit stuff, but without varbits +-- because Oracle has no varbits. +-- +-- This scheme is usable in PG, too, but probably not as +-- efficient as Don's varbit scheme. So we use it only in Oracle +-- + +create or replace package tree +as + function hex_to_int ( + p_hex in raw + ) return integer; + + function int_to_hex ( + p_int in integer + ) return raw; + + function increment_key ( + tree_key in raw + ) return raw; + + function next_key ( + parent_key in raw, + max_child_key in raw + ) return raw; + + function left ( + raw_key in raw + ) return raw; + + function right ( + raw_key in raw + ) return raw; + + function ancestor_key ( + raw_key in raw, + tree_level in integer + ) return raw; + + function tree_level ( + raw_key in raw + ) return integer; + + function ancestor_p ( + ancestor_key in raw, + child_key in raw + ) return char; + +end tree; +/ +show errors + + +create or replace package body tree +as + function hex_to_int ( + p_hex in raw + ) return integer + is + v_int integer; + v_current_pow integer; + v_current_pos integer; + v_current_char integer; + begin + v_current_pow:= 1; + v_current_pos:= length(p_hex); + v_int := 0; + + WHILE v_current_pos > 0 LOOP + v_current_char:= ascii(upper(substr(p_hex, v_current_pos, 1))); + + if (v_current_char between 48 and 57) + then + -- between 1 and 9 + v_int:= v_int + (v_current_pow * (v_current_char - 48)); + else + -- between A and F + v_int:= v_int + (v_current_pow * (v_current_char - 55)); + end if; + + -- change things + v_current_pow:= v_current_pow * 16; + v_current_pos:= v_current_pos - 1; + END LOOP; + + return v_int; + end; + + function int_to_hex ( + p_int in integer + ) return raw + is + v_hex raw(9); + v_current_pow integer; + v_remainder integer; + v_current_div integer; + begin + -- 16 ^ 8 + v_current_pow:= 4294967296; + v_remainder:= p_int; + v_hex:= ''; + + WHILE v_remainder > 0 + LOOP + v_current_div:= floor(v_remainder/v_current_pow); + + -- we're not prepending 0's + if v_current_div > 0 or length(v_hex) > 0 then + -- 0-9 or A-F + if v_current_div between 0 and 9 + then v_hex:= v_hex || chr(48 + v_current_div); + else v_hex:= v_hex || chr (55 + v_current_div); + end if; + end if; + + -- adjust for next round + v_remainder:= mod(v_remainder, v_current_pow); + v_current_pow:= v_current_pow / 16; + END LOOP; + + return v_hex; + end int_to_hex; + + function increment_key ( + tree_key in raw + ) return raw + is + begin + if tree_key is NULL + then return '000000'; + else + return (int_to_hex(hex_to_int(tree_key) +1)); + end if; + end increment_key; + + function next_key ( + parent_key in raw, + max_child_key in raw + ) return raw + is + begin + return parent_key || lpad(increment_key(max_child_key),6,'0'); + end next_key; + + function left ( + raw_key in raw + ) return raw + is + begin + return raw_key || '000000'; + end left; + + function right ( + raw_key in raw + ) return raw + is + begin + return raw_key || 'ffffff'; + end right; + + function ancestor_key ( + raw_key in raw, + tree_level in integer + ) return raw + is + begin + return substr(raw_key, 1, 6 * tree_level); + end ancestor_key; + + function tree_level ( + raw_key in raw + ) return integer + is + begin + return length(raw_key) / 6; + end tree_level; + + function ancestor_p ( + ancestor_key in raw, + child_key in raw + ) return char + is + begin + if substr(child_key,1, length(ancestor_key)) = ancestor_key + then return 't'; + else return 'f'; + end if; + end ancestor_p; +end tree; +/ +show errors Index: openacs-4/packages/forums/tcl/forums-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/forums-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/tcl/forums-procs.tcl 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,95 @@ +ad_library { + + Forums Library + + @creation-date 2002-05-17 + @author Ben Adida + @cvs-id $Id: forums-procs.tcl,v 1.1 2002/05/29 21:40:10 ben Exp $ + +} + +namespace eval forum { + + ad_proc -public new { + {-forum_id ""} + {-name:required} + {-charter ""} + {-presentation_type "flat"} + {-posting_policy "open"} + {-package_id:required} + } { + create a new forum + } { + # Prepare the variables for instantiation + set extra_vars [ns_set create] + oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {forum_id name charter presentation_type posting_policy package_id} + + # Instantiate the forum + set forum_id [package_instantiate_object -extra_vars $extra_vars forums_forum] + + return $forum_id + } + + ad_proc -public edit { + {-forum_id:required} + {-name:required} + {-charter ""} + {-presentation_type "flat"} + {-posting_policy "open"} + } { + edit a forum + } { + # This is a straight DB update + db_dml update_forum {} + } + + ad_proc -public get { + {-forum_id:required} + {-array:required} + } { + get the fields for a forum + } { + # Select the info into the upvar'ed Tcl Array + upvar $array row + db_1row select_forum {} -column_array row + } + + ad_proc -public new_questions_allow { + {-forum_id:required} + } { + # Give the public the right to ask new questions + permission::grant -object_id $forum_id \ + -party_id [acs_magic_object registered_users] \ + -privilege forum_create + } + + ad_proc -public new_questions_deny { + {-forum_id:required} + } { + # Revoke the right from the public to ask new questions + permission::revoke -object_id $forum_id \ + -party_id [acs_magic_object registered_users] \ + -privilege forum_create + } + + ad_proc -public new_questions_allowed_p { + {-forum_id:required} + } { + permission::permission_p -object_id $forum_id \ + -party_id [acs_magic_object registered_users] \ + -privilege forum_create + } + + ad_proc -public enable { + {-forum_id:required} + } { + # Enable the forum, no big deal + db_dml update_forum_enabled_p {} + } + + ad_proc -public disable { + {-forum_id:required} + } { + db_dml update_forum_disabled_p {} + } +} Index: openacs-4/packages/forums/tcl/forums-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/forums-procs.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/tcl/forums-procs.xql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,38 @@ + + + + + +update forums_forums set +name= :name, +charter= :charter, +presentation_type= :presentation_type, +posting_policy= :posting_policy +where +forum_id= :forum_id + + + + + + + select * from forums_forums where forum_id = :forum_id + + + + + + +update forums_forums set enabled_p='t' +where forum_id= :forum_id + + + + + +update forums_forums set enabled_p='f' +where forum_id= :forum_id + + + + Index: openacs-4/packages/forums/tcl/forums-security-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/forums-security-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/tcl/forums-security-procs.tcl 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,118 @@ +ad_library { + + Forums Security Library + + @creation-date 2002-05-25 + @author Ben Adida + @cvs-id $Id: forums-security-procs.tcl,v 1.1 2002/05/29 21:40:10 ben Exp $ + +} + +namespace eval forum::security { + + ad_proc -public can_read_forum_p { + {-user_id ""} + {-forum_id:required} + } { + # hack + return 1 + } + + ad_proc -public require_read_forum { + {-user_id ""} + {-forum_id:required} + } { + + } + + ad_proc -public can_read_message_p { + {-user_id ""} + {-message_id:required} + } { + # hack + return 1 + } + + ad_proc -public require_read_message { + {-user_id ""} + {-message_id:required} + } { + + } + + ad_proc -public can_post_forum_p { + {-user_id ""} + {-forum_id:required} + } { + return [permission::permission_p -object_id $forum_id \ + -party_id $user_id \ + -privilege forum_create] + } + + ad_proc -public require_post_forum { + {-user_id ""} + {-forum_id:required} + } { + + } + + ad_proc -public can_post_message_p { + {-user_id ""} + {-message_id:required} + } { + # hack + return 1 + } + + ad_proc -public require_post_message { + {-user_id ""} + {-message_id:required} + } { + + } + + ad_proc -public can_moderate_forum_p { + {-user_id ""} + {-forum_id:required} + } { + # hack + return 1 + } + + ad_proc -public require_moderate_forum { + {-user_id ""} + {-forum_id:required} + } { + + } + + ad_proc -public can_moderate_message_p { + {-user_id ""} + {-message_id:required} + } { + # hack + return 1 + } + + ad_proc -public require_moderate_message { + {-user_id ""} + {-message_id:required} + } { + + } + + ad_proc -public can_admin_forum_p { + {-user_id ""} + {-forum_id:required} + } { + # hack + return 1 + } + + ad_proc -public require_admin_forum { + {-user_id ""} + {-forum_id:required} + } { + + } +} Index: openacs-4/packages/forums/tcl/messages-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/messages-procs-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/tcl/messages-procs-oracle.xql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,43 @@ + + + oracle8.1.6 + + + +select message_id, forum_id, subject, content, person.name(user_id) as user_name, +party.email(user_id) as user_email, +forums_forum.name(forum_id) as forum_name, +forums_message.root_message_id(forums_messages.message_id) as root_message_id, +(select subject from forums_messages fm2 +where message_id= forums_message.root_message_id(forums_messages.message_id)) as root_subject, +posting_date, tree_sortkey, parent_id, state, html_p +from forums_messages +where message_id= :message_id + + + + + +declare begin + forums_message.delete_thread(:message_id); +end; + + + + + +declare begin +forums_message.thread_close(:message_id); +end; + + + + + +declare begin +forums_message.thread_open(:message_id); +end; + + + + Index: openacs-4/packages/forums/tcl/messages-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/messages-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/tcl/messages-procs.tcl 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,154 @@ +ad_library { + + Forums Library - for Messages + + @creation-date 2002-05-20 + @author Ben Adida + @cvs-id $Id: messages-procs.tcl,v 1.1 2002/05/29 21:40:10 ben Exp $ + +} + +namespace eval forum::message { + + ad_proc -public new { + {-forum_id:required} + {-message_id ""} + {-parent_id ""} + {-subject:required} + {-content:required} + {-html_p "f"} + {-user_id ""} + } { + create a new message + } { + # If no user_id is provided, we set it + # to the currently logged-in user + if {[empty_string_p $user_id]} { + set user_id [ad_conn user_id] + } + + # Prepare the variables for instantiation + set extra_vars [ns_set create] + oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {forum_id message_id parent_id subject content html_p user_id} + + db_transaction { + # Instantiate the message + set message_id [package_instantiate_object -extra_vars $extra_vars forums_message] + + do_notifications -message_id $message_id + } + + return $message_id + } + + ad_proc -public do_notifications { + {-message_id:required} + } { + # Select all the important information + get -message_id $message_id -array message + + set new_content "$message(user_name) ($message(user_email)) posted on [util_AnsiDatetoPrettyDate $message(posting_date)]:" + append new_content "\n\n" + append new_content $message(content) + + # Do the notification for the forum + notification::new -type_id [notification::type::get_type_id -short_name forums_forum_notif] \ + -object_id $message(forum_id) -response_id $message(message_id) -notif_subject $message(subject) -notif_text $new_content + + # Eventually we need notification for the root message too + # FIXME + } + + ad_proc -public edit { + {-message_id:required} + {-subject:required} + {-content:required} + {-html_p:required} + } { + Editing a message. There is no versioning here! + This means this function is for admins only! + } { + # do the update + db_dml update_message {} + } + + ad_proc -public set_html_p { + {-message_id:required} + {-html_p:required} + } { + set whether a message is HTML or not + } { + # Straight update to the DB + db_dml update_message_html_p + } + + ad_proc -public get { + {-message_id:required} + {-array:required} + } { + get the fields for a forum + } { + # Select the info into the upvar'ed Tcl Array + upvar $array row + db_1row select_message {} -column_array row + } + + ad_proc -private set_state { + {-message_id:required} + {-state:required} + } { + Set the new state for a message + Usually used for approval + } { + # simple DB update + db_dml update_message_state {} + } + + ad_proc -public reject { + {-message_id:required} + } { + Reject a message + } { + set_state -message_id $message_id -state rejected + } + + ad_proc -public approve { + {-message_id:required} + } { + approve a message + } { + set_state -message_id $message_id -state approved + } + + ad_proc -public delete { + {-message_id:required} + } { + delete a message and obviously all of its descendents + } { + db_transaction { + # Remove the notifications + notification::request::delete_all -object_id $message_id + + # Remove the message + db_exec_plsql delete_message {} + } + } + + ad_proc -public close { + {-message_id:required} + } { + close a thread + This is not exactly a cheap operation if the thread is long + } { + db_exec_plsql thread_close {} + } + + ad_proc -public open { + {-message_id:required} + } { + reopen a thread + This is not exactly a cheap operation if the thread is long + } { + db_exec_plsql thread_open {} + } +} Index: openacs-4/packages/forums/tcl/messages-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/messages-procs.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/tcl/messages-procs.xql 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,31 @@ + + + + + +update forums_messages set +html_p= :html_p +where +message_id= :message_id + + + + + +update forums_messages set +subject= :subject, +content= :content, +html_p= :html_p +where message_id= :message_id + + + + + +update forums_messages set +state= :state +where message_id= :message_id + + + + Index: openacs-4/packages/forums/www/forum-view-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/Attic/forum-view-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/forum-view-oracle.xql 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,24 @@ + + + + + + select message_id, subject, user_id, person.name(user_id) as user_name, posting_date, state + from forums_messages_approved + where forum_id = :forum_id + and parent_id is NULL + order by posting_date desc + + + + + + select message_id, subject, user_id, person.name(user_id) as user_name, posting_date, state + from forums_messages + where forum_id = :forum_id + and parent_id is NULL + order by posting_date desc + + + + Index: openacs-4/packages/forums/www/forum-view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/forum-view.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/forum-view.adp 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,21 @@ + +Forum: @forum.name@ +@context_bar@ + + +[Administer this Forum]   + + +[Manage/Moderate this Forum] + + +

+@notification_chunk@ +

+ + Index: openacs-4/packages/forums/www/forum-view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/forum-view.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/forum-view.tcl 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,39 @@ + +ad_page_contract { + + One Forum View + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-24 + @cvs-id $Id: forum-view.tcl,v 1.1 2002/05/29 21:40:10 ben Exp $ +} { + forum_id:integer,notnull +} + +# Security Check +forum::security::require_read_forum -forum_id $forum_id + +set package_id [ad_conn package_id] + +set user_id [ad_verify_and_get_user_id] +set admin_p [forum::security::can_admin_forum_p -forum_id $forum_id] +set moderate_p [forum::security::can_moderate_forum_p -forum_id $forum_id] + +# Get forum data +forum::get -forum_id $forum_id -array forum + +if {!$moderate_p} { + # Normal select + db_multirow messages messages_select {} +} else { + # Moderator select! + db_multirow messages messages_select_moderator {} +} + +set post_p [forum::security::can_post_forum_p -forum_id $forum_id] + +set notification_chunk [notification::display::request_widget -type forums_forum_notif -object_id $forum_id -pretty_name $forum(name) -url [ad_conn url]?forum_id=$forum_id] + +set context_bar [list $forum(name)] + +ad_return_template Index: openacs-4/packages/forums/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/index.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/index.adp 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,12 @@ + +Forums +@context_bar@ + + Index: openacs-4/packages/forums/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/index.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/index.tcl 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,29 @@ + +ad_page_contract { + + List of Forums + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-24 + @cvs-id $Id: index.tcl,v 1.1 2002/05/29 21:40:10 ben Exp $ +} { +} + +set package_id [ad_conn package_id] + +set user_id [ad_verify_and_get_user_id] +set admin_p [ad_permission_p $package_id admin] + +db_multirow forums forums_select { + select forum_id, name, posting_policy + from forums_forums_enabled + where package_id = :package_id + and + (posting_policy= 'open' or posting_policy= 'moderated' or + acs_permission.permission_p(:user_id, forum_id, 'forum_read') ='t') + order by name +} + +set context_bar "" + +ad_return_template Index: openacs-4/packages/forums/www/master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/Attic/master.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/master.adp 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,7 @@ + +@title@ +@context_bar@ +

@title@

+
+

+ Index: openacs-4/packages/forums/www/master.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/Attic/master.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/master.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,6 @@ + +if {[info exists context_bar]} { + set context_bar [eval ad_context_bar $context_bar] +} else { + set context_bar "" +} Index: openacs-4/packages/forums/www/message-email.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-email.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/message-email.adp 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,13 @@ + +Email Message: @message.forum_name@ - @message.subject@ + + +You're emailing a copy of a posting to a friend.

+Subject of Posting: @message.subject@
+Body of Posting:
+

+@message.content@ +
+

+ + Index: openacs-4/packages/forums/www/message-email.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-email.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/message-email.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,56 @@ + +ad_page_contract { + + Forward a message to a friend + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-28 + @cvs-id $id: Exp $ +} { + message_id:integer,notnull +} + +form create message + +element create message message_id \ + -label "Message ID" -datatype integer -widget hidden + +element create message to_email \ + -label "Email" -datatype text -widget text -html {size 60} + +element create message subject \ + -label "Subject" -datatype text -widget text -html {size 80} + +element create message pre_body \ + -label "Your Note" -datatype text -widget textarea -html {cols 80 rows 10 wrap hard} + + +if {[form is_valid message]} { + template::form get_values message message_id to_email subject pre_body + + # Get the data + forum::message::get -message_id $message_id -array message + + set new_body "$pre_body" + append new_body "\n\n===================================\n\n" + append new_body "$message(user_name) wrote, on [util_AnsiDatetoPrettyDate $message(posting_date)]:\n" + append new_body "Subject: $message(subject)\n\n" + append new_body "$message(content)\n" + + # Send the email + acs_mail_lite::send -to_addr $to_email \ + -from_addr [cc_email_from_party [ad_conn user_id]] \ + -subject $subject \ + -body $new_body + + ad_returnredirect "message-view?message_id=$message_id" + ad_script_abort +} + +# Get the message information +forum::message::get -message_id $message_id -array message + +element set_properties message subject -value "\[Fwd from $message(user_name): $message(subject)\]" +element set_properties message message_id -value $message_id + +ad_return_template Index: openacs-4/packages/forums/www/message-post.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-post.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/message-post.adp 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,5 @@ + +Post to Forum: @forum.name@ + + + Index: openacs-4/packages/forums/www/message-post.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-post.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/message-post.tcl 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,70 @@ + +ad_page_contract { + + Form to create message and insert it + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-25 + @cvs-id $id: Exp $ +} { + {forum_id ""} + {parent_id ""} +} + +# Either forum_id or parent_id has to be non-null +if {[empty_string_p $forum_id] && [empty_string_p $parent_id]} { + # error! + return -code error +} + +# We would use the nice ad_form construct if we could +form create message + +element create message message_id \ + -label "Message ID" -datatype integer -widget hidden + +element create message subject \ + -label "Subject" -datatype text -widget text -html {size 60} + +element create message content \ + -label "Body" -datatype text -widget textarea -html {rows 30 cols 60 wrap soft} + +element create message parent_id \ + -label "parent ID" -datatype integer -widget hidden -optional + +element create message forum_id \ + -label "forum ID" -datatype integer -widget hidden + +element create message html_p \ + -label "Format" -datatype text -widget select -options {{text f} {html t}} + +if {[form is_valid message]} { + template::form get_values message message_id forum_id parent_id subject content html_p + + forum::message::new -forum_id $forum_id \ + -message_id $message_id \ + -parent_id $parent_id \ + -subject $subject \ + -content $content \ + -html_p $html_p + + ad_returnredirect "message-view?message_id=$message_id" + ad_script_abort +} + +set message_id [db_nextval acs_object_id_seq] + +if {[empty_string_p $forum_id]} { + # get the parent message information + forum::message::get -message_id $parent_id -array parent_message + set forum_id $parent_message(forum_id) +} + +forum::get -forum_id $forum_id -array forum + +# Prepare the other data +element set_properties message forum_id -value $forum_id +element set_properties message parent_id -value $parent_id +element set_properties message message_id -value $message_id + +ad_return_template Index: openacs-4/packages/forums/www/message-post.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/Attic/message-post.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/message-post.xql 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,10 @@ + + + + + +select forum_id from forums_messages where message_id= :parent_id + + + + Index: openacs-4/packages/forums/www/message-view-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-view-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/message-view-oracle.xql 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,25 @@ + + + oracle8.1.6 + + + +select message_id, subject, content, person.name(user_id) as user_name, posting_date, tree.tree_level(tree_sortkey) as tree_level, state, user_id +from forums_messages_approved +where forum_id= :forum_id +and tree_sortkey between tree.left(:tree_sortkey) and tree.right(:tree_sortkey) +order by tree_sortkey + + + + + +select message_id, subject, content, person.name(user_id) as user_name, posting_date, tree.tree_level(tree_sortkey) as tree_level, state, user_id +from forums_messages +where forum_id= :forum_id +and tree_sortkey between tree.left(:tree_sortkey) and tree.right(:tree_sortkey) +order by tree_sortkey + + + + Index: openacs-4/packages/forums/www/message-view-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-view-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/message-view-postgresql.xql 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,12 @@ + + + postgresql7.1 + + + +select message_id, subject, content, party__name(user_id) as user_name, posting_date from forums_messages +where parent_id= :message_id order by posting_date + + + + Index: openacs-4/packages/forums/www/message-view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-view.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/message-view.adp 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,37 @@ + +Forum @forum.name@: @message.subject@ +@context_bar@ + +

+@notification_chunk@ +

+ + +response to @message.root_subject@

+ + +@message.subject@ + +

+ +

+@message.content@ +
+ +

+Respond! +  |   +Email + + +

+Administration: [@message.state@] [ delete | approve | reject | edit] + + +

Responses

+ + Index: openacs-4/packages/forums/www/message-view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/message-view.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/message-view.tcl 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,58 @@ + +ad_page_contract { + + View a message (and its children) + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-25 + @cvs-id $id: Exp $ +} { + message_id:integer,notnull +} + +# Security +forum::security::require_read_message -message_id $message_id + +# Check if the user has admin on the message +set moderate_p [forum::security::can_moderate_message_p -message_id $message_id] +set post_p [forum::security::can_post_message_p -message_id $message_id] + +# Load up the message information +forum::message::get -message_id $message_id -array message + +# Check if the message is approved +if {!$moderate_p && $message(state) != "approved"} { + ad_returnredirect "forum-view?forum_id=$message(forum_id)" + ad_script_abort +} + +# Load up the forum information +forum::get -forum_id $message(forum_id) -array forum + +# Check preferences for user + +# Set some variables for easy SQL access +set forum_id $message(forum_id) +set tree_sortkey $message(tree_sortkey) + +if {!$moderate_p} { + # Select publicly viewable items + db_multirow responses select_message_responses {} +} else { + # Select all items + db_multirow responses select_message_responses_moderator {} +} + +# If this is a top-level thread, we allow subscriptions here +if {[empty_string_p $message(parent_id)]} { + set notification_chunk [notification::display::request_widget -type forums_message_notif -object_id $message_id -pretty_name $message(subject) -url [ad_conn url]?message_id=$message_id] +} else { + set notification_chunk "" +} + +set context_bar [list [list "./forum-view?forum_id=$message(forum_id)" "$message(forum_name)"] {One Message}] + +ad_return_template + + + Index: openacs-4/packages/forums/www/messsage-view-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/Attic/messsage-view-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/messsage-view-oracle.xql 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,12 @@ + + + oracle8.1.6 + + + +select message_id, subject, content, party.name(user_id) as user_name, posting_date from forums_messages +where parent_id= :message_id order by posting_date + + + + Index: openacs-4/packages/forums/www/test.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/Attic/test.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/test.tcl 29 May 2002 21:40:10 -0000 1.1 @@ -0,0 +1,9 @@ + +db_transaction { + # create the forum + set forum_id [forum::new -name "test" -charter "test chrater" -presentation_type "flat" -posting_policy "open" -package_id [ad_conn package_id]] + + set msg_id [forum::message::new -forum_id $forum_id -subject "Test" -content "this is rocking content" -user_id [ad_conn user_id]] +} + +doc_body_append $msg_id Index: openacs-4/packages/forums/www/user-history-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/Attic/user-history-oracle.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/user-history-oracle.xql 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,16 @@ + + + oracle8.1.6 + + + +select message_id, subject, posting_date, forums_forums.forum_id, forums_forums.name as forum_name +from forums_messages, forums_forums +where forums_messages.forum_id = forums_forums.forum_id +and user_id= :user_id +and package_id = :package_id +$sql_order_by + + + + Index: openacs-4/packages/forums/www/user-history.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/user-history.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/user-history.adp 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,27 @@ + +Forums: Posting History for @user.full_name@ +@context_bar@ + +
+@dimensional_chunk@ +
+

+ +

Index: openacs-4/packages/forums/www/user-history.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/user-history.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/user-history.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,38 @@ + +ad_page_contract { + + Posting History for a User + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-29 + @cvs-id $id: Exp $ +} { + user_id:integer,notnull + {view "date"} +} + +set package_id [ad_conn package_id] + +# FIXME: for now this shows all postings everywhere in all forums! + +# choosing the view +set dimensional_list { + { + view "View:" date { + {date "by Date" { order by date desc } } + {forum "by Forum" { order by forums_forums.name, date desc } } + } + } +} + +set sql_order_by [ad_dimensional_sql $dimensional_list] + +# Select the postings +db_multirow messages select_messages {} + +# Get user information +oacs::user::get -user_id $user_id -array user + +set dimensional_chunk [ad_dimensional $dimensional_list] +set context_bar {{Posting History}} +ad_return_template Index: openacs-4/packages/forums/www/admin/forum-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/admin/Attic/forum-add-edit.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/admin/forum-add-edit.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,17 @@ + +ad_page_contract { + + create or edit a forum + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-24 + @cvs-id $Id: forum-add-edit.tcl,v 1.1 2002/05/29 21:40:11 ben Exp $ +} { +} + +# Load up forum information + +# use ad_form to do some funky stuff with loading up or editing a forum + + + Index: openacs-4/packages/forums/www/admin/forum-disable.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/admin/forum-disable.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/admin/forum-disable.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,15 @@ + +ad_page_contract { + + Disable a Forum + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-28 + @cvs-id $id: Exp $ +} { + forum_id:integer,notnull +} + +forum::disable -forum_id $forum_id + +ad_returnredirect "./" Index: openacs-4/packages/forums/www/admin/forum-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/admin/forum-edit.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/admin/forum-edit.adp 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,5 @@ + +Edit Forum: @forum.name@ + + + Index: openacs-4/packages/forums/www/admin/forum-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/admin/forum-edit.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/admin/forum-edit.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,71 @@ + +ad_page_contract { + + Edit a Forum + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-25 + @cvs-id $id: Exp $ +} { + forum_id:integer,notnull +} + +form create forum + +element create forum forum_id \ + -label "Forum ID" -datatype integer -widget hidden + +element create forum name \ + -label "Name" -datatype text -widget text -html {size 60} + +element create forum charter \ + -label "Charter" -datatype text -widget textarea -html {cols 60 rows 10 wrap soft} + +element create forum presentation_type \ + -label "Presentation" -datatype text -widget select -options {{Flat flat} {Threaded threaded}} + +element create forum posting_policy \ + -label "Posting Policy" -datatype text -widget select -options {{open open} {moderated moderated} {closed closed}} + +element create forum new_threads_p \ + -label "Users Can Create New Threads" -datatype integer -widget radio -options {{yes 1} {no 0}} + +if {[form is_valid forum]} { + template::form get_values forum forum_id name charter presentation_type posting_policy new_threads_p + + forum::edit -forum_id $forum_id \ + -name $name \ + -charter $charter \ + -presentation_type $presentation_type \ + -posting_policy $posting_policy + + # Users can create new threads? + if {$new_threads_p} { + forum::new_questions_allow -forum_id $forum_id + } else { + forum::new_questions_deny -forum_id $forum_id + } + + ad_returnredirect "../forum-view?forum_id=$forum_id" + ad_script_abort +} + +# Select the info +set package_id [ad_conn package_id] +forum::get -forum_id $forum_id -array forum + +# Proper scoping? +if {$package_id != $forum(package_id)} { + ns_log Error "Forum Administration: Bad Scoping of Forum #$forum_id in Forum Editing" + ad_returnredirect "./" + ad_script_abort +} + +element set_properties forum forum_id -value $forum_id +element set_properties forum name -value $forum(name) +element set_properties forum charter -value $forum(charter) +element set_properties forum presentation_type -value $forum(presentation_type) +element set_properties forum posting_policy -value $forum(posting_policy) +element set_properties forum new_threads_p -value [forum::new_questions_allowed_p -forum_id $forum_id] + +ad_return_template Index: openacs-4/packages/forums/www/admin/forum-enable.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/admin/forum-enable.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/admin/forum-enable.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,15 @@ + +ad_page_contract { + + Disable a Forum + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-28 + @cvs-id $id: Exp $ +} { + forum_id:integer,notnull +} + +forum::enable -forum_id $forum_id + +ad_returnredirect "./" Index: openacs-4/packages/forums/www/admin/forum-new.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/admin/forum-new.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/admin/forum-new.adp 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,5 @@ + +Create New Forum + + + Index: openacs-4/packages/forums/www/admin/forum-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/admin/forum-new.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/admin/forum-new.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,61 @@ + +ad_page_contract { + + Create a Forum + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-25 + @cvs-id $id: Exp $ +} { +} + +# scoping +set package_id [ad_conn package_id] + +form create forum + +element create forum forum_id \ + -label "Forum ID" -datatype integer -widget hidden + +element create forum name \ + -label "Name" -datatype text -widget text -html {size 60} + +element create forum charter \ + -label "Charter" -datatype text -widget textarea -html {cols 60 rows 10 wrap soft} + +element create forum presentation_type \ + -label "Presentation" -datatype text -widget select -options {{Flat flat} {Threaded threaded}} + +element create forum posting_policy \ + -label "Posting Policy" -datatype text -widget select -options {{open open} {moderated moderated} {closed closed}} + +element create forum new_threads_p \ + -label "Users Can Create New Threads" -datatype integer -widget radio -options {{yes 1} {no 0}} + +if {[form is_valid forum]} { + template::form get_values forum forum_id name charter presentation_type posting_policy new_threads_p + + set forum_id [forum::new -forum_id $forum_id \ + -name $name \ + -charter $charter \ + -presentation_type $presentation_type \ + -posting_policy $posting_policy \ + -package_id $package_id] + + # Users can create new threads? + if {$new_threads_p} { + forum::new_questions_allow -forum_id $forum_id + } else { + forum::new_questions_deny -forum_id $forum_id + } + + ad_returnredirect "../" + ad_script_abort +} + +# Pre-fetch the forum_id +set forum_id [db_nextval acs_object_id_seq] +element set_properties forum forum_id -value $forum_id +element set_properties forum new_threads_p -value 1 + +ad_return_template Index: openacs-4/packages/forums/www/admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/admin/index.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/admin/index.adp 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,21 @@ + +Forums Administration + + +

Forums

+ Index: openacs-4/packages/forums/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/admin/index.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/admin/index.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,19 @@ + +ad_page_contract { + + Forums Administration + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-24 + @cvs-id $Id: index.tcl,v 1.1 2002/05/29 21:40:11 ben Exp $ +} { +} + +# scoping +set package_id [ad_conn package_id] + +# List of forums +db_multirow forums select_forums {} + +ad_return_template + Index: openacs-4/packages/forums/www/admin/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/admin/Attic/index.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/admin/index.xql 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,13 @@ + + + + + +select forum_id, name, posting_policy, enabled_p +from forums_forums +where package_id= :package_id +order by enabled_p desc, name + + + + Index: openacs-4/packages/forums/www/moderate/forum.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/moderate/forum.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/moderate/forum.adp 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,16 @@ + +Manage Forum: @forum.name@ + + +

Pending Threads

+ + Index: openacs-4/packages/forums/www/moderate/forum.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/moderate/forum.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/moderate/forum.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,22 @@ + +ad_page_contract { + + Moderate a Forum + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-24 + @cvs-id $Id: forum.tcl,v 1.1 2002/05/29 21:40:11 ben Exp $ +} { + forum_id:integer,notnull +} + +# Check that the user can moderate the forum +forum::security::require_moderate_forum -forum_id $forum_id + +# Get forum data +forum::get -forum_id $forum_id -array forum + +# Get the threads that need approval +db_multirow pending_threads select_pending_threads {} + +ad_return_template Index: openacs-4/packages/forums/www/moderate/forum.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/moderate/Attic/forum.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/moderate/forum.xql 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,21 @@ + + + + + +select message_id, subject, user_id, posting_date, state, +tree.tree_level(tree_sortkey) as tree_level +from forums_messages +where message_id in +(select message_id +from forums_messages_pending +where forum_id= :forum_id) +or tree_sortkey in +(select substr(tree_sortkey,1,6) +from forums_messages_pending +where forum_id= :forum_id) +order by tree_sortkey + + + + Index: openacs-4/packages/forums/www/moderate/message-approve.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/moderate/message-approve.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/moderate/message-approve.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,20 @@ + +ad_page_contract { + + Approve a Message + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-24 + @cvs-id $Id: message-approve.tcl,v 1.1 2002/05/29 21:40:11 ben Exp $ +} { + message_id:integer,notnull + {return_url "../message-view"} +} + +# Check that the user can moderate the forum +forum::security::require_moderate_message -message_id $message_id + +# Approve the message +forum::message::approve -message_id $message_id + +ad_returnredirect "$return_url?message_id=$message_id" Index: openacs-4/packages/forums/www/moderate/message-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/moderate/message-delete.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/moderate/message-delete.adp 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,20 @@ + +Confirm Delete: @message.subject@ + + +Are you sure you want to delete this message? +

+@message.subject@ + +

+ +

+@message.content@ +
+ +

+ +Yes +

+No +

Index: openacs-4/packages/forums/www/moderate/message-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/moderate/message-delete.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/moderate/message-delete.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,31 @@ + +ad_page_contract { + + Delete a Message + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-24 + @cvs-id $Id: message-delete.tcl,v 1.1 2002/05/29 21:40:11 ben Exp $ +} { + message_id:integer,notnull + {return_url ""} + {confirm_p 0} +} + +# Check that the user can moderate the forum +forum::security::require_moderate_message -message_id $message_id + +# Select the stuff +forum::message::get -message_id $message_id -array message + +# Confirm? +if {!$confirm_p} { + set url_vars [export_url_vars message_id return_url] + ad_return_template +} else { + # Delete the message and all children + forum::message::delete -message_id $message_id + + # Redirect to the forum + ad_returnredirect "../forum-view?forum_id=$message(forum_id)" +} Index: openacs-4/packages/forums/www/moderate/message-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/moderate/message-edit.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/moderate/message-edit.adp 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,5 @@ + +Edit Message: @message.subject@ + + + Index: openacs-4/packages/forums/www/moderate/message-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/moderate/message-edit.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/moderate/message-edit.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,51 @@ + +ad_page_contract { + + Form to edit a message + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-25 + @cvs-id $id: Exp $ +} { + message_id:integer,notnull + {return_url "../message-view"} +} + +# We would use the nice ad_form construct if we could +form create message + +element create message message_id \ + -label "Message ID" -datatype integer -widget hidden + +element create message subject \ + -label "Subject" -datatype text -widget text -html {size 60} + +element create message content \ + -label "Body" -datatype text -widget textarea -html {rows 30 cols 60 wrap soft} + +element create message html_p \ + -label "Format" -datatype text -widget select -options {{text f} {html t}} + +if {[form is_valid message]} { + template::form get_values message message_id subject content html_p + + forum::message::edit \ + -message_id $message_id \ + -subject $subject \ + -content $content \ + -html_p $html_p + + ad_returnredirect "$return_url?message_id=$message_id" + ad_script_abort +} + +forum::message::get -message_id $message_id -array message +forum::get -forum_id $message(forum_id) -array forum + +# Prepare the other data +element set_properties message message_id -value $message_id +element set_properties message subject -value $message(subject) +element set_properties message content -value $message(content) +element set_properties message html_p -value $message(html_p) + +ad_return_template Index: openacs-4/packages/forums/www/moderate/message-reject.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/moderate/message-reject.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/forums/www/moderate/message-reject.tcl 29 May 2002 21:40:11 -0000 1.1 @@ -0,0 +1,20 @@ + +ad_page_contract { + + Reject a Message + + @author Ben Adida (ben@openforce) + @creation-date 2002-05-24 + @cvs-id $Id: message-reject.tcl,v 1.1 2002/05/29 21:40:11 ben Exp $ +} { + message_id:integer,notnull + {return_url "../message-view"} +} + +# Check that the user can moderate the forum +forum::security::require_moderate_message -message_id $message_id + +# Reject the message +forum::message::reject -message_id $message_id + +ad_returnredirect "$return_url?message_id=$message_id"