Diff for /loncom/interface/londocs.pm between versions 1.634 and 1.641

version 1.634, 2017/08/13 20:52:58 version 1.641, 2017/11/10 15:47:49
Line 4104  END Line 4104  END
                     }                      }
                 }                  }
                 if ($url ne '') {                  if ($url ne '') {
                     $url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');                      $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
                 }                  }
             } elsif (!$env{'request.role.adv'}) {              } elsif (!$env{'request.role.adv'}) {
                 my $checkencrypt;                  my $checkencrypt;
Line 4125  END Line 4125  END
                     my $shownsymb = &Apache::lonenc::encrypted($symb);                      my $shownsymb = &Apache::lonenc::encrypted($symb);
                     my $shownurl = &Apache::lonenc::encrypted($url);                      my $shownurl = &Apache::lonenc::encrypted($url);
                     if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {                      if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {
                         $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');                          $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
                         if ($env{'request.enc'} ne '') {                          if ($env{'request.enc'} ne '') {
                             delete($env{'request.enc'});                              delete($env{'request.enc'});
                         }                          }
Line 4588  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 4603  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 4640  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 4654  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 4706  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 4729  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 4737  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 5200  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 5282  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 5304  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 5576  sub handler { Line 5678  sub handler {
   undef($hadchanges);    undef($hadchanges);
           $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,            $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
                                               \%allfiles,\%codebase,$context,$crstype);                                                \%allfiles,\%codebase,$context,$crstype);
             undef($navmap);
   if ($hadchanges) {    if ($hadchanges) {
       &mark_hash_old();        &mark_hash_old();
   }    }
Line 6375  unless ($container eq 'page') { Line 6478  unless ($container eq 'page') {
              $r->print('<p><span class="LC_error">'.$error.'</span></p>');               $r->print('<p><span class="LC_error">'.$error.'</span></p>');
           }            }
           if ($hadchanges) {            if ($hadchanges) {
              &mark_hash_old();                unless (&is_hash_old()) {
           }                    &mark_hash_old();
                 }
     }
   
           &changewarning($r,'');            &changewarning($r,'');
         }          }
Line 6998  sub editing_js { Line 7103  sub editing_js {
                 } else {                  } else {
                     $url = $res;                      $url = $res;
                 }                  }
                 $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='.                  $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"');
                              &HTML::Entities::encode($caller,'<>&"');                  if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) {
                       $backtourl .= '?navmap=1';
                   } else {
                       $backtourl .= '?symb='.
                                     &HTML::Entities::encode($caller,'<>&"');
                   }
                 if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {                  if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
                     if (($ENV{'SERVER_PORT'} == 443) &&                      if (($ENV{'SERVER_PORT'} == 443) &&
                         ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {                          ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
Line 8720  check on this Line 8830  check on this
   
 Verify Content  Verify Content
   
 =item devalidateversioncache() & checkversions()  =item devalidateversioncache() 
   
   =item checkversions()
   
 Check Versions  Check Versions
   

Removed from v.1.634  
changed lines
  Added in v.1.641


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