Index: openacs-4/packages/faq/faq.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/faq.info,v diff -u -r1.10 -r1.11 --- openacs-4/packages/faq/faq.info 11 Dec 2003 21:40:03 -0000 1.10 +++ openacs-4/packages/faq/faq.info 1 Apr 2004 22:52:45 -0000 1.11 @@ -7,17 +7,20 @@ f f - + Jennie Kim Housman Elizabeth Wirth Manage simple Question and Answer style FAQs 2003-11-10 Ybos Corporation Handles frequently asked questions Q&A presentation. Can be one Q&A per page or all presented flat. Straightforward application with room for improvement. - - + + - + + + + Index: openacs-4/packages/faq/sql/oracle/faq-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/sql/oracle/faq-create.sql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/faq/sql/oracle/faq-create.sql 30 Sep 2003 12:10:07 -0000 1.4 +++ openacs-4/packages/faq/sql/oracle/faq-create.sql 1 Apr 2004 22:52:45 -0000 1.5 @@ -1,6 +1,9 @@ --- @jennie.ybos.net --- @wirth.ybos.net - +-- Datamodel create for faq +-- +-- @author @jennie.ybos.net,@wirth.ybos.net,openacs port @samir.symphinity.com +-- +-- @cvs-id $Id$ +-- begin acs_object_type.create_type ( supertype => 'acs_object', @@ -57,209 +60,6 @@ -create or replace package faq -as - - function new_faq ( - faq_id in faqs.faq_id%TYPE default null, - faq_name in faqs.faq_name%TYPE, - separate_p in faqs.separate_p%TYPE default 'f', - object_type in acs_objects.object_type%TYPE default 'faq', - 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 acs_objects.object_id%TYPE; - - - - procedure delete_faq ( - faq_id in faqs.faq_id%TYPE - ); - - - function new_q_and_a ( - entry_id in faq_q_and_as.entry_id%TYPE default null, - faq_id in faq_q_and_as.faq_id%TYPE, - question in faq_q_and_as.question%TYPE, - answer in faq_q_and_as.answer%TYPE, - sort_key in faq_q_and_as.sort_key%TYPE, - object_type in acs_objects.object_type%TYPE default 'faq_q_and_a', - 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 acs_objects.object_id%TYPE; - - - - procedure delete_q_and_a ( - entry_id in faq_q_and_as.entry_id%TYPE - ); - - - procedure clone ( - old_package_id in apm_packages.package_id%TYPE default NULL, - new_package_id in apm_packages.package_id%TYPE default NULL - ); - - -end faq; -/ -show errors - - - - -create or replace package body faq -as - function new_q_and_a ( - entry_id in faq_q_and_as.entry_id%TYPE default null, - faq_id in faq_q_and_as.faq_id%TYPE, - question in faq_q_and_as.question%TYPE, - answer in faq_q_and_as.answer%TYPE, - sort_key in faq_q_and_as.sort_key%TYPE, - object_type in acs_objects.object_type%TYPE default 'faq_q_and_a', - 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 acs_objects.object_id%TYPE - is - v_entry_id faq_q_and_as.entry_id%TYPE; - begin - v_entry_id := acs_object.new ( - object_id => entry_id, - object_type => object_type, - creation_date => creation_date, - creation_user => creation_user, - creation_ip => creation_ip, - context_id => context_id - ); - insert into faq_q_and_as - (entry_id, faq_id, question, answer, sort_key) - values - (v_entry_id, new_q_and_a.faq_id, new_q_and_a.question, new_q_and_a.answer, new_q_and_a.sort_key); - - return v_entry_id; - end new_q_and_a; - - - - - procedure delete_q_and_a ( - entry_id in faq_q_and_as.entry_id%TYPE - ) - is - begin - delete from faq_q_and_as where entry_id = faq.delete_q_and_a.entry_id; - acs_object.del(entry_id); - end delete_q_and_a; - - - - - function new_faq ( - faq_id in faqs.faq_id%TYPE default null, - faq_name in faqs.faq_name%TYPE, - separate_p in faqs.separate_p%TYPE default 'f', - object_type in acs_objects.object_type%TYPE default 'faq', - 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 acs_objects.object_id%TYPE - is - v_faq_id faqs.faq_id%TYPE; - begin - - v_faq_id := acs_object.new ( - object_id => faq_id, - object_type => object_type, - creation_date => creation_date, - creation_user => creation_user, - creation_ip => creation_ip, - context_id => context_id - ); - insert into faqs - (faq_id, faq_name,separate_p) - values - (v_faq_id, new_faq.faq_name,new_faq.separate_p); - - return v_faq_id; - end new_faq; - - - procedure delete_faq ( - faq_id faqs.faq_id%TYPE - ) - is - begin - - -- Because q_and_a's are objects, we need to - -- loop through a list of them, and call an explicit - -- delete function for each one. (i.e. each - -- entry_id) - - declare cursor q_and_a_cur is - select entry_id from faq_q_and_as where faq_id = faq.delete_faq.faq_id; - begin - for entry_list in q_and_a_cur - loop - delete_q_and_a(entry_list.entry_id); - end loop; - end; - - delete from faqs where faq_id=faq.delete_faq.faq_id; - acs_object.del(faq_id); - - end delete_faq; - - - procedure clone ( - old_package_id in apm_packages.package_id%TYPE default null, - new_package_id in apm_packages.package_id%TYPE default null - ) - is - v_faq_id faqs.faq_id%TYPE; - v_entry_id faq_q_and_as.entry_id%TYPE; - begin - -- get all the faqs belonging to the old package, - -- and create new faqs for the new package - for one_faq in (select * - from acs_objects o, faqs f - where o.object_id = f.faq_id - and o.context_id = faq.clone.old_package_id) - loop - - -- faq is "scoped" by using the acs_objects.context_id - v_faq_id := faq.new_faq ( - faq_name => one_faq.faq_name, - separate_p => one_faq.separate_p, - context_id => faq.clone.new_package_id - ); - - for entry in (select * from faq_q_and_as f - where faq_id = one_faq.faq_id) - loop - -- now (surprise!) copy all the entries of this faq - v_entry_id := faq.new_q_and_a ( - context_id => entry.faq_id, - faq_id=> v_faq_id, - question => entry.question, - answer => entry.answer, - sort_key => entry.sort_key - ); - end loop; - end loop; - end clone; - - -end faq; -/ -show errors - - declare default_context acs_objects.object_id%TYPE; registered_users acs_objects.object_id%TYPE; @@ -321,3 +121,5 @@ end; / + +@@ faq-package-create.sql \ No newline at end of file Index: openacs-4/packages/faq/sql/oracle/faq-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/sql/oracle/faq-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq/sql/oracle/faq-package-create.sql 1 Apr 2004 22:52:45 -0000 1.1 @@ -0,0 +1,217 @@ +-- Package create for faq +-- +-- @author @jennie.ybos.net,@wirth.ybos.net,openacs port @samir.symphinity.com +-- +-- @cvs-id $Id: faq-package-create.sql,v 1.1 2004/04/01 22:52:45 jeffd Exp $ +-- + +create or replace package faq +as + + function new_faq ( + faq_id in faqs.faq_id%TYPE default null, + faq_name in faqs.faq_name%TYPE, + separate_p in faqs.separate_p%TYPE default 'f', + object_type in acs_objects.object_type%TYPE default 'faq', + 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 acs_objects.object_id%TYPE; + + + + procedure delete_faq ( + faq_id in faqs.faq_id%TYPE + ); + + + function new_q_and_a ( + entry_id in faq_q_and_as.entry_id%TYPE default null, + faq_id in faq_q_and_as.faq_id%TYPE, + question in faq_q_and_as.question%TYPE, + answer in faq_q_and_as.answer%TYPE, + sort_key in faq_q_and_as.sort_key%TYPE, + object_type in acs_objects.object_type%TYPE default 'faq_q_and_a', + 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 acs_objects.object_id%TYPE; + + + + procedure delete_q_and_a ( + entry_id in faq_q_and_as.entry_id%TYPE + ); + + + procedure clone ( + old_package_id in apm_packages.package_id%TYPE default NULL, + new_package_id in apm_packages.package_id%TYPE default NULL + ); + + +end faq; +/ +show errors + + + + +create or replace package body faq +as + function new_q_and_a ( + entry_id in faq_q_and_as.entry_id%TYPE default null, + faq_id in faq_q_and_as.faq_id%TYPE, + question in faq_q_and_as.question%TYPE, + answer in faq_q_and_as.answer%TYPE, + sort_key in faq_q_and_as.sort_key%TYPE, + object_type in acs_objects.object_type%TYPE default 'faq_q_and_a', + 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 acs_objects.object_id%TYPE + is + v_entry_id faq_q_and_as.entry_id%TYPE; + v_package_id acs_objects.package_id%TYPE; + begin + select package_id into v_package_id from acs_objects where object_id = p_faq_id; + + v_entry_id := acs_object.new ( + object_id => entry_id, + object_type => object_type, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => context_id, + package_id => v_package_id, + title => question + ); + insert into faq_q_and_as + (entry_id, faq_id, question, answer, sort_key) + values + (v_entry_id, new_q_and_a.faq_id, new_q_and_a.question, new_q_and_a.answer, new_q_and_a.sort_key); + + return v_entry_id; + end new_q_and_a; + + + + + procedure delete_q_and_a ( + entry_id in faq_q_and_as.entry_id%TYPE + ) + is + begin + delete from faq_q_and_as where entry_id = faq.delete_q_and_a.entry_id; + acs_object.del(entry_id); + end delete_q_and_a; + + + + + function new_faq ( + faq_id in faqs.faq_id%TYPE default null, + faq_name in faqs.faq_name%TYPE, + separate_p in faqs.separate_p%TYPE default 'f', + object_type in acs_objects.object_type%TYPE default 'faq', + 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 acs_objects.object_id%TYPE + is + v_faq_id faqs.faq_id%TYPE; + begin + + v_faq_id := acs_object.new ( + object_id => faq_id, + object_type => object_type, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => context_id, + package_id => context_id, + title => faq_name + ); + insert into faqs + (faq_id, faq_name,separate_p) + values + (v_faq_id, new_faq.faq_name,new_faq.separate_p); + + return v_faq_id; + end new_faq; + + + procedure delete_faq ( + faq_id faqs.faq_id%TYPE + ) + is + begin + + -- Because q_and_a's are objects, we need to + -- loop through a list of them, and call an explicit + -- delete function for each one. (i.e. each + -- entry_id) + + declare cursor q_and_a_cur is + select entry_id from faq_q_and_as where faq_id = faq.delete_faq.faq_id; + begin + for entry_list in q_and_a_cur + loop + delete_q_and_a(entry_list.entry_id); + end loop; + end; + + delete from faqs where faq_id=faq.delete_faq.faq_id; + acs_object.del(faq_id); + + end delete_faq; + + + procedure clone ( + old_package_id in apm_packages.package_id%TYPE default null, + new_package_id in apm_packages.package_id%TYPE default null + ) + is + v_faq_id faqs.faq_id%TYPE; + v_entry_id faq_q_and_as.entry_id%TYPE; + begin + -- get all the faqs belonging to the old package, + -- and create new faqs for the new package + for one_faq in (select * + from acs_objects o, faqs f + where o.object_id = f.faq_id + and o.context_id = faq.clone.old_package_id) + loop + + -- faq is "scoped" by using the acs_objects.context_id + v_faq_id := faq.new_faq ( + faq_name => one_faq.faq_name, + separate_p => one_faq.separate_p, + context_id => faq.clone.new_package_id + ); + + for entry in (select * from faq_q_and_as f + where faq_id = one_faq.faq_id) + loop + -- now (surprise!) copy all the entries of this faq + v_entry_id := faq.new_q_and_a ( + context_id => entry.faq_id, + faq_id=> v_faq_id, + question => entry.question, + answer => entry.answer, + sort_key => entry.sort_key + ); + end loop; + end loop; + end clone; + + +end faq; +/ +show errors + + Index: openacs-4/packages/faq/sql/oracle/upgrade/upgrade-5.2.0d1-5.2.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/sql/oracle/upgrade/upgrade-5.2.0d1-5.2.0d2.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq/sql/oracle/upgrade/upgrade-5.2.0d1-5.2.0d2.sql 1 Apr 2004 22:52:45 -0000 1.1 @@ -0,0 +1 @@ +@@ ../faq-package-create.sql Index: openacs-4/packages/faq/sql/postgresql/faq-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/sql/postgresql/faq-create.sql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/faq/sql/postgresql/faq-create.sql 17 May 2003 10:33:37 -0000 1.4 +++ openacs-4/packages/faq/sql/postgresql/faq-create.sql 1 Apr 2004 22:52:46 -0000 1.5 @@ -1,8 +1,9 @@ --- @jennie.ybos.net --- @wirth.ybos.net ---openacs port @samir.symphinity.com - - +-- Datamodel create for faq +-- +-- @author @jennie.ybos.net,@wirth.ybos.net,openacs port @samir.symphinity.com +-- +-- @cvs-id $Id$ +-- create function inline_0 () returns integer as ' begin @@ -16,14 +17,13 @@ null, -- package_name ''f'', -- abstract_p null, -- type_extension_table - ''faq.name'' -- name_method + ''faq__name'' -- name_method ); return 0; end;' language 'plpgsql'; select inline_0 (); - drop function inline_0 (); @@ -75,165 +75,8 @@ sort_key integer not null ); -create function faq__new_q_and_a (integer,integer,varchar,varchar,integer,varchar,timestamptz,integer,varchar,integer - ) returns integer as -' -declare - p_entry_id alias for $1; -- default null, - p_faq_id alias for $2; - p_question alias for $3; - p_answer alias for $4; - p_sort_key alias for $5; - p_object_type alias for $6; -- default faq_q_and_a - p_creation_date alias for $7; --in acs_objects.creation_date%TYPE default sysdate, - p_creation_user alias for $8; --in acs_objects.creation_user%TYPE default null, - p_creation_ip alias for $9; -- in acs_objects.creation_ip%TYPE default null, - p_context_id alias for $10; --in acs_objects.context_id%TYPE default null - v_entry_id faq_q_and_as.entry_id%TYPE; -begin - v_entry_id := acs_object__new ( - p_entry_id, - p_object_type, - p_creation_date, - p_creation_user, - p_creation_ip, - p_context_id - ); - insert into faq_q_and_as - (entry_id, faq_id, question, answer, sort_key) - values - (v_entry_id, p_faq_id, p_question, p_answer, p_sort_key); - return v_entry_id; -end;' language 'plpgsql'; -create function faq__delete_q_and_a (integer) -returns integer as ' -declare - p_entry_id alias for $1; -begin - delete from faq_q_and_as where entry_id = p_entry_id; - raise NOTICE ''Deleting FAQ_Q_and_A...''; - PERFORM acs_object__delete(p_entry_id); - - return 0; - -end;' language 'plpgsql'; - - -create function faq__new_faq (integer, varchar, boolean,varchar,timestamptz,integer,varchar,integer ) -returns integer as ' -declare - p_faq_id alias for $1; - p_faq_name alias for $2; - p_separate_p alias for $3; - p_object_type alias for $4; - p_creation_date alias for $5; - p_creation_user alias for $6; - p_creation_ip alias for $7; - p_context_id alias for $8; - v_faq_id faqs.faq_id%TYPE; -begin - - v_faq_id := acs_object__new ( - p_faq_id, - p_object_type, - p_creation_date, - p_creation_user, - p_creation_ip, - p_context_id - ); - - insert into faqs - (faq_id, faq_name,separate_p) - values - (v_faq_id, p_faq_name,p_separate_p); - -return v_faq_id; - -end;' language 'plpgsql'; - - -create function faq__delete_faq (integer) -returns integer as ' -declare - p_faq_id alias for $1; - del_rec record; -begin - -- Because q_and_as are objects, we need to - -- loop through a list of them, and call an explicit - -- delete function for each one. (i.e. each - -- entry_id) - for del_rec in select entry_id from faq_q_and_as - where faq_id = p_faq_id - loop - PERFORM faq__delete_q_and_a(del_rec.entry_id); - end loop; - - delete from faqs where faq_id = p_faq_id; - - PERFORM acs_object__delete(p_faq_id); - - return 0; - -end;' language 'plpgsql'; - -create function faq__name(integer) -returns varchar as ' -declare - p_faq_id alias for $1; - v_faq_name faqs.faq_name%TYPE; -begin - select faq_name into v_faq_name - from faqs - where faq_id = p_faq_id; - - return v_faq_name; -end; -' language 'plpgsql'; - -create function faq__clone (integer,integer) -returns integer as ' -declare - p_new_package_id alias for $1; --default null, - p_old_package_id alias for $2; --default null - v_faq_id faqs.faq_id%TYPE; - one_faq record; - entry record; - -begin - -- get all the faqs belonging to the old package, - -- and create new faqs for the new package - for one_faq in select * - from acs_objects o, faqs f - where o.object_id = f.faq_id - and o.context_id = p_old_package_id - loop - v_faq_id := faq__new_faq ( - one_faq.faq_name, - one_faq.separate_p, - p_new_package_id - ); - - for entry in select * from faq_q_and_as - where faq_id = one_faq.faq_id - loop - - perform faq__new_q_and_a ( - entry.faq_id, - v_faq_id, - entry.question, - entry.answer, - entry.sort_key - ); - end loop; - end loop; - return 0; - end; -' language 'plpgsql'; - - - select acs_privilege__create_privilege('faq_view_faq'); select acs_privilege__create_privilege('faq_create_faq'); select acs_privilege__create_privilege('faq_delete_faq'); @@ -287,7 +130,7 @@ -- give the public the power to view q_and_as by default PERFORM acs_permission__grant_permission ( default_context,the_public, ''faq_view_q_and_a''); - + return 0; end;' language 'plpgsql'; @@ -298,6 +141,7 @@ drop function inline_2 (); +\i faq-package-create.sql Index: openacs-4/packages/faq/sql/postgresql/faq-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/sql/postgresql/faq-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq/sql/postgresql/faq-package-create.sql 1 Apr 2004 22:52:46 -0000 1.1 @@ -0,0 +1,171 @@ +-- Package create for faq +-- +-- @author @jennie.ybos.net,@wirth.ybos.net,openacs port @samir.symphinity.com +-- +-- @cvs-id $Id: faq-package-create.sql,v 1.1 2004/04/01 22:52:46 jeffd Exp $ +-- + +create or replace function faq__new_q_and_a (integer,integer,varchar,varchar,integer,varchar,timestamptz,integer,varchar,integer) returns integer as +' +declare + p_entry_id alias for $1; -- default null, + p_faq_id alias for $2; + p_question alias for $3; + p_answer alias for $4; + p_sort_key alias for $5; + p_object_type alias for $6; -- default faq_q_and_a + p_creation_date alias for $7; --in acs_objects.creation_date%TYPE default sysdate, + p_creation_user alias for $8; --in acs_objects.creation_user%TYPE default null, + p_creation_ip alias for $9; -- in acs_objects.creation_ip%TYPE default null, + p_context_id alias for $10; --in acs_objects.context_id%TYPE default null + v_entry_id faq_q_and_as.entry_id%TYPE; + v_package_id acs_objects.package_id%TYPE; +begin + select package_id into v_package_id from acs_objects where object_id = p_faq_id; + + v_entry_id := acs_object__new ( + p_entry_id, + p_object_type, + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id, + ''t'', + p_question, + v_package_id + ); + insert into faq_q_and_as + (entry_id, faq_id, question, answer, sort_key) + values + (v_entry_id, p_faq_id, p_question, p_answer, p_sort_key); + return v_entry_id; + +end;' language 'plpgsql'; + +create or replace function faq__delete_q_and_a (integer) +returns integer as ' +declare + p_entry_id alias for $1; +begin + delete from faq_q_and_as where entry_id = p_entry_id; + raise NOTICE ''Deleting FAQ_Q_and_A...''; + PERFORM acs_object__delete(p_entry_id); + + return 0; + +end;' language 'plpgsql'; + + +create or replace function faq__new_faq (integer, varchar, boolean,varchar,timestamptz,integer,varchar,integer ) +returns integer as ' +declare + p_faq_id alias for $1; + p_faq_name alias for $2; + p_separate_p alias for $3; + p_object_type alias for $4; + p_creation_date alias for $5; + p_creation_user alias for $6; + p_creation_ip alias for $7; + p_context_id alias for $8; + v_faq_id faqs.faq_id%TYPE; +begin + + v_faq_id := acs_object__new ( + p_faq_id, + p_object_type, + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id, + ''t'', + p_faq_name, + p_context_id ); + + insert into faqs + (faq_id, faq_name,separate_p) + values + (v_faq_id, p_faq_name,p_separate_p); + +return v_faq_id; + +end;' language 'plpgsql'; + + +create or replace function faq__delete_faq (integer) +returns integer as ' +declare + p_faq_id alias for $1; + del_rec record; +begin + -- Because q_and_as are objects, we need to + -- loop through a list of them, and call an explicit + -- delete function for each one. (i.e. each + -- entry_id) + for del_rec in select entry_id from faq_q_and_as + where faq_id = p_faq_id + loop + PERFORM faq__delete_q_and_a(del_rec.entry_id); + end loop; + + delete from faqs where faq_id = p_faq_id; + + PERFORM acs_object__delete(p_faq_id); + + return 0; + +end;' language 'plpgsql'; + +create or replace function faq__name(integer) +returns varchar as ' +declare + p_faq_id alias for $1; + v_faq_name faqs.faq_name%TYPE; +begin + select faq_name into v_faq_name + from faqs + where faq_id = p_faq_id; + + return v_faq_name; +end; +' language 'plpgsql'; + +create or replace function faq__clone (integer,integer) +returns integer as ' +declare + p_new_package_id alias for $1; --default null, + p_old_package_id alias for $2; --default null + v_faq_id faqs.faq_id%TYPE; + one_faq record; + entry record; + +begin + -- get all the faqs belonging to the old package, + -- and create new faqs for the new package + for one_faq in select * + from acs_objects o, faqs f + where o.object_id = f.faq_id + and o.context_id = p_old_package_id + loop + v_faq_id := faq__new_faq ( + one_faq.faq_name, + one_faq.separate_p, + p_new_package_id + ); + + for entry in select * from faq_q_and_as + where faq_id = one_faq.faq_id + loop + + perform faq__new_q_and_a ( + entry.faq_id, + v_faq_id, + entry.question, + entry.answer, + entry.sort_key + ); + end loop; + end loop; + return 0; + end; +' language 'plpgsql'; + Index: openacs-4/packages/faq/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql 1 Apr 2004 22:52:46 -0000 1.1 @@ -0,0 +1,5 @@ +-- fix name method, update package + +update acs_objects set name_method = 'faq__name' where name_method = 'faq.name' and object_type = 'faq'; + +\i ../faq-package-create.sql Index: openacs-4/packages/faq/tcl/faq-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/tcl/faq-install-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq/tcl/faq-install-procs.tcl 1 Apr 2004 22:52:47 -0000 1.1 @@ -0,0 +1,39 @@ +ad_library { + FAQ install callbacks + + @creation-date 2004-04-01 + @author Jeff Davis davis@xarg.net + @cvs-id $Id: faq-install-procs.tcl,v 1.1 2004/04/01 22:52:47 jeffd Exp $ +} + +namespace eval faq::install {} + +ad_proc -private faq::install::package_install {} { + package install callback +} { + faq::sc::register_implementations +} + +ad_proc -private faq::install::package_uninstall {} { + package uninstall callback +} { + faq::sc::unregister_implementations +} + +ad_proc -private faq::install::package_upgrade { + {-from_version_name:required} + {-to_version_name:required} +} { + Package before-upgrade callback +} { + apm_upgrade_logic \ + -from_version_name $from_version_name \ + -to_version_name $to_version_name \ + -spec { + 5.2.0d1 5.2.0d2 { + # need to install the faq callbacks + faq::sc::register_faq_fts_impl + faq::sc::register_faq_q_and_a_fts_impl + } + } +} Index: openacs-4/packages/faq/tcl/faq-sc-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/tcl/faq-sc-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq/tcl/faq-sc-procs.tcl 1 Apr 2004 22:52:47 -0000 1.1 @@ -0,0 +1,133 @@ +ad_library { + FAQ Fts contract bindings. + + @creation-date 2004-04-01 + @author Jeff Davis davis@xarg.net + @cvs-id $Id: faq-sc-procs.tcl,v 1.1 2004/04/01 22:52:47 jeffd Exp $ +} + +namespace eval faq::fts {} + +ad_proc -private faq::fts::datasource { faq_id } { + returns a datasource for a faq event to + be indexed by the full text search engine. + + @param faq_id + + @author davis@xarg.net + @creation_date 2004-04-01 +} { + set title [db_string name {select faq_name from faqs where faq_id = :faq_id} -default "FAQ $faq_id"] + set content {} + db_foreach qa { select question, answer from faq_q_and_as where faq_id = :faq_id } { + append content "Q: $question\n\nA: $answer\n\n" + } + + return [list object_id $faq_id \ + title $title \ + content $content \ + keywords {} \ + storage_type text \ + mime_type text/plain ] +} + +ad_proc -private faq::fts::url { faq_id } { + returns a url for a faq to the search package + + @author davis@xarg.net + @creation_date 2004-04-01 +} { + set faq_package_id [db_string package_id {select package_id from acs_objects where object_id = :faq_id} -default {}] + + return "[ad_url][apm_package_url_from_id $faq_package_id]one-faq?faq_id=$faq_id" +} + +namespace eval faq_qanda::fts {} + + +ad_proc -private faq_qanda::fts::datasource { entry_id } { + returns a datasource for a faq q/a to + be indexed by the full text search engine. + + @param entry_id + + @author davis@xarg.net + @creation_date 2004-04-01 +} { + set title [db_string name { + select f.faq_name from faqs + where faq_id = (select faq_id from faq_q_and_as where entry_id = :entry_id) + } -default "FAQ $faq_id"] + + if {[db_0or1row get {select question, answer from faq_q_and_as where entry_id = :entry_id}]} { + append title ": $question" + set content "Q: $question\n\nA: $answer\n\n" + } else { + set content {} + } + + return [list object_id $entry_id \ + title $title \ + content $content \ + keywords {} \ + storage_type text \ + mime_type text/plain ] +} + +ad_proc -private faq_qanda::fts::url { entry_id } { + returns a url for a faq to the search package + + @author davis@xarg.net + @creation_date 2004-04-01 +} { + set faq_package_id [db_string package_id {select package_id from acs_objects where object_id = :entry_id} -default {}] + + return "[ad_url][apm_package_url_from_id $faq_package_id]one-question?entry_id=$entry_id" +} + + +namespace eval faq::sc {} + +ad_proc -private faq::sc::register_implementations {} { + Register the faq content type fts contract +} { + db_transaction { + faq::sc::register_faq_fts_impl + faq::sc::register_faq_q_and_a_fts_impl + } +} + +ad_proc -private faq::sc::unregister_implementations {} { + db_transaction { + acs_sc::impl::delete -contract_name FtsContentProvider -impl_name faq + acs_sc::impl::delete -contract_name FtsContentProvider -impl_name faq_q_and_a + } +} + +ad_proc -private faq::sc::register_faq_fts_impl {} { + set spec { + name "faq" + aliases { + datasource faq::fts::datasource + url faq::fts::url + } + contract_name FtsContentProvider + owner faq + } + + acs_sc::impl::new_from_spec -spec $spec +} + +ad_proc -private faq::sc::register_faq_q_and_a_fts_impl {} { + set spec { + name "faq_q_and_a" + aliases { + datasource faq_qanda::fts::datasource + url faq_qanda::fts::url + } + contract_name FtsContentProvider + owner faq + } + + acs_sc::impl::new_from_spec -spec $spec +}