Diff for /loncom/interface/londocs.pm between versions 1.484.2.85.2.1 and 1.484.2.93.2.11

version 1.484.2.85.2.1, 2020/01/16 18:51:30 version 1.484.2.93.2.11, 2023/03/12 02:22:09
Line 86  sub storemap { Line 86  sub storemap {
   
     if ($map =~ /^default/) {      if ($map =~ /^default/) {
         $hadchanges=1;          $hadchanges=1;
     } else {      } elsif ($contentchg) {
         $suppchanges=1;          $suppchanges=1;
     }      }
     return ($errtext,0);      return ($errtext,0);
Line 178  sub default_folderpath { Line 178  sub default_folderpath {
     }      }
 }  }
   
   sub validate_supppath {
       my ($coursenum,$coursedom) = @_;
       my $backto;
       if ($env{'form.supppath'} ne '') {
           my @items = split(/\&/,$env{'form.supppath'});
           my ($badpath,$got_supp,$supppath,%supphidden,%suppids);
           for (my $i=0; $i<@items; $i++) {
               my $odd = $i%2;
               if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
                   $badpath = 1;
                   last;
               } elsif ($odd) {
                   my $suffix;
                   my $idx = $i-1;
                   if ($items[$i] =~ /^([^:]*)::(|1):::$/) {
                       $backto .= '&'.$1;
                   } elsif ($items[$idx] eq 'supplemental') {
                       $backto .= '&'.$items[$i];
                   } else {
                       $backto .= '&'.$items[$i];
                       my $is_hidden;
                       unless ($got_supp) {
                           my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
                           if (ref($supplemental) eq 'HASH') {
                               if (ref($supplemental->{'hidden'}) eq 'HASH') {
                                   %supphidden = %{$supplemental->{'hidden'}};
                               }
                               if (ref($supplemental->{'ids'}) eq 'HASH') {
                                   %suppids = %{$supplemental->{'ids'}};
                               }
                           }
                           $got_supp = 1;
                       }
                       if (ref($suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}) eq 'ARRAY') {
                           my $mapid = $suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}->[0];
                           if ($supphidden{$mapid}) {
                               $is_hidden = 1;
                           }
                       }
                       $suffix = '::'.$is_hidden.':::';
                   }
                   $supppath .= '&'.$items[$i].$suffix;
               } else {
                   $supppath .= '&'.$items[$i];
                   $backto .= '&'.$items[$i];
               }
           }
           if ($badpath) {
               delete($env{'form.supppath'});
           } else {
               $supppath =~ s/^\&//;
               $backto =~ s/^\&//;
               $env{'form.supppath'} = $supppath;
           }
       }
       return $backto;
   }
   
 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 715  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 726  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 754  sub group_import { Line 812  sub group_import {
                             if (@deleted) {                              if (@deleted) {
                                 &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);                                  &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
                             }                              }
                           } else {
                               return (&mt('Failed to save update to external tool.'),1);
                         }                          }
                     }                      }
                 }                  }
Line 783  sub group_import { Line 843  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 885  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 864  END Line 926  END
         &storemap($coursenum, $coursedom, $folder.'.'.$container,1);          &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
     unless ($fatal) {      unless ($fatal) {
         if ($folder =~ /^supplemental/) {          if ($folder =~ /^supplemental/) {
             &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);  
             my ($errtext,$fatal) = &mapread($coursenum,$coursedom,              my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
                                             $folder.'.'.$container);                                              $folder.'.'.$container);
         }          }
Line 1097  sub docs_change_log { Line 1158  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{/([^/]+)$});
               } elsif ($is_supp) {
                   $title = &Apache::loncommon::parse_supplemental_title($title);
               }
               $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 1166  sub update_paste_buffer { Line 1233  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 1181  sub update_paste_buffer { Line 1254  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 1194  sub update_paste_buffer { Line 1267  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 1391  sub print_paste_buffer { Line 1470  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 2661  sub apply_fixups { Line 2740  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 2943  sub update_parameter { Line 3031  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 3380  sub editor { Line 3468  sub editor {
         $r->print('</div>');          $r->print('</div>');
     }      }
   
       if ((!$allowed) && ($folder =~ /^supplemental_\d+$/)) {
           my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
           if (ref($supplemental) eq 'HASH') {
               if ((ref($supplemental->{'hidden'}) eq 'HASH') &&
                   (ref($supplemental->{'ids'}) eq 'HASH')) {
                   if (ref($supplemental->{'ids'}->{"/uploaded/$coursedom/$coursenum/$folder.$container"}) eq 'ARRAY') {
                       my $mapnum = $supplemental->{'ids'}->{"/uploaded/$coursedom/$coursenum/$folder.$container"}->[0];
                       if ($supplemental->{'hidden'}->{$mapnum}) {
                           $ishidden = 1;
                       }
                   }
               }
           }
       }
   
     my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);      my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
     %filters =  (      %filters =  (
                   canremove      => [],                    canremove      => [],
Line 3403  sub editor { Line 3506  sub editor {
             push(@allmapidx,$res);              push(@allmapidx,$res);
         }          }
   
           if (($supplementalflag) && (!$allowed) && (!$env{'request.role.adv'})) {
               if (($ishidden) || ((&LONCAPA::map::getparameter($res,'parameter_hiddenresource'))[0]=~/^yes$/i)) {
                   $idx++;
                   next;
               }
           }
         $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,          $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
                               $coursenum,$coursedom,$crstype,                                $coursenum,$coursedom,$crstype,
                               $pathitem,$supplementalflag,$container,                                $pathitem,$supplementalflag,$container,
                               \%filters,\%curr_groups,$ltitoolsref,$canedit,                                \%filters,\%curr_groups,$ltitoolsref,$canedit,
                               $isencrypted,$navmapref,$hostname);                                $isencrypted,$ishidden,$navmapref,$hostname);
         $idx++;          $idx++;
         $shown++;          $shown++;
     }      }
Line 3416  sub editor { Line 3525  sub editor {
     my $need_save;      my $need_save;
     if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {      if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {
         my $toolslink;          my $toolslink;
         if ($allowed) {          if ($allowed || $canedit) {
               my $helpitem = 'Navigation_Screen';
               if (!$allowed) {
                   $helpitem = 'Supplemental_Navigation';
               }
             $toolslink = '<table><tr><td>'              $toolslink = '<table><tr><td>'
                        .&Apache::loncommon::help_open_menu('Navigation Screen',                         .&Apache::loncommon::help_open_menu('Navigation Screen',
                                                            'Navigation_Screen',undef,'RAT')                                                             $helpitem,undef,'RAT')
                        .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'                         .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
                        .'<td align="left"><ul id="LC_toolbar">'                         .'<td align="left"><ul id="LC_toolbar">'
                        .'<li><a href="/adm/coursedocs?forcesupplement=1&amp;command=editsupp" '                         .'<li><a href="/adm/coursedocs?forcesupplement=1&amp;command=editsupp" '
Line 3435  sub editor { Line 3548  sub editor {
                           .&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="2">'.&mt('Actions').'</th>'
                           .'<th>'.&mt('Document').'</th>';                            .'<th>'.&mt('Document').'</th>'
                 if ($folder !~ /^supplemental/) {                            .'<th colspan="2">'.&mt('Settings').'</th>'
                     $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';                            .&Apache::loncommon::end_data_table_header_row();
                 }  
                 $to_show .= &Apache::loncommon::end_data_table_header_row();  
                 if ($folder !~ /^supplemental/) {                  if ($folder !~ /^supplemental/) {
                     $lists{'canhide'} = join(',',@allidx);                      $lists{'canhide'} = join(',',@allidx);
                     $lists{'canrandomlyorder'} = join(',',@allmapidx);                      $lists{'canrandomlyorder'} = join(',',@allmapidx);
Line 3467  sub editor { Line 3578  sub editor {
                                 '</td>'.                                  '</td>'.
                                 '<td>&nbsp;</td>'.                                  '<td>&nbsp;</td>'.
                                 '<td>&nbsp;</td>'.                                  '<td>&nbsp;</td>'.
                                 '<td colspan="4">'.                                  '<td colspan="2">'.
                                 &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 3786  sub is_supplemental_title { Line 3897  sub is_supplemental_title {
 sub entryline {  sub entryline {
     my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,      my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
         $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,          $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
         $ltitoolsref,$canedit,$isencrypted,$navmapref,$hostname)=@_;          $ltitoolsref,$canedit,$isencrypted,$ishidden,$navmapref,$hostname)=@_;
     my ($foldertitle,$renametitle,$oldtitle);      my ($foldertitle,$renametitle,$oldtitle,$encodedtitle);
     if (&is_supplemental_title($title)) {      if (&is_supplemental_title($title)) {
  ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);   ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
           $encodedtitle=$title;
     } else {      } else {
  $title=&HTML::Entities::encode($title,'"<>&\'');   $title=&HTML::Entities::encode($title,'"<>&\'');
           $encodedtitle=$title;
  $renametitle=$title;   $renametitle=$title;
  $foldertitle=$title;   $foldertitle=$title;
     }      }
Line 3813  sub entryline { Line 3926  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 4013  END Line 4126  END
     my $ispage;      my $ispage;
     my $containerarg;      my $containerarg;
     my $folderurl;      my $folderurl;
       my $plainurl;
     if ($uploaded) {      if ($uploaded) {
         if (($extension eq 'sequence') || ($extension eq 'page')) {          if (($extension eq 'sequence') || ($extension eq 'page')) {
             $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;              $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
Line 4031  END Line 4145  END
                 $url='/adm/supplemental?';                  $url='/adm/supplemental?';
             }              }
  } else {   } else {
     &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);              $plainurl = $url;
  }   }
     }      }
   
     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 4056  END Line 4178  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 4067  END Line 4189  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)) {              my ($checkencrypt,$shownurl);
                 my $shownsymb = $symb;              if (!$env{'request.role.adv'}) {
                 if ($isexternal) {  
                     if ($url =~ /^([^#]+)#([^#]+)$/) {  
                         $url = $1;  
                         $anchor = $2;  
                         my $escan = &escape('#');  
                         $shownsymb =~ s/^([^\#]+)#([^\#]+)$/$1$escan$2/;  
                     }  
                 }  
                 unless ($env{'request.role.adv'}) {  
                     if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {  
                         $url = '';  
                     }  
                     if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {  
                         $url = '';  
                         $hiddenres = 1;  
                     }  
                 }  
                 if ($url ne '') {  
                     $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb);  
                 }  
             } elsif (!$env{'request.role.adv'}) {  
                 my $checkencrypt;  
                 if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||                  if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
                       $isencrypted || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {                      ($isencrypted) || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
                     $checkencrypt = 1;                      $checkencrypt = 1;
                 } elsif (ref($navmapref)) {                  } elsif (ref($navmapref)) {
                     unless (ref($$navmapref)) {                      unless (ref($$navmapref)) {
Line 4110  END Line 4210  END
                         }                          }
                     }                      }
                 }                  }
                 if ($checkencrypt) {              }
                     my $shownsymb = &Apache::lonenc::encrypted($symb);              if ($checkencrypt) {
                     my $shownurl = &Apache::lonenc::encrypted($url);                  my $currenc = $env{'request.enc'};
                     if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {                  $env{'request.enc'} = 1;
                         $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);                  $shownsymb = &Apache::lonenc::encrypted($symb);
                         if ($env{'request.enc'} ne '') {                  $shownurl = &Apache::lonenc::encrypted($url);
                             delete($env{'request.enc'});                  if (&Apache::lonnet::symbverify($symb,$url)) {
                         }                      $url = $shownurl;
                     } else {  
                         $url='';  
                     }  
                 } else {                  } else {
                     $url='';                      $url = '';
                 }                  }
             } else {                  $env{'request.enc'} = $currenc;
                 $url='';              } elsif (&Apache::lonnet::symbverify($symb,$url)) {
                   $shownsymb = $symb;
                   if ($isexternal) {
                       $url =~ s/\#[^#]+$//;
                       if ($container eq 'page') {
                           $url = &Apache::lonnet::clutter($url);
                       }
                   }
                   $shownurl = $url;
               }
               unless ($env{'request.role.adv'}) {
                   if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
                       $url = '';
                   }
                   if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
                       $url = '';
                       $hiddenres = 1;
                   }
               }
               if ($url ne '') {
                   $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
             }              }
  }   }
     } elsif ($supplementalflag) {      } elsif ($supplementalflag) {
Line 4134  END Line 4251  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 4146  END Line 4263  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 4154  END Line 4271  END
                 }                  }
                 $nomodal = 1;                  $nomodal = 1;
             }              }
           } elsif (($uploaded) && (!$allowed) && ($url ne '/adm/supplemental?')) {
               my $embstyle=&Apache::loncommon::fileembstyle($extension);
               unless ($embstyle eq 'ssi') {
                   if (($embstyle eq 'img')
                    || ($embstyle eq 'emb')
                    || ($embstyle eq 'wrp')) {
                       $url='/adm/wrapper'.$url;
                   } elsif ($url !~ /\.(sequence|page)$/) {
                       $url='/adm/coursedocs/showdoc'.$url;
                   }
               }
           }
           unless ($allowed && $env{'request.role.adv'}) {
               if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
                   $hiddenres = 1;
               }
         }          }
     }      }
     my ($rand_pick_text,$rand_order_text,$hiddenfolder);      my ($rand_pick_text,$rand_order_text,$hiddenfolder);
Line 4165  END Line 4298  END
         if (!$allowed && $supplementalflag) {          if (!$allowed && $supplementalflag) {
             $folderpath.=$containerarg.'&'.$foldername;              $folderpath.=$containerarg.'&'.$foldername;
             $url.='folderpath='.&escape($folderpath);              $url.='folderpath='.&escape($folderpath);
               if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
                   $hiddenfolder = 1;
               }
         } else {          } else {
             my $rpicknum = (&LONCAPA::map::getparameter($orderidx,              my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
                                                         'parameter_randompick'))[0];                                                          'parameter_randompick'))[0];
Line 4250  $form_end; Line 4386  $form_end;
         $url .= ($url =~ /\?/) ? '&amp;':'?';          $url .= ($url =~ /\?/) ? '&amp;':'?';
         $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');          $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
         if ($title) {          if ($title) {
             $url .= '&amp;title='.&HTML::Entities::encode($renametitle,'<>&"');              $url .= '&amp;title='.$encodedtitle;
         }          }
         if ((($isexternal) || ($isexttool)) && $orderidx) {          if ((($isexternal) || ($isexttool)) && $orderidx) {
             $url .= '&amp;idx='.$orderidx;              $url .= '&amp;idx='.$orderidx;
Line 4285  $form_end; Line 4421  $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 4305  $form_end; Line 4441  $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;
     my $link;      my ($link,$nolink);
     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>';          if ($allowed && !$env{'request.role.adv'} && !$isfolder && !$ispage) {
               if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
                   $nolink = 1;
               }
           }
           if ($nolink) {
               $line .= '<img src="'.$icon.'" alt="" class="LC_icon" /></a>';
           } else {
               $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
           }
     } elsif ($url) {      } elsif ($url) {
        if ($anchor ne '') {         if ($anchor ne '') {
            if ($supplementalflag) {             if ($supplementalflag) {
Line 4316  $form_end; Line 4461  $form_end;
                $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');                 $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
            }             }
        }         }
   
        if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) {         if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) {
            $link = 'http://'.$hostname.$url;             $link = 'http://'.$hostname.$url;
        } else {         } else {
            $link = $url;             $link = $url;
        }         }
        $link = &js_escape($link.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes'.$anchor);         $link = &js_escape($link.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes'.$anchor);
        if ($nomodal) {         if ($allowed && !$env{'request.role.adv'} && !$isfolder && !$ispage && !$uploaded) {
              if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
                  $nolink = 1;
              }
          }
          if ($nolink) {
              $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
          } elsif ($nomodal) {
            $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.             $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
                   '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';                    '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
        } else {         } else {
Line 4335  $form_end; Line 4486  $form_end;
     }      }
     $line.='</span></td><td'.$tdwidth.'>';      $line.='</span></td><td'.$tdwidth.'>';
     if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {      if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
        $line.='<a href="'.$url.'">'.$title.'</a>';         if ($nolink) {
              $line.=$title;
          } else {
              $line.='<a href="'.$url.'">'.$title.'</a>';
          }
          if (!$allowed && $supplementalflag && $canedit && $isfolder) {
              my $editicon = &Apache::loncommon::lonhttpdurl('/res/adm/pages').'/editmap.png';
              my $editurl = $url;
              $editurl =~ s{^\Q/adm/supplemental?\E}{/adm/coursedocs?command=direct&amp;forcesupplement=1&amp;};
              $line .= '&nbsp;'.'<a href="'.$editurl.'">'.
                       '<img src="'.$editicon.'" alt="'.&mt('Edit Content').'" title="'.&mt('Edit Content').'" />'.
                       '</a>';
          }
          if ((($hiddenfolder) || ($hiddenres)) && (!$allowed) && ($supplementalflag))  {
              $line.= ' <span class="LC_warning">('.&mt('hidden').')</span> ';
          }
     } elsif ($url) {      } elsif ($url) {
        if ($nomodal) {         if ($nolink) {
              $line.=$title;
          } elsif ($nomodal) {
            $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.             $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
                   $title.'</a>';                    $title.'</a>';
        } else {         } else {
Line 4351  $form_end; Line 4519  $form_end;
     $line.="$extresform</td>";      $line.="$extresform</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 ($uploaded && $url && !$isfolder && !$ispage) {
   my %lt=&Apache::lonlocal::texthash(          if (($plainurl ne '') && ($env{'request.role.adv'} || $allowed || !$hiddenres)) {
        'hd' => 'Hidden',              &Apache::lonnet::allowuploaded('/adm/coursedoc',$plainurl);
        'ec' => 'URL hidden');  
         my ($enctext,$hidtext);  
         if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {  
             $enctext = ' checked="checked"';  
             if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {  
                 push(@{$filtersref->{'encrypturl'}},$orderidx);  
             }  
         }          }
       }
       if ($allowed) {
           my %lt=&Apache::lonlocal::texthash(
                                 'hd' => 'Hidden',
                                 'ec' => 'URL hidden');
           my ($enctext,$hidtext,$formhidden,$formurlhidden);
         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);
             }              }
         }          }
         my $formhidden = 'edit_hiddenresource_'.$orderidx;          $formhidden = 'edit_hiddenresource_'.$orderidx;
         my $formurlhidden = 'edit_encrypturl_'.$orderidx;          $line.=(<<ENDPARMS);
  $line.=(<<ENDPARMS);  
   <td class="LC_docs_entry_parameter">    <td class="LC_docs_entry_parameter">
     <form action="/adm/coursedocs" method="post" name="$formhidden">      <form action="/adm/coursedocs" method="post" name="$formhidden">
     $form_param      $form_param
     $form_common      $form_common
     <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>      <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
     $form_end      $form_end
   ENDPARMS
           if ($folder =~/^supplemental/) {
               $line.= "\n    <td>";
           } else {
               if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
                   $enctext = ' checked="checked"';
                   if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
                       push(@{$filtersref->{'encrypturl'}},$orderidx);
                   }
               }
               $formurlhidden = 'edit_encrypturl_'.$orderidx;
       $line.=(<<ENDPARMS);
     <br />      <br />
     <form action="/adm/coursedocs" method="post" name="$formurlhidden">      <form action="/adm/coursedocs" method="post" name="$formurlhidden">
     $form_param      $form_param
Line 4387  $form_end; Line 4565  $form_end;
   <td class="LC_docs_entry_parameter">$rand_pick_text<br />    <td class="LC_docs_entry_parameter">$rand_pick_text<br />
                                       $rand_order_text</td>                                        $rand_order_text</td>
 ENDPARMS  ENDPARMS
           }
     }      }
     $line.=&Apache::loncommon::end_data_table_row();      $line.=&Apache::loncommon::end_data_table_row();
     return $line;      return $line;
Line 4720  sub short_urls { Line 4899  sub short_urls {
         $r->rflush();          $r->rflush();
         my $readonly;          my $readonly;
         if ($canedit) {          if ($canedit) {
             my ($numnew,$errors) = &Apache::loncommon::make_short_symbs($cdom,$cnum,$navmap);              my ($numnew,$errors) = &Apache::loncommon::get_requested_shorturls($cdom,$cnum,$navmap);
             if ($numnew) {              if ($numnew) {
                 $r->print('<p class="LC_info">'.&mt('Created [quant,_1,URL]',$numnew).'</p>');                  $r->print('<p class="LC_info">'.&mt('Created [quant,_1,URL]',$numnew).'</p>');
             }              }
Line 4755  sub contentverifyform { Line 4934  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 5214  sub handler { Line 5393  sub handler {
 #  #
 # --------------------------------------------- Initialize help topics for this  # --------------------------------------------- Initialize help topics for this
     foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',      foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
                        'Adding_External_Resource','Adding_External_Tool',                 'Adding_External_Resource','Adding_External_Tool',
                        'Navigate_Content','Adding_Folders','Docs_Overview',                         'Navigate_Content','Adding_Folders','Docs_Overview',
                        'Load_Map','Supplemental','Score_Upload_Form',                 'Load_Map','Supplemental','Score_Upload_Form', 
                        'Adding_Pages','Importing_LON-CAPA_Resource',                 'Adding_Pages','Importing_LON-CAPA_Resource',
                        'Importing_IMS_Course','Uploading_From_Harddrive',                 'Importing_IMS_Course','Uploading_From_Harddrive',
                        'Course_Roster','Web_Page','Dropbox','Simple_Problem') {                         'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
  $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);   $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
     }      }
Line 5235  sub handler { Line 5414  sub handler {
     $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');      $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
     
     my ($allowed,$canedit,$canview,$disabled);      my ($allowed,$canedit,$canview,$disabled);
   # does this user have privileges to modify content.
       if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
 # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.  # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
     unless ($r->uri eq '/adm/supplemental') {          unless ($r->uri eq '/adm/supplemental') {
         # does this user have privileges to modify content.    
         if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {  
             $allowed = 1;              $allowed = 1;
             $canedit = 1;          }
             $canview = 1;          $canedit = 1;
         } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {          $canview = 1;
       } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
   # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
           unless ($r->uri eq '/adm/supplemental') {
             $allowed = 1;              $allowed = 1;
             $canview = 1;  
         }          }
           $canview = 1;
     }      }
     unless ($canedit) {      unless ($canedit) {
         $disabled = ' disabled="disabled"';          $disabled = ' disabled="disabled"';
Line 5299  sub handler { Line 5481  sub handler {
 # Get the parameters that may be needed  # Get the parameters that may be needed
 #  #
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['folderpath',                                              ['folderpath','title',
                                              'forcesupplement','forcestandard',                                               'forcesupplement','forcestandard',
                                              'tools','symb','command','supppath']);                                               'tools','symb','command','supppath']);
   
Line 5346  sub handler { Line 5528  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'});          &Apache::loncommon::validate_folderpath($supplementalflag,$allowed,$coursenum,$coursedom);
         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'});  
         }  
     }      }
   
       my $backto_supppath;
     if ($env{'form.supppath'} ne '') {      if ($env{'form.supppath'} ne '') {
         my @items = split(/\&/,$env{'form.supppath'});          if ($supplementalflag && $allowed) {
         my $badpath;              $backto_supppath = &validate_supppath($coursenum,$coursedom);
         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'});  
         }          }
     }      }
   
Line 5395  sub handler { Line 5556  sub handler {
                &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);                 &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
            &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>             &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
                $env{'form.command'}.'_'.$env{'form.symb'}});                 $env{'form.command'}.'_'.$env{'form.symb'}});
        } elsif ($env{'form.supppath'} ne '') {         } elsif (($env{'form.supppath'} ne '') && $supplementalflag && $allowed) {
            $env{'form.folderpath'}=$env{'form.supppath'};             $env{'form.folderpath'}=$env{'form.supppath'};
            &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>             &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
                $env{'form.command'}.'_'.$env{'form.supppath'}});                 $env{'form.command'}.'_'.$backto_supppath});
        }         }
    } elsif ($env{'form.command'} eq 'editdocs') {     } elsif ($env{'form.command'} eq 'editdocs') {
        $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);         $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
Line 5433  sub handler { Line 5594  sub handler {
         } else {          } else {
             undef($env{'form.folderpath'});              undef($env{'form.folderpath'});
         }          }
           if ($env{'form.folderpath'} ne '') {
               &Apache::loncommon::validate_folderpath($supplementalflag,$allowed,$coursenum,$coursedom);
           }
     }      }
         
 # 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 5448  sub handler { Line 5612  sub handler {
                                   $env{'form.folderpath'};                                    $env{'form.folderpath'};
     }      }
 # If allowed and user's role is not advanced check folderpath is not hidden  # If allowed and user's role is not advanced check folderpath is not hidden
     if (($allowed) && (!$env{'request.role.adv'}) &&      my $hidden_and_empty;
         ($env{'form.folderpath'} ne '') && (!$supplementalflag)) {      if (($allowed) && (!$env{'request.role.adv'}) && ($env{'form.folderpath'} ne '')) {
         my $folderurl;          my ($folderurl,$foldername,$hiddenfolder);
         my @pathitems = split(/\&/,$env{'form.folderpath'});          my @pathitems = split(/\&/,$env{'form.folderpath'});
         my $folder = $pathitems[-2];          my $folder = $pathitems[-2];
         if ($folder eq '') {          if ($folder eq '') {
             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';
             }              }
             unless (ref($navmap)) {              if ($supplementalflag) {
                 $navmap = Apache::lonnavmaps::navmap->new();                  ($foldername,$hiddenfolder) = ($pathitems[-1] =~ /^([^:]*)::(|1):::$/);
             }                  $foldername = &HTML::Entities::decode(&unescape($foldername));
             if (ref($navmap)) {                  my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
                 if (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {                  if (ref($supplemental) eq 'HASH') {
                     my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);                      my ($suppmap,$suppmapnum);
                     unless (@resources) {                      if ($folder eq 'supplemental') {
                         undef($env{'form.folderpath'});                          $suppmap = 'default';
                           $suppmapnum = 0;
                       } elsif ($folder =~ /^supplemental_(\d+)$/) {
                           $suppmap = $1;
                           $suppmapnum = $suppmap;
                       }
                       if ($hiddenfolder) {
                           my $hascontent;
                           foreach my $key (reverse(sort(keys(%{$supplemental->{'ids'}})))) {
                               if ($key =~ m{^\Q/uploaded/$coursedom/$coursenum/supplemental/$suppmap/\E}) {
                                   $hascontent = 1;
                               } elsif (ref($supplemental->{'ids'}->{$key}) eq 'ARRAY') {
                                   foreach my $id (@{$supplemental->{'ids'}->{$key}}) {
                                       if ($id =~ /^$suppmapnum\:/) {
                                           $hascontent = 1;
                                           last;
                                       }
                                   }
                               }
                               last if ($hascontent);
                           }
                           unless ($hascontent) {
                               if ($foldername ne '') {
                                   $hidden_and_empty = $foldername;
                               } else {
                                   $hidden_and_empty = $folder;
                               }
                           }
                       }
                   }
               } else {
                   unless (ref($navmap)) {
                       $navmap = Apache::lonnavmaps::navmap->new();
                   }
                   ($foldername,$hiddenfolder) = ($pathitems[-1] =~ /^([^:]*):|\d+:|1:(|1):|1:|1$/);
                   $foldername = &HTML::Entities::decode(&unescape($foldername));
                   if (ref($navmap)) {
                       if ($hiddenfolder ||
                           (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes')) {
                           my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
                           unless (@resources) {
                               if ($foldername ne '') {
                                   $hidden_and_empty = $foldername;
                               } else {
                                   $hidden_and_empty = $folder;
                               }
                           }
                     }                      }
                 }                  }
             }              }
               if ($hidden_and_empty ne '') {
                   splice(@pathitems,-2);
                   if (@pathitems) {
                       $env{'form.folderpath'} = join('&',@pathitems);
                   } else {
                       undef($env{'form.folderpath'});
                   }
               }
         }          }
     }      }
   
   
 # If after all of this, we still don't have any paths, make them  # If after all of this, we still don't have any paths, make them
     unless ($env{'form.folderpath'}) {      unless ($env{'form.folderpath'}) {
        if ($supplementalflag) {         if ($supplementalflag) {
Line 5561  sub handler { Line 5778  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 5570  sub handler { Line 5787  sub handler {
                        &inject_data_js().                         &inject_data_js().
                        &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).                         &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
                        &Apache::lonextresedit::extedit_javascript(\%ltitools);                         &Apache::lonextresedit::extedit_javascript(\%ltitools);
               my $onload = "javascript:resize_scrollbox('contentscroll','1','1');";
               if ($hidden_and_empty ne '') {
                   my $alert = &mt("Additional privileges required to edit empty and hidden folder: '[_1]'",
                                   $hidden_and_empty);
                   $onload .= "javascript:alert('".&js_escape($alert)."');";
               }
             $addentries = {              $addentries = {
                             onload   => "javascript:resize_scrollbox('contentscroll','1','1');",                              onload => $onload,
                           };                            };
         }          }
         $script .= &paste_popup_js();           $script .= &paste_popup_js(); 
Line 5592  sub handler { Line 5815  sub handler {
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
   
     if ($showdoc) {      if ($showdoc) {
         $r->print(&Apache::loncommon::start_page("$crstype documents",undef,          my $args;
                                                 {'force_register' => $showdoc,}));          if ($supplementalflag) {
               my $title = &HTML::Entities::encode($env{'form.title'},'\'"<>&');
               my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
               $args = {'bread_crumbs' => $brcrum};
           } else {
               $args = {'force_register' => $showdoc};
           }
           $r->print(&Apache::loncommon::start_page("$crstype documents",undef,$args));
     } elsif ($toolsflag) {      } elsif ($toolsflag) {
         my ($breadtext,$breadtitle);          my ($breadtext,$breadtitle);
         $breadtext = "$crstype Editor";          $breadtext = "$crstype Editor";
Line 5611  sub handler { Line 5841  sub handler {
                      $breadtitle)                       $breadtitle)
                  );                   );
     } elsif ($r->uri eq '/adm/supplemental') {      } elsif ($r->uri eq '/adm/supplemental') {
           unless ($env{'request.role.adv'}) {
               unless (&Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom)) {
                   $r->internal_redirect('/adm/navmaps');
                   return OK;
               }
           }
         my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);          my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
         $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,          $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
                                                 {'bread_crumbs' => $brcrum,}));                                                  {'bread_crumbs' => $brcrum,}));
Line 5641  sub handler { Line 5877  sub handler {
   my %codebase = ();    my %codebase = ();
   my ($upload_result,$upload_output,$uploadphase);    my ($upload_result,$upload_output,$uploadphase);
   if ($canedit) {    if ($canedit) {
         undef($suppchanges);
       if (($env{'form.uploaddoc.filename'}) &&        if (($env{'form.uploaddoc.filename'}) &&
   ($env{'form.cmd'}=~/^upload_(\w+)/)) {    ($env{'form.cmd'}=~/^upload_(\w+)/)) {
           my $context = $1;             my $context = $1; 
Line 5652  sub handler { Line 5889  sub handler {
   if ($hadchanges) {    if ($hadchanges) {
       &mark_hash_old();        &mark_hash_old();
   }    }
             if ($suppchanges) {
                 &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
                 undef($suppchanges);
             }
           $r->print($upload_output);            $r->print($upload_output);
       } elsif ($env{'form.phase'} eq 'upload_embedded') {        } elsif ($env{'form.phase'} eq 'upload_embedded') {
           # Process file upload - phase two - upload embedded objects             # Process file upload - phase two - upload embedded objects 
Line 5706  sub handler { Line 5947  sub handler {
  'lnks' => 'Import from Stored Links',   'lnks' => 'Import from Stored Links',
                 'impm' => 'Import from Assembled Map',                  'impm' => 'Import from Assembled Map',
                 'extr' => 'External Resource',                  'extr' => 'External Resource',
                 'extt' => 'External Tool',                   'extt' => 'External Tool',
                 'selm' => 'Select Map',                  'selm' => 'Select Map',
                 'load' => 'Load Map',                  'load' => 'Load Map',
                 'newf' => 'New Folder',                  'newf' => 'New Folder',
Line 5927  HIDDENFORM Line 6168  HIDDENFORM
 #  #
   
     my $savefolderpath;      my $savefolderpath;
       my $hostname = $r->hostname();
   
     if ($allowed) {      if ($allowed) {
        my $folder=$env{'form.folder'};         my $folder=$env{'form.folder'};
Line 6118  NSYLFORM Line 6360  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 6167  my %orderhash = ( Line 6415  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 6199  unless ($container eq 'page') { Line 6447  unless ($container eq 'page') {
        unless ($supplementalflag) {         unless ($supplementalflag) {
    $folder='supplemental';     $folder='supplemental';
        }         }
        if ($folder =~ /^supplemental$/ &&         if (($folder eq 'supplemental') &&
    (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {     (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
           $env{'form.folderpath'} = &supplemental_base();            $env{'form.folderpath'} = &supplemental_base();
        } elsif ($allowed) {         } elsif ($allowed) {
Line 6325  my %suporderhash = ( Line 6573  my %suporderhash = (
                 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]                  'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
                 );                  );
         if ($supplementalflag) {          if ($supplementalflag) {
            my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,              $suppchanges = 0;
                                $supplementalflag,\%suporderhash,$iconpath,$pathitem,              my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
                                \%ltitools,$canedit,$hostname);                                  $supplementalflag,\%suporderhash,$iconpath,$pathitem,
            if ($error) {                                  \%ltitools,$canedit,$hostname);
               $r->print('<p><span class="LC_error">'.$error.'</span></p>');              if ($error) {
            } else {                  $r->print('<p><span class="LC_error">'.$error.'</span></p>');
                if ($suppchanges) {              }
                    my %servers = &Apache::lonnet::internet_dom_servers($coursedom);              if ($suppchanges) {
                    my @ids=&Apache::lonnet::current_machine_ids();                  &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
                    foreach my $server (keys(%servers)) {                  undef($suppchanges);
                        next if (grep(/^\Q$server\E$/,@ids));              }
                        my $hashid=$coursenum.':'.$coursedom;  
                        my $cachekey = &escape('suppcount').':'.&escape($hashid);  
                        &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);  
                    }  
                    &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);  
                    undef($suppchanges);  
                }  
            }  
         }          }
     } elsif ($supplementalflag) {      } elsif ($supplementalflag) {
         my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,          my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
                             $supplementalflag,'',$iconpath,$pathitem,'',$hostname);                              $supplementalflag,'',$iconpath,$pathitem,'',$canedit,
                               $hostname);
         if ($error) {          if ($error) {
             $r->print('<p><span class="LC_error">'.$error.'</span></p>');              $r->print('<p><span class="LC_error">'.$error.'</span></p>');
         }          }
Line 6509  sub remove_archive { Line 6750  sub remove_archive {
             if ($url eq $env{'form.archiveurl'}) {              if ($url eq $env{'form.archiveurl'}) {
                 if (&handle_edit_cmd($docuname,$docudom)) {                  if (&handle_edit_cmd($docuname,$docudom)) {
                     ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);                      ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
                       if ($suppchanges) {
                           &Apache::lonnet::update_supp_caches($docudom,$docuname);
                           undef($suppchanges);
                       }
                     if ($fatal) {                      if ($fatal) {
                         if ($container eq 'page') {                          if ($container eq 'page') {
                             $delwarning = &mt('An error occurred updating the contents of the current page.');                              $delwarning = &mt('An error occurred updating the contents of the current page.');
Line 6818  sub editing_js { Line 7063  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 6827  sub editing_js { Line 7072  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;
                             }                              }
Line 6846  sub editing_js { Line 7091  sub editing_js {
     } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {      } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
         $backtourl = '/adm/menu';          $backtourl = '/adm/menu';
     } elsif ($supplementalflag) {      } elsif ($supplementalflag) {
         $backtourl = '/adm/supplemental';          if (($env{'request.role.adv'}) ||
               (&Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom))) {
               $backtourl = '/adm/supplemental';
           } else {
               $backtourl = '/adm/navmaps';
           }
     } else {      } else {
         $backtourl = '/adm/navmaps';          $backtourl = '/adm/navmaps';
     }      }
Line 6871  sub editing_js { Line 7121  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 6879  function makenewfolder(targetform,folder Line 7129  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 6888  function makeexamupload() { Line 7138  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 6897  function makesmppage() { Line 7147  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 6912  function makewebpage(type) { Line 7162  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 6921  function makesmpproblem() { Line 7171  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 6930  function makedropbox() { Line 7180  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 6939  function makebulboard() { Line 7189  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.1  
changed lines
  Added in v.1.484.2.93.2.11


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