Diff for /loncom/interface/londocs.pm between versions 1.627 and 1.637

version 1.627, 2017/05/10 00:03:08 version 1.637, 2017/08/27 02:36:49
Line 603  sub recurse_html { Line 603  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};
Line 678  sub group_import { Line 678  sub group_import {
                     my @deleted;                      my @deleted;
                     if (ref($ltitoolsref->{$toolid}) eq 'HASH') {                      if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
                         $toolhash{'id'} = $toolid;                          $toolhash{'id'} = $toolid;
                         if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'window')) {                          if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
                               ($toolhash{'target'} eq 'window')) {
                             if ($toolhash{'target'} eq 'window') {                              if ($toolhash{'target'} eq 'window') {
                                 foreach my $item ('width','height') {                                  foreach my $item ('width','height') {
                                     $toolhash{$item} =~ s/^\s+//;                                      $toolhash{$item} =~ s/^\s+//;
Line 696  sub group_import { Line 697  sub group_import {
                         } elsif ($residx) {                          } elsif ($residx) {
                             $toolhash{'target'} = $toolsettings{'target'};                              $toolhash{'target'} = $toolsettings{'target'};
                             if ($toolhash{'target'} eq 'window') {                              if ($toolhash{'target'} eq 'window') {
                                 foreach my $item ('width','height') {                                   foreach my $item ('width','height') {
                                     $toolhash{$item} = $toolsettings{$item};                                      $toolhash{$item} = $toolsettings{$item};
                                 }                                  }
                             }                              }
Line 716  sub group_import { Line 717  sub group_import {
                                     }                                      }
                                 }                                  }
                             }                              }
                           } elsif ($toolhash{'target'} eq 'tab') {
                               foreach my $item ('width','height') {
                                   delete($toolhash{$item});
                                   if ($residx) {
                                       if ($toolsettings{$item}) {
                                           push(@deleted,$item);
                                       }
                                   }
                               }
                         }                          }
                         if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {                          if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
                             foreach my $item ('label','title','linktext','explanation') {                              foreach my $item ('label','title','linktext','explanation') {
Line 802  $initialtext Line 812  $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 961  sub docs_change_log { Line 971  sub docs_change_log {
     if ($supplementalflag) {      if ($supplementalflag) {
         $tid = 2;          $tid = 2;
     }      }
     my ($breadcrumbtrail) =       my ($breadcrumbtrail) =
         &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);          &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
     $r->print($breadcrumbtrail.      $r->print($breadcrumbtrail.
               &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,                &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
Line 1160  sub update_paste_buffer { Line 1170  sub update_paste_buffer {
         foreach my $suffix (@currpaste) {          foreach my $suffix (@currpaste) {
              my $cid = $env{'docs.markedcopy_crs_'.$suffix};               my $cid = $env{'docs.markedcopy_crs_'.$suffix};
              my $url = $env{'docs.markedcopy_url_'.$suffix};               my $url = $env{'docs.markedcopy_url_'.$suffix};
              my $mapidx = $env{'docs.markedcopy_map_'.$suffix};                          my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
              if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&               if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
                  ($url ne '')) {                   ($url ne '')) {
                  $pasteurls{$cid.'_'.$url.'_'.$mapidx} = 1;                   $pasteurls{$cid.'_'.$url.'_'.$mapidx} = 1;
Line 1339  sub print_paste_buffer { Line 1349  sub print_paste_buffer {
                         } else {                          } else {
                             $canpaste = 0;                              $canpaste = 0;
                             $nopaste = &mt('Paste from another course unavailable.');                              $nopaste = &mt('Paste from another course unavailable.');
                         }                                 }
                     }                      }
                 }                  }
                 if ($canpaste) {                  if ($canpaste) {
                     push(@pasteable,$suffix);                      push(@pasteable,$suffix);
                 }                    }
             }              }
             my $buffer;              my $buffer;
             if ($is_external) {              if ($is_external) {
Line 1662  sub do_paste_from_buffer { Line 1672  sub do_paste_from_buffer {
             $srcdom{$suffix} = $srcd;              $srcdom{$suffix} = $srcd;
             $srcnum{$suffix} = $srcn;              $srcnum{$suffix} = $srcn;
         } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||          } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
                  ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg|ext\.tool)$})) {                   ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$}) ||
             my $srctype= $1;                   ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
             my ($srcd,$srcn) = split(/_/,$cid);              my ($srcd,$srcn) = split(/_/,$cid);
 # When paste buffer was populated using an active role in a different course  # When paste buffer was populated using an active role in a different course
 # check for mdc privilege in the course from which the resource was pasted  # check for mdc privilege in the course from which the resource was pasted
Line 1673  sub do_paste_from_buffer { Line 1683  sub do_paste_from_buffer {
                     next;                      next;
                 }                  }
             }              }
             if (($srctype eq 'ext.tool') && ($srcd ne $coursedom)) {  # When buffer was populated using an active role in a different course
   # disallow pasting of External Tool if course is in a different domain.
               if (($url =~ m{/ext\.tool$}) && ($srcd ne $coursedom)) {
                 $notindom{$suffix} = 1;                  $notindom{$suffix} = 1;
                 next;                  next;
             }              }
Line 1855  sub do_paste_from_buffer { Line 1867  sub do_paste_from_buffer {
                 }                  }
             }              }
             unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {              unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
                 my (%lockerr,$msg);                   my (%lockerr,$msg);
                 my ($newurl,$result,$errtext) =                  my ($newurl,$result,$errtext) =
                     &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);                      &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
                 if ($result eq 'ok') {                  if ($result eq 'ok') {
Line 1914  sub do_paste_from_buffer { Line 1926  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')) {
                         my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";                          my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
Line 2154  sub dbcopy { Line 2166  sub dbcopy {
                 if (!$suffix) {                  if (!$suffix) {
                     if ($prefix eq 'smppg') {                      if ($prefix eq 'smppg') {
                         $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);                          $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
                       } elsif ($prefix eq 'exttool') {
                           $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url);
                     } else {                      } else {
                         $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);                          $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
                     }                      }
Line 2901  sub update_parameter { Line 2915  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 3004  sub update_parameter { Line 3018  sub update_parameter {
   
 sub handle_edit_cmd {  sub handle_edit_cmd {
     my ($coursenum,$coursedom) =@_;      my ($coursenum,$coursedom) =@_;
       my $haschanges = 0;
     if ($env{'form.cmd'} eq '') {      if ($env{'form.cmd'} eq '') {
         return 0;          return $haschanges; 
     }      }
     my ($cmd,$idx)=split('_',$env{'form.cmd'});      my ($cmd,$idx)=split('_',$env{'form.cmd'});
   
Line 3020  sub handle_edit_cmd { Line 3035  sub handle_edit_cmd {
     &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);      &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
  }   }
  splice(@LONCAPA::map::order, $idx, 1);   splice(@LONCAPA::map::order, $idx, 1);
           $haschanges = 1;
     } elsif ($cmd eq 'cut') {      } elsif ($cmd eq 'cut') {
  &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);   &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
  splice(@LONCAPA::map::order, $idx, 1);   splice(@LONCAPA::map::order, $idx, 1);
           $haschanges = 1;
     } elsif ($cmd eq 'up'      } elsif ($cmd eq 'up'
      && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {       && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
  @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];   @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
           $haschanges = 1;
     } elsif ($cmd eq 'down'      } elsif ($cmd eq 'down'
      && defined($LONCAPA::map::order[$idx+1])) {       && defined($LONCAPA::map::order[$idx+1])) {
  @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];   @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
           $haschanges = 1;
     } elsif ($cmd eq 'rename') {      } elsif ($cmd eq 'rename') {
  my $comment = &LONCAPA::map::qtunescape($env{'form.title'});   my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
  if ($comment=~/\S/) {   if ($comment=~/\S/) {
Line 3042  sub handle_edit_cmd { Line 3057  sub handle_edit_cmd {
 # Devalidate title cache  # Devalidate title cache
  my $renamed_url=&LONCAPA::map::qtescape($url);   my $renamed_url=&LONCAPA::map::qtescape($url);
  &Apache::lonnet::devalidate_title_cache($renamed_url);   &Apache::lonnet::devalidate_title_cache($renamed_url);
           $haschanges = 1;
     } else {      } elsif ($cmd eq 'setalias') {
  return 0;          my $newvalue = $env{'form.alias'};
           if ($newvalue ne '') {
               unless (Apache::lonnet::get_symb_from_alias($newvalue)) {
                   &LONCAPA::map::storeparameter($idx,'parameter_0_mapalias',$newvalue,
                                                 'string');
                   &remember_parms($idx,'mapalias','set',$newvalue);
                   $haschanges = 1;
               }
           }
       } elsif ($cmd eq 'delalias') {
           my $current = (&LONCAPA::map::getparameter($idx,'parameter_0_mapalias'))[0];  
           if ($current ne '') {
               &LONCAPA::map::delparameter($idx,'parameter_0_mapalias');
               &remember_parms($idx,'mapalias','del');
               $haschanges = 1;
           }
     }      }
     return 1;      return $haschanges;
 }  }
   
 sub editor {  sub editor {
Line 3170  sub editor { Line 3200  sub editor {
 # Rename, cut, copy or remove a single resource  # Rename, cut, copy or remove a single resource
  if (&handle_edit_cmd($coursenum,$coursedom)) {   if (&handle_edit_cmd($coursenum,$coursedom)) {
             my $contentchg;              my $contentchg;
             if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {              if ($env{'form.cmd'} =~ m{^(remove|cut|setalias|delalias)_}) {
                 $contentchg = 1;                  $contentchg = 1;
             }              }
     ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);      ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
Line 3410  sub editor { Line 3440  sub editor {
                           .&Apache::loncommon::start_data_table(undef,'contentlist')                            .&Apache::loncommon::start_data_table(undef,'contentlist')
                           .&Apache::loncommon::start_data_table_header_row()                            .&Apache::loncommon::start_data_table_header_row()
                           .'<th colspan="2">'.&mt('Move').'</th>'                            .'<th colspan="2">'.&mt('Move').'</th>'
                           .'<th colspan="2">'.&mt('Actions').'</th>'                            .'<th colspan="3">'.&mt('Actions').'</th>'
                           .'<th>'.&mt('Document').'</th>';                            .'<th>'.&mt('Document').'</th>';
                 if ($folder !~ /^supplemental/) {                  if ($folder !~ /^supplemental/) {
                     $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';                      $to_show .= '<th colspan="2">'.&mt('Settings').'</th>';
                 }                  }
                 $to_show .= &Apache::loncommon::end_data_table_header_row();                  $to_show .= &Apache::loncommon::end_data_table_header_row();
                 if ($folder !~ /^supplemental/) {                  if ($folder !~ /^supplemental/) {
Line 3431  sub editor { Line 3461  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>'.
                                 &multiple_check_form('actions',\%lists,$canedit).                                  &multiple_check_form('actions',\%lists,$canedit).
                                 '</td>'.                                  '</td>'.
                                 '<td>&nbsp;</td>'.                                  '<td colspan="3">&nbsp;</td>'.
                                 '<td>&nbsp;</td>'.                                  '<td colspan="2">'.
                                 '<td colspan="4">'.  
                                 &multiple_check_form('settings',\%lists,$canedit).                                  &multiple_check_form('settings',\%lists,$canedit).
                                 '</td>'.                                  '</td>'.
                                 &Apache::loncommon::end_data_table_row();                                  &Apache::loncommon::end_data_table_row();
Line 3683  sub process_file_upload { Line 3712  sub process_file_upload {
                     my $uploadphase = 'upload_embedded';                      my $uploadphase = 'upload_embedded';
                     my $primaryurl = &HTML::Entities::encode($url,'<>&"');                      my $primaryurl = &HTML::Entities::encode($url,'<>&"');
     my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);       my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx); 
                     my ($embedded,$num) =                       my ($embedded,$num) =
                         &Apache::loncommon::ask_for_embedded_content(                          &Apache::loncommon::ask_for_embedded_content(
                             '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});                              '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
                     if ($embedded) {                      if ($embedded) {
Line 3791  sub entryline { Line 3820  sub entryline {
     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
     my ($esc_path, $path, $symb);      my ($esc_path, $path, $symb, $curralias);
     if ($env{'form.folderpath'}) {      if ($env{'form.folderpath'}) {
  $esc_path=&escape($env{'form.folderpath'});   $esc_path=&escape($env{'form.folderpath'});
  $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');   $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
Line 3860  END Line 3889  END
                 'ct' => 'Cut',                  'ct' => 'Cut',
  'rn' => 'Rename',   'rn' => 'Rename',
  'cp' => 'Copy',   'cp' => 'Copy',
                   'da' => 'Unset alias', 
                   'sa' => 'Set alias',
                 'ex' => 'External Resource',                  'ex' => 'External Resource',
                 'et' => 'External Tool',                  'et' => 'External Tool',
                 'ed' => 'Edit',                  'ed' => 'Edit',
Line 3890  END Line 3921  END
             ($url!~/$LONCAPA::assess_page_seq_re/)) {              ($url!~/$LONCAPA::assess_page_seq_re/)) {
             $confirm_removal = 1;              $confirm_removal = 1;
         }          }
           if ($url =~ /$LONCAPA::assess_re/) {
               $curralias = (&LONCAPA::map::getparameter($orderidx,'parameter_0_mapalias'))[0];
           }
   
  if ($denied{'copy'}) {   if ($denied{'copy'}) {
             $copylink=(<<ENDCOPY)              $copylink=(<<ENDCOPY)
Line 4172  END Line 4206  END
                     }                      }
                 }                  }
             }              }
               
 # Append randompick number, hidden, and encrypted with ":" to foldername,  # Append randompick number, hidden, and encrypted with ":" to foldername,
 # so it gets transferred between levels  # so it gets transferred between levels
     $folderpath.=$containerarg.'&'.$foldername.      $folderpath.=$containerarg.'&'.$foldername.
Line 4233  $form_end; Line 4267  $form_end;
     }      }
     my ($tdalign,$tdwidth);      my ($tdalign,$tdwidth);
     if ($allowed) {      if ($allowed) {
         my $fileloc =           my $fileloc =
             &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));              &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
         if ($isexternal) {          if ($isexternal) {
             ($editlink,$extresform) =               ($editlink,$extresform) =
                 &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,                  &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
                                                      undef,undef,undef,undef,undef,undef,                                                       undef,undef,undef,undef,undef,undef,
                                                      undef,$disabled);                                                       undef,$disabled);
Line 4253  $form_end; Line 4287  $form_end;
                 if ($supplementalflag) {                  if ($supplementalflag) {
                     $suppanchor = $anchor;                      $suppanchor = $anchor;
                 }                  }
                 my $jscall =                   my $jscall =
                     &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,                      &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
                                                             $switchserver,                                                              $switchserver,
                                                             $forceedit,                                                              $forceedit,
Line 4277  $form_end; Line 4311  $form_end;
         $reinit = &mt('(re-initialize course to access)');          $reinit = &mt('(re-initialize course to access)');
     }      }
     $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;      $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
       if ($url =~ /$LONCAPA::assess_re/) {
           $line.= '<br />';
           if ($curralias ne '') {
               $line.='<span class="LC_nobreak"><a href="javascript:delalias('."'$esc_path','$orderidx'".');" class="LC_docs_alias">'.
                      $lt{'da'}.'</a></span>';
           } else {
               $line.='<span class="LC_nobreak"><a href="javascript:setalias('."'$esc_path','$orderidx'".');" class="LC_docs_alias">'.
                      $lt{'sa'}.'</a></span>';
           }
       }
       $line.='</td><td>';
     my $link;      my $link;
     if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {      if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
        $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';         $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
Line 4316  $form_end; Line 4361  $form_end;
            $line.=&Apache::loncommon::modal_link($link,$title,600,500);             $line.=&Apache::loncommon::modal_link($link,$title,600,500);
        }         }
     } elsif (($hiddenfolder) || ($hiddenres)) {      } elsif (($hiddenfolder) || ($hiddenres)) {
        $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">'.&mt('(Hidden)').'</span>';         $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
     } else {      } else {
        $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';         $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
     }      }
     $line.="$extresform</td>";      if (($allowed) && ($curralias ne '')) {
           $line .= '<br /><span class="LC_docs_alias_name">('.$curralias.')</span>';
       } else {
           $line .= $extresform;
       }
       $line .= '</td>';
     $rand_pick_text = '&nbsp;' if ($rand_pick_text eq '');      $rand_pick_text = '&nbsp;' if ($rand_pick_text eq '');
     $rand_order_text = '&nbsp;' if ($rand_order_text eq '');      $rand_order_text = '&nbsp;' if ($rand_order_text eq '');
     if (($allowed) && ($folder!~/^supplemental/)) {      if (($allowed) && ($folder!~/^supplemental/)) {
Line 4465  sub new_timebased_suffix { Line 4515  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 4538  sub untiehash { Line 4588  sub untiehash {
   
   
 sub checkonthis {  sub checkonthis {
     my ($r,$url,$level,$title)=@_;      my ($r,$url,$level,$title,$checkstale)=@_;
     $url=&unescape($url);      $url=&unescape($url);
     $alreadyseen{$url}=1;      $alreadyseen{$url}=1;
     $r->rflush();      $r->rflush();
Line 4553  sub checkonthis { Line 4603  sub checkonthis {
        $r->print('<a href="'.$url.'" target="cat">'.         $r->print('<a href="'.$url.'" target="cat">'.
  ($title?$title:$url).'</a> ');   ($title?$title:$url).'</a> ');
        if ($url=~/^\/res\//) {         if ($url=~/^\/res\//) {
             my $updated;
             if (($checkstale) && ($url !~ m{^/res/lib/templates/}) &&
                 ($url !~ /\.\d+\.\w+$/)) {
                 $updated = &Apache::lonnet::remove_stale_resfile($url);
             }
   my $result=&Apache::lonnet::repcopy(    my $result=&Apache::lonnet::repcopy(
                               &Apache::lonnet::filelocation('',$url));                                &Apache::lonnet::filelocation('',$url));
           if ($result eq 'ok') {            if ($result eq 'ok') {
              $r->print('<span class="LC_success">'.&mt('ok').'</span>');               $r->print('<span class="LC_success">'.&mt('ok').'</span>');
                if ($updated) {
                    $r->print('<br />');
                    for (my $i=0;$i<=$level*5;$i++) {
                        $r->print('&nbsp;');
                    }
                    $r->print('- '.&mt('Outdated copy removed'));
                }
              $r->rflush();               $r->rflush();
              &Apache::lonnet::countacc($url);               &Apache::lonnet::countacc($url);
              $url=~/\.(\w+)$/;               $url=~/\.(\w+)$/;
Line 4590  sub checkonthis { Line 4652  sub checkonthis {
                 &Apache::lonnet::metadata($url,'dependencies');                  &Apache::lonnet::metadata($url,'dependencies');
              foreach my $dep (split(/\,/,$dependencies)) {               foreach my $dep (split(/\,/,$dependencies)) {
  if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {   if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
                     &checkonthis($r,$dep,$level+1);                      &checkonthis($r,$dep,$level+1,'',$checkstale);
                  }                   }
              }               }
           } elsif ($result eq 'unavailable') {            } elsif ($result eq 'unavailable') {
Line 4604  sub checkonthis { Line 4666  sub checkonthis {
           } else {            } else {
              $r->print('<span class="LC_error">'.&mt('access denied').'</span>');               $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
           }            }
             if (($updated) && ($result ne 'ok')) {
                 $r->print('<br />'.&mt('Outdated copy removed'));
             }
        }         }
     }      }
 }  }
Line 4656  sub list_symbs { Line 4721  sub list_symbs {
     $r->print(&endContentScreen());      $r->print(&endContentScreen());
 }  }
   
   sub contentverifyform {
       my ($r) = @_;
       my $crstype = &Apache::loncommon::course_type();
       $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
       $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
       $r->print(&startContentScreen('tools'));
       $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
       $r->print('<form method="post" action="/adm/coursedocs"><p>'.
                 &mt('Include a check if files copied from elsewhere are up to date (will increase verification time)?').
                 '&nbsp;<span class="LC_nobreak">'.
                 '<label><input type="radio" name="checkstale" value="0" checked="checked" />'.
                 &mt('No').'</label>'.('&nbsp;'x2).
                 '<label><input type="radio" name="checkstale" value="1" />'.
                 &mt('Yes').'</label></span></p><p>'.
                 '<input type="submit" value="'.&mt('Verify content').' "/>'.
                 '<input type="hidden" value="1" name="tools" />'.
                 '<input type="hidden" value="1" name="verify" /></p></form>');
       $r->print(&endContentScreen());
       return;
   }
   
 sub verifycontent {  sub verifycontent {
     my ($r) = @_;      my ($r,$checkstale) = @_;
     my $crstype = &Apache::loncommon::course_type();      my $crstype = &Apache::loncommon::course_type();
     $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));      $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));      $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
Line 4679  sub verifycontent { Line 4764  sub verifycontent {
    }     }
        }         }
        if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {         if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
            &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});             &checkonthis($r,$hash{$key},0,$hash{'title_'.$1},$checkstale);
        }         }
    }     }
    &untiehash();     &untiehash();
Line 4687  sub verifycontent { Line 4772  sub verifycontent {
     $r->print(&endContentScreen());      $r->print(&endContentScreen());
 }  }
   
   
 sub devalidateversioncache {  sub devalidateversioncache {
     my $src=shift;      my $src=shift;
     &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.      &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
Line 5150  sub handler { Line 5234  sub handler {
         $disabled = ' disabled="disabled"';          $disabled = ' disabled="disabled"';
     }      }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
       if ($env{'form.inhibitmenu'}) {
           unless ($env{'form.inhibitmenu'} eq 'yes') {
               delete($env{'form.inhibitmenu'});
           }
       }
   
   if ($allowed && $env{'form.verify'}) {    if ($allowed && $env{'form.verify'}) {
       &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');        &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
       &verifycontent($r);        if (!$canedit) {
             &verifycontent($r);
         } elsif (($env{'form.checkstale'} ne '') && ($env{'form.checkstale'} =~ /^\d$/)) {
             &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1&verify=1&checkstale=$env{'form.checkstale'}",
                                                     text=>'Results',
                                                     faq=>273,
                                                     bug=>'Instructor Interface'});
             &verifycontent($r,$env{'form.checkstale'});
         } else {
             &contentverifyform($r);
         }
   } elsif ($allowed && $env{'form.listsymbs'}) {    } elsif ($allowed && $env{'form.listsymbs'}) {
       &init_breadcrumbs('listsymbs','List Content IDs');        &init_breadcrumbs('listsymbs','List Content IDs');
       &list_symbs($r);        &list_symbs($r);
Line 5232  sub handler { Line 5332  sub handler {
                                              'forcesupplement','forcestandard',                                               'forcesupplement','forcestandard',
                                              'tools','symb','command','supppath']);                                               'tools','symb','command','supppath']);
   
       foreach my $item ('forcesupplement','forcestandard','tools') {
           next if ($env{'form.'.$item} eq '');
           unless ($env{'form.'.$item} eq '1') {
               delete($env{'form.'.$item});
           }
       }
   
       if ($env{'form.command'}) {
           unless ($env{'form.command'} =~ /^(direct|directnav|editdocs|editsupp|contents|home)$/) {
               delete($env{'form.command'});
           }
       }
   
       if ($env{'form.symb'}) {
           my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
           unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) { 
               delete($env{'form.symb'});
           }
       }
   
 # standard=1: this is a "new-style" course with an uploaded map as top level  # standard=1: this is a "new-style" course with an uploaded map as top level
 # standard=2: this is a "old-style" course, and there is nothing we can do  # standard=2: this is a "old-style" course, and there is nothing we can do
   
Line 5254  sub handler { Line 5374  sub handler {
     my $toolsflag=0;      my $toolsflag=0;
     if ($env{'form.tools'}) { $toolsflag=1; }      if ($env{'form.tools'}) { $toolsflag=1; }
   
       if ($env{'form.folderpath'} ne '') {
           my @items = split(/\&/,$env{'form.folderpath'});
           my $badpath;
           for (my $i=0; $i<@items; $i++) {
               my $odd = $i%2;
               if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) {
                   $badpath = 1;
               } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) {
                   $badpath = 1;
               }
               last if ($badpath);
           }
           if ($badpath) {
               delete($env{'form.folderpath'});
           }
       }
   
       if ($env{'form.supppath'} ne '') {
           my @items = split(/\&/,$env{'form.supppath'});
           my $badpath;
           for (my $i=0; $i<@items; $i++) {
               my $odd = $i%2;
               if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
                   $badpath = 1; 
               }
               last if ($badpath);
           }
           if ($badpath) {
               delete($env{'form.supppath'});
           }
       }
   
     my $script='';      my $script='';
     my $showdoc=0;      my $showdoc=0;
     my $addentries = {};      my $addentries = {};
Line 5541  sub handler { Line 5693  sub handler {
           my ($destination,$dir_root) = &embedded_destination();            my ($destination,$dir_root) = &embedded_destination();
           my $url_root = '/uploaded/'.$docudom.'/'.$docuname;            my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
           my $actionurl = '/adm/coursedocs';            my $actionurl = '/adm/coursedocs';
           my ($result,$flag) =             my ($result,$flag) =
               &Apache::loncommon::upload_embedded('coursedoc',$destination,                &Apache::loncommon::upload_embedded('coursedoc',$destination,
                   $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,                    $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
                   $actionurl);                    $actionurl);
Line 5552  sub handler { Line 5704  sub handler {
           my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};            my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
           my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};            my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
           my ($destination,$dir_root) = &embedded_destination();            my ($destination,$dir_root) = &embedded_destination();
           my $result =             my $result =
               &Apache::loncommon::modify_html_refs('coursedoc',$destination,                &Apache::loncommon::modify_html_refs('coursedoc',$destination,
                                                    $docuname,$docudom,undef,                                                     $docuname,$docudom,undef,
                                                    $dir_root);                                                     $dir_root);
           $r->print($result.&return_to_editor());               $r->print($result.&return_to_editor());
       } elsif ($env{'form.phase'} eq 'decompress_uploaded') {        } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
           $uploadphase = 'decompress_phase_one';            $uploadphase = 'decompress_phase_one';
           $r->print(&decompression_phase_one().            $r->print(&decompression_phase_one().
Line 5582  sub handler { Line 5734  sub handler {
                 'impo' => 'Import',                  'impo' => 'Import',
  'lnks' => 'Import from Stored Links',   'lnks' => 'Import from Stored Links',
                 'impm' => 'Import from Assembled Map',                  'impm' => 'Import from Assembled Map',
                 'imcr' => 'Import from Course Resources',                     'imcr' => 'Import from Course Resources',
                 'extr' => 'External Resource',                  'extr' => 'External Resource',
                 'extt' => 'External Tool',                  'extt' => 'External Tool',
                 'selm' => 'Select Map',                  'selm' => 'Select Map',
Line 5593  sub handler { Line 5745  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)',
                 'stpr' => 'Standard Problem',                  'stpr' => 'Standard Problem',
                 'news' => 'New sub-directory',                  'news' => 'New sub-directory',
                 'crpr' => 'Create Problem',                  'crpr' => 'Create Problem',
Line 5822  CRSFORM Line 5974  CRSFORM
    <input type="hidden" name="copyfolder" />     <input type="hidden" name="copyfolder" />
    $containertag     $containertag
  </form>   </form>
    <form name="aliasform" method="post" action="/adm/coursedocs">
      <input type="hidden" name="alias" />
      <input type="hidden" name="cmd" />
      $containertag
    </form>
   
 HIDDENFORM  HIDDENFORM
         $r->print(&makesimpleeditform($pathitem)."\n".          $r->print(&makesimpleeditform($pathitem)."\n".
Line 6042  NWEBFORM Line 6199  NWEBFORM
                 $numauthor ++;                  $numauthor ++;
             }              }
         }          }
         my ($pickdir,$showtitle);;          my ($pickdir,$showtitle);
         if ($numauthor) {          if ($numauthor) {
             my @order;              my @order;
             my $defrole;              my $defrole;
Line 6351  unless ($container eq 'page') { Line 6508  unless ($container eq 'page') {
  <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">   <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
         <fieldset id="uploadsuppdocform" style="display: none;">          <fieldset id="uploadsuppdocform" style="display: none;">
         <legend>$lt{'upfi'}</legend>          <legend>$lt{'upfi'}</legend>
  <input type="hidden" name="active" value="ee" />   <input type="hidden" name="active" value="ee" />
  $fileupload   $fileupload
  <br />   <br />
  <br />   <br />
Line 6478  my %suporderhash = ( Line 6635  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 6510  my %suporderhash = ( Line 6667  my %suporderhash = (
                 &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');                  &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
   }    }
  }   }
  unless ($noendpage) {    unless ($noendpage) {
      $r->print(&Apache::loncommon::end_page());       $r->print(&Apache::loncommon::end_page());
  }   }
  return OK;   return OK;
Line 6519  my %suporderhash = ( Line 6676  my %suporderhash = (
 sub embedded_form_elems {  sub embedded_form_elems {
     my ($phase,$primaryurl,$newidx) = @_;      my ($phase,$primaryurl,$newidx) = @_;
     my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');      my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
       $newidx =~s /\D+//g;
     return <<STATE;      return <<STATE;
     <input type="hidden" name="folderpath" value="$folderpath" />      <input type="hidden" name="folderpath" value="$folderpath" />
     <input type="hidden" name="cmd" value="upload_embedded" />      <input type="hidden" name="cmd" value="upload_embedded" />
Line 6539  sub embedded_destination { Line 6697  sub embedded_destination {
     } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {      } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
         $destination .=  $2.'/';          $destination .=  $2.'/';
     }      }
     $destination .= $env{'form.newidx'};      my $newidx = $env{'form.newidx'};
       $newidx =~s /\D+//g;
       if ($newidx) {
           $destination .= $newidx;
       }
     my $dir_root = '/userfiles';      my $dir_root = '/userfiles';
     return ($destination,$dir_root);      return ($destination,$dir_root);
 }  }
Line 6565  sub decompression_info { Line 6727  sub decompression_info {
     }      }
     unshift(@hiddens,$pathitem);      unshift(@hiddens,$pathitem);
     foreach my $item (@hiddens) {      foreach my $item (@hiddens) {
           if ($item eq 'newidx') {
               next if ($env{'form.'.$item} =~ /\D/);
           }
         if ($env{'form.'.$item}) {          if ($env{'form.'.$item}) {
             $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.              $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
                            &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";                             &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
Line 6582  sub decompression_phase_one { Line 6747  sub decompression_phase_one {
         $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});          $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
     } else {      } else {
         my $file = $1;          my $file = $1;
         $output =           $output =
             &Apache::loncommon::process_decompression($docudom,$docuname,$file,              &Apache::loncommon::process_decompression($docudom,$docuname,$file,
                                                       $destination,$dir_root,                                                        $destination,$dir_root,
                                                       $hiddenelem);                                                        $hiddenelem);
Line 6889  sub editing_js { Line 7054  sub editing_js {
                                           p_ctr2b => '?',                                            p_ctr2b => '?',
                                           p_ctr3a => 'Cut those',                                            p_ctr3a => 'Cut those',
                                           p_ctr3b => 'items?',                                            p_ctr3b => 'items?',
                                             setal   => 'Enter a (unique) alias',
                                             delal   => 'Are you sure you want to eliminate the alias?',
                                           rpck    => 'Enter number to pick (e.g., 3)',                                            rpck    => 'Enter number to pick (e.g., 3)',
                                           imsfile => 'You must choose an IMS package for import',                                            imsfile => 'You must choose an IMS package for import',
                                           imscms  => 'You must select which Course Management System was the source of the IMS package',                                            imscms  => 'You must select which Course Management System was the source of the IMS package',
Line 7091  function changename(folderpath,index,old Line 7258  function changename(folderpath,index,old
     }      }
 }  }
   
   function setalias(folderpath,index) {
       var alias = prompt('$js_lt{"setal"}');
       if ((alias != null) && (alias != '')) {
           this.document.forms.aliasform.alias.value=alias;
           this.document.forms.aliasform.cmd.value='setalias_'+index;
           this.document.forms.aliasform.folderpath.value=folderpath;
           this.document.forms.aliasform.submit();
       }
   }
   
   function delalias(folderpath,index) {
       if (confirm('$js_lt{"delal"}')) {
           this.document.forms.aliasform.cmd.value='delalias_'+index;
           this.document.forms.aliasform.folderpath.value=folderpath;
           this.document.forms.aliasform.submit();
       }
   }
   
 ENDNEWSCRIPT  ENDNEWSCRIPT
     } else {      } else {
         $jsmakefunctions = <<ENDNEWSCRIPT;          $jsmakefunctions = <<ENDNEWSCRIPT;
Line 7135  function changename() { Line 7320  function changename() {
     alert("$js_lt{'edri'}");      alert("$js_lt{'edri'}");
 }  }
   
   function setalias() {
       alert("$js_lt{'edri'}");
   }
   
   function delalias() {
       alert("$js_lt{'edri'}");
   }
   
 function makenew() {  function makenew() {
     alert("$js_lt{'edri'}");      alert("$js_lt{'edri'}");
 }  }
Line 8629  check on this Line 8822  check on this
   
 Verify Content  Verify Content
   
 =item devalidateversioncache() & checkversions()  =item devalidateversioncache() 
   
   =item checkversions()
   
 Check Versions  Check Versions
   

Removed from v.1.627  
changed lines
  Added in v.1.637


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