Diff for /loncom/interface/londocs.pm between versions 1.484.2.48 and 1.568

version 1.484.2.48, 2013/12/31 15:20:31 version 1.568, 2013/11/13 01:40:07
Line 195  ENDJS Line 195  ENDJS
         } else {          } else {
             &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,              &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
                                                                    'dumpdocs',$cdom,$cnum);                                                                     'dumpdocs',$cdom,$cnum);
         }   }
         my @todump = &Apache::loncommon::get_env_multiple('form.archive');          my @todump = &Apache::loncommon::get_env_multiple('form.archive');
         my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,          my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
             %newcontent,%has_simpleprobs);              %newcontent,%has_simpleprobs);
Line 206  ENDJS Line 206  ENDJS
                 if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {                  if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
                     $tocopy{$1} = $name;                      $tocopy{$1} = $name;
                     $display{$item} = $1;                      $display{$item} = $1;
                     $lookup{$1} = $item;                      $lookup{$1} = $item; 
                 } elsif ($res eq 'lib/templates/simpleproblem.problem') {                  } elsif ($res eq 'lib/templates/simpleproblem.problem') {
                     $simpleproblems{$item} = {                      $simpleproblems{$item} = {
                                                 symb => $resources{$item},                                                  symb => $resources{$item},
Line 306  $contents{content}.' Line 306  $contents{content}.'
 </div>';  </div>';
                 }                  }
                 if ($contents{webreferences}) {                  if ($contents{webreferences}) {
                     $content .= '                      $content .= ' 
 <div class="LC_Box">  <div class="LC_Box">
 <h4 class="LC_hcell">Web References</h4>'.  <h4 class="LC_hcell">Web References</h4>'.
 $contents{webreferences}.'  $contents{webreferences}.'
Line 316  $contents{webreferences}.' Line 316  $contents{webreferences}.'
 </body>  </body>
 </html>  </html>
 ';  ';
                 $newcontent{'/'.$simplepages{$item}{res}} = $content;                  $newcontent{'/'.$simplepages{$item}{res}} = $content; 
             }              }
         }          }
         foreach my $item (keys(%tocopy)) {   foreach my $item (keys(%tocopy)) {
             unless ($item=~/\.(sequence|page)$/) {              unless ($item=~/\.(sequence|page)$/) {
                 my $currurlpath = $prefix.$item;                  my $currurlpath = $prefix.$item;
                 my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);                  my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
Line 350  $contents{webreferences}.' Line 350  $contents{webreferences}.'
                 if ($simpleproblems{$num}) {                  if ($simpleproblems{$num}) {
                     $newfilename=$title.'/'.$simpleproblems{$num}{'name'};                      $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
                 } else {                  } else {
                     $newfilename=$title.'/'.$replacehash{$item};              $newfilename=$title.'/'.$replacehash{$item};
                 }                  }
                 $newfilename=~s/\.(\w+)$//;          $newfilename=~s/\.(\w+)$//;
                my $ext=$1;          my $ext=$1;
                 $newfilename=&clean($newfilename);          $newfilename=&clean($newfilename);
                 $newfilename.='.'.$ext;          $newfilename.='.'.$ext;
                 my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});                  my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$}); 
                 if ($newrelpath ne $replacehash{$item}) {                  if ($newrelpath ne $replacehash{$item}) {
                     $replacehash{$item} = $newrelpath;                      $replacehash{$item} = $newrelpath;
                 }                  }
                 my @dirs=split(/\//,$newfilename);          my @dirs=split(/\//,$newfilename);
                 my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";          my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
                 my $makepath=$path;          my $makepath=$path;
                 my $fail;          my $fail;
                 my $origin;                  my $origin;
                 for (my $i=0;$i<$#dirs;$i++) {          for (my $i=0;$i<$#dirs;$i++) {
                     $makepath.='/'.$dirs[$i];      $makepath.='/'.$dirs[$i];
                     unless (-e $makepath) {      unless (-e $makepath) {
                         unless(mkdir($makepath,0755)) {          unless(mkdir($makepath,0755)) { 
                             $fail = &mt('Directory creation failed.');                              $fail = &mt('Directory creation failed.');
                         }                          }
                     }      }
                 }          }
                 if ($i == 0) {                  if ($i == 0) {
                     $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';              $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
                 } else {                  } else {
                     $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.                      $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
                                   '<span class="LC_fontsize_small" style="font-weight: bold;">'.                                    '<span class="LC_fontsize_small" style="font-weight: bold;">'.
                                   &mt('(dependency)').'</span>: ';                                    &mt('(dependency)').'</span>: ';
                 }                  }
                 if (-e $path.'/'.$newfilename) {                  if (-e $path.'/'.$newfilename) {
                     $fail = &mt('Destination already exists -- not overwriting.');                      $fail = &mt('Destination already exists -- not overwriting.'); 
                 } else {          } else {
                     if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {                      if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
                         if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||                          if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
                             ($item =~ /^simpleproblem_/)) {                              ($item =~ /^simpleproblem_/)) {
Line 404  $contents{webreferences}.' Line 404  $contents{webreferences}.'
                                         while (my $token = $parser->get_token) {                                          while (my $token = $parser->get_token) {
                                             if ($token->[0] eq 'S') {                                              if ($token->[0] eq 'S') {
                                                 if (($token->[1] eq 'resource') &&                                                  if (($token->[1] eq 'resource') &&
                                                     ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&                                                      ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') && 
                                                     ($changes{$token->[2]->{'id'}})) {                                                      ($changes{$token->[2]->{'id'}})) {
                                                     my $id = $token->[2]->{'id'};                                                      my $id = $token->[2]->{'id'};
                                                     $updatedcontent .= '<'.$token->[1];                                                      $updatedcontent .= '<'.$token->[1];
                                                     foreach my $attrib (@{$token->[3]}) {                                                      foreach my $attrib (@{$token->[3]}) {
                                                        next unless ($attrib =~ /^(src|type|title|id)$/);                                                          next unless ($attrib =~ /^(src|type|title|id)$/);
                                                         if ($attrib eq 'src') {                                                          if ($attrib eq 'src') {
                                                             my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);                                                              my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/); 
                                                             if ($file) {                                                              if ($file) {
                                                                 $updatedcontent .= ' '.$attrib.'="'.$file.'"';                                                                  $updatedcontent .= ' '.$attrib.'="'.$file.'"';
                                                             } else {                                                              } else {
                                                                 $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';                                                                  $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"'; 
                                                             }                                                              }
                                                         } else {                                                          } else {
                                                             $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';                                                              $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
Line 430  $contents{webreferences}.' Line 430  $contents{webreferences}.'
                                              }                                               }
                                          }                                           }
                                          print $fh $updatedcontent;                                           print $fh $updatedcontent;
                                     } else {                                      } else {  
                                         print $fh &Apache::lonclonecourse::rewritefile(                          print $fh &Apache::lonclonecourse::rewritefile(
                      &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),                       &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
                                                       (%replacehash,$crs => '')                                        (%replacehash,$crs => '')
                                                                                       );                                );
                                     }                                      }
                                 } else {                                  } else {
                                     print $fh                      print $fh
                                         &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);                                          &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
                                 }                  }
                             } else {                              } else {
                                 $fail = &mt('Source does not exist.');                                  $fail = &mt('Source does not exist.');  
                             }                              }
                         }                          }
                         $fh->close();                          $fh->close();
                     } else {              } else {
                         $fail = &mt('Could not write to destination.');          $fail = &mt('Could not write to destination.');
                     }                      }
                 }          }
                 my $text;                  my $text;
                 if ($fail) {          if ($fail) {
                     $text = '<span class="LC_error">'.&mt('fail').('&nbsp;'x3).$fail.'</span>';                      $text = '<span class="LC_error">'.&mt('fail').('&nbsp;'x3).$fail.'</span>';
                 } else {          } else {
                     $text = '<span class="LC_success">'.&mt('ok').'</span>';                      $text = '<span class="LC_success">'.&mt('ok').'</span>';
                 }                  }
                 if ($i == 0) {                  if ($i == 0) {
                     $result .= $text;                      $result .= $text;
                 } else {                  } else {
                     $depresult .= $text.'</li>';                      $depresult .= $text.'</li>';
                 }          }
             }              }
             $r->print($result);              $r->print($result);
             if ($depresult) {              if ($depresult) {
Line 476  $contents{webreferences}.' Line 476  $contents{webreferences}.'
             $r->rflush();              $r->rflush();
             my ($preamble,$formname);              my ($preamble,$formname);
             $formname = 'dumpdoc';              $formname = 'dumpdoc';
             unless ($home==1) {      unless ($home==1) {
                 $preamble = '<div class="LC_left_float">'.          $preamble = '<div class="LC_left_float">'.
                             '<fieldset><legend>'.              '<fieldset><legend>'.
                             &mt('Select the Authoring Space').                              &mt('Select the Authoring Space').
                             '</legend><select name="authorspace">';                              '</legend><select name="authorspace">';
             }      }
             my @orderspaces = ();              my @orderspaces = ();
             foreach my $key (sort(keys(%outhash))) {      foreach my $key (sort(keys(%outhash))) {
                 if ($key=~/^home_(.+)$/) {                  if ($key=~/^home_(.+)$/) {
                     if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {                      if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
                         unshift(@orderspaces,$1);                          unshift(@orderspaces,$1);
                     } else {                      } else {
                         push(@orderspaces,$1);                          push(@orderspaces,$1);
                     }                      }
                 }                  } 
             }  
             if ($home>1) {  
                 $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';  
             }              }
             foreach my $user (@orderspaces) {              foreach my $user (@orderspaces) {
                 if ($home==1) {   if ($home==1) {
                     $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';      $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
                 } else {   } else {
                     $preamble .= '<option value="'.$user.'">'.$user.' - '.      $preamble .= '<option value="'.$user.'">'.$user.' - '.
                                  &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';           &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
                 }          }
             }      }
             unless ($home==1) {      unless ($home==1) {
                 $preamble .= '</select></fieldset></div>'."\n";          $preamble .= '</select></fieldset></div>'."\n";
             }      }
             my $title=$origcrsdata{'description'};      my $title=$origcrsdata{'description'};
             $title=~s/[\/\s]+/\_/gs;      $title=~s/[\/\s]+/\_/gs;
             $title=&clean($title);      $title=&clean($title);
             $preamble .= '<div class="LC_left_float">'.      $preamble .= '<div class="LC_left_float">'.
                          '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.                           '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
                          '<input type="text" size="50" name="authorfolder" value="'.                           '<input type="text" size="50" name="authorfolder" value="'.
                          $title.'" />'.                           $title.'" />'.
                          '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";                           '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
             my %uploadedfiles;              my %uploadedfiles;
             &tiehash();      &tiehash();
             foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {      foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
                 my ($ext)=($file=~/\.(\w+)$/);          my ($ext)=($file=~/\.(\w+)$/);
 # FIXME Check supplemental here  # FIXME Check supplemental here
                 my $title=$hash{'title_'.$hash{          my $title=$hash{'title_'.$hash{
                                 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};                  'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
                 if (!$title) {          if (!$title) {
                     $title=$file;      $title=$file;
                 } else {          } else {
                     $title=~s|/|_|g;      $title=~s|/|_|g;
                 }          }
                 $title=~s/\.(\w+)$//;          $title=~s/\.(\w+)$//;
                 $title=&clean($title);          $title=&clean($title);
                 $title.='.'.$ext;          $title.='.'.$ext;
 #           $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"  #    $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
                 $uploadedfiles{$file} = $title;                  $uploadedfiles{$file} = $title;
             }      }
             &untiehash();      &untiehash();
             $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,              $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
                                                                  undef,undef,$preamble,$home,\%uploadedfiles));                                                                   undef,undef,$preamble,$home,\%uploadedfiles));
         }          }
Line 563  sub recurse_html { Line 560  sub recurse_html {
                 } else {                  } else {
                     $relfile = $dependency;                      $relfile = $dependency;
                     $depurl = $currurlpath;                      $depurl = $currurlpath;
                     $depurl =~ s{[^/]+$}{};                       $depurl =~ s{[^/]+$}{};  
                     $depurl .= $dependency;                      $depurl .= $dependency;
                     ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});                      ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$}); 
                 }                  }
                 next if ($relfile eq '');                  next if ($relfile eq '');
                 my $newname = $replacehash->{$container};                  my $newname = $replacehash->{$container};
                 $newname =~ s{[^/]+$}{};                  $newname =~ s{[^/]+$}{};
                 $replacehash->{$newcontainer} = $newname.$relfile;                  $replacehash->{$newcontainer} = $newname.$relfile;
                 $deps->{$item}{$newcontainer} = 1;                  $deps->{$item}{$newcontainer} = 1;
                 my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});                  my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});  
                 my $depfile = &Apache::lonnet::filelocation('',$depurl);                  my $depfile = &Apache::lonnet::filelocation('',$depurl);
                 my $type = $mm->checktype_filename($depfile);                  my $type = $mm->checktype_filename($depfile);
                 if ($type eq 'text/html') {                  if ($type eq 'text/html') {
Line 666  $initialtext Line 663  $initialtext
 </html>  </html>
 END  END
                 $env{'form.output'}=$newhtml;                  $env{'form.output'}=$newhtml;
                 my $result =                  my $result = 
                     &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,                      &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
                                                           'output',                                                            'output',
                                                           "$filepath/$residx/$fname.html");                                                            "$filepath/$residx/$fname.html");
Line 691  END Line 688  END
                           removefrommap => \%removefrommap,                            removefrommap => \%removefrommap,
                           removeparam   => \%removeparam,                            removeparam   => \%removeparam,
                       );                        );
         my ($result,$msgsarray,$lockerror) =          my ($result,$msgsarray,$lockerror) = 
             &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);              &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
         if (keys(%import_errors) > 0) {          if (keys(%import_errors) > 0) {
             $fixuperrors =              $fixuperrors =
Line 1124  sub print_paste_buffer { Line 1121  sub print_paste_buffer {
   
     my @currpaste = split(/,/,$env{'docs.markedcopies'});      my @currpaste = split(/,/,$env{'docs.markedcopies'});
     my ($pasteitems,@pasteable);      my ($pasteitems,@pasteable);
     my $clipboardcount = 0;  
   
 # Construct identifiers for current contents of user's paste buffer  # Construct identifiers for current contents of user's paste buffer
     foreach my $suffix (@currpaste) {      foreach my $suffix (@currpaste) {
Line 1133  sub print_paste_buffer { Line 1129  sub print_paste_buffer {
         my $url = $env{'docs.markedcopy_url_'.$suffix};          my $url = $env{'docs.markedcopy_url_'.$suffix};
         if (($cid =~ /^$match_domain\_$match_courseid$/) &&          if (($cid =~ /^$match_domain\_$match_courseid$/) &&
             ($url ne '')) {              ($url ne '')) {
             $clipboardcount ++;  
             my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,              my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
                 $canpaste,$nopaste,$othercrs,$areachange);                  $canpaste,$nopaste,$othercrs,$areachange);
             my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];              my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
Line 1227  sub print_paste_buffer { Line 1222  sub print_paste_buffer {
         $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';          $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
         $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';          $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
         if (@pasteable) {          if (@pasteable) {
             my $value = &mt('Paste to current folder');              $buttons = '<input type="submit" name="pastemarked" value="'.&mt('Paste selected').'" />'.('&nbsp;'x2);
             if ($container eq 'page') {  
                 $value = &mt('Paste to current page');  
             }  
             $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.('&nbsp;'x2);  
         }  
         $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Clear selected').'" />'.('&nbsp;'x2);  
         if ($clipboardcount > 1) {  
             $buttons .=  
                 '<span style="text-decoration:line-through">'.('&nbsp;'x20).'</span>'.('&nbsp;'x2).  
                 '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.  
                 ('&nbsp;'x2).  
                 '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.  
                 ('&nbsp;'x2);  
         }          }
         $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.          $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Clear selected').'" />'.
                     '</form>';                      '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
           $form_end = '</form>';
     } else {      } else {
         $pasteitems = &mt('Clipboard is empty');          $pasteitems = &mt('Clipboard is empty');
     }      }
Line 1397  function validateClipboard() { Line 1380  function validateClipboard() {
     }      }
 }  }
   
 function checkClipboard() {  
     if (document.pasteform.pasting.length > 1) {  
         for (var i=0; i<document.pasteform.pasting.length; i++) {  
             document.pasteform.pasting[i].checked = true;  
         }  
     }  
     return;  
 }  
   
 function uncheckClipboard() {  
     if (document.pasteform.pasting.length >1) {  
         for (var i=0; i<document.pasteform.pasting.length; i++) {  
             document.pasteform.pasting[i].checked = false;  
         }  
     }  
     return;  
 }  
   
 END  END
   
 }  }
Line 1661  sub do_paste_from_buffer { Line 1626  sub do_paste_from_buffer {
                     next;                      next;
         }          }
                 if ($lockerr{$prefix}) {                  if ($lockerr{$prefix}) {
                     $lockerrs{$suffix} = $lockerr{$prefix};                      $lockerrs{$suffix} = $lockerr{$prefix};  
                 }                  }
             }              }
         }          }
Line 1700  sub do_paste_from_buffer { Line 1665  sub do_paste_from_buffer {
                     if ($newdocsdir eq '') {                      if ($newdocsdir eq '') {
                         $newdocsdir = 'default';                          $newdocsdir = 'default';
                     }                      }
                     if (($prefixchg{$suffix}) ||                      if (($prefixchg{$suffix}) || 
                         ($srcdom{$suffix} ne $coursedom) ||                           ($srcdom{$suffix} ne $coursedom) || 
                         ($srcnum{$suffix} ne $coursenum) ||                          ($srcnum{$suffix} ne $coursenum) ||
                         ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {                          ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
Line 1907  sub dbcopy { Line 1872  sub dbcopy {
     if (ref($dbref) eq 'HASH') {      if (ref($dbref) eq 'HASH') {
         if ($url =~ m{/(smppg|bulletinboard)$}) {          if ($url =~ m{/(smppg|bulletinboard)$}) {
             my $prefix = $1;              my $prefix = $1;
             if (($dbref->{'cdom'} =~ /^$match_domain$/) &&              if (($dbref->{'cdom'} =~ /^$match_domain$/) && 
                 ($dbref->{'cnum'} =~ /^$match_courseid$/)) {                  ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
                 my $db_name;                  my $db_name;
                 my $marker = (split(m{/},$url))[4];                  my $marker = (split(m{/},$url))[4];
Line 1942  sub dbcopy { Line 1907  sub dbcopy {
                         my $photo = $contents{'uploaded.photourl'};                          my $photo = $contents{'uploaded.photourl'};
                         my ($subdir,$fname) =                          my ($subdir,$fname) =
                             ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});                              ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
                         my $newphoto;                          my $newphoto; 
                         if ($fname ne '') {                          if ($fname ne '') {
                             my $content = &Apache::lonnet::getfile($photo);                              my $content = &Apache::lonnet::getfile($photo);
                             unless ($content eq '-1') {                              unless ($content eq '-1') {
                                 $env{'form.'.$suffix.'.photourl'} = $content;                                  $env{'form.'.$suffix.'.photourl'} = $content;
                                 $newphoto =                                  $newphoto = 
                                     &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");                                      &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
                                 delete($env{'form.'.$suffix.'.photourl'});                                  delete($env{'form.'.$suffix.'.photourl'});
                             }                              }
Line 2092  sub url_paste_fixups { Line 2057  sub url_paste_fixups {
             }              }
             next if ($token->[2]->{'type'} eq 'external');              next if ($token->[2]->{'type'} eq 'external');
             if ($token->[2]->{'type'} eq 'zombie') {              if ($token->[2]->{'type'} eq 'zombie') {
                 next if ($skip);                  next if ($skip);  
                 $zombies->{$oldurl}{$id} = $ressrc;                  $zombies->{$oldurl}{$id} = $ressrc;
                 $changed = 1;                  $changed = 1;
             } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {              } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
Line 2538  sub update_parameter { Line 2503  sub update_parameter {
                          'randomorder'    => {},                           'randomorder'    => {},
                       );                        );
         foreach my $which (keys(%allchecked)) {          foreach my $which (keys(%allchecked)) {
             $env{'form.all'.$which} =~ s/,$//;              $env{'form.all'.$which} =~ s/,$//;   
             if ($which eq 'randompick') {              if ($which eq 'randompick') {
                 foreach my $item (split(/,/,$env{'form.all'.$which})) {                  foreach my $item (split(/,/,$env{'form.all'.$which})) {
                     my ($res,$value) = split(/:/,$item);                      my ($res,$value) = split(/:/,$item);
Line 2565  sub update_parameter { Line 2530  sub update_parameter {
             foreach my $which (keys(%allchecked)) {              foreach my $which (keys(%allchecked)) {
                 if (($which eq 'randompick' || $which eq 'randomorder')) {                  if (($which eq 'randompick' || $which eq 'randomorder')) {
                     next if (!$is_map);                      next if (!$is_map);
                 }                  } 
                 my $oldvalue = 0;                  my $oldvalue = 0;
                 my $newvalue = 0;                  my $newvalue = 0;
                 if ($allchecked{$which}{$res}) {                  if ($allchecked{$which}{$res}) {
Line 3024  sub editor { Line 2989  sub editor {
                     if (@allidx > 0) {                      if (@allidx > 0) {
                         my $path;                          my $path;
                         if ($env{'form.folderpath'}) {                          if ($env{'form.folderpath'}) {
                             $path =                              $path = 
                                 &HTML::Entities::encode($env{'form.folderpath'},'<>&"');                                  &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
                         }                          }
                         if (@allidx > 1) {                          if (@allidx > 1) {
                             $to_show .=                              $to_show .= 
                                 &Apache::loncommon::continue_data_table_row().                                  &Apache::loncommon::continue_data_table_row().
                                 '<td colspan="2">&nbsp;</td>'.                                  '<td colspan="2">&nbsp;</td>'.
                                 '<td>'.                                  '<td>'.
Line 3172  sub process_file_upload { Line 3137  sub process_file_upload {
     }      }
     my $quotatype = 'unofficial';      my $quotatype = 'unofficial';
     if ($crstype eq 'Community') {      if ($crstype eq 'Community') {
         $quotatype = 'community';          $quotatype = 'community';    
     } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) {      } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) {
         $quotatype = 'official';          $quotatype = 'official';
     } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {  
         $quotatype = 'textbook';  
     }      }
     if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {      if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
         $filesize = int($filesize/1000); #expressed in kb          $filesize = int($filesize/1000); #expressed in kb
Line 3644  $form_common."\n". Line 3607  $form_common."\n".
 $form_param."\n".  $form_param."\n".
 $form_common."\n".  $form_common."\n".
 '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'.  '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'.
 $form_end;  $form_end; 
         }          }
     } elsif ($supplementalflag && !$allowed) {      } elsif ($supplementalflag && !$allowed) {
         $url .= ($url =~ /\?/) ? '&amp;':'?';          $url .= ($url =~ /\?/) ? '&amp;':'?';
Line 3848  sub new_timebased_suffix { Line 3811  sub new_timebased_suffix {
         }          }
     }      }
     if ($freedlock ne 'ok') {      if ($freedlock ne 'ok') {
         $locknotfreed =          $locknotfreed = 
             '<div class="LC_error">'.              '<div class="LC_error">'.
             &mt('There was a problem removing a lockfile.').' ';              &mt('There was a problem removing a lockfile.').' ';
         if ($type eq 'paste') {          if ($type eq 'paste') {
Line 4067  sub devalidateversioncache { Line 4030  sub devalidateversioncache {
 sub checkversions {  sub checkversions {
     my ($r) = @_;      my ($r) = @_;
     my $crstype = &Apache::loncommon::course_type();      my $crstype = &Apache::loncommon::course_type();
     $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));      $r->print(&Apache::loncommon::start_page("Check $crstype Document Versions"));
     $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));      $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions"));
     $r->print(&startContentScreen('tools'));      $r->print(&startContentScreen('tools'));
   
     my $header='';      my $header='';
Line 4224  $lt{'sc'}: <input type="submit" name="se Line 4187  $lt{'sc'}: <input type="submit" name="se
 <br clear="all" />  <br clear="all" />
 <hr />  <hr />
 <h4>$lt{'vers'}</h4>  <h4>$lt{'vers'}</h4>
   <input type="submit" name="setversions" value="$lt{'save'}" />
 ENDHEADERS  ENDHEADERS
     #number of columns for version history      #number of columns for version history
     my %changedbytime;  
     foreach my $key (keys(%changes)) {  
         #excludes not versionable problems from resource version history:  
         next if ($key =~ /^\/res\/lib\/templates/);  
         my $chg;  
         if ($env{'form.timerange'} eq 'all') {  
             my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);  
             $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');  
         } else {  
             $chg = $changes{$key};  
             next if ($chg < $starttime);  
         }  
         push(@{$changedbytime{$chg}},$key);  
     }  
     if (keys(%changedbytime) == 0) {  
         &untiehash();  
         $r->print(&mt('No content changes in imported content in specified time frame').  
                   &endContentScreen());  
         return;  
     }  
     $r->print(      $r->print(
         '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.  
         &Apache::loncommon::start_data_table().          &Apache::loncommon::start_data_table().
         &Apache::loncommon::start_data_table_header_row().          &Apache::loncommon::start_data_table_header_row().
         '<th>'.&mt('Resources').'</th>'.          '<th>'.&mt('Resources').'</th>'.
Line 4257  ENDHEADERS Line 4200  ENDHEADERS
         '<th>'.&mt('History').'</th>'.          '<th>'.&mt('History').'</th>'.
         &Apache::loncommon::end_data_table_header_row()          &Apache::loncommon::end_data_table_header_row()
     );      );
     foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {      foreach my $key (sort(keys(%changes))) {
         foreach my $key (sort(@{$changedbytime{$chg}})) {          #excludes not versionable problems from resource version history:
             my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);          next unless ($changes{$key}>$starttime && $key !~ /^\/res\/lib\/templates/);
             my $currentversion=&Apache::lonnet::getversion($key);          my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
             if ($currentversion<0) {          my $currentversion=&Apache::lonnet::getversion($key);
                 $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';          if ($currentversion<0) {
             }              $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
             my $linkurl=&Apache::lonnet::clutter($key);          }
             $r->print(          my $linkurl=&Apache::lonnet::clutter($key);
                 &Apache::loncommon::start_data_table_row().          $r->print(
                 '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.              &Apache::loncommon::start_data_table_row().
                 '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.              '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
                 '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.              '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
                 &Apache::lonlocal::locallocaltime($chg).')</span></td>'.              '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
                 '<td align="right">'              &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate')).')</span></td>'.
             );              '<td align="right">'
             # Used in course          );
             my $usedversion=$hash{'version_'.$linkurl};          # Used in course
             if (($usedversion) && ($usedversion ne 'mostrecent')) {          my $usedversion=$hash{'version_'.$linkurl};
           if (($usedversion) && ($usedversion ne 'mostrecent')) {
                 if ($usedversion != $currentversion) {                  if ($usedversion != $currentversion) {
                     $r->print('<span class="LC_warning">'.$usedversion.'</span>');                      $r->print('<span class="LC_warning">'.$usedversion.'</span>');
                 } else {                  } else {
Line 4284  ENDHEADERS Line 4228  ENDHEADERS
             } else {              } else {
                 $r->print($currentversion);                  $r->print($currentversion);
             }              }
             $r->print('</td><td title="'.$lt{'vu'}.'">');          $r->print('</td><td title="'.$lt{'vu'}.'">');
             # Set version          # Set version
             $r->print(&Apache::loncommon::select_form(          $r->print(&Apache::loncommon::select_form(
                       $setversions{$linkurl},              $setversions{$linkurl},
                       'set_version_'.$linkurl,              'set_version_'.$linkurl,
                       {'select_form_order' => ['',1..$currentversion,'mostrecent'],              {'select_form_order' => ['',1..$currentversion,'mostrecent'],
                        '' => '',               '' => '',
                        'mostrecent' => &mt('most recent'),               'mostrecent' => &mt('most recent'),
                        map {$_,$_} (1..$currentversion)}));               map {$_,$_} (1..$currentversion)}));
             my $lastold=1;          my $lastold=1;
             for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {          for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
                 my $url=$root.'.'.$prevvers.'.'.$extension;              my $url=$root.'.'.$prevvers.'.'.$extension;
                 if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {              if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
                     $lastold=$prevvers;                  $lastold=$prevvers;
                 }              }
             }          }
             $r->print('</td>');          $r->print('</td>');
             # List all available versions          # List all available versions
             $r->print('<td valign="top"><span class="LC_fontsize_medium">');          $r->print('<td valign="top"><span class="LC_fontsize_medium">');
             for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {          for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
                 my $url=$root.'.'.$prevvers.'.'.$extension;              my $url=$root.'.'.$prevvers.'.'.$extension;
                 $r->print(              $r->print(
                     '<span class="LC_nobreak">'                  '<span class="LC_nobreak">'
                    .'<a href="'.&Apache::lonnet::clutter($url).'">'                 .'<a href="'.&Apache::lonnet::clutter($url).'">'
                    .&mt('Version [_1]',$prevvers).'</a>'                 .&mt('Version [_1]',$prevvers).'</a>'
                    .' ('.&Apache::lonlocal::locallocaltime(                 .' ('.&Apache::lonlocal::locallocaltime(
                          &Apache::lonnet::metadata($url,'lastrevisiondate'))                           &Apache::lonnet::metadata($url,'lastrevisiondate'))
                    .')');                 .')');
                 if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {              if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
                     $r->print(                  $r->print(
                         ' <a href="/adm/diff?filename='.                      ' <a href="/adm/diff?filename='.
                         &Apache::lonnet::clutter($root.'.'.$extension).                      &Apache::lonnet::clutter($root.'.'.$extension).
                         &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').                      &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
                         '" target="diffs">'.&mt('Diffs').'</a>');                      '" target="diffs">'.&mt('Diffs').'</a>');
                 }  
                 $r->print('</span><br />');  
             }              }
             $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());              $r->print('</span><br />');
         }          }
           $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
     }      }
     $r->print(      $r->print(
         &Apache::loncommon::end_data_table().          &Apache::loncommon::end_data_table().
Line 4332  ENDHEADERS Line 4275  ENDHEADERS
   
     &untiehash();      &untiehash();
     $r->print(&endContentScreen());      $r->print(&endContentScreen());
     return;  
 }  }
   
 sub mark_hash_old {  sub mark_hash_old {
Line 4387  $help{'Caching'}.'</p></form>'."\n\n"); Line 4329  $help{'Caching'}.'</p></form>'."\n\n");
   
   
 sub init_breadcrumbs {  sub init_breadcrumbs {
     my ($form,$text,$help)=@_;      my ($form,$text)=@_;
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
     &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",      &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
     text=>&Apache::loncommon::course_type().' Editor',      text=>&Apache::loncommon::course_type().' Editor',
     faq=>273,      faq=>273,
     bug=>'Instructor Interface',      bug=>'Instructor Interface',
                                             help => $help});                                              help => 'Docs_Adding_Course_Doc'});
     &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',      &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
     text=>$text,      text=>$text,
     faq=>273,      faq=>273,
Line 4429  sub startContentScreen { Line 4371  sub startContentScreen {
     if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {      if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
         $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b>&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Overview').'&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";          $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b>&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Overview').'&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
         $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Search').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";          $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Search').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
           $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Content Index').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
         $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';          $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
     } else {      } else {
         $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Main Content Editor').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";          $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.&mt('Main Content Editor').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></a></li>'."\n";
Line 4476  sub handler { Line 4419  sub handler {
                'Adding_Folders','Docs_Overview', 'Load_Map',                 'Adding_Folders','Docs_Overview', 'Load_Map',
                'Supplemental','Score_Upload_Form','Adding_Pages',                 'Supplemental','Score_Upload_Form','Adding_Pages',
                'Importing_LON-CAPA_Resource','Importing_IMS_Course',                 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
                        'Uploading_From_Harddrive','Course_Roster','Web_Page',                         'Uploading_From_Harddrive',
                        'Dropbox','Simple_Problem') {                 'Check_Resource_Versions','Verify_Content',
                          'Course_Roster','Web_Page','Dropbox') {
  $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);   $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
     }      }
     # Composite help files      # Composite help files
Line 4485  sub handler { Line 4429  sub handler {
     'Docs_About_Syllabus,Docs_Editing_Templated_Pages');      'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
     $help{'Simple Page'} = &Apache::loncommon::help_open_topic(      $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
     'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');      'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
       $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
       'Option_Response_Simple');
     $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(      $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
     'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');      'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
     $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(      $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
Line 4505  sub handler { Line 4451  sub handler {
       &choose_dump_server($r);        &choose_dump_server($r);
       return OK;        return OK;
   } elsif ($allowed && $env{'form.verify'}) {    } elsif ($allowed && $env{'form.verify'}) {
       &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');        &init_breadcrumbs('verify','Verify Content');
       &verifycontent($r);        &verifycontent($r);
   } elsif ($allowed && $env{'form.listsymbs'}) {    } elsif ($allowed && $env{'form.listsymbs'}) {
       &init_breadcrumbs('listsymbs','List Content IDs');        &init_breadcrumbs('listsymbs','List Content IDs');
Line 4518  sub handler { Line 4464  sub handler {
       }        }
       &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);        &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);
   } elsif ($allowed && $env{'form.versions'}) {    } elsif ($allowed && $env{'form.versions'}) {
       &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');        &init_breadcrumbs('versions','Check/Set Resource Versions');
       &checkversions($r);        &checkversions($r);
   } elsif ($allowed && $env{'form.dumpcourse'}) {    } elsif ($allowed && $env{'form.dumpcourse'}) {
       &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');        &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
Line 4689  sub handler { Line 4635  sub handler {
                 $script .= &dump_switchserver_js(@hosts);                   $script .= &dump_switchserver_js(@hosts); 
             }              }
         } else {          } else {
             my $tid = 1;  
             my @tabids;              my @tabids;
             if ($supplementalflag) {              if ($supplementalflag) {
                 @tabids = ('002','ee2','ff2');                  @tabids = ('002','ee2','ff2');
                 $tid = 2;  
             } else {              } else {
                 @tabids = ('aa1','bb1','cc1','ff1');                  @tabids = ('aa1','bb1','cc1','ff1');
                 unless ($env{'form.folderpath'} =~ /\:1$/) {                  unless ($env{'form.folderpath'} =~ /\:1$/) {
Line 4705  sub handler { Line 4649  sub handler {
     $script .= &editing_js($udom,$uname,$supplementalflag).      $script .= &editing_js($udom,$uname,$supplementalflag).
                        &history_tab_js().                         &history_tab_js().
                        &inject_data_js().                         &inject_data_js().
                        &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).                         &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr).
                        &Apache::lonextresedit::extedit_javascript();                         &Apache::lonextresedit::extedit_javascript();
             $addentries = {              $addentries = {
                             onload   => "javascript:resize_scrollbox('contentscroll','1','1');",                              onload   => "javascript:resize_scrollbox('contentscroll','1','1');",
Line 4730  sub handler { Line 4674  sub handler {
     if ($showdoc) {      if ($showdoc) {
         $r->print(&Apache::loncommon::start_page("$crstype documents",undef,          $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
                                                 {'force_register' => $showdoc,}));                                                  {'force_register' => $showdoc,}));
     } elsif ($toolsflag) {  
         &Apache::lonhtmlcommon::add_breadcrumb({  
             href=>"/adm/coursedocs",text=>"$crstype Contents"});  
         $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)  
                  .&Apache::loncommon::help_open_menu('','',273,'RAT')  
                  .&Apache::lonhtmlcommon::breadcrumbs(  
                      'Editing Course Contents')  
                  );  
     } elsif ($r->uri eq '/adm/supplemental') {      } elsif ($r->uri eq '/adm/supplemental') {
         my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);          my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
         $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,          $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
Line 4830  sub handler { Line 4766  sub handler {
                 'navc' => 'Table of Contents',                  'navc' => 'Table of Contents',
                 'sipa' => 'Simple Course Page',                  'sipa' => 'Simple Course Page',
                 'sipr' => 'Simple Problem',                  'sipr' => 'Simple Problem',
                 'webp' => 'Blank Web Page (editable)',                  'webp' => 'Blank Web Page (editable)', 
                 'drbx' => 'Drop Box',                  'drbx' => 'Drop Box',
                 'scuf' => 'External Scores (handgrade, upload, clicker)',                  'scuf' => 'External Scores (handgrade, upload, clicker)',
                 'bull' => 'Discussion Board',                  'bull' => 'Discussion Board',
Line 5008  HIDDENFORM Line 4944  HIDDENFORM
   
  my $newnavform=(<<NNFORM);   my $newnavform=(<<NNFORM);
  <form action="/adm/coursedocs" method="post" name="newnav">   <form action="/adm/coursedocs" method="post" name="newnav">
  <input type="hidden" name="active" value="ee" />   <input type="hidden" name="active" value="cc" />
  $pathitem   $pathitem
  <input type="hidden" name="importdetail"    <input type="hidden" name="importdetail" 
  value="$lt{'navc'}=/adm/navmaps" />   value="$lt{'navc'}=/adm/navmaps" />
Line 5018  HIDDENFORM Line 4954  HIDDENFORM
 NNFORM  NNFORM
  my $newsmppageform=(<<NSPFORM);   my $newsmppageform=(<<NSPFORM);
  <form action="/adm/coursedocs" method="post" name="newsmppg">   <form action="/adm/coursedocs" method="post" name="newsmppg">
  <input type="hidden" name="active" value="ee" />   <input type="hidden" name="active" value="cc" />
  $pathitem   $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>   <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
Line 5032  NSPFORM Line 4968  NSPFORM
  $pathitem   $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>   <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
  $help{'Simple_Problem'}   $help{'Simple Problem'}
  </form>   </form>
   
 NSPROBFORM  NSPROBFORM
Line 5059  NEXUFORM Line 4995  NEXUFORM
   
  my $newbulform=(<<NBFORM);   my $newbulform=(<<NBFORM);
  <form action="/adm/coursedocs" method="post" name="newbul">   <form action="/adm/coursedocs" method="post" name="newbul">
  <input type="hidden" name="active" value="dd" />   <input type="hidden" name="active" value="cc" />
  $pathitem   $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>   <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
Line 5069  NBFORM Line 5005  NBFORM
   
  my $newaboutmeform=(<<NAMFORM);   my $newaboutmeform=(<<NAMFORM);
  <form action="/adm/coursedocs" method="post" name="newaboutme">   <form action="/adm/coursedocs" method="post" name="newaboutme">
  <input type="hidden" name="active" value="dd" />   <input type="hidden" name="active" value="cc" />
  $pathitem   $pathitem
  <input type="hidden" name="importdetail"    <input type="hidden" name="importdetail" 
  value="$plainname=/adm/$udom/$uname/aboutme" />   value="$plainname=/adm/$udom/$uname/aboutme" />
Line 5080  NAMFORM Line 5016  NAMFORM
   
  my $newaboutsomeoneform=(<<NASOFORM);   my $newaboutsomeoneform=(<<NASOFORM);
  <form action="/adm/coursedocs" method="post" name="newaboutsomeone">   <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
  <input type="hidden" name="active" value="dd" />   <input type="hidden" name="active" value="cc" />
  $pathitem   $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>   <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
Line 5089  NASOFORM Line 5025  NASOFORM
   
  my $newrosterform=(<<NROSTFORM);   my $newrosterform=(<<NROSTFORM);
  <form action="/adm/coursedocs" method="post" name="newroster">   <form action="/adm/coursedocs" method="post" name="newroster">
  <input type="hidden" name="active" value="dd" />   <input type="hidden" name="active" value="cc" />
  $pathitem   $pathitem
  <input type="hidden" name="importdetail"    <input type="hidden" name="importdetail" 
  value="$lt{'rost'}=/adm/viewclasslist" />   value="$lt{'rost'}=/adm/viewclasslist" />
Line 5110  NROSTFORM Line 5046  NROSTFORM
         }          }
         my $newwebpageform =(<<NWEBFORM);          my $newwebpageform =(<<NWEBFORM);
         <form action="/adm/coursedocs" method="post" name="newwebpage">          <form action="/adm/coursedocs" method="post" name="newwebpage">
         <input type="hidden" name="active" value="ee" />          <input type="hidden" name="active" value="cc" />
         $pathitem          $pathitem
         <input type="hidden" name="importdetail" value="$newwebpage" />          <input type="hidden" name="importdetail" value="$newwebpage" />
         <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>          <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
Line 5134  my $newfolderb; Line 5070  my $newfolderb;
  <form action="/adm/coursedocs" method="post" name="newpage">   <form action="/adm/coursedocs" method="post" name="newpage">
  <input type="hidden" name="folderpath" value="$path" />   <input type="hidden" name="folderpath" value="$path" />
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <input type="hidden" name="active" value="ee" />   <input type="hidden" name="active" value="cc" />
  <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>   <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
  $help{'Adding_Pages'}   $help{'Adding_Pages'}
  </form>   </form>
Line 5145  NPFORM Line 5081  NPFORM
  <form action="/adm/coursedocs" method="post" name="newfolder">   <form action="/adm/coursedocs" method="post" name="newfolder">
  $pathitem   $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <input type="hidden" name="active" value="" />   <input type="hidden" name="active" value="aa" />
  <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}   <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
  </form>   </form>
 NFFORM  NFFORM
   
  my $newsylform=(<<NSYLFORM);   my $newsylform=(<<NSYLFORM);
  <form action="/adm/coursedocs" method="post" name="newsyl">   <form action="/adm/coursedocs" method="post" name="newsyl">
  <input type="hidden" name="active" value="ee" />   <input type="hidden" name="active" value="cc" />
  $pathitem   $pathitem
  <input type="hidden" name="importdetail"    <input type="hidden" name="importdetail" 
  value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />   value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
Line 5164  NSYLFORM Line 5100  NSYLFORM
   
  my $newgroupfileform=(<<NGFFORM);   my $newgroupfileform=(<<NGFFORM);
  <form action="/adm/coursedocs" method="post" name="newgroupfiles">   <form action="/adm/coursedocs" method="post" name="newgroupfiles">
  <input type="hidden" name="active" value="dd" />   <input type="hidden" name="active" value="cc" />
  $pathitem   $pathitem
  <input type="hidden" name="importdetail"   <input type="hidden" name="importdetail"
  value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />   value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
Line 5281  SUPDOCFORM Line 5217  SUPDOCFORM
   
  my $supnewfolderform=(<<SNFFORM);   my $supnewfolderform=(<<SNFFORM);
  <form action="/adm/coursedocs" method="post" name="supnewfolder">   <form action="/adm/coursedocs" method="post" name="supnewfolder">
  <input type="hidden" name="active" value="" />   <input type="hidden" name="active" value="ee" />
         $pathitem          $pathitem
  <input type="hidden" name="importdetail" value="" />   <input type="hidden" name="importdetail" value="" />
  <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>    <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a> 
Line 5374  my %suporderhash = ( Line 5310  my %suporderhash = (
                    }                     }
                    &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);                     &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
                    undef($suppchanges);                     undef($suppchanges);
                }                 }  
            }             } 
         }          }
     } elsif ($supplementalflag) {      } elsif ($supplementalflag) {
         my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,          my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
Line 5522  sub remove_archive { Line 5458  sub remove_archive {
     } else {      } else {
         my $currcmd = $env{'form.cmd'};          my $currcmd = $env{'form.cmd'};
         my $position = $env{'form.position'};          my $position = $env{'form.position'};
         if ($position > 0) {           if ($position > 0) {
             $env{'form.cmd'} = 'remove_'.$position;              $env{'form.cmd'} = 'remove_'.$position;
             my ($title,$url,@rrest) =               my ($title,$url,@rrest) = 
                 split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);                  split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
Line 5594  sub generate_admin_menu { Line 5530  sub generate_admin_menu {
                 {   linktext   => $lt{'vc'},                  {   linktext   => $lt{'vc'},
                     url        => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",                      url        => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
                     permission => 'F',                      permission => 'F',
                     help       => 'Docs_Verify_Content',                      help       => 'Verify_Content',
                     icon       => 'verify.png',                      icon       => 'verify.png',
                     linktitle  => 'Verify contents can be retrieved/rendered',                      linktitle  => 'Verify contents can be retrieved/rendered',
                 },                  },
                 {   linktext => $lt{'cv'},                  {   linktext => $lt{'cv'},
                     url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",                      url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
                     permission => 'F',                      permission => 'F',
                     help       => 'Docs_Check_Resource_Versions',                      help       => 'Check_Resource_Versions',
                     icon       => 'resversion.png',                      icon       => 'resversion.png',
                     linktitle  => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",                      linktitle  => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
                 },                  },
Line 5626  sub generate_admin_menu { Line 5562  sub generate_admin_menu {
                 {   linktext   => $lt{'dcd'},                  {   linktext   => $lt{'dcd'},
                     url        => $dumpurl,                      url        => $dumpurl,
                     permission => $candump,                      permission => $candump,
                     help       => 'Docs_Dump_Course_Docs',                      #help => '',
                     icon       => 'dump.png',                      icon       => 'dump.png',
                     linktitle  => $lt{'dcd'},                      linktitle  => $lt{'dcd'},
                 },                  },
Line 5646  sub generate_edit_table { Line 5582  sub generate_edit_table {
     my $form;      my $form;
     my $activetab;      my $activetab;
     my $active;      my $active;
     if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {      if (($env{'form.active'} ne '') && ($env{'form.active'} ne 'aa')) {
         $activetab = $env{'form.active'};          $activetab = $env{'form.active'};
     }      }
     my $backicon = $iconpath.'clickhere.gif';      my $backicon = $iconpath.'clickhere.gif';
Line 5681  sub generate_edit_table { Line 5617  sub generate_edit_table {
             $form .= '<li style="float:right" '.$active              $form .= '<li style="float:right" '.$active
                 .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'."\n";                  .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'."\n";
         } else {          } else {
     $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";      $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
   
  }   }
     }      }
Line 5749  sub editing_js { Line 5685  sub editing_js {
                                           p_msb => 'Title for the Problem',                                            p_msb => 'Title for the Problem',
                                           p_mdb => 'Title for the Drop Box',                                            p_mdb => 'Title for the Drop Box',
                                           p_mbb => 'Title for the Discussion Board',                                            p_mbb => 'Title for the Discussion Board',
                                           p_mwp => 'Title for Web Page',                                            p_mwp => 'Title for Web Page', 
                                           p_mab => "Enter user:domain for User's Personal Information Page",                                            p_mab => "Enter user:domain for User's Personal Information Page",
                                           p_mab2 => 'Personal Information Page of ',                                            p_mab2 => 'Personal Information Page of ',
                                           p_mab_alrt1 => 'Not a valid user:domain',                                            p_mab_alrt1 => 'Not a valid user:domain',
Line 5863  function makewebpage(type) { Line 5799  function makewebpage(type) {
        formname = this.document.forms.newwebpage;         formname = this.document.forms.newwebpage;
    }     }
    if (title) {     if (title) {
        var webpage = formname.importdetail.value;         var webpage = formname.importdetail.value; 
        formname.importdetail.value = escape(title)+'='+webpage;         formname.importdetail.value = escape(title)+'='+webpage;
        formname.submit();         formname.submit();
    }     }
Line 6244  for (i = 0; i < currentLis.length; i++) Line 6180  for (i = 0; i < currentLis.length; i++)
   
 function hideAll(current, nav, data) {  function hideAll(current, nav, data) {
 unselectInactive(nav);  unselectInactive(nav);
 if (current) {  if(current.className == 'right'){
     if (current.className == 'right'){  
  current.className = 'right active'   current.className = 'right active'
     } else {   }else{
  current.className = 'active';   current.className = 'active';
     }  
 }  }
 currentData = document.getElementById(data);  currentData = document.getElementById(data);
 currentDivs = currentData.getElementsByTagName('DIV');  currentDivs = currentData.getElementsByTagName('DIV');
Line 6280  function openTabs(pageId) { Line 6214  function openTabs(pageId) {
 }  }
   
 function showPage(current, pageId, nav, data) {  function showPage(current, pageId, nav, data) {
         currstate = current.className;  
  hideAll(current, nav, data);   hideAll(current, nav, data);
  openTabs(pageId);   openTabs(pageId);
  unselectInactive(nav);   unselectInactive(nav);
         if ((currstate == 'active') || (currstate == 'right active')) {   current.className = 'active';
             if (currstate == 'active') {  
                 current.className = '';  
             } else {  
                 current.className = 'right';  
             }  
             activeTab = '';  
             toggleUpload();  
             toggleMap();  
             resize_scrollbox('contentscroll','1','0');  
             return;  
         } else {  
             current.className = 'active';  
         }  
  currentData = document.getElementById(pageId);   currentData = document.getElementById(pageId);
  currentData.style.display = 'block';   currentData.style.display = 'block';
         activeTab = pageId;          activeTab = pageId;
Line 6685  ENDINJECT Line 6605  ENDINJECT
 sub dump_switchserver_js {  sub dump_switchserver_js {
     my @hosts = @_;      my @hosts = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
         dump => 'Copying content to Authoring Space requires switching server.',          dump => 'Copying Content to Authoring Space requires switching server.',
         swit => 'Switch server?',          swit => 'Switch server?',
         duco => 'Copying Content to Authoring Space',          duco => 'Copying Content to Authoring Space',
         yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',          yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',

Removed from v.1.484.2.48  
changed lines
  Added in v.1.568


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