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.1 -r1.2 --- openacs-4/packages/faq/sql/oracle/faq-create.sql 20 Apr 2001 20:51:10 -0000 1.1 +++ openacs-4/packages/faq/sql/oracle/faq-create.sql 29 May 2002 23:05:24 -0000 1.2 @@ -96,6 +96,13 @@ entry_id in faq_q_and_as.entry_id%TYPE ); + + procedure clone ( + old_package_id in apm_packages.package_id%TYPE, + new_package_id in apm_packages.package_id%TYPE + ); + + end faq; / show errors @@ -208,6 +215,45 @@ 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 @@ -273,4 +319,4 @@ ); end; -/ \ No newline at end of file +/ Index: openacs-4/packages/news/sql/oracle/news-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news/sql/oracle/news-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/news/sql/oracle/news-create.sql 25 Oct 2001 11:39:29 -0000 1.3 +++ openacs-4/packages/news/sql/oracle/news-create.sql 29 May 2002 23:04:16 -0000 1.4 @@ -294,6 +294,10 @@ revision_id in cr_revisions.revision_id%TYPE ); + procedure clone ( + new_package_id in cr_news.package_id%TYPE default null, + old_package_id in cr_news.package_id%TYPE default null + ); end news; / @@ -684,7 +688,63 @@ end revision_set_active; + procedure clone ( + new_package_id in cr_news.package_id%TYPE default null, + old_package_id in cr_news.package_id%TYPE default null + ) + is + new_news_id integer; + begin + for one_news in (select + publish_date, + content.blob_to_string(cr.content) as text, + cr.nls_language, + cr.title as title, + cr.mime_type, + cn.package_id, + archive_date, + approval_user, + approval_date, + approval_ip, + ao.creation_date, + ao.creation_ip, + ao.creation_user + from + cr_items ci, + cr_revisions cr, + cr_news cn, + acs_objects ao + where + (ci.item_id = cr.item_id + and ci.live_revision = cr.revision_id + and cr.revision_id = cn.news_id + and cr.revision_id = ao.object_id) + or (ci.live_revision is null + and ci.item_id = cr.item_id + and cr.revision_id = content_item.get_latest_revision(ci.item_id) + and cr.revision_id = cn.news_id + and cr.revision_id = ao.object_id)) + loop + new_news_id := news.new( + publish_date => one_news.publish_date, + text => one_news.text, + nls_language => one_news.nls_language, + title => one_news.title, + mime_type => one_news.mime_type, + package_id => news.clone.new_package_id, + archive_date => one_news.archive_date, + approval_user => one_news.approval_user, + approval_date => one_news.approval_date, + approval_ip => one_news.approval_ip, + creation_date => one_news.creation_date, + creation_ip => one_news.creation_ip, + creation_user => one_news.creation_user + ); + + end loop; + end clone; + -- currently not used, because we want to audit revisions procedure revision_delete ( revision_id in cr_revisions.revision_id%TYPE