Diff for /loncom/imspackages/imsimport.pm between versions 1.46 and 1.49

version 1.46, 2014/12/11 01:07:38 version 1.49, 2023/07/23 13:33:52
Line 38  use HTML::Entities(); Line 38  use HTML::Entities();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonupload;  use Apache::lonupload;
 use File::Basename();  use File::Basename();
   use File::Path();
 use LONCAPA;  use LONCAPA;
   
 # ----------------------------------------------------------------  Jscript One  # ----------------------------------------------------------------  Jscript One
Line 57  sub jscript_one { Line 58  sub jscript_one {
     my $end_page =       my $end_page = 
  &Apache::loncommon::end_page({'js_ready' => 1,});   &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',                 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',                 cmss => 'You must choose the Course Management System from which the IMS package was exported',
                );
       my %html_lt = &Apache::lonlocal::texthash( 
                loca => 'Location:',                 loca => 'Location:',
                newd => 'New Directory',                 newd => 'New Directory',
                nndi => 'Enter the name of the new directory where you will store the contents of your IMS package.',                 nndi => 'Enter the name of the new directory where you will store the contents of your IMS package.',
                go => 'Go',                  go => 'Go', 
              );               );
       &js_escape(\%js_lt);
       &html_escape(\%html_lt);
     return <<"END_OF_ONE";      return <<"END_OF_ONE";
 function verify() {  function verify() {
  if ((document.forms.$formname.newdir.value == '')  || (!document.forms.$formname.newdir.value)) {   if ((document.forms.$formname.newdir.value == '')  || (!document.forms.$formname.newdir.value)) {
    alert('$lt{'ddir'}')     alert('$js_lt{'ddir'}')
    return false     return false
  }   }
  if (document.forms.$formname.source.selectedIndex == 0) {   if (document.forms.$formname.source.selectedIndex == 0) {
    alert('$lt{'cmss'}');     alert('$js_lt{'cmss'}');
    return false     return false
  }   }
  return true   return true
Line 92  function createWin() { Line 97  function createWin() {
   newWindow.document.write("\\n<img border='0' src='/adm/lonInterFace/author.jpg' alt='[Author Header]' />\\n")    newWindow.document.write("\\n<img border='0' src='/adm/lonInterFace/author.jpg' alt='[Author Header]' />\\n")
   newWindow.document.write("<table border='0' cellspacing='0' cellpadding='0' width='600'>\\n")    newWindow.document.write("<table border='0' cellspacing='0' cellpadding='0' width='600'>\\n")
   newWindow.document.write("<tr><td width='2'>&nbsp;</td><td width='3'>&nbsp;</td>\\n")    newWindow.document.write("<tr><td width='2'>&nbsp;</td><td width='3'>&nbsp;</td>\\n")
   newWindow.document.write("<td><h3>$lt{'loca'} <tt>$fullpath</tt></h3><h3>$lt{'newd'}</h3></td></tr>\\n")    newWindow.document.write("<td><h3>$html_lt{'loca'} <tt>$fullpath</tt></h3><h3>$html_lt{'newd'}</h3></td></tr>\\n")
   newWindow.document.write("<tr><td width='2'>&nbsp;</td><td width='3'>&nbsp;</td>\\n")    newWindow.document.write("<tr><td width='2'>&nbsp;</td><td width='3'>&nbsp;</td>\\n")
   newWindow.document.write("<td><form name='fileaction' action='/adm/cfile' method='post'>\\n")    newWindow.document.write("<td><form name='fileaction' action='/adm/cfile' method='post'>\\n")
   newWindow.document.write("$lt{'nndi'}<br /><br />")    newWindow.document.write("$html_lt{'nndi'}<br /><br />")
   newWindow.document.write("<input type='hidden' name='filename' value='$fullpath' />")    newWindow.document.write("<input type='hidden' name='filename' value='$fullpath' />")
   newWindow.document.write("<input type='hidden' name='action' value='newdir' />")    newWindow.document.write("<input type='hidden' name='action' value='newdir' />")
   newWindow.document.write("<input type='hidden' name='callingmode' value='imsimport' />")    newWindow.document.write("<input type='hidden' name='callingmode' value='imsimport' />")
   newWindow.document.write("$fullpath<input type='text' name='newfilename' value='' />")    newWindow.document.write("$fullpath<input type='text' name='newfilename' value='' />")
   newWindow.document.write("<input type='button' value='$lt{'go'}' onclick='document.fileaction.submit();' />")    newWindow.document.write("<input type='button' value='$html_lt{'go'}' onclick='document.fileaction.submit();' />")
   newWindow.document.write("</td></tr>\\n")    newWindow.document.write("</td></tr>\\n")
   newWindow.document.write("</table>")    newWindow.document.write("</table>")
   newWindow.document.write('$end_page')    newWindow.document.write('$end_page')
Line 133  sub jscript_two { Line 138  sub jscript_two {
     $course_list = '"'.join('","',@crslist).'"';      $course_list = '"'.join('","',@crslist).'"';
     $$numcrs = @crslist;      $$numcrs = @crslist;
   
     my %lt = &Apache::lonlocal::texthash(      my %js_lt = &Apache::lonlocal::texthash(
                   sel    => 'Please select',                    sel    => 'Please select',
                   impto  => 'Import topics only',                    impto  => 'Import topics only',
                   imptpa => 'Import topics + posts (with author)',                    imptpa => 'Import topics + posts (with author)',
Line 147  sub jscript_two { Line 152  sub jscript_two {
                   errte  => 'You must select a target course when importing enrollment information.',                    errte  => 'You must select a target course when importing enrollment information.',
                   errcc  => 'You must check at least one Content Type.',                    errcc  => 'You must check at least one Content Type.',
        );         );
       &js_escape(\%js_lt);
     return <<"END_OF_TWO";      return <<"END_OF_TWO";
   
 function checkCourse() {  function checkCourse() {
Line 195  function setCourse(step2Form,call) { Line 201  function setCourse(step2Form,call) {
     step2Form.targetcourse.length = 0      step2Form.targetcourse.length = 0
     if (call == 'add') {      if (call == 'add') {
         step2Form.targetcourse.length = 0          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<courseID_array.length; i++) {          for (var i=0; i<courseID_array.length; i++) {
             step2Form.targetcourse.options[i+1] = new Option(courseTitle_array[i],courseID_array[i],false,false)              step2Form.targetcourse.options[i+1] = new Option(courseTitle_array[i],courseID_array[i],false,false)
         }          }
Line 215  function setOptions(caller,itemnum) { Line 221  function setOptions(caller,itemnum) {
   opForm.elements[menu].length = 0    opForm.elements[menu].length = 0
   if (opForm.elements[itemnum*2].checked == true) {    if (opForm.elements[itemnum*2].checked == true) {
     if (caller == "board") {      if (caller == "board") {
       opForm.elements[menu].options[0] = new Option("$lt{'sel'}","-1",true,true)        opForm.elements[menu].options[0] = new Option("$js_lt{'sel'}","-1",true,true)
       opForm.elements[menu].options[1] = new Option("$lt{'impto'}","topics",true,true)        opForm.elements[menu].options[1] = new Option("$js_lt{'impto'}","topics",true,true)
       opForm.elements[menu].options[2] = new Option("$lt{'imptpa'}","allpost",true,true)        opForm.elements[menu].options[2] = new Option("$js_lt{'imptpa'}","allpost",true,true)
       opForm.elements[menu].options[3] = new Option("$lt{'imptpn'}","allanon",true,true)        opForm.elements[menu].options[3] = new Option("$js_lt{'imptpn'}","allanon",true,true)
     }      }
     else {       else { 
       if (caller == "users") {        if (caller == "users") {
         opForm.elements[menu].length = 0          opForm.elements[menu].length = 0
         opForm.elements[menu].options[0] = new Option("$lt{'sel'}","-1",true,true)          opForm.elements[menu].options[0] = new Option("$js_lt{'sel'}","-1",true,true)
         opForm.elements[menu].options[1] = new Option("$lt{'enrst'}","students",true,true)          opForm.elements[menu].options[1] = new Option("$js_lt{'enrst'}","students",true,true)
         opForm.elements[menu].options[2] = new Option("$lt{'enrall'}","all",true,true)          opForm.elements[menu].options[2] = new Option("$js_lt{'enrall'}","all",true,true)
       }        }
     }      }
   }    }
   else {    else {
     opForm.elements[menu].options[0] = new Option("$lt{'notreq'}","0",true,true)      opForm.elements[menu].options[0] = new Option("$js_lt{'notreq'}","0",true,true)
   }    }
   opForm.elements[menu].selectedIndex = 0    opForm.elements[menu].selectedIndex = 0
   if (numCrs > 0) {    if (numCrs > 0) {
Line 248  function verify(caller) { Line 254  function verify(caller) {
       totcheck ++        totcheck ++
       if (opForm.elements[2*i].name == "board") {         if (opForm.elements[2*i].name == "board") { 
         if (opForm.elements[2*i+1].selectedIndex == 0) {               if (opForm.elements[2*i+1].selectedIndex == 0) {     
           alert("$lt{'errao'}")            alert("$js_lt{'errao'}")
           return false            return false
         }          }
         if (numCrs == 0) {          if (numCrs == 0) {
Line 257  function verify(caller) { Line 263  function verify(caller) {
         }          }
         else {          else {
           if (opForm.targetcourse.selectedIndex == 0) {            if (opForm.targetcourse.selectedIndex == 0) {
             alert("$lt{'errtd'}")              alert("$js_lt{'errtd'}")
             return false              return false
           }            }
         }          }
       }        }
       if (opForm.elements[2*i].name == "users") {        if (opForm.elements[2*i].name == "users") {
         if (opForm.elements[2*i+1].selectedIndex == 0) {               if (opForm.elements[2*i+1].selectedIndex == 0) {     
           alert("$lt{'errap'}")            alert("$js_lt{'errap'}")
           return false            return false
         }          }
         if (numCrs == 0) {          if (numCrs == 0) {
Line 273  function verify(caller) { Line 279  function verify(caller) {
         }          }
         else {          else {
           if (opForm.targetcourse.selectedIndex == 0) {            if (opForm.targetcourse.selectedIndex == 0) {
             alert("$lt{'errte'}")              alert("$js_lt{'errte'}")
             return false              return false
           }            }
         }          }
Line 281  function verify(caller) { Line 287  function verify(caller) {
     }      }
   }    }
   if (totcheck == 0) {    if (totcheck == 0) {
     alert("$lt{'errcc'}");      alert("$js_lt{'errcc'}");
     return false      return false
   }    }
   return true    return true
Line 635  sub display_three { Line 641  sub display_three {
         );          );
         my $londocroot = $r->dir_config('lonDocRoot');          my $londocroot = $r->dir_config('lonDocRoot');
         if ($destdir =~ m{^\Q$londocroot/priv/$udom/$uname/$dirpath\E}) {          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') {      } elsif ($manifest_result eq 'nomanifest') {
         $r->print(          $r->print(
Line 767  END_JS Line 773  END_JS
     }      }
   
     my $title = 'Upload IMS package to Authoring Space';      my $title = 'Upload IMS package to Authoring Space';
       my $crsauthor;
       if ($env{'request.course.id'}) {
           my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
           my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
           if (($udom eq $cdom) && ($uname eq $cnum)) {
               $title = 'Upload IMS package to Course Authoring Space';
               $crsauthor = 1;
           }
       }
   
     $r->print(&Apache::loncommon::start_page($title, $javascript));      $r->print(&Apache::loncommon::start_page($title, $javascript));
   
     if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {      unless ($crsauthor) {
         $r->print('<p><span class="LC_info">'          if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
                   .&mt('Co-Author [_1]',$uname.':'.$udom)              $r->print('<p><span class="LC_info">'
                   .'</span></p>'                        .&mt('Co-Author [_1]',$uname.':'.$udom)
         );                        .'</span></p>'
               );
           }
     }      }
     if ($env{'form.phase'} eq 'two') {      if ($env{'form.phase'} eq 'two') {
         my $flag = &Apache::lonupload::phasetwo($r,$fn,'imsimport');          my $flag = &Apache::lonupload::phasetwo($r,$fn,'imsimport');

Removed from v.1.46  
changed lines
  Added in v.1.49


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>