Diff for /loncom/interface/londocs.pm between versions 1.484.2.57 and 1.586

version 1.484.2.57, 2014/12/21 19:20:41 version 1.586, 2014/10/15 07:24:43
Line 196  ENDJS Line 196  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 207  ENDJS Line 207  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 307  $contents{content}.' Line 307  $contents{content}.'
 </div>';  </div>';
                 }                  }
                 if ($contents{webreferences}) {                  if ($contents{webreferences}) {
                     $content .= '                      $content .= ' 
 <div class="LC_Box">  <div class="LC_Box">
 <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.  <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
 $contents{webreferences}.'  $contents{webreferences}.'
Line 317  $contents{webreferences}.' Line 317  $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 351  $contents{webreferences}.' Line 351  $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 405  $contents{webreferences}.' Line 405  $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 431  $contents{webreferences}.' Line 431  $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 477  $contents{webreferences}.' Line 477  $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) {              if ($home>1) {
                 $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';                  $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 564  sub recurse_html { Line 564  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 667  $initialtext Line 667  $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 692  END Line 692  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 977  sub docs_change_log { Line 977  sub docs_change_log {
   
 sub update_paste_buffer {  sub update_paste_buffer {
     my ($coursenum,$coursedom,$folder) = @_;      my ($coursenum,$coursedom,$folder) = @_;
     my (@possibles,%removals,%cuts,$output);      my (@possibles,%removals,%cuts);
     if ($env{'form.multiremove'}) {      if ($env{'form.multiremove'}) {
         $env{'form.multiremove'} =~ s/,$//;          $env{'form.multiremove'} =~ s/,$//;
         map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});          map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
Line 1045  sub update_paste_buffer { Line 1045  sub update_paste_buffer {
         next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));          next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));
         my ($suffix,$errortxt,$locknotfreed) =          my ($suffix,$errortxt,$locknotfreed) =
             &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');              &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
         if ($suffix ne '') {          push(@newpaste,$suffix);
             push(@newpaste,$suffix);          if ($locknotfreed) {
         } else {              return $locknotfreed;
             if ($locknotfreed) {              last;
                 return $locknotfreed;  
             }  
         }          }
         if (&is_supplemental_title($title)) {          if (&is_supplemental_title($title)) {
             &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});              &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
Line 1084  sub update_paste_buffer { Line 1082  sub update_paste_buffer {
                 }                  }
             }              }
         }          }
         if ($locknotfreed) {  
             $output = $locknotfreed;  
             last;  
         }  
     }      }
     if (@newpaste) {      if (@newpaste) {
         $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));          $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
     }      }
     &Apache::lonnet::appenv(\%addtoenv);      &Apache::lonnet::appenv(\%addtoenv);
     delete($env{'form.markcopy'});      delete($env{'form.markcopy'});
     return $output;      return;
 }  }
   
 sub recurse_uploaded_maps {  sub recurse_uploaded_maps {
Line 1197  sub print_paste_buffer { Line 1191  sub print_paste_buffer {
                     $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));                      $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
                     $icon .= '/navmap.folder.closed.gif';                      $icon .= '/navmap.folder.closed.gif';
                 }                  }
                 my $title = $env{'docs.markedcopy_title_'.$suffix};  
                 if ($title eq '') {  
                     ($title) = ($url =~ m{/([^/]+)$});  
                 }  
                 $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.                  $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
                           ': '.                            ': '.
                           &Apache::loncommon::parse_supplemental_title(                            &Apache::loncommon::parse_supplemental_title(
                              &LONCAPA::map::qtescape($title));                               &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}));
             }              }
             $pasteitems .= '<div class="LC_left_float">';              $pasteitems .= '<div class="LC_left_float">';
             my ($options,$onclick);              my ($options,$onclick);
Line 1242  sub print_paste_buffer { Line 1232  sub print_paste_buffer {
             my $value = &mt('Paste to current folder');              my $value = &mt('Paste to current folder');
             if ($container eq 'page') {              if ($container eq 'page') {
                 $value = &mt('Paste to current page');                  $value = &mt('Paste to current page');
             }              } 
             $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.('&nbsp;'x2);              $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.('&nbsp;'x2);
         }          }
         $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Clear selected').'" />'.('&nbsp;'x2);          $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.('&nbsp;'x2);
         if ($clipboardcount > 1) {          if ($clipboardcount > 1) {
             $buttons .=              $buttons .=
                 '<span style="text-decoration:line-through">'.('&nbsp;'x20).'</span>'.('&nbsp;'x2).                  '<span style="text-decoration:line-through">'.('&nbsp;'x20).'</span>'.('&nbsp;'x2).
Line 1413  function checkClipboard() { Line 1403  function checkClipboard() {
     if (document.pasteform.pasting.length > 1) {      if (document.pasteform.pasting.length > 1) {
         for (var i=0; i<document.pasteform.pasting.length; i++) {          for (var i=0; i<document.pasteform.pasting.length; i++) {
             document.pasteform.pasting[i].checked = true;              document.pasteform.pasting[i].checked = true;
         }          } 
     }      }
     return;      return;
 }  }
Line 1673  sub do_paste_from_buffer { Line 1663  sub do_paste_from_buffer {
                     next;                      next;
         }          }
                 if ($lockerr{$prefix}) {                  if ($lockerr{$prefix}) {
                     $lockerrs{$suffix} = $lockerr{$prefix};                      $lockerrs{$suffix} = $lockerr{$prefix};  
                 }                  }
             }              }
         }          }
Line 1712  sub do_paste_from_buffer { Line 1702  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 1919  sub dbcopy { Line 1909  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 1954  sub dbcopy { Line 1944  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 2104  sub url_paste_fixups { Line 2094  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 2550  sub update_parameter { Line 2540  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 2577  sub update_parameter { Line 2567  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 3036  sub editor { Line 3026  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 3184  sub process_file_upload { Line 3174  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.coursecode'}) {      } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
         $quotatype = 'official';          $quotatype = 'official';
     } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {      } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
Line 3371  sub entryline { Line 3361  sub entryline {
     $renametitle=~s/"/%22/g;      $renametitle=~s/"/%22/g;
     $renametitle=~s/ /%20/g;      $renametitle=~s/ /%20/g;
     $oldtitle = $renametitle;      $oldtitle = $renametitle;
     $renametitle=~s/\&#39\;/\\\'/g;      $renametitle=~s/\&#39;/\\\'/g;
     my $line=&Apache::loncommon::start_data_table_row();      my $line=&Apache::loncommon::start_data_table_row();
     my ($form_start,$form_end,$form_common,$form_param);      my ($form_start,$form_end,$form_common,$form_param);
 # Edit commands  # Edit commands
Line 3661  $form_common."\n". Line 3651  $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 3836  sub new_timebased_suffix { Line 3826  sub new_timebased_suffix {
     if ($type eq 'paste') {      if ($type eq 'paste') {
         $prefix = $type;          $prefix = $type;
         $namespace = 'courseeditor';          $namespace = 'courseeditor';
         $idtype = 'addcode';  
     } elsif ($type eq 'map') {      } elsif ($type eq 'map') {
         $prefix = 'docs';          $prefix = 'docs';
         if ($area eq 'supplemental') {          if ($area eq 'supplemental') {
Line 3848  sub new_timebased_suffix { Line 3837  sub new_timebased_suffix {
         $prefix = $type;          $prefix = $type;
         $namespace = 'templated';          $namespace = 'templated';
     }      }
       $idtype = 'concat';
     my ($suffix,$freedlock,$error) =      my ($suffix,$freedlock,$error) =
         &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);          &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num);
     if (!$suffix) {      if (!$suffix) {
         if ($type eq 'paste') {          if ($type eq 'paste') {
             $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');              $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
Line 3865  sub new_timebased_suffix { Line 3855  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') {
             if ($freedlock eq 'nolock') {              &mt('This will prevent use of the paste buffer until th next log-in.');
                 $locknotfreed =  
                     '<div class="LC_error">'.  
                     &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.  
   
                     &mt('As a result addition of items to the clipboard wll be unavailable until your next log-in.');  
             } else {  
                 $locknotfreed .=  
                     &mt('This will prevent addition of items to the clipboard until your next log-in.');  
             }  
         } elsif ($type eq 'map') {          } elsif ($type eq 'map') {
             $locknotfreed .=              &mt('This will prevent creation of additional folders or composite pages in this course.');
                 &mt('This will prevent creation of additional folders or composite pages in this course.');  
         } elsif ($type eq 'smppg') {          } elsif ($type eq 'smppg') {
             $locknotfreed .=              $locknotfreed .=
                 &mt('This will prevent creation of additional simple pages in this course.');                  &mt('This will prevent creation of additional simple pages in this course.');
Line 4274  ENDHEADERS Line 4254  ENDHEADERS
         return;          return;
     }      }
     $r->print(      $r->print(
         '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.         '<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 4317  ENDHEADERS Line 4297  ENDHEADERS
                       $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;
Line 4456  sub startContentScreen { Line 4436  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 4853  sub handler { Line 4834  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 5401  my %suporderhash = ( Line 5382  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 5785  sub editing_js { Line 5766  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 5835  sub editing_js { Line 5816  sub editing_js {
             if (&Apache::lonnet::is_on_map($res)) {              if (&Apache::lonnet::is_on_map($res)) {
                 $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.                  $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.
                              &HTML::Entities::encode($caller,'<>&"');                               &HTML::Entities::encode($caller,'<>&"');
                 $backtourl = &Apache::loncommon::escape_single($backtourl);   
             } else {              } else {
                 $backtourl = '/adm/navmaps';                  $backtourl = '/adm/navmaps';
             }              }
Line 5900  function makewebpage(type) { Line 5880  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 6281  for (i = 0; i < currentLis.length; i++) Line 6261  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) { 
     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);
Line 6323  function showPage(current, pageId, nav, Line 6303  function showPage(current, pageId, nav,
  unselectInactive(nav);   unselectInactive(nav);
         if ((currstate == 'active') || (currstate == 'right active')) {          if ((currstate == 'active') || (currstate == 'right active')) {
             if (currstate == 'active') {              if (currstate == 'active') {
                 current.className = '';          current.className = '';
             } else {              } else {
                 current.className = 'right';                  current.className = 'right';
             }              }
             activeTab = '';              activeTab = ''; 
             toggleUpload();              toggleUpload();
             toggleMap();              toggleMap();
             resize_scrollbox('contentscroll','1','0');              resize_scrollbox('contentscroll','1','0');

Removed from v.1.484.2.57  
changed lines
  Added in v.1.586


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.