Index: dotlrn_packages/packages/forums/tcl/forums-lams-procs.tcl =================================================================== diff -u -r94a8cfca91c1b9faa220c616213544c23edeb6b9 -r047f65288b26d8b00bcf16094866f1fb39bdd8be --- dotlrn_packages/packages/forums/tcl/forums-lams-procs.tcl (.../forums-lams-procs.tcl) (revision 94a8cfca91c1b9faa220c616213544c23edeb6b9) +++ dotlrn_packages/packages/forums/tcl/forums-lams-procs.tcl (.../forums-lams-procs.tcl) (revision 047f65288b26d8b00bcf16094866f1fb39bdd8be) @@ -87,3 +87,77 @@ } +ad_proc -public forum::lams::export_instance { + {-forum_id ""} +} { + Exports an instance of forum +} { + + # gets the content of the forum + forum::get -forum_id $forum_id -array forum + + # exports the array to text + set export_forum_as_string [array get forum] + + set tmp_folder [ns_tmpnam] + file mkdir $tmp_folder + set path_to_file [file join $tmp_folder forum_$forum_id] + + set filer [open $path_to_file w+] + + puts -nonewline $filer $export_forum_as_string + + close $filer + + # send the file back to the call + + ns_set put [ad_conn outputheaders] Content-Disposition "attachment;filename=\"forum_$forum_id.txt\"" + ns_set put [ad_conn outputheaders] Content-Type "text/txt" + ns_set put [ad_conn outputheaders] Content-Size "[file size $path_to_file]" + ns_returnfile 200 text/txt $path_to_file + + # clean up + file delete -force $path_to_file + ad_script_abort + +} + +ad_proc -public forum::lams::import_instance { + -file_path:required + -user_id + -course_id +} { + Import an instance of forum +} { + + # open file + + set filer [open $file_path r] + + set content [read $filer] + + ns_log Debug "Importing tool content: $content" + + array set forum $content + + close $filer + + set forum_name $forum(name) + set forum_charter $forum(charter) + set presentation_type $forum(presentation_type) + set posting_policy $forum(posting_policy) + set forum_package_id [forum::lams::get_package_instance -community_id $course_id] + + set new_forum_id [forum::new -name $forum_name \ + -charter $forum_charter \ + -presentation_type $presentation_type \ + -posting_policy $posting_policy \ + -package_id $forum_package_id \ + ] + + forum::lams::is_lams -forum_id $new_forum_id + + return $new_forum_id + +} +