Index: openacs-4/packages/imsld/www/admin/imsld-export-2-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-export-2-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-export-2-postgresql.xql 18 Feb 2009 11:03:03 -0000 1.1
@@ -0,0 +1,13 @@
+
+
+
+
+ select imsld_file_id, file_name, path_to_file from imsld_cp_files where imsld_file_id > :this_imsld and :next_imsld > imsld_file_id and file_name != 'imsmanifest.xml'
+
+
+
+
+ select imsld_file_id, file_name, path_to_file from imsld_cp_files where imsld_file_id > :this_imsld and file_name != 'imsmanifest.xml'
+
+
+
Index: openacs-4/packages/imsld/www/admin/imsld-export-2.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-export-2.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-export-2.adp 18 Feb 2009 11:03:03 -0000 1.1
@@ -0,0 +1,2 @@
+imsld export
+
Index: openacs-4/packages/imsld/www/admin/imsld-export-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-export-2.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-export-2.tcl 18 Feb 2009 11:03:03 -0000 1.1
@@ -0,0 +1,161 @@
+ad_page_contract {
+ Export Uol
+
+ @author cvalencia@inv.it.uc3m.es
+ @creation-date Dec 2008
+} {
+ imsld_id:integer
+ uol_name:nohtml
+ include_all:nohtml
+}
+
+#Check if the user who attemps to enter the page has admin priviledges
+set package_id [ad_conn package_id]
+set admin_p [permission::permission_p -object_id $package_id \
+ -privilege admin]
+
+#Delete all files in tmp
+exec rm -fr [acs_package_root_dir imsld]/www/tmp/
+
+#Zip file name
+if {$uol_name != ""} {
+ set download_name "${uol_name}.zip"
+} else {
+ set download_name "exported_UoL.zip"
+}
+regsub -all { } $download_name {_} download_name
+
+##########################
+# Create imsmanifest.xml #
+##########################
+
+#Create tmp directory if it doesn't exist
+if {[file isdirectory [acs_package_root_dir imsld]/www/tmp] == 0} {
+ exec mkdir [acs_package_root_dir imsld]/www/tmp
+}
+
+#Create new temporal directory to store output
+set in_path [ns_tmpnam]
+#############################################################################
+#############################################################################
+set path [acs_package_root_dir imsld]/www$in_path
+
+#set path $in_path
+#############################################################################
+#############################################################################
+exec mkdir $path
+
+#Open a new file to write imsmanifest.xml
+set manifest [open "${path}/imsmanifest.xml" w]
+
+#Write manifest document
+set information [imsld::export::uol -run_imsld_id $imsld_id]
+
+#Write manifest file
+puts $manifest ""
+puts $manifest $information
+
+#Close imsmanifest.xml file
+close $manifest
+
+
+
+###################
+# Create zip file #
+###################
+
+#Create output file
+set out_file [file join ${path} ${download_name}]
+
+#Get manifest_id
+db_1row get_imsld_data {select organization_id from imsld_imslds where imsld_id = :imsld_id}
+db_1row get_manifest_id {select manifest_id from imsld_cp_organizations where organization_id = cr_items.latest_revision and cr_items.item_id = :organization_id}
+
+#Store imsld_id in a variable to use it later
+set this_imsld $imsld_id
+
+
+#Get files and include them in our export directory
+db_multirow get_files get_files {select resource_id, href from imsld_cp_resources where manifest_id = :manifest_id} {
+ #Create folders if necessary to create directory tree
+ set inside_path ""
+ set position [string last "/" $href]
+ if {$position > 0 && [string first "http:" $href] == -1} {
+ set inside_path [string range $href 0 [expr $position-1]]
+ #file mkdir $path/$inside_path/
+ }
+
+ #If the resources is a link, it has no files to be copied
+ if {[string first "http:" $href] == -1} {
+ #Call proc to copy resource files to export temporal directory
+ imsld::export::files::copy_files -resource_id $resource_id -path $path
+ }
+
+}
+
+if {$include_all == "Yes"} {
+ #Save additional files of the UoL which are not used in the player
+ #Get imsld_id of next UoL
+ if {[db_0or1row get_next_imsld {select organization_id from imsld_imslds where imsld_id > :this_imsld limit 1}] == 1} {
+ set next_imsld $organization_id
+ db_multirow get_files get_files_1 {} {
+ #Create directories if necessary to complete the tree
+ set inside_path ""
+ set position [string last $file_name $path_to_file]
+ if {$position > 0} {
+ set inside_path ${inside_path}[string range $path_to_file 0 [expr $position-1]]
+ file mkdir $path/$inside_path/
+ }
+ #Copy file
+ if {[fs_file_p [expr $imsld_file_id-1]] == 1} {
+ set data [fs__datasource $imsld_file_id]
+ set url [lindex $data [expr [lsearch $data content]+1]]
+ file copy -force $url "$path/${inside_path}${file_name}"
+ }
+ }
+ } else {
+ #If the UoL we are going to export is the last one stored, then copy all
+ # files with id greater than imsld_id
+ db_multirow get_files get_files_2 {} {
+ #Create directories if necessary to complete the tree
+ set inside_path ""
+ set position [string last $file_name $path_to_file]
+ if {$position > 0} {
+ set inside_path ${inside_path}[string range $path_to_file 0 [expr $position-1]]
+ file mkdir $path/$inside_path/
+ }
+ #Copy file
+ if {[fs_file_p [expr $imsld_file_id-1]] == 1} {
+ set data [fs__datasource $imsld_file_id]
+ set url [lindex $data [expr [lsearch $data content]+1]]
+ file copy -force $url "$path/${inside_path}${file_name}"
+ }
+ }
+ }
+}
+
+
+#Create zip archive
+set cmd "zip -r '$out_file' *"
+set copy "cp ${path}/imsmanifest.xml ./imsmanifest.xml"
+with_catch errmsg {
+ exec bash -c "cd '$path'; $cmd; cd -"
+} {
+ error $errmsg
+}
+
+##########################################################################
+##########################################################################
+##Return file download url
+if {[string index $in_path 0] ne "/"} {
+ ad_returnredirect "../${in_path}/${download_name}"
+} else {
+ ad_returnredirect "..${in_path}/${download_name}"
+}
+#set a [ns_http list]
+#ns_returnredirect "${in_path}/${download_name}"
+#ad_returnredirect "export_down"
+#Remove temporary files and folder
+#exec rm -fr $path
+##########################################################################
+##########################################################################
Index: openacs-4/packages/imsld/www/admin/imsld-export-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-export-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-export-postgresql.xql 18 Feb 2009 11:03:03 -0000 1.1
@@ -0,0 +1,13 @@
+
+
+
+
+ select imsld_file_id, path_to_file from imsld_cp_files where imsld_file_id > :this_imsld and :next_imsld > imsld_file_id and file_name != 'imsmanifest.xml'
+
+
+
+
+ select imsld_file_id, path_to_file from imsld_cp_files where imsld_file_id > :this_imsld and file_name != 'imsmanifest.xml'
+
+
+
Index: openacs-4/packages/imsld/www/admin/imsld-export.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-export.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-export.adp 18 Feb 2009 11:03:03 -0000 1.1
@@ -0,0 +1,10 @@
+imsld export
+imsld export
+
+@heading@
+@intro@@anchor_msg@
+
+
+
+
+#imsld.Go_back_to_admin#
Index: openacs-4/packages/imsld/www/admin/imsld-export.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-export.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/imsld/www/admin/imsld-export.tcl 18 Feb 2009 11:03:03 -0000 1.1
@@ -0,0 +1,77 @@
+ad_page_contract {
+ Export Uol
+
+ @author cvalencia@inv.it.uc3m.es
+ @creation-date Feb 2008
+} {
+ imsld_id:integer
+}
+
+#Get package_id to check if user has admin privileges
+set package_id [ad_conn package_id]
+permission::require_permission \
+ -object_id $package_id \
+ -privilege admin
+
+#Delete files from tmp directory
+exec rm -fr "[acs_package_root_dir imsld]/www/tmp/*"
+
+#Get UoL name
+db_1row get_imsld_identifier {select title from cr_revisions where revision_id = :imsld_id}
+set aux_export_url "&uol_name=$title&include_all=Yes"
+if {$title == ""} {
+ set title "Unknown name"
+}
+
+#Set page messages
+set heading "[_ imsld.export_heading]: $title"
+set intro "[_ imsld.export_intro] "
+set export_url "./imsld-export-2.tcl?imsld_id=$imsld_id"
+set anchor_msg "export"
+
+
+template::list::create \
+ -name resource_files \
+ -multirow get_resource_files \
+ -elements {
+ path_to_file {
+ label "[_ imsld.export_files]"
+ }
+ warning {
+ label "[_ imsld.export_warnings]"
+ }
+}
+
+set this_imsld $imsld_id
+#Choose query for db_multirow
+if {[db_0or1row get_next_imsld {select organization_id from imsld_imslds where imsld_id > :this_imsld limit 1}] == 1} {
+ set next_imsld $organization_id
+ set get_files get_files_1
+} else {
+ set get_files get_files_2
+}
+
+set number_of_files 0
+db_multirow -local \
+ -extend {warning} \
+ get_resource_files $get_files {} {
+ if {[db_0or1row get_file_resource {select object_id_one from acs_rels, cr_items where latest_revision = :imsld_file_id and item_id = object_id_two and rel_type = 'imsld_res_files_rel' limit 1}] == 1} {
+ set warning "OK"
+ } else {set warning "[_ imsld.export_warning_msg1]"}
+}
+
+#Create Export button
+ad_form -name export_button \
+ -form {
+ {imsld_id:integer(hidden)}
+ {name:text {label "[_ imsld.export_uol_name]"} {html {size 30}}}
+ {include_all:text(radio) {label "[_ imsld.export_resources_question]"} {options {{"[_ imsld.export_yes]" "Yes"} {"[_ imsld.export_no]" "No"}}}}
+ } \
+ -on_request {
+ set name $title
+ set include_all "Yes"
+ } \
+ -on_submit {
+ ad_returnredirect "${export_url}&uol_name=${name}&include_all=${include_all}"
+ ad_script_abort
+}
Index: openacs-4/packages/imsld/www/admin/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/index.tcl,v
diff -u -r1.19 -r1.20
--- openacs-4/packages/imsld/www/admin/index.tcl 9 Dec 2008 14:13:12 -0000 1.19
+++ openacs-4/packages/imsld/www/admin/index.tcl 18 Feb 2009 11:03:03 -0000 1.20
@@ -72,6 +72,13 @@
[_ imsld.create_new_run]
}
}
+ export {
+ label {}
+ sub_class narrow
+ display_template {
+
+ }
+ }
delete {
label {}
sub_class narrow