Diff for /loncom/interface/londocs.pm between versions 1.484.2.91 and 1.484.2.95

version 1.484.2.91, 2021/02/10 12:46:11 version 1.484.2.95, 2024/07/03 15:15:00
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 992  sub docs_change_log { Line 1031  sub docs_change_log {
  }   }
  $r->print('</ul>');   $r->print('</ul>');
  if ($docslog{$id}{'logentry'}{'parameter_res'}) {   if ($docslog{$id}{'logentry'}{'parameter_res'}) {
     $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');              my ($title,$url) = split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'},3);
               if ($title eq '') {
                   ($title) = ($url =~ m{/([^/]+)$});
               }
               $r->print(&LONCAPA::map::qtescape($title).':<ul>');
     foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {      foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
  if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {   if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
 # FIXME: internationalization seems wrong here  # FIXME: internationalization seems wrong here
Line 1288  sub print_paste_buffer { Line 1331  sub print_paste_buffer {
             }              }
             $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';              $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
             if ($nopaste) {              if ($nopaste) {
                  $pasteitems .= $nopaste;                      $pasteitems .= ' <span class="LC_cusr_emph">'.$nopaste.'</span>';   
             } else {              } else {
                 if ($othercrs) {                  if ($othercrs) {
                     $pasteitems .= $othercrs;                      $pasteitems .= $othercrs;
Line 2524  sub apply_fixups { Line 2567  sub apply_fixups {
             $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;              $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
         }          }
         my $mapcontent = &Apache::lonnet::getfile($key);          my $mapcontent = &Apache::lonnet::getfile($key);
           if (($mapcontent eq '-1') && ($before{'map'} eq 'supplemental') &&
               ($after{'map'} eq 'default') &&
               ($key =~ m{^/uploaded/$match_domain/$match_courseid/supplemental_\d+\.sequence$})) {
               $mapcontent = '<map>'."\n".
                             '<resource id="1" src="" type="start" />'."\n".
                             '<link from="1" to="2" index="1" />'."\n".
                             '<resource id="2" src="" type="finish" />'."\n".
                             '</map>';
           }
         if ($mapcontent eq '-1') {          if ($mapcontent eq '-1') {
             if (ref($errors) eq 'HASH') {              if (ref($errors) eq 'HASH') {
                 $errors->{$key} = 1;                  $errors->{$key} = 1;
Line 2806  sub update_parameter { Line 2858  sub update_parameter {
             my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);              my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
             $name=&LONCAPA::map::qtescape($name);              $name=&LONCAPA::map::qtescape($name);
             $url=&LONCAPA::map::qtescape($url);              $url=&LONCAPA::map::qtescape($url);
             next unless ($name && $url);              next unless ($url);
             my $is_map;              my $is_map;
             if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {              if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
                 $is_map = 1;                  $is_map = 1;
Line 3388  sub multiple_check_form { Line 3440  sub multiple_check_form {
     return unless (ref($listsref) eq 'HASH');      return unless (ref($listsref) eq 'HASH');
     my $disabled;      my $disabled;
     unless ($canedit) {      unless ($canedit) {
         $disabled = 'disabled="disabled"';          $disabled = ' disabled="disabled"';
     }      }
     my $output =      my $output =
     '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.      '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
Line 3665  sub entryline { Line 3717  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, $shownsymb);
     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 3923  END Line 3975  END
             } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {              } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
                 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://})) {
                     unless (&Apache::lonnet::uses_sts()) {                      unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
                         $url .= '?usehttp=1';                          $url .= '?usehttp=1';
                     }                      }
                     $nomodal = 1;                      $nomodal = 1;
                 }                  }
     }      }
             if (&Apache::lonnet::symbverify($symb,$url)) {              if (&Apache::lonnet::symbverify($symb,$url)) {
                 my $shownsymb = $symb;                  $shownsymb = $symb;
                 if ($isexternal) {                  if ($isexternal) {
                     $url =~ s/\#[^#]+$//;                      $url =~ s/\#[^#]+$//;
                     if ($container eq 'page') {                      if ($container eq 'page') {
Line 3965  END Line 4017  END
                     }                      }
                 }                  }
                 if ($checkencrypt) {                  if ($checkencrypt) {
                     my $shownsymb = &Apache::lonenc::encrypted($symb);                      $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='.&escape($shownsymb);                          $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
Line 3988  END Line 4040  END
                 $url = $1;                  $url = $1;
                 $anchor = $2;                  $anchor = $2;
                 if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {                  if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
                     unless (&Apache::lonnet::uses_sts()) {                      unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
                         if ($hostname ne '') {                          if ($hostname ne '') {
                             $url = 'http://'.$hostname.$url;                              $url = 'http://'.$hostname.$url;
                         }                          }
Line 4000  END Line 4052  END
         } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {          } elsif ($url =~ 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://})) {
                 unless (&Apache::lonnet::uses_sts()) {                  unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
                     if ($hostname ne '') {                      if ($hostname ne '') {
                         $url = 'http://'.$hostname.$url;                          $url = 'http://'.$hostname.$url;
                     }                      }
Line 4128  $form_end; Line 4180  $form_end;
                     &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,                      &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
                                                             $switchserver,                                                              $switchserver,
                                                             $forceedit,                                                              $forceedit,
                                                             undef,$symb,                                                              undef,$symb,$shownsymb,
                                                             &escape($env{'form.folderpath'}),                                                              &escape($env{'form.folderpath'}),
                                                             $renametitle,$hostname,                                                              $renametitle,$hostname,
                                                             '','',1,$suppanchor);                                                              '','',1,$suppanchor);
Line 4207  $form_end; Line 4259  $form_end;
         }          }
         if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {          if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
             $hidtext = ' checked="checked"';              $hidtext = ' checked="checked"';
             if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {              if (($ishash) && (ref($filtersref->{'hiddenresource'}) eq 'ARRAY')) {
                 push(@{$filtersref->{'hiddenresource'}},$orderidx);                  push(@{$filtersref->{'hiddenresource'}},$orderidx);
             }              }
         }          }
Line 5139  sub handler { Line 5191  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 5225  sub handler { Line 5253  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 5561  sub handler { Line 5592  sub handler {
  my $fileupload=(<<FIUP);   my $fileupload=(<<FIUP);
         $quotainfo          $quotainfo
  $lt{'file'}:<br />   $lt{'file'}:<br />
  <input type="file" name="uploaddoc" class="LC_flUpload" size="40" $disabled />  
         <input type="hidden" id="LC_free_space" value="$free_space" />  
 FIUP  FIUP
   
  my $checkbox=(<<CHBO);   my $checkbox=(<<CHBO);
  <!-- <label>$lt{'parse'}?   <!-- <label>$lt{'parse'}?
  <input type="checkbox" name="parserflag" />   <input type="checkbox" name="parserflag" />
Line 5584  CHBO Line 5612  CHBO
         <fieldset id="uploadimsform" style="display: none;">          <fieldset id="uploadimsform" style="display: none;">
         <legend>$lt{'imsf'}</legend>          <legend>$lt{'imsf'}</legend>
         $fileupload          $fileupload
           <input type="file" name="uploaddoc" id="uploaddocims" class="LC_flUpload LC_uploaddoc" size="40" $disabled />
           <input type="hidden" id="LC_free_space_ims" value="$free_space" />
         <br />          <br />
         <p>          <p>
         $lt{'cms'}:&nbsp;           $lt{'cms'}:&nbsp; 
Line 5610  IMSFORM Line 5640  IMSFORM
         <legend>$lt{'upfi'}</legend>          <legend>$lt{'upfi'}</legend>
  <input type="hidden" name="active" value="aa" />   <input type="hidden" name="active" value="aa" />
  $fileupload   $fileupload
           <input type="file" name="uploaddoc" class="LC_flUpload" size="40" $disabled />
           <input type="hidden" id="LC_free_space" value="$free_space" />
  <br />   <br />
  $lt{'title'}:<br />   $lt{'title'}:<br />
  <input type="text" size="60" name="comment" $disabled />   <input type="text" size="60" name="comment" $disabled />
Line 6004  unless ($container eq 'page') { Line 6036  unless ($container eq 'page') {
         <legend>$lt{'upfi'}</legend>          <legend>$lt{'upfi'}</legend>
  <input type="hidden" name="active" value="ee" />   <input type="hidden" name="active" value="ee" />
  $fileupload   $fileupload
           <input type="file" name="uploaddoc" id="uploaddocsupp" class="LC_flUpload LC_uploaddoc" size="40" $disabled />
           <input type="hidden" id="LC_free_space_supp" value="$free_space" />
  <br />   <br />
  <br />   <br />
  <span class="LC_nobreak">   <span class="LC_nobreak">
Line 6016  unless ($container eq 'page') { Line 6050  unless ($container eq 'page') {
  $pathitem   $pathitem
  <input type="hidden" name="cmd" value="upload_supplemental" />   <input type="hidden" name="cmd" value="upload_supplemental" />
         <input type='submit' value="$lt{'upld'}" />          <input type='submit' value="$lt{'upld'}" />
           </fieldset>
         </form>          </form>
 SUPDOCFORM  SUPDOCFORM
   
Line 6584  sub editing_js { Line 6619  sub editing_js {
                 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://})) {
                         unless (&Apache::lonnet::uses_sts()) {                          unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
                             if ($hostname ne '') {                              if ($hostname ne '') {
                                 $backtourl = 'http://'.$hostname.$backtourl;                                  $backtourl = 'http://'.$hostname.$backtourl;
                             }                              }
Line 6593  sub editing_js { Line 6628  sub editing_js {
                     }                      }
                 } elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) {                  } elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) {
                     if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) {                      if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) {
                         unless (&Apache::lonnet::uses_sts()) {                          unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
                             if ($hostname ne '') {                              if ($hostname ne '') {
                                 $backtourl = 'http://'.$hostname.$backtourl;                                  $backtourl = 'http://'.$hostname.$backtourl;
                             }                              }

Removed from v.1.484.2.91  
changed lines
  Added in v.1.484.2.95


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