Diff for /loncom/interface/londocs.pm between versions 1.484.2.85.2.6 and 1.484.2.85.2.9

version 1.484.2.85.2.6, 2020/09/09 02:34:27 version 1.484.2.85.2.9, 2021/04/23 13:35:26
Line 178  sub default_folderpath { Line 178  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 657  sub group_import { Line 696  sub group_import {
                 my $marker = $2;                  my $marker = $2;
                 my $info = $3;                  my $info = $3;
                 my ($toolid,%toolhash,%toolsettings);                  my ($toolid,%toolhash,%toolsettings);
                 my @extras = ('linktext','explanation','crslabel','crstitle');                  my @extras = ('linktext','explanation','crslabel','crstitle','crsappend');
                 my @toolinfo = split(/:/,$info);                  my @toolinfo = split(/:/,$info);
                 if ($residx) {                  if ($residx) {
                     %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);                      %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
Line 668  sub group_import { Line 707  sub group_import {
                 $toolid =~ s/\D//g;                  $toolid =~ s/\D//g;
                 ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},                  ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
                  $toolhash{'linktext'},$toolhash{'explanation'},                   $toolhash{'linktext'},$toolhash{'explanation'},
                  $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;                   $toolhash{'crslabel'},$toolhash{'crstitle'},$toolhash{'crsappend'}) = @toolinfo;
                 foreach my $item (@extras) {                  foreach my $item (@extras) {
                     $toolhash{$item} = &unescape($toolhash{$item});                      $toolhash{$item} = &unescape($toolhash{$item});
                 }                  }
Line 783  sub group_import { Line 822  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 824  END Line 864  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 5364  sub handler { Line 5405  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 5451  sub handler { Line 5468  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 5579  sub handler { Line 5599  sub handler {
                 }                  }
             }              }
             my $tabidstr = join("','",@tabids);              my $tabidstr = join("','",@tabids);
             %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom);              %ltitools = &Apache::lonnet::get_domain_lti($coursedom,'consumer');
             my $posslti = keys(%ltitools);              my $posslti = keys(%ltitools);
             my $hostname = $r->hostname();              my $hostname = $r->hostname();
             $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,              $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
Line 6896  sub editing_js { Line 6916  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 6904  function makenewfolder(targetform,folder Line 6924  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 6913  function makeexamupload() { Line 6933  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 6922  function makesmppage() { Line 6942  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 6937  function makewebpage(type) { Line 6957  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 6946  function makesmpproblem() { Line 6966  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 6955  function makedropbox() { Line 6975  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 6964  function makebulboard() { Line 6984  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.85.2.6  
changed lines
  Added in v.1.484.2.85.2.9


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