Diff for /loncom/imspackages/imsimport.pm between versions 1.9 and 1.39

version 1.9, 2005/02/14 22:46:12 version 1.39, 2013/06/04 22:20:28
Line 1 Line 1
   # The LearningOnline Network with CAPA
   # 
   # $Id$
   #
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
Line 25  package Apache::imsimport; Line 29  package Apache::imsimport;
   
 use strict;  use strict;
 use Apache::Constants qw(:common :http :methods);  use Apache::Constants qw(:common :http :methods);
 use Apache::loncacc;  
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::Log();  
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::imsprocessor;  use Apache::imsprocessor;
   use Apache::lonlocal;
 use HTML::Parser;  use HTML::Parser;
 use HTML::Entities();  use HTML::Entities();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonupload;  use Apache::lonupload;
 use File::Basename();  use File::Basename();
                                                                                               use LONCAPA;
   
 # ----------------------------------------------------------------  Jscript One  # ----------------------------------------------------------------  Jscript One
 sub jscript_one {  sub jscript_one {
     my ($fullpath,$jsref) = @_;      my ($fullpath,$formname) = @_;
     $$jsref = <<"END_OF_ONE";  
       my %body_layout = ('rightmargin'  => "0",
          'leftmargin'   => "0",
          'marginwidth'  => "0",
          'topmargin'    => "0",
          'marginheight' => "0");
       my $start_page = 
    &Apache::loncommon::start_page('Create IMS import directory',undef,
          {'only_body'   => 1,
    'add_entries' => \%body_layout,
    'js_ready'    => 1,});
       my $end_page = 
    &Apache::loncommon::end_page({'js_ready' => 1,});
   
       my %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',
                  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', 
                );
       return <<"END_OF_ONE";
 function verify() {  function verify() {
  if ((document.forms.dataForm.newdir.value == '')  || (!document.forms.dataForm.newdir.value)) {   if ((document.forms.$formname.newdir.value == '')  || (!document.forms.$formname.newdir.value)) {
    alert("You must choose a destination directory for the import")     alert('$lt{'ddir'}')
    return false     return false
  }   }
  if (document.forms.dataForm.source.selectedIndex == 0) {   if (document.forms.$formname.source.selectedIndex == 0) {
    alert("You must choose the Course Management System from which the IMS package was exported");     alert('$lt{'cmss'}');
    return false     return false
  }   }
  return true   return true
Line 54  function verify() { Line 80  function verify() {
   
 function nextPage() {  function nextPage() {
   if (verify()) {    if (verify()) {
     document.forms.dataForm.submit()      document.forms.$formname.submit();
   }    }
 }  }
   
 function createWin() {  function createWin() {
   document.dataForm.newdir.value = "";    document.$formname.newdir.value = "";
   newWindow = window.open("","CreateDir","HEIGHT=400,WIDTH=750,scrollbars=yes")    newWindow = window.open("","CreateDir","HEIGHT=400,WIDTH=750,scrollbars=yes")
   newWindow.document.open()    newWindow.document.open()
   newWindow.document.write("<html><head><title>Create IMS import directory</title><meta http-equiv='pragma' content='no-cache'>\\n")    newWindow.document.write('$start_page')
   newWindow.document.write("</head><body bgcolor='#CCFFDD' topmargin='0' leftmargin='0' marginheight='0'marginwidth='0' rightmargin='0'>\\n")    newWindow.document.write("\\n<img border='0' src='/adm/lonInterFace/author.jpg' alt='[Author Header]' />\\n")
   newWindow.document.write("<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' bgcolor='#CCFFDD'>\\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>Location: <tt>$fullpath</tt></h3><h3>New Directory</h3></td></tr>\\n")    newWindow.document.write("<td><h3>$lt{'loca'} <tt>$fullpath</tt></h3><h3>$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("<font face='arial,helvetica,sans-serif'>Enter the name of the new directory where you will store the contents of your IMS package.<br /><br />")    newWindow.document.write("$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='Go' onClick='document.fileaction.submit();' />")    newWindow.document.write("<input type='button' value='$lt{'go'}' onClick='document.fileaction.submit();' />")
   newWindow.document.write("</td></tr>\\n")    newWindow.document.write("</td></tr>\\n")
   newWindow.document.write("</table></body></html>")    newWindow.document.write("</table>")
     newWindow.document.write('$end_page')
   newWindow.document.close()    newWindow.document.close()
   newWindow.focus()    newWindow.focus()
 }  }
Line 88  END_OF_ONE Line 114  END_OF_ONE
   
 # ----------------------------------------------------------------  Jscript Two  # ----------------------------------------------------------------  Jscript Two
 sub jscript_two {  sub jscript_two {
     my ($javascript,$user,$dom,$numcrs) = @_;      my ($user,$dom,$numcrs) = @_;
     my %crsentry = ();      my %crsentry = ();
     my $course_list;      my $course_list;
     my $title_list;      my $title_list;
Line 107  sub jscript_two { Line 133  sub jscript_two {
     $course_list = '"'.join('","',@crslist).'"';      $course_list = '"'.join('","',@crslist).'"';
     $$numcrs = @crslist;      $$numcrs = @crslist;
   
     $$javascript = qq#      return <<"END_OF_TWO";
   
 function checkCourse() {  function checkCourse() {
   courseID_array = new Array($course_list)    courseID_array = new Array($course_list)
Line 253  function nextPage(caller) { Line 279  function nextPage(caller) {
   }    }
 }  }
   
 #;  END_OF_TWO
   
 }  }
   
 # ----------------------------------------------------------------  Jscript Three  
 sub jscript_three {  
     my $javascript = shift;  
 }  
   
 # ---------------------------------------------------------------- Display One  # ---------------------------------------------------------------- Display One
 sub display_one {  sub display_one {
     my ($r,$uname,$fn,$fullpath) = @_;      my ($r,$fn,$fullpath,$formname) = @_;
     $r->print(<<"END_OF_ONE");      $r->print('<form name="'.$formname.'" method="post">'.
 <form name="dataForm" method="post">                &Apache::lonhtmlcommon::topic_bar(1,&mt('Specify the Course Management system used to create the package')).
 <table border='0' bgcolor='#CCFFDD' cellspacing='0' cellpadding ='0' width='100%'>          &mt('Choose the CMS used to create your IMS content package.').'&nbsp;&nbsp;
     <tr>  
      <td colspan='2'>  
       <table border='0' cellspacing='0' cellpadding='0'>  
        <tr>  
         <td colspan='2'  align='left'>&nbsp;  
         </td>  
        </tr>  
        <tr bgcolor='#ccddaa'>  
         <td valign='middle'><img src='/res/adm/pages/bl_step1.gif'>&nbsp;  
         </td>  
         <td width='100%' align='left'>&nbsp;&nbsp;  
          <font face='arial,helvetica,sans-serif'><b>Specify the Course Management system used to create the package.</b>&nbsp;&nbsp;  
          </font>  
        </td>  
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;</td>  
       </tr>  
       <tr>  
        <td>&nbsp;</td>  
        <td>  
         <font face='Arial,Helvetica,sans-serif'>  
 Please choose the CMS used to create your IMS content package.&nbsp;&nbsp;  
         <select name="source">          <select name="source">
          <option value='-1' selected="true">Please select           <option value="-1" selected="selected">Please select</option>
          <option value='bb6'>Blackboard 6           <option value="bb5">Blackboard 5</option>
          <option value='bb5'>Blackboard 5           <option value="bb6">Blackboard 6</option>
          <option value='angel'>ANGEL           <option value="angel5">ANGEL 5.5</option>
         </select>           <option value="webctce4">WebCT 4 Campus Edition</option>
         </font>           <option value="webctvista4">WebCT Vista 4</option>
        </td>          </select><br />'."\n".
       </tr>          &Apache::lonhtmlcommon::topic_bar(2,&mt('Create a directory where you will unpack your IMS package'))."\n".
       <tr>           &mt('Create a destination LON-CAPA directory in which to store the contents of the IMS package file.').'&nbsp;&nbsp;<input type="button" name="createdir" value="Create Directory" onClick="javascript:createWin()" /><input type="hidden" name="newdir" value="" /><br /><br />
        <td colspan='2'>&nbsp;</td>            <input type="hidden" name="filename" value="'.$fn.'" />
       </tr>            <input type="hidden" name="phase" value="three" />
       <tr>            <input type="button" name="nextpage" value="'.&mt('Proceed').'" onClick="javascript:nextPage();" />&nbsp;&nbsp;&nbsp;&nbsp;
        <td colspan='2'>&nbsp;</td>            <input type="button" name="exitpage" value="'.&mt('Exit now').'" onClick="javascript:location.href='."'$fullpath'".'" />
       </tr>           </form>');
       <tr bgcolor='#ccddaa'>  
        <td valign='middle'><img src='/res/adm/pages/bl_step2.gif'>  
        </td>  
        <td width='100%' align='left'>&nbsp;&nbsp;  
         <font face='arial,helvetica,sans-serif'><b>Create a directory where you will unpack your IMS package.</b>&nbsp;&nbsp;</font></td>  
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;</td>  
       </tr>  
        <td>&nbsp;</td>  
        <td>  
         <font face='Arial,Helvetica,sans-serif'>  
 Please choose a destination LON-CAPA directory in which to store the contents of the IMS package file. <input type="button" name="createdir" value="Create Directory" onClick="javascript:createWin()"><input type="hidden" name="newdir" value=""></font>  
        </td>  
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;<br /><br /></td>  
       </tr>  
       <tr>  
        <td>&nbsp;</td>  
        <td><font face='arial,helvetica,sans-serif'>If you have selected the CMS used to create the IMS package, and have created a destination directory, click the 'Proceed' button to continue the IMS package upload process.</font></td>  
       </tr>  
       <tr>  
        <td colspan='2'>  
           <input type="hidden" name="uploaduname" value="$uname">  
           <input type="hidden" name="filename" value="$fn">  
           <input type="hidden" name="phase" value="three">  
        </td>  
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;</td>  
       </tr>  
       <tr>  
        <td colspan='2'>  
         <table border='0' cellspacing='0' cellpadding='0' width="100%">  
          <tr>  
           <td align='left'>  
            <input type='button' name='exitpage' value='Exit now' onClick="javascript:location.href='$fullpath'">  
           </td>  
           <td align='right'>  
            <input type="button" name="nextpage" value="Proceed" onClick="javascript:nextPage()">  
           </td>  
          </tr>  
         </table>  
        </td>  
       </tr>  
      </table>  
     </td>  
    </tr>  
   </table>  
 </form>  
 END_OF_ONE  
 }  }
   
 # ---------------------------------------------------------------- Display Two  # ---------------------------------------------------------------- Display Two
 sub display_two {  sub display_two {
     my ($r,$zipupload,$areas,$areaname,$cmsmap,$uname,$newdir,$numcrs,$fullpath) = @_;      my ($r,$zipupload,$areas,$areaname,$cmsmap,$fn,$numcrs,$fullpath) = @_;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder','source']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder','source']);
     my $cms = $ENV{'form.source'};      my $cms = $env{'form.source'};
     my $dirname = $ENV{'form.newdir'};      my $tempdir = &Apache::imsprocessor::create_tempdir('CSTR',$env{'form.newdir'},'');
     my $tempdir = &Apache::imsprocessor::create_tempdir('CSTR',$dirname,'');  
     my $fname = &Apache::imsprocessor::uploadzip('CSTR',$tempdir,$zipupload);      my $fname = &Apache::imsprocessor::uploadzip('CSTR',$tempdir,$zipupload);
     my $unzip_result = '';      my $unzip_result = '';
     my $manifest_result = '';      my $manifest_result = '';
Line 380  sub display_two { Line 325  sub display_two {
     my %hrefs = ();      my %hrefs = ();
     my %resinfo = ();      my %resinfo = ();
     my %count = ();      my %count = ();
     my @bgcolors = ("#eeeeee","#dddddd");  
       my %lt = &Apache::lonlocal::texthash(
                     cont => 'Choose which content types you wish to import',
                     impo => 'Import',
                     type => 'Content type',
                     addo => 'Additional options',
                     chec => 'Check Import first',
                     bbus => 'Choose a course to receive bulletin boards and user enrollment',
                     list => 'A listing of possible course targets will be displayed if import of bulletin boards and/or enrollment is checked above (step 3). If you do not plan to import either of these content types, there is no need to specify a course.',
                     chco => 'Choose course:',
                     nreq => 'Not required',
                     yodo => 'You do not have active course coordinator status in any LON-CAPA courses currently, so bulletin boards and enrollment information included in your IMS package will be discarded, regardless of your import choice for these two items above (step 3).',
                     ifyo => "If you wish to import bulletin boards and/or user information into LON-CAPA please click 'Exit now' to quit the current IMS import process, and contact your domain coordinator and request a course coordinator role in a LON-CAPA course into which you can upload bulletin boards and/or enroll users.",
                     impa => 'Import package',
                     unpa => 'Unpacking of your IMS package failed because an IMS manifest file was not located in the package',
                     proc => 'Processing of your IMS package failed because the file you uploaded could not be unzipped',
                     exit => 'Exit now',
       );
   
     my $counter = 0;      my $counter = 0;
     my $iter = 0;      my $iter = 0;
Line 397  sub display_two { Line 359  sub display_two {
                 users => 0,                  users => 0,
                 );                  );
     my $conditions;      my $conditions;
   
     if ($unzip_result eq 'ok') {      if ($unzip_result eq 'ok') {
         $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo,'choose',\%includedres,\%includeditems);          $manifest_result = &Apache::imsprocessor::process_manifest($cms,
                               $tempdir,\%resources,\%items,\%hrefs,\%resinfo,
                               'choose',\%includedres,\%includeditems);
         if ($manifest_result eq 'ok') {          if ($manifest_result eq 'ok') {
             foreach my $res (sort keys %resources) {              foreach my $res (sort keys %resources) {
                 if ($cms eq 'bb5' || $cms eq 'bb6') {                  if ($cms eq 'bb5' || $cms eq 'bb6' || $cms eq 'webctce4' 
                       || $cms eq 'webctvista4') {
                     foreach my $area (keys %{$$cmsmap{$cms}}) {                      foreach my $area (keys %{$$cmsmap{$cms}}) {
                         if ($resources{$res}{type} eq $$cmsmap{$cms}{$area}) {                          if ($resources{$res}{type} eq $$cmsmap{$cms}{$area}) {
                             $count{$area} ++;                              $count{$area} ++;
                         }                          }
                     }                      }
                 } elsif ($cms eq 'angel') {                  } elsif ($cms eq 'angel5') {
                     foreach my $area (keys %{$$cmsmap{$cms}}) {                      foreach my $area (keys %{$$cmsmap{$cms}}) {
                         if ($area eq 'doc') {                          if ($area eq 'doc') {
                             if (grep/^$resources{$res}{type}$/,@{$$cmsmap{$cms}{doc}}) {                              if (grep/^$resources{$res}{type}$/,@{$$cmsmap{$cms}{doc}}) {
Line 432  sub display_two { Line 396  sub display_two {
                 $conditions = 'none';                  $conditions = 'none';
             }              }
   
             $r->print(<<ENDBLOCK);              $r->print('<form name="pickoptions" method="post">'.
 <form name="pickoptions" method="post">                        &Apache::lonhtmlcommon::topic_bar(3,$lt{'cont'}).
   <table border='0' cellspacing='0' cellpadding ='0' width='100%'>                        &Apache::loncommon::start_data_table().
    <tr>                        &Apache::loncommon::start_data_table_header_row().
     <td colspan='2'>                        '<th>'.$lt{'impo'}.'</th><th>'.$lt{'type'}.'</th><th>'.
      <table border='0' cellspacing='0' cellpadding='0'>                        $lt{'addo'}.'</th>'.
       <tr>                        &Apache::loncommon::end_data_table_header_row());
        <td colspan='2'  align='left'>&nbsp;  
        </td>  
       </tr>  
       <tr bgcolor='#ccddaa'>  
        <td valign='middle'><img src='/res/adm/pages/bl_step3.gif'>  
        </td>  
        <td width='100%' align='left'>&nbsp;&nbsp;  
         <font face='arial,helvetica,sans-serif'><b>Choose which content types you wish to import</b></font>  
        </td>  
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;</td>  
       </tr>  
       <tr>  
        <td>&nbsp;</td>  
        <td>  
         <table border='0' cellspacing='0' cellpadding='1' bgcolor='#000000'>  
          <tr>  
           <td>  
            <table border='0' cellspacing='0' cellpadding='0' bgcolor='#ffffff' width='100%'>  
             <tr>  
              <td>  
               <table border='0' cellspacing='1' cellpadding='1' bgcolor='#ffffff' width='100%'>  
                <tr bgcolor='#ccddaa'>  
                 <td align='center'><font face='arial,helvetica,sans-serif'><b>Import?</b></font></td>             
                 <td align='center'><font face='arial,helvetica,sans-serif'><b>Content type</b></font></td>  
                 <td align='center'><font face='arial,helvetica,sans-serif'><b>Additional options</b></font></td>  
                </tr>  
 ENDBLOCK  
             foreach my $area (@{$areas}) {              foreach my $area (@{$areas}) {
                 if ($count{$area} > 0) {                  if ($count{$area} > 0) {
                     my $count_tag = 'flag_'.$counter;                      my $count_tag = 'flag_'.$counter;
                     $r->print("               <tr bgcolor='@bgcolors[$iter]'>                      $r->print(&Apache::loncommon::start_data_table_row()."\n".
                 <td align='left'><font face='arial,helvetica,sans-serif'><input name='$area' type='checkbox' ");                                '<td><input name="'.$area.'" type="checkbox" ');
                     if ($area eq 'board' || $area eq 'users') {                      if ($area eq 'board' || $area eq 'users') {
                         $r->print(qq|onClick='javascript:setOptions("$area","$counter")'|);                          $r->print('onClick="javascript:setOptions('."'$area','$counter'".');" ');
                     }                      }
                     $r->print("/></font></td>                      $r->print('/></td>'.
                 <td align='left'><font face='arial,helvetica,sans-serif'>&nbsp;&nbsp;$$areaname{$area}&nbsp;&nbsp; - $count{$area} item(s)</font></td>");                                '<td>&nbsp;&nbsp;'.$$areaname{$area}.'&nbsp;&nbsp; - '.
                                 &mt('[quant,_1,item]',$count{$area}).'</td>');
                     if ($area eq 'board') {                      if ($area eq 'board') {
                         $r->print("            <td align='left'><font face='arial,helvetica,sans-serif'>&nbsp;&nbsp;                          $r->print('<td>&nbsp;&nbsp;
                  <select name='db_handling'>                   <select name="db_handling">
                   <option value='-2'>&lt;-- Check Import first                    <option value="-2">&lt;-- '.$lt{'chec'}.'</option>
                  </select></font>                   </select>
                 </td>");                  </td>');
                     } elsif ($area eq 'users') {                      } elsif ($area eq 'users') {
                         $r->print("            <td align='left'><font face='arial,helvetica,sans-serif'>&nbsp;&nbsp;                          $r->print('<td>&nbsp;&nbsp;
                  <select name='user_handling'>                   <select name="user_handling">
                   <option value='-2'>&lt;-- Check Import first                    <option value="-2">&lt;-- '.$lt{'chec'}.'</option>
                  </select>                   </select>
                  </font>                          </td>');
                 </td>");  
                     } else {                      } else {
                         $r->print("            <td align='left'><font face='arial,helvetica,sans-serif'>&nbsp;&nbsp;None<input type='hidden' name='$count_tag' /></font></td>");                          $r->print('<td>&nbsp;&nbsp;'.&mt('None')."\n".
                                     '<input type="hidden" name="'.$count_tag.'" /></td>');
                     }                      }
                     $counter ++;                      $counter ++;
                     $iter = $counter%2;                      $r->print(&Apache::loncommon::end_data_table_row());
                 }                  }
             }              }
             $r->print(<<ENDBLOCKTWO);              $r->print(&Apache::loncommon::end_data_table());
                </tr>  
               </table>  
              </td>  
             </tr>  
            </table>  
           </td>  
          </tr>  
         </table>  
        </td>  
       </tr>  
       <tr>  
        <td colspan='2'  align='left'>&nbsp;  
        </td>  
       </tr>  
 ENDBLOCKTWO  
             if ($count{board} + $count{users} > 0) {              if ($count{board} + $count{users} > 0) {
                 $r->print("                  $r->print(&Apache::lonhtmlcommon::topic_bar(4,$lt{'bbus'}));
       <tr bgcolor='#ccddaa'>  
        <td valign='middle'><img src='/res/adm/pages/bl_step4.gif'>  
        </td>  
        <td width='100%' align='left'>&nbsp;&nbsp;  
         <font face='arial,helvetica,sans-serif'><b>Choose a course to receive bulletin boards and user enrollment.</b></font>  
        </td>  
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;</td>  
       </tr>  
                 ");  
                 if ($$numcrs > 0) {                  if ($$numcrs > 0) {
                     $r->print("      <tr>                      $r->print($lt{'list'}.'<br /><br />'.$lt{'chco'}.'&nbsp;&nbsp;'."\n".
        <td>&nbsp;</td>                                '<select name="targetcourse">
        <td><font face='arial,helvetica,sans-serif'>A listing of possible course targets will be displayed if import of bulletin boards and/or enrollment is checked above (step 3). If you do not plan to import either of these content types, there is no need to specify a course.                                  <option value="-1">'.$lt{'nreq'}.'</option>
 <br /><br />                                 </select>');
 Choose course:&nbsp;&nbsp;  
                  <select name='targetcourse'>  
                   <option value='-1'>Not required  
                  </select></font>  
        </td>  
       </tr>  
 ");  
                 } else {                  } else {
                     $r->print("       <tr>                      $r->print($lt{'yodo'}.' '.$lt{'ifyo'});
 <td>&nbsp;</td>  
 <td><font face='arial,helvetica,sans-serif'>You do not have active course coordinator status in any LON-CAPA courses currently, so bulletin boards and enrollment information included in your IMS package will be discarded, regardless of your import choice for these two items above (step 3). If you wish to import bulletin boards and/or user information into LON-CAPA please click 'Exit now' to quit the current IMS import process, and contact your domain coordinator and request a course coordinator role in a LON-CAPA course into which you can upload bulletin boards and/or enroll users.</font>  
         ");  
                 }                  }
             }              }
             $r->print(<<ENDBLOCK);              $r->print('<br /><br />
       <tr>            <input type="hidden" name="newdir" value="'.$env{'form.newdir'}.'" />
        <td colspan='2'>&nbsp;<br /><br /></td>            <input type="hidden" name="conditions" value="'.$conditions.'" />
       </tr>            <input type="hidden" name="source" value="'.$cms.'" />
       <tr>            <input type="hidden" name="tempdir" value="'.$tempdir.'" />
        <td>&nbsp;</td>            <input type="hidden" name="filename" value="'.$fn.'" />
        <td><font face='arial,helvetica,sans-serif'>Once you have checked the checkboxes for all areas you wish to import from the IMS package, and selected additional options (if available) you should click the 'Import package' button.</font></td>            <input type="hidden" name="phase" value="four" />'."\n");
       </tr>  
       <tr>  
        <td colspan='2'>&nbsp;  
           <input type="hidden" name="newdir" value="$ENV{'form.newdir'}" />  
           <input type="hidden" name="conditions" value="$conditions" />  
           <input type="hidden" name="source" value="$cms" />  
           <input type="hidden" name="tempdir" value="$tempdir" />  
           <input type="hidden" name="uploaduname" value="$uname">  
           <input type="hidden" name="filename" value="$fname">  
           <input type="hidden" name="phase" value="four" />  
 ENDBLOCK  
             if ($count{board} == 0) {              if ($count{board} == 0) {
                 $r->print('            <input type="hidden" name="board" value="" />'."\n");                  $r->print('<input type="hidden" name="board" value="" />'."\n");
             }              }
             if ($count{users} == 0) {              if ($count{users} == 0) {
                 $r->print('            <input type="hidden" name="users" value="" />'."\n");                  $r->print('<input type="hidden" name="users" value="" />'."\n");
             }              }
             $r->print(<<ENDDOCUMENT);              $r->print('<input type="button" name="nextpage" value="'.$lt{'impa'}.'" onClick="javascript:nextPage('."'$counter.'".')" />&nbsp;&nbsp;&nbsp;
        </td>             <input type="button" name="exitpage" value="'.$lt{'exit'}.'" onClick="javascript:location.href='."'$fullpath'".'" /></form>');
       </tr>  
       <tr>  
        <td colspan='2'>  
         <table border='0' cellspacing='0' cellpadding='0' width="100%">  
          <tr>  
           <td align='left'>  
            <input type='button' name='exitpage' value='Exit now' onClick="javascript:location.href='$fullpath'">  
           </td>  
           <td align='right'>  
            <input type="button" name="nextpage" value="Import package" onClick="javascript:nextPage($counter)">  
           </td>  
          </tr>  
         </table>  
        </td>  
       </tr>  
      </table>  
     </td>  
    </tr>  
   </table>  
 ENDDOCUMENT  
         } else {          } else {
             $r->print("Unpacking of your IMS package failed because an IMS manifest file was not located in the package\n");              $r->print($lt{'unpa'});
         }          }
     } else {      } else {
         $r->print("Processing of your IMS package failed because the file you uploaded could not be unzipped\n");          $r->print($lt{'proc'});
     }      }
 }  }
   
 # ---------------------------------------------------------------- Display Three  # ---------------------------------------------------------------- Display Three
 sub display_three {  sub display_three {
     my ($r,$uname,$udom,$areas,$areaname,$cmsmap,$destdir,$newdir) = @_;      my ($r,$uname,$udom,$areas,$areaname,$cmsmap,$destdir,$dirpath) = @_;
     my $crs = '';      my $crs = '';
     my $cdom = '';      my $cdom = '';
     my $chome = '';  
     my $db_handling = '';      my $db_handling = '';
     my $timenow = time;       my $timenow = time; 
     my $announce_handling = 'ok';      my $announce_handling = 'ok';
     my $cms = $ENV{'form.source'};      my $cms = $env{'form.source'};
     if ( defined($ENV{'form.bb_crs'}) ) {      if ( defined($env{'form.bb_crs'}) ) {
         ($cdom,$crs) = split/\//,$ENV{'form.bb_crs'};          ($cdom,$crs) = split/\//,$env{'form.bb_crs'};
         $chome = &Apache::lonnet::homeserver($crs,$cdom);  
     }       } 
     my $user_crs = '';      my $user_crs = '';
     my $user_cdom = '';      my $user_cdom = '';
     my $user_handling = '';      my $user_handling = '';
     if ( defined($ENV{'form.user_crs'}) ) {      if ( defined($env{'form.user_crs'}) ) {
         ($user_cdom,$user_crs) = split/\//,$ENV{'form.user_crs'};          ($user_cdom,$user_crs) = split/\//,$env{'form.user_crs'};
     }      }
     my $seqstem = "/res/$udom/$uname/$newdir";      my $seqstem = "/res/$udom/$uname/$dirpath";
     my %importareas = ();      my %importareas = ();
     my %includedres = ();      my %includedres = ();
     my %includeditems = ();      my %includeditems = ();
       my %randompicks = ();
     my @targets = ();      my @targets = ();
     my %resources = ();      my %resources = ();
     my %items = ();      my %items = ();
Line 637  sub display_three { Line 505  sub display_three {
                    board => 0,                              board => 0,         
                    quiz => 0,                     quiz => 0,
                    surv => 0,                     surv => 0,
                      file => 0,
     );      );
   
     my @pages = ();      my @pages = ();
     my @sequences = ();      my @sequences = ();
     my @resrcfiles = ();      my @resrcfiles = ();
       my @assessmentfiles = ();
   
     my $tempdir = $ENV{'form.tempdir'};      my $tempdir = $env{'form.tempdir'};
   
     foreach my $area (@{$areas}) {      foreach my $area (@{$areas}) {
         if (defined($ENV{"form.$area"}) ) {          if (defined($env{"form.$area"}) ) {
             if ($cms eq 'angel' && $area eq 'doc') {              if ($cms eq 'angel5' && $area eq 'doc') {
                 foreach (@{$$cmsmap{$cms}{$area}}) {                  foreach (@{$$cmsmap{$cms}{$area}}) {
                     $importareas{$_} = 1;                      $importareas{$_} = 1;
                 }                  }
Line 655  sub display_three { Line 525  sub display_three {
                 $importareas{$$cmsmap{$cms}{$area}} = 1;                  $importareas{$$cmsmap{$cms}{$area}} = 1;
             }              }
             if ($area eq 'board') {              if ($area eq 'board') {
                 $db_handling = $ENV{'form.db_handling'};                  $db_handling = $env{'form.db_handling'};
             } elsif ($area eq 'users') {              } elsif ($area eq 'users') {
                 $user_handling = $ENV{'form.user_handling'};                  $user_handling = $env{'form.user_handling'};
             }              }
         }          }
     }      }
   
     my $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo,'prepare',\%includedres);      my %lt = &Apache::lonlocal::texthash (
                    yims => 'Your IMS package has been processed successfully.',
                    plsv => 'Please view the imported items and use the LON-CAPA editing tools to make changes.',
                    tseq => "The sequences directory contains a file named 'Top.sequence' which includes links to the items found at the top level of your IMS package. From there you can follow links to display all the imported items. Alternatively, you can browse the pages, sequences, problems and resfiles directories directly. Note if you rename a file, you will need to modify any .sequence files or .page files which include a reference to the renamed file.",
                    tfin => 'The final step in the IMS import process is to publish the materials you have imported into your Authoring Space so that you can use them in a course. Once your files are published, subsequent re-publication will result in the storage of information about changes between the different versions.',
                    disp => 'Display new directory',
                    proc => 'Processing of your IMS package failed, because the IMS content package did not contain an IMS manifest file.'
                );
       my $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,
                             \%resources,\%items,\%hrefs,\%resinfo,'prepare',
                             \%includedres);
     if ($manifest_result eq 'ok') {      if ($manifest_result eq 'ok') {
         foreach my $res (sort keys %resources) {          foreach my $res (sort keys %resources) {
             if ($importareas{$resources{$res}{type}}) {              if ($importareas{$resources{$res}{type}}) {
                 $includedres{$res} = 1;                  $includedres{$res} = 1;
                   if ($resources{$res}{type} eq 'webct.manifest' || 
                        $resources{$res}{type} eq 'webct.assessment' ||
                        $resources{$res}{type} eq 'webct.question') {
                       push(@assessmentfiles,$res);
                   }   
             }              }
         }          }
         foreach my $itm (sort keys %items) {          foreach my $itm (sort keys %items) {
Line 678  sub display_three { Line 563  sub display_three {
         &Apache::imsprocessor::get_parents(\%includeditems,\%items,$itm);          &Apache::imsprocessor::get_parents(\%includeditems,\%items,$itm);
     }      }
   
     $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo,'build',\%includedres,\%includeditems);      $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,
                          \%resources,\%items,\%hrefs,\%resinfo,'build',
                          \%includedres,\%includeditems);
     if ($manifest_result eq 'ok') {      if ($manifest_result eq 'ok') {
         &Apache::imsprocessor::target_resources(\%resources,\%importareas,\@targets);          &Apache::imsprocessor::target_resources(\%resources,\%importareas,\@targets);
   
Line 695  sub display_three { Line 582  sub display_three {
         my @topnames = ();          my @topnames = ();
         my @packages = ();          my @packages = ();
   
         &Apache::imsprocessor::process_resinfo($cms,'CSTR',$tempdir,$destdir,\%items,\%resources,\@targets,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$seqstem,$seqstem,\@resrcfiles,\@packages,\%hrefs,\@pages,\@sequences);          &Apache::imsprocessor::process_resinfo($cms,'CSTR',$tempdir,$destdir,\%items,\%resources,\@targets,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$seqstem,$seqstem,\@resrcfiles,\@packages,\%hrefs,\@pages,\@sequences,\%randompicks);
   
         my $copy_result = &Apache::imsprocessor::copy_resources('CSTR',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow,\%importareas);          my $copy_result = &Apache::imsprocessor::copy_resources('CSTR',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$destdir,$timenow,\@assessmentfiles,\%total);
         
         &Apache::imsprocessor::build_structure($cms,'CSTR',$destdir,\%items,\%resinfo,\%resources,\@targets,\%hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages,\%includeditems);          &Apache::imsprocessor::build_structure($cms,'CSTR',$destdir,\%items,\%resinfo,\%resources,\@targets,\%hrefs,$udom,$uname,$dirpath,$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages,\%includeditems,\%randompicks);
   
         $r->print("<h3>IMS import completed</h3>");          $r->print("<h3>IMS import completed</h3>");
   
         if ($cms eq 'bb5') {          if ($cms eq 'angel5') {
             $r->print("<font face='arial,helvetica,sans-serif'>Your IMS package has been processed successfully. A total of $total{seq} sequences, $total{page} pages, $total{board} bulletin boards, $total{quiz} quizzes, $total{surv} surveys and $total{prob} problems have been created.<br /><br />\n");              $r->print($lt{'yims'}.' '.&mt('A total of [quant,_1,sequence], [quant,_2,composite page], and [quant,_3,bulletin board] have been created, and [quant,_4,file] copied.',$total{seq},$total{page},$total{board},$total{file})."\n");
         } elsif ($cms eq 'angel') {          } else {
             $r->print("<font face='arial,helvetica,sans-serif'>Your IMS package has been processed successfully. A total of $total{seq} sequences, $total{page} pages, and $total{board} bulletin boards have been created.<br /><br />\n");              $r->print($lt{'yims'}.' '.&mt('A total of [quant,_1,sequence], [quant,_2,composite page], [quant,_3,bulletin board], [quant,_4,quiz,quizzes], [quant,_5,survey], and [quant,_6,problem] have been created, and [quant,_7,file] copied.',$total{seq},$total{page},$total{board},$total{quiz},$total{surv},$total{prob},$total{file})."\n");
         }          }
        $r->print("Please view the imported items and use the LON-CAPA editing tools to make changes.  The sequences directory contains a file named 'Top.sequence' whichincludes links to the items found at the top level of your IMS package. From there you can follow links to display all the imported items. Alternatively, you can browse the pages, sequences, problems and resfiles directories directly. Note if you rename a file, you will need to modify any .sequence files or .page files which include a reference to the renamed file.<br /><br />The final step in the IMS import process is to publish the materials you have imported into your Construction Space so that you can use them in a course. Once your file are published, subsequent re-publication will result in the storage of information about changes between the different versions.<br /><br /><a href='/priv/".$uname."/".$newdir."'>Display new directory</a></font>");           $r->print('<br /><br />'.$lt{'plsv'}.' '.$lt{'tseq'}.'<br /><br />'.$lt{'tfin'}.'<br /><br /><a href="/priv/'.$udom.'/'.$uname.'/'.$dirpath.'/">'.$lt{'disp'}.'</a>');
         if ($destdir =~ m-^/home/$uname/public_html/-) {           my $londocroot = $r->dir_config('lonDocRoot');
           if ($destdir =~ m{^\Q$londocroot/priv/$udom/$uname/$dirpath\E}) {
             system (" rm -r -f $destdir/temp");              system (" rm -r -f $destdir/temp");
         }          }
     } elsif ($manifest_result eq 'nomanifest') {      } elsif ($manifest_result eq 'nomanifest') {
         $r->print("<font face='arial,helvetica,sans-serif'>Processing of your IMS package failed, because the IMS content package did not contain an IMS manifest file.</font>");          $r->print($lt{'proc'});
     }      }
 }  }
   
 # ---------------------------------------------------------------- Get LON-CAPA Course Coordinator roles for this user  # ---------------------------------------------------------------- Get LON-CAPA Course Coordinator roles for this user
 sub get_ccroles {  sub get_ccroles {
     my ($user,$dom,$crsentry,$crslist) = @_;      my ($user,$dom,$crsentry,$crslist) = @_;
     my %roles = ();      my %roles;
     unless ($user eq '') {      unless ($user eq '') {
         %roles = &Apache::lonnet::dump('roles',$dom,$user);          my $ccrole = 'cc';
           %roles = &Apache::lonnet::get_my_roles($user,$dom,'userroles',undef,[$ccrole]);
     }      }
     my $iter = 0;      my $iter = 0;
     my @codes = ();      my @codes = ();
     my %courses = ();      my %courses = ();
     my @crslist = ();      my @crslist = ();
     my %descrip =();      my %descrip =();
     foreach my $key (keys %roles ) {      foreach my $key (keys(%roles)) {
         if ($key =~ m/^\/(\w+)\/(\w+)_cc$/) {          if ($key =~ m{^/($LONCAPA::domain_re)/($LONCAPA::username_re)_cc$}) {
             my $cdom = $1;              my $cdom = $1;
             my $crs = $2;              my $crs = $2;
             my $role_end = 0;              my $currcode = '';
             my $role_start = 0;              my %settings = &Apache::lonnet::get('environment',['internal.coursecode','description'],$cdom,$crs);
             my $active_chk = 1;              if (defined($settings{'description'}) ) {
             if ( $roles{$key} =~ m/^cc_(\d+)/ ) {                  $descrip{$crs} = $settings{'description'};
                 $role_end = $1;              } else {
                 if ( $roles{$key} =~ m/^cc_($role_end)_(\d+)$/ )                  $descrip{$crs} = 'Unknown';
                 {  
                     $role_start = $2;  
                 }  
             }  
             if ($role_start > 0) {  
                 if (time < $role_start) {  
                     $active_chk = 0;  
                 }  
             }  
             if ($role_end > 0) {  
                 if (time > $role_end) {  
                     $active_chk = 0;  
                 }  
             }              }
             if ($active_chk) {              if (defined($settings{'internal.coursecode'}) ) {
                 my $currcode = '';                  $currcode = $settings{'internal.coursecode'};
                 my %settings = &Apache::lonnet::get('environment',['internal.coursecode','description'],$cdom,$crs);                  if ($currcode eq '') {
                 if (defined($settings{'description'}) ) {  
                     $descrip{$crs} = $settings{'description'};  
                 } else {  
                     $descrip{$crs} = 'Unknown';  
                 }  
                 if (defined($settings{'internal.coursecode'}) ) {  
                     $currcode = $settings{'internal.coursecode'};  
                     if ($currcode eq '') {  
                         $currcode = "____".$iter;  
                         $iter ++;  
                     }  
                 } else {  
                     $currcode = "____".$iter;                      $currcode = "____".$iter;
                     $iter ++;                      $iter ++;
                 }                  }
                 unless (grep/^$currcode$/,@codes) {              } else {
                     push @codes,$currcode;                  $currcode = "____".$iter;
                     @{$courses{$currcode}} = ();                  $iter ++;
                 }              }
                 push @{$courses{$currcode}}, $cdom.'/'.$crs;              unless (grep/^$currcode$/,@codes) {
                   push @codes,$currcode;
                   @{$courses{$currcode}} = ();
             }              }
               push @{$courses{$currcode}}, $cdom.'/'.$crs;
         }          }
     }      }
     foreach my $code (sort @codes) {      foreach my $code (sort @codes) {
Line 794  sub get_ccroles { Line 661  sub get_ccroles {
 # ---------------------------------------------------------------- Main Handler  # ---------------------------------------------------------------- Main Handler
 sub handler {  sub handler {
     my $r=shift;      my $r=shift;
     my $uname;  
     my $udom;  
     my $javascript = '';  
     my $page_name = '';  
     my $current_page = '';  
     my $loadentries = '';  
     my $qcount = '';  
   
 # get personal information for this user      my $fn=$env{'form.filename'};
     my $user=$ENV{'user.name'};  
     my $dom=$ENV{'user.domain'};  
   
 #      if ($env{'form.filename1'}) {
 # re-attach user          $fn=$env{'form.filename1'}.$env{'form.filename2'};
 #  
     if ($ENV{'form.uploaduname'}) {  
         $ENV{'form.filename'}='/priv/'.$ENV{'form.uploaduname'}.'/'.  
             $ENV{'form.filename'};  
     }  
     ($uname,$udom)=  
         &Apache::loncacc::constructaccess($ENV{'form.filename'},  
                                           $r->dir_config('lonDefDomain'));  
     unless (($uname) && ($udom)) {  
         $r->log_reason($uname.' at '.$udom.  
                        ' trying to publish file '.$ENV{'form.filename'}.  
                        ' - not authorized',  
                        $r->filename);  
         return HTTP_NOT_ACCEPTABLE;  
     }      }
                                                                                                    $fn=~s{\+}{}g;
     my $fn;  
     if ($ENV{'form.filename'}) {      unless ($fn) {
         $fn=$ENV{'form.filename'};          $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
         $fn=~s/^http\:\/\/[^\/]+\///;  
         $fn=~s/^\///;  
         $fn=~s/(\~|priv\/)(\w+)//;  
         $fn=~s/\/+/\//g;  
     } else {  
         $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.  
                        ' unspecified filename for upload', $r->filename);                         ' unspecified filename for upload', $r->filename);
         return HTTP_NOT_FOUND;          return HTTP_NOT_FOUND;
     }      }
     my $zipupload = '/home/'.$uname.'/public_html'.$fn;  
     my $pathname = &File::Basename::dirname($fn);      my ($uname,$udom) = &Apache::lonnet::constructaccess($fn);
     my $fullpath = '/priv/'.$uname.$pathname;      if (($uname eq '') || ($udom eq '')) {
     unless ($pathname eq '/') {          $r->log_reason($uname.' at '.$udom.
                          ' trying to publish file '.$fn.' - not authorized',
                          $r->filename);
           return HTTP_NOT_ACCEPTABLE;
       }
   
       my $londocroot = $r->dir_config('lonDocRoot');
       my $zipupload = $londocroot.$fn;
       my $fullpath = &File::Basename::dirname($fn);
       unless ($fullpath =~ m{/$}) {
         $fullpath .= '/';          $fullpath .= '/';
     }      }
     my $loadentries = '';  
   
   # get personal information for this user
       my $user=$env{'user.name'};
       my $dom=$env{'user.domain'};
   
       my $javascript = '';
       my $page_name = '';
       my $current_page = '';
       my $qcount = '';
     my @areas = ();      my @areas = ();
     my %cmsmap = ();      my %cmsmap = ();
     my %areaname = ();      my %areaname = ();
Line 854  sub handler { Line 708  sub handler {
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
   
     if ($ENV{'form.phase'} eq 'two') {      my $formname_one = 'info';
         &jscript_one($fullpath,\$javascript,$uname,$udom);      if ($env{'form.phase'} eq 'two') {
     } elsif ($ENV{'form.phase'} eq 'three') {          $javascript = &jscript_one($fullpath,$formname_one);
         &jscript_two(\$javascript,$user,$dom,\$numcrs);      } elsif ($env{'form.phase'} eq 'three') {
     } elsif ($ENV{'form.phase'} eq 'four') {          $javascript = &jscript_two($user,$dom,\$numcrs);
         &jscript_three(\$javascript);      }
     }      if ($javascript ne '') {
     $r->print("<html><head><title>LON-CAPA Construction Space</title><script type=\"text/javascript\">\n//<!--\n$javascript\n// --></script>\n</head>");          $javascript = <<"END_JS";
                                                                                                <script type="text/javascript">
     $r->print(&Apache::loncommon::bodytag('Upload IMS package to Construction Space',undef,$loadentries));  // <![CDATA[
                                                                                                
     if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {  $javascript
         $r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname.  
                   &mt(' at ').$udom.'</font></h3>');  // ]]>
     }     </script>
     if ($ENV{'form.phase'} eq 'two') {  END_JS
         my $flag = &Apache::lonupload::phasetwo($r,$fn,$uname,$udom,'imsimport');      }
   
       my $title = 'Upload IMS package to Authoring Space';
       $r->print(&Apache::loncommon::start_page($title, $javascript));
   
       if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
           $r->print('<p><span class="LC_info">'
                     .&mt('Co-Author [_1]',$uname.':'.$udom)
                     .'</span></p>'
           );
       }
       if ($env{'form.phase'} eq 'two') {
           my $flag = &Apache::lonupload::phasetwo($r,$fn,'imsimport');
         if ($flag eq 'ok') {          if ($flag eq 'ok') {
             &display_one($r,$uname,$fn,$fullpath);              &display_one($r,$fn,$fullpath,$formname_one);
         }          }
     } elsif ( ($ENV{'form.phase'} eq 'three') || ($ENV{'form.phase'} eq 'four') ) {      } elsif ( ($env{'form.phase'} eq 'three') || ($env{'form.phase'} eq 'four') ) {
         my $docroot = $ENV{'form.newdir'};          my $destdir = $env{'form.newdir'};
         my $newdir = '';          my $dirpath = $destdir;
         if ($docroot =~ m|public_html/(.+)$|) {          $dirpath =~ s{^\Q$londocroot/priv/$udom/$uname/\E}{};
             $newdir = $1;  
         }          if ($env{'form.phase'} eq 'three') {
         if ($ENV{'form.phase'} eq 'three') {              &display_two($r,$zipupload,\@areas,\%areaname,\%cmsmap,$fn,\$numcrs,$fullpath);
             &display_two ($r,$zipupload,\@areas,\%areaname,\%cmsmap,$uname,$newdir,\$numcrs,$fullpath);          } elsif ($env{'form.phase'} eq 'four') {
         } elsif ($ENV{'form.phase'} eq 'four') {              &display_three($r,$uname,$udom,\@areas,\%areaname,\%cmsmap,$destdir,$dirpath);
             &display_three ($r,$uname,$udom,\@areas,\%areaname,\%cmsmap,$docroot,$newdir);  
         }          }
     } else {      } else {
         &Apache::lonupload::phaseone($r,$fn,$uname,$udom,'imsimport');          &Apache::lonupload::phaseone($r,$fn,'imsimport');
     }      }
     $r->print('</body></html>');      $r->print(&Apache::loncommon::end_page());
     return OK;      return OK;
 }  }
 1;  1;

Removed from v.1.9  
changed lines
  Added in v.1.39


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