--- loncom/imspackages/imsimport.pm 2014/12/11 01:07:38 1.46
+++ loncom/imspackages/imsimport.pm 2017/11/05 20:04:30 1.48
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: imsimport.pm,v 1.46 2014/12/11 01:07:38 raeburn Exp $
+# $Id: imsimport.pm,v 1.48 2017/11/05 20:04:30 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,6 +38,7 @@ use HTML::Entities();
use Apache::lonlocal;
use Apache::lonupload;
use File::Basename();
+use File::Path();
use LONCAPA;
# ---------------------------------------------------------------- Jscript One
@@ -57,22 +58,26 @@ sub jscript_one {
my $end_page =
&Apache::loncommon::end_page({'js_ready' => 1,});
- my %lt = &Apache::lonlocal::texthash(
+ my %js_lt = &Apache::lonlocal::texthash(
ddir => 'You must choose a destination directory for the import',
cmss => 'You must choose the Course Management System from which the IMS package was exported',
+ );
+ my %html_lt = &Apache::lonlocal::texthash(
loca => 'Location:',
newd => 'New Directory',
nndi => 'Enter the name of the new directory where you will store the contents of your IMS package.',
go => 'Go',
);
+ &js_escape(\%js_lt);
+ &html_escape(\%html_lt);
return <<"END_OF_ONE";
function verify() {
if ((document.forms.$formname.newdir.value == '') || (!document.forms.$formname.newdir.value)) {
- alert('$lt{'ddir'}')
+ alert('$js_lt{'ddir'}')
return false
}
if (document.forms.$formname.source.selectedIndex == 0) {
- alert('$lt{'cmss'}');
+ alert('$js_lt{'cmss'}');
return false
}
return true
@@ -92,15 +97,15 @@ function createWin() {
newWindow.document.write("\\n\\n")
newWindow.document.write("
\\n")
newWindow.document.write(" | | \\n")
- newWindow.document.write("$lt{'loca'} $fullpath$lt{'newd'} |
\\n")
+ newWindow.document.write("$html_lt{'loca'} $fullpath$html_lt{'newd'} | \\n")
newWindow.document.write(" | | \\n")
newWindow.document.write(" |
\\n")
newWindow.document.write("
")
newWindow.document.write('$end_page')
@@ -133,7 +138,7 @@ sub jscript_two {
$course_list = '"'.join('","',@crslist).'"';
$$numcrs = @crslist;
- my %lt = &Apache::lonlocal::texthash(
+ my %js_lt = &Apache::lonlocal::texthash(
sel => 'Please select',
impto => 'Import topics only',
imptpa => 'Import topics + posts (with author)',
@@ -147,6 +152,7 @@ sub jscript_two {
errte => 'You must select a target course when importing enrollment information.',
errcc => 'You must check at least one Content Type.',
);
+ &js_escape(\%js_lt);
return <<"END_OF_TWO";
function checkCourse() {
@@ -195,7 +201,7 @@ function setCourse(step2Form,call) {
step2Form.targetcourse.length = 0
if (call == 'add') {
step2Form.targetcourse.length = 0
- step2Form.targetcourse.options[0] = new Option("$lt{'sel'}","0",true,true)
+ step2Form.targetcourse.options[0] = new Option("$js_lt{'sel'}","0",true,true)
for (var i=0; i 0) {
@@ -248,7 +254,7 @@ function verify(caller) {
totcheck ++
if (opForm.elements[2*i].name == "board") {
if (opForm.elements[2*i+1].selectedIndex == 0) {
- alert("$lt{'errao'}")
+ alert("$js_lt{'errao'}")
return false
}
if (numCrs == 0) {
@@ -257,14 +263,14 @@ function verify(caller) {
}
else {
if (opForm.targetcourse.selectedIndex == 0) {
- alert("$lt{'errtd'}")
+ alert("$js_lt{'errtd'}")
return false
}
}
}
if (opForm.elements[2*i].name == "users") {
if (opForm.elements[2*i+1].selectedIndex == 0) {
- alert("$lt{'errap'}")
+ alert("$js_lt{'errap'}")
return false
}
if (numCrs == 0) {
@@ -273,7 +279,7 @@ function verify(caller) {
}
else {
if (opForm.targetcourse.selectedIndex == 0) {
- alert("$lt{'errte'}")
+ alert("$js_lt{'errte'}")
return false
}
}
@@ -281,7 +287,7 @@ function verify(caller) {
}
}
if (totcheck == 0) {
- alert("$lt{'errcc'}");
+ alert("$js_lt{'errcc'}");
return false
}
return true
@@ -635,7 +641,7 @@ sub display_three {
);
my $londocroot = $r->dir_config('lonDocRoot');
if ($destdir =~ m{^\Q$londocroot/priv/$udom/$uname/$dirpath\E}) {
- system (" rm -r -f $destdir/temp");
+ &File::Path::remove_tree("$destdir/temp",{ safe => 1 });
}
} elsif ($manifest_result eq 'nomanifest') {
$r->print(