Index: openacs-4/packages/faq/tcl/faq-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/tcl/faq-callback-procs.tcl,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/faq/tcl/faq-callback-procs.tcl 20 Jul 2005 15:39:24 -0000 1.1.2.1 +++ openacs-4/packages/faq/tcl/faq-callback-procs.tcl 23 Sep 2005 14:38:28 -0000 1.1.2.2 @@ -13,3 +13,67 @@ db_dml update_faqs {} } + +ad_proc -public -callback datamanager::copy_faq -impl datamanager { + -object_id:required + -selected_community:required +} { + Copy a faq to another class or community. Q&A are also copied +} { + +#get data about the faq + db_1row get_faq_package_id {} + db_1row get_faq_name {} + + set user_id [ad_conn user_id] + set creation_ip [ad_conn host] + set faq_id [db_nextval acs_object_id_seq] + + +#then, the faq is copied + db_transaction { + db_exec_plsql create_faq { + begin + :1 := faq.new_faq ( + faq_id => :faq_id, + faq_name => :faq_name, + separate_p => :separate_p, + creation_user => :user_id, + creation_ip => :creation_ip, + context_id => :package_id + ); + end; + } + } + +#get list of Q&A (ids) + set q_a_list [db_list_of_lists get_q_a_list {}] + + set q_a_number [llength $q_a_list] + +#for each Q&A, one entry + for {set i 0} {$i < $q_a_number} {incr i} { + + set one_question [lindex [lindex $q_a_list $i] 0] + set one_answer [lindex [lindex $q_a_list $i] 1] + set entry_id [db_nextval acs_object_id_seq] + set sort_key $entry_id + + db_transaction { + db_exec_plsql create_q_and_a { + begin + :1 := faq.new_q_and_a ( + entry_id => :entry_id, + context_id => :faq_id, + faq_id=> :faq_id, + question => :one_question, + answer => :one_answer, + sort_key => :sort_key, + creation_user => :user_id, + creation_ip => :creation_ip + ); + end; + } + } + } +} Index: openacs-4/packages/faq/tcl/faq-callback-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq/tcl/Attic/faq-callback-procs.xql,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/faq/tcl/faq-callback-procs.xql 20 Jul 2005 15:39:24 -0000 1.1.2.1 +++ openacs-4/packages/faq/tcl/faq-callback-procs.xql 23 Sep 2005 14:38:28 -0000 1.1.2.2 @@ -14,5 +14,53 @@ + + + SELECT b.object_id as package_id + FROM acs_objects as a,acs_objects as b + WHERE a.context_id=:selected_community and a.object_type='apm_package' and a.object_id=b.context_id and b.title='FAQ'; + + + + + SELECT faq_name,separate_p + FROM faqs + WHERE faq_id=:object_id; + + + + + + SELECT question,answer + FROM faq_q_and_as + WHERE faq_id=:object_id; + + + + + + + + select faq__new_q_and_a ( + :entry_id, + :faq_id, + :one_question, + :one_answer, + :sort_key, + 'faq_q_and_a', + now(), + :user_id, + :creation_ip, + :faq_id + ); + + + + + + select faq__new_faq (:faq_id, :faq_name,:separate_p,'faq', now(), :user_id,:creation_ip,:package_id); + + +