Diff for /loncom/interface/londocs.pm between versions 1.484.2.86 and 1.484.2.92

version 1.484.2.86, 2020/01/20 20:09:37 version 1.484.2.92, 2021/12/17 16:38:35
Line 177  sub default_folderpath { Line 177  sub default_folderpath {
     }      }
 }  }
   
   sub validate_folderpath {
       my ($supplementalflag) = @_;
       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'});
           }
       }
       return;
   }
   
   sub validate_suppath {
       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'});
           }
       }
       return;
   }
   
 sub dumpcourse {  sub dumpcourse {
     my ($r) = @_;      my ($r) = @_;
     my $crstype = &Apache::loncommon::course_type();      my $crstype = &Apache::loncommon::course_type();
Line 676  sub group_import { Line 715  sub group_import {
     }      }
     my $ext = 'false';      my $ext = 'false';
     if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }      if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
     $name = &LONCAPA::map::qtunescape($name);  
             if ($name eq '') {  
                 $name = &LONCAPA::map::qtunescape(&mt('Web Page'));  
             }  
             if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {              if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
                 my $filepath = $1;                  my $filepath = $1;
                 my $fname = $name;                  my $fname;
                 if ($fname =~ /^\W+$/) {                  if ($name eq '') {
                       $name = &mt('Web Page');
                     $fname = 'web';                      $fname = 'web';
                 } else {                  } else {
                     $fname =~ s/\W/_/g;                      $fname = $name;
                 }                      $fname=&Apache::lonnet::clean_filename($fname);
                 if (length($fname) > 15) {                      if ($fname eq '') {
                     $fname = substr($fname,0,14);                          $fname = 'web';
                       } elsif (length($fname) > 15) {
                           $fname = substr($fname,0,14);
                       }
                 }                  }
                   my $title = &Apache::loncommon::cleanup_html($name);
                 my $initialtext = &mt('Replace with your own content.');                  my $initialtext = &mt('Replace with your own content.');
                 my $newhtml = <<END;                  my $newhtml = <<END;
 <html>  <html>
 <head>  <head>
 <title>$name</title>  <title>$title</title>
 </head>  </head>
 <body bgcolor="#ffffff">  <body bgcolor="#ffffff">
 $initialtext  $initialtext
Line 717  END Line 757  END
                     return (&mt('Failed to save new web page.'),1);                      return (&mt('Failed to save new web page.'),1);
                 }                  }
             }              }
               $name = &LONCAPA::map::qtunescape($name);
             $url  = &LONCAPA::map::qtunescape($url);              $url  = &LONCAPA::map::qtunescape($url);
     $LONCAPA::map::resources[$residx] =      $LONCAPA::map::resources[$residx] =
  join(':', ($name, $url, $ext, 'normal', 'res'));   join(':', ($name, $url, $ext, 'normal', 'res'));
Line 1059  sub update_paste_buffer { Line 1100  sub update_paste_buffer {
 # Construct identifiers for current contents of user's paste buffer  # Construct identifiers for current contents of user's paste buffer
     if (@currpaste) {      if (@currpaste) {
         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;                  if ($url eq '/res/lib/templates/simpleproblem.problem') {
              }                      $pasteurls{$cid.'_'.$mapidx} = 1;
                   } elsif ($url =~ m{^/res/$match_domain/$match_username/}) {
                       $pasteurls{$url} = 1;
                   } else {
                       $pasteurls{$cid.'_'.$url} = 1;
                   }
               }
         }          }
     }      }
   
Line 1074  sub update_paste_buffer { Line 1121  sub update_paste_buffer {
   
     my @pathitems = split(/\&/,$env{'form.folderpath'});      my @pathitems = split(/\&/,$env{'form.folderpath'});
     my @folderconf = split(/\:/,$pathitems[-1]);      my @folderconf = split(/\:/,$pathitems[-1]);
     my $ispage = $folderconf[4];      my $ispage = $folderconf[5];
   
     foreach my $item (@possibles) {      foreach my $item (@possibles) {
         my ($orderidx,$cmd) = split(/:/,$item);          my ($orderidx,$cmd) = split(/:/,$item);
Line 1087  sub update_paste_buffer { Line 1134  sub update_paste_buffer {
                                           $env{'form.folderpath'},\%curr_groups);                                            $env{'form.folderpath'},\%curr_groups);
         next if ($denied{'copy'});          next if ($denied{'copy'});
         $url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};          $url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};
         next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx}));          if ($url eq '/res/lib/templates/simpleproblem.problem') {
               next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx}));
           } elsif ($url =~ m{^/res/$match_domain/$match_username/}) {
               next if (exists($pasteurls{$url}));
           } else {
               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 '') {          if ($suffix ne '') {
Line 3874  END Line 3927  END
     my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);      my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
     my $orig_url = $url;      my $orig_url = $url;
     $orig_url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};      $orig_url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};
     $url=~s{^http(|s)(&colon;|:)//}{/adm/wrapper/ext/};      if ($container eq 'page') {
           $url=~s{^http(|s)(&colon;|:)//}{/ext/};
       } else {
           $url=~s{^http(|s)(&colon;|:)//}{/adm/wrapper/ext/};
       }
     if (!$supplementalflag && $residx && $symb) {      if (!$supplementalflag && $residx && $symb) {
         if ((!$isfolder) && (!$ispage)) {          if ((!$isfolder) && (!$ispage)) {
     (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);      (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
     $url=&Apache::lonnet::clutter($url);              if (($url =~ m{^ext/}) && ($container eq 'page')) {
                   $url=&Apache::lonnet::clutter_with_no_wrapper($url);
               } else {
                   $url=&Apache::lonnet::clutter($url);
               }
     if ($url=~/^\/*uploaded\//) {      if ($url=~/^\/*uploaded\//) {
         $url=~/\.(\w+)$/;          $url=~/\.(\w+)$/;
         my $embstyle=&Apache::loncommon::fileembstyle($1);          my $embstyle=&Apache::loncommon::fileembstyle($1);
Line 3892  END Line 3953  END
             } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {              } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
                 my $wrapped = $1;                  my $wrapped = $1;
                 my $exturl = $2;                  my $exturl = $2;
                 if ($wrapped eq '') {                  if (($wrapped eq '') && ($container ne 'page')) {
                     $url='/adm/wrapper'.$url;                      $url='/adm/wrapper'.$url;
                 }                  }
                 if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {                  if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
Line 3910  END Line 3971  END
             if (&Apache::lonnet::symbverify($symb,$url)) {              if (&Apache::lonnet::symbverify($symb,$url)) {
                 my $shownsymb = $symb;                  my $shownsymb = $symb;
                 if ($isexternal) {                  if ($isexternal) {
                     if ($url =~ /^([^#]+)#([^#]+)$/) {                      $url =~ s/\#[^#]+$//;
                         $url = $1;                      if ($container eq 'page') {
                         $anchor = $2;                          $url = &Apache::lonnet::clutter($url);
                         my $escan = &escape('#');  
                         $shownsymb =~ s/^([^\#]+)#([^\#]+)$/$1$escan$2/;  
                     }                      }
                 }                  }
                 unless ($env{'request.role.adv'}) {                  unless ($env{'request.role.adv'}) {
Line 4531  sub contentverifyform { Line 4590  sub contentverifyform {
               &mt('No').'</label>'.('&nbsp;'x2).                &mt('No').'</label>'.('&nbsp;'x2).
               '<label><input type="radio" name="checkstale" value="1" />'.                '<label><input type="radio" name="checkstale" value="1" />'.
               &mt('Yes').'</label></span></p><p>'.                &mt('Yes').'</label></span></p><p>'.
               '<input type="submit" value="'.&mt('Verify content').' "/>'.                '<input type="submit" value="'.&mt('Verify Content').' "/>'.
               '<input type="hidden" value="1" name="tools" />'.                '<input type="hidden" value="1" name="tools" />'.
               '<input type="hidden" value="1" name="verify" /></p></form>');                '<input type="hidden" value="1" name="verify" /></p></form>');
     $r->print(&endContentScreen());      $r->print(&endContentScreen());
Line 5119  sub handler { Line 5178  sub handler {
     if ($env{'form.tools'}) { $toolsflag=1; }      if ($env{'form.tools'}) { $toolsflag=1; }
   
     if ($env{'form.folderpath'} ne '') {      if ($env{'form.folderpath'} ne '') {
         my @items = split(/\&/,$env{'form.folderpath'});          &validate_folderpath($supplementalflag);
         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 '') {      if ($env{'form.supppath'} ne '') {
         my @items = split(/\&/,$env{'form.supppath'});          &validate_suppath();
         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='';
Line 5205  sub handler { Line 5240  sub handler {
         } else {          } else {
             undef($env{'form.folderpath'});              undef($env{'form.folderpath'});
         }          }
           if ($env{'form.folderpath'} ne '') {
               &validate_folderpath($supplementalflag);
           }
     }      }
         
 # If we are not allowed to make changes, all we can see are supplemental docs  # If we are not allowed to make changes, all we can see are supplemental docs
Line 5229  sub handler { Line 5267  sub handler {
             undef($env{'form.folderpath'});              undef($env{'form.folderpath'});
         } else {          } else {
             $folderurl = "uploaded/$coursedom/$coursenum/$folder";              $folderurl = "uploaded/$coursedom/$coursenum/$folder";
             if ((split(/\:/,$pathitems[-1]))[4]) {              if ((split(/\:/,$pathitems[-1]))[5]) {
                 $folderurl .= '.page';                  $folderurl .= '.page';
             } else {              } else {
                 $folderurl .= '.sequence';                  $folderurl .= '.sequence';
Line 5882  NSYLFORM Line 5920  NSYLFORM
  $help{'Group Portfolio'}   $help{'Group Portfolio'}
  </form>   </form>
 NGFFORM  NGFFORM
  @specialdocumentsforma=(          if ($container eq 'page') {
               @specialdocumentsforma=(
           {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
               );
           } else {
       @specialdocumentsforma=(
  {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'"  onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},   {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'"  onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
  {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},   {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
  {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},   {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},          {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},          {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
         );              );
           }
         $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));          $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
   
   
Line 5926  my %orderhash = ( Line 5970  my %orderhash = (
                 'aa' => ['Upload',$fileuploadform],                  'aa' => ['Upload',$fileuploadform],
                 'bb' => ['Import',$importpubform],                  'bb' => ['Import',$importpubform],
                 'cc' => ['Grading',$gradingform],                  'cc' => ['Grading',$gradingform],
                   'ee' => ['Other',$specialdocumentsform],
                 );                  );
 unless ($container eq 'page') {  unless ($container eq 'page') {
     $orderhash{'00'} = ['Newfolder',$newfolderform];      $orderhash{'00'} = ['Newfolder',$newfolderform];
     $orderhash{'dd'} = ['Collaboration',$communityform];      $orderhash{'dd'} = ['Collaboration',$communityform];
     $orderhash{'ee'} = ['Other',$specialdocumentsform];  
 }  }
   
  $hadchanges=0;   $hadchanges=0;
Line 6605  sub editing_js { Line 6649  sub editing_js {
 function makenewfolder(targetform,folderseq) {  function makenewfolder(targetform,folderseq) {
     var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');      var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
     if (foldername) {      if (foldername) {
        targetform.importdetail.value=escape(foldername)+"="+folderseq;         targetform.importdetail.value=encodeURIComponent(foldername)+"="+folderseq;
         targetform.submit();          targetform.submit();
     }      }
 }  }
Line 6613  function makenewfolder(targetform,folder Line 6657  function makenewfolder(targetform,folder
 function makenewpage(targetform,folderseq) {  function makenewpage(targetform,folderseq) {
     var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');      var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
     if (pagename) {      if (pagename) {
         targetform.importdetail.value=escape(pagename)+"="+folderseq;          targetform.importdetail.value=encodeURIComponent(pagename)+"="+folderseq;
         targetform.submit();          targetform.submit();
     }      }
 }  }
Line 6622  function makeexamupload() { Line 6666  function makeexamupload() {
    var title=prompt('$js_lt{"p_mxu"}');     var title=prompt('$js_lt{"p_mxu"}');
    if (title) {     if (title) {
     this.document.forms.newexamupload.importdetail.value=      this.document.forms.newexamupload.importdetail.value=
  escape(title)+'=/res/lib/templates/examupload.problem';   encodeURIComponent(title)+'=/res/lib/templates/examupload.problem';
     this.document.forms.newexamupload.submit();      this.document.forms.newexamupload.submit();
    }     }
 }  }
Line 6631  function makesmppage() { Line 6675  function makesmppage() {
    var title=prompt('$js_lt{"p_msp"}');     var title=prompt('$js_lt{"p_msp"}');
    if (title) {     if (title) {
     this.document.forms.newsmppg.importdetail.value=      this.document.forms.newsmppg.importdetail.value=
  escape(title)+'=/adm/$udom/$uname/new/smppg';   encodeURIComponent(title)+'=/adm/$udom/$uname/new/smppg';
     this.document.forms.newsmppg.submit();      this.document.forms.newsmppg.submit();
    }     }
 }  }
Line 6646  function makewebpage(type) { Line 6690  function makewebpage(type) {
    }     }
    if (title) {     if (title) {
        var webpage = formname.importdetail.value;         var webpage = formname.importdetail.value;
        formname.importdetail.value = escape(title)+'='+webpage;         formname.importdetail.value = encodeURIComponent(title)+'='+webpage;
        formname.submit();         formname.submit();
    }     }
 }  }
Line 6655  function makesmpproblem() { Line 6699  function makesmpproblem() {
    var title=prompt('$js_lt{"p_msb"}');     var title=prompt('$js_lt{"p_msb"}');
    if (title) {     if (title) {
     this.document.forms.newsmpproblem.importdetail.value=      this.document.forms.newsmpproblem.importdetail.value=
  escape(title)+'=/res/lib/templates/simpleproblem.problem';   encodeURIComponent(title)+'=/res/lib/templates/simpleproblem.problem';
     this.document.forms.newsmpproblem.submit();      this.document.forms.newsmpproblem.submit();
    }     }
 }  }
Line 6664  function makedropbox() { Line 6708  function makedropbox() {
    var title=prompt('$js_lt{"p_mdb"}');     var title=prompt('$js_lt{"p_mdb"}');
    if (title) {     if (title) {
     this.document.forms.newdropbox.importdetail.value=      this.document.forms.newdropbox.importdetail.value=
         escape(title)+'=/res/lib/templates/DropBox.problem';          encodeURIComponent(title)+'=/res/lib/templates/DropBox.problem';
     this.document.forms.newdropbox.submit();      this.document.forms.newdropbox.submit();
    }     }
 }  }
Line 6673  function makebulboard() { Line 6717  function makebulboard() {
    var title=prompt('$js_lt{"p_mbb"}');     var title=prompt('$js_lt{"p_mbb"}');
    if (title) {     if (title) {
     this.document.forms.newbul.importdetail.value=      this.document.forms.newbul.importdetail.value=
  escape(title)+'=/adm/$udom/$uname/new/bulletinboard';   encodeURIComponent(title)+'=/adm/$udom/$uname/new/bulletinboard';
     this.document.forms.newbul.submit();      this.document.forms.newbul.submit();
    }     }
 }  }

Removed from v.1.484.2.86  
changed lines
  Added in v.1.484.2.92


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