Diff for /loncom/interface/londocs.pm between versions 1.617 and 1.629

version 1.617, 2016/11/29 03:01:04 version 1.629, 2017/05/10 20:32:27
Line 654  sub group_import { Line 654  sub group_import {
             }              }
         }          }
  if ($url) {   if ($url) {
             if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/exttool)s?\:?(.*)$}) {              if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/ext\.tool)\:?(.*)$}) {
                 $url = $1;                  $url = $1;
                 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 @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 669  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{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;                   $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;
                 $toolhash{'crslabel'} = &unescape($toolhash{'crslabel'});                  foreach my $item (@extras) {
                 $toolhash{'crstitle'} = &unescape($toolhash{'crstitle'});                      $toolhash{$item} = &unescape($toolhash{$item});
                   }
                 if (ref($ltitoolsref) eq 'HASH') {                  if (ref($ltitoolsref) eq 'HASH') {
                     my @deleted;                      my @deleted;
                     if (ref($ltitoolsref->{$toolid}) eq 'HASH') {                      if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
                         if ($ltitoolsref->{$toolid}->{'url'} =~ m{^https://}) {  
                             $url =~ s/exttool$/exttools/;  
                         }  
                         $toolhash{'id'} = $toolid;                          $toolhash{'id'} = $toolid;
                         if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'window')) {                          if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
                               ($toolhash{'target'} eq 'window')) {
                             if ($toolhash{'target'} eq 'window') {                              if ($toolhash{'target'} eq 'window') {
                                 foreach my $item ('width','height') {                                  foreach my $item ('width','height') {
                                     $toolhash{$item} =~ s/^\s+//;                                      $toolhash{$item} =~ s/^\s+//;
                                     $toolhash{$item} =~ s/\s+$//;                                      $toolhash{$item} =~ s/\s+$//;
                                       if ($toolhash{$item} =~ /\D/) {
                                           delete($toolhash{$item});
                                           if ($residx) {
                                               if ($toolsettings{$item}) {
                                                   push(@deleted,$item);
                                               }
                                           }
                                       }
                                 }                                  }
                             }                              }
                         } elsif ($residx) {                          } elsif ($residx) {
                             $toolhash{'target'} = $toolsettings{'target'};                              $toolhash{'target'} = $toolsettings{'target'};
                             if ($toolhash{'target'} eq 'window') {                              if ($toolhash{'target'} eq 'window') {
                                 $toolhash{'width'} = $toolsettings{'width'};                                  foreach my $item ('width','height') { 
                                 $toolhash{'height'} = $toolsettings{'height'};                                        $toolhash{$item} = $toolsettings{$item};
                                   }
                             }                              }
                         } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {                          } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {
                             $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};                              $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};
Line 699  sub group_import { Line 709  sub group_import {
                             }                              }
                         }                          }
                         if ($toolhash{'target'} eq 'iframe') {                          if ($toolhash{'target'} eq 'iframe') {
                             delete($toolhash{'width'});                              foreach my $item ('width','height','linktext','explanation') {
                             delete($toolhash{'height'});                                  delete($toolhash{$item});
                             if ($residx) {                                  if ($residx) {
                                 if ($toolsettings{'width'}) {                                      if ($toolsettings{$item}) {
                                     push(@deleted,'width');                                          push(@deleted,$item);
                                       }
                                 }                                  }
                                 if ($toolsettings{'height'}) {                              }
                                     push(@deleted,'height');                          } elsif ($toolhash{'target'} eq 'tab') {
                               foreach my $item ('width','height') {
                                   delete($toolhash{$item});
                                   if ($residx) {
                                       if ($toolsettings{$item}) {
                                           push(@deleted,$item);
                                       }
                                 }                                  }
                             }                              }
                         }                          }
                         if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {                          if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
                             foreach my $item ('label','title') {                               foreach my $item ('label','title','linktext','explanation') {
                                   my $crsitem;
                                   if (($item eq 'label') || ($item eq 'title')) {
                                       $crsitem = 'crs'.$item;
                                   } else {
                                       $crsitem = $item;
                                   }
                                 if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {                                  if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {
                                     $toolhash{'crs'.$item} =~ s/^\s+//;                                      $toolhash{$crsitem} =~ s/^\s+//;
                                     $toolhash{'crs'.$item} =~ s/\s+$//;                                      $toolhash{$crsitem} =~ s/\s+$//;
                                     if ($toolhash{'crs'.$item} eq '') {                                      if ($toolhash{$crsitem} eq '') {
                                         delete($toolhash{'crs'.$item});                                          delete($toolhash{$crsitem});
                                     }                                      }
                                 } else {                                  } else {
                                     delete($toolhash{'crs'.$item});                                      delete($toolhash{$crsitem});
                                 }                                  }
                                 if (($residx) && (exists($toolsettings{'crs'.$item}))) {                                  if (($residx) && (exists($toolsettings{$crsitem}))) {
                                     unless (exists($toolhash{'crs'.$item})) {                                      unless (exists($toolhash{$crsitem})) {
                                         push(@deleted,'crs'.$item);                                          push(@deleted,$crsitem);
                                     }                                      }
                                 }                                  }
                             }                              }
Line 748  sub group_import { Line 771  sub group_import {
                     $donechk = 1;                      $donechk = 1;
                 }                  }
                 if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {                  if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
                     &contained_map_check($url,$folder,\%removefrommap,\%removeparam,                      &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
                                          \%addedmaps,\%hierarchy,\%titles,$allmaps);                                          \%removeparam,\%addedmaps,\%hierarchy,\%titles,$allmaps);
                     $importuploaded = 1;                      $importuploaded = 1;
                 } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {                  } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
                     next if ($allmaps->{$url});                      next if ($allmaps->{$url});
Line 920  sub docs_change_log { Line 943  sub docs_change_log {
              '// <![CDATA['."\n".               '// <![CDATA['."\n".
              &Apache::loncommon::display_filter_js('docslog')."\n".               &Apache::loncommon::display_filter_js('docslog')."\n".
              &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag,               &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag,
                          $coursedom,$coursenum,'','',$canedit,\$navmap)."\n".                           $coursedom,$coursenum,'','',$canedit,'',\$navmap)."\n".
              &history_tab_js()."\n".               &history_tab_js()."\n".
              &Apache::lonratedt::editscript('simple')."\n".               &Apache::lonratedt::editscript('simple')."\n".
              '// ]]>'."\n".               '// ]]>'."\n".
Line 1200  sub update_paste_buffer { Line 1223  sub update_paste_buffer {
                 $subdir = $prefix;                  $subdir = $prefix;
             }              }
             my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);              my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
             &contained_map_check($url,$folder,\%removefrommap,\%removeparam,\%addedmaps,              &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
                                  \%hierarchy,\%titles,\%allmaps);                                   \%removeparam,\%addedmaps,\%hierarchy,\%titles,\%allmaps);
             if (ref($hierarchy{$url}) eq 'HASH') {              if (ref($hierarchy{$url}) eq 'HASH') {
                 my ($nested,$nestednames);                  my ($nested,$nestednames);
                 &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);                  &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
Line 1279  sub print_paste_buffer { Line 1302  sub print_paste_buffer {
             my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];              my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
             if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?:&colon;|:))//} ) {              if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?:&colon;|:))//} ) {
                 $is_external = 1;                  $is_external = 1;
             } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/exttools?$}) {              } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
                 $is_exttool = 1;                  $is_exttool = 1;
             }              }
             if ($folder =~ /^supplemental/) {              if ($folder =~ /^supplemental/) {
Line 1313  sub print_paste_buffer { Line 1336  sub print_paste_buffer {
                         $is_uploaded_map = 1;                          $is_uploaded_map = 1;
                     }                      }
                 } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||                  } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
                          ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg)$})) {                           ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$})) {
                     if ($cid ne $env{'request.course.id'}) {                      if ($cid ne $env{'request.course.id'}) {
                         my ($srcdom,$srcnum) = split(/_/,$cid);                          my ($srcdom,$srcnum) = split(/_/,$cid);
                         if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {                          if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
                             $othercrs = '<br />'.&mt('(from another course)');                              if (($is_exttool) && ($srcdom ne $coursedom)) {
                                   $canpaste = 0;
                                   $nopaste = &mt('Paste from another domain unavailable.');
                               } else {
                                   $othercrs = '<br />'.&mt('(from another course)');
                               }
                         } else {                          } else {
                             $canpaste = 0;                              $canpaste = 0;
                             $nopaste = &mt('Paste from another course unavailable.');                              $nopaste = &mt('Paste from another course unavailable.');
                         }                                 }
                     }                      }
                 }                  }
                 if ($canpaste) {                  if ($canpaste) {
                     push(@pasteable,$suffix);                      push(@pasteable,$suffix);
                 }                    }
             }              }
             my $buffer;              my $buffer;
             if (($is_external) || ($is_exttool)) {              if ($is_external) {
                 $buffer = &mt('External Resource').': '.                  $buffer = &mt('External Resource').': '.
                     &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.                      &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
                     &LONCAPA::map::qtescape($url).')';                      &LONCAPA::map::qtescape($url).')';
               } elsif ($is_exttool) {
                   $buffer = &mt('External Tool').': '.
                       &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
             } else {              } else {
                 my $icon = &Apache::loncommon::icon($extension);                  my $icon = &Apache::loncommon::icon($extension);
                 if ($extension eq 'sequence' &&                  if ($extension eq 'sequence' &&
Line 1490  sub supp_pasteable { Line 1521  sub supp_pasteable {
         ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||          ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
         ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||          ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
         ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||          ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
         ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/exttools?$})) {          ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
         return 1;          return 1;
     }      }
     return;      return;
Line 1612  sub do_paste_from_buffer { Line 1643  sub do_paste_from_buffer {
         return();          return();
     }      }
   
     my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%duplicate,      my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%notindom,%duplicate,
         %prefixchg,%srcdom,%srcnum,%srcmapidx,%marktomove,$save_err,$lockerrors,$allresult);          %prefixchg,%srcdom,%srcnum,%srcmapidx,%marktomove,$save_err,$lockerrors,$allresult);
   
     foreach my $suffix (@topaste) {      foreach my $suffix (@topaste) {
Line 1641  sub do_paste_from_buffer { Line 1672  sub do_paste_from_buffer {
             $srcdom{$suffix} = $srcd;              $srcdom{$suffix} = $srcd;
             $srcnum{$suffix} = $srcn;              $srcnum{$suffix} = $srcn;
         } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||          } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
                  ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$})) {                   ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg|ext\.tool)$})) {
               my $srctype= $1;
             my ($srcd,$srcn) = split(/_/,$cid);              my ($srcd,$srcn) = split(/_/,$cid);
 # When paste buffer was populated using an active role in a different course  # When paste buffer was populated using an active role in a different course
 # check for mdc privilege in the course from which the resource was pasted  # check for mdc privilege in the course from which the resource was pasted
Line 1651  sub do_paste_from_buffer { Line 1683  sub do_paste_from_buffer {
                     next;                      next;
                 }                  }
             }              }
               if (($srctype eq 'ext.tool') && ($srcd ne $coursedom)) {
                   $notindom{$suffix} = 1;
                   next;
               }
             $srcdom{$suffix} = $srcd;              $srcdom{$suffix} = $srcd;
             $srcnum{$suffix} = $srcn;              $srcnum{$suffix} = $srcn;
         }          }
Line 1659  sub do_paste_from_buffer { Line 1695  sub do_paste_from_buffer {
         if ($url=~/\.(page|sequence)$/) {          if ($url=~/\.(page|sequence)$/) {
             $is_map{$suffix} = 1;               $is_map{$suffix} = 1; 
         }          }
   
         if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {          if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
             my $oldprefix = $1;              my $oldprefix = $1;
 # When pasting content from Main Content to Supplemental Content and vice versa   # When pasting content from Main Content to Supplemental Content and vice versa 
Line 1704  sub do_paste_from_buffer { Line 1739  sub do_paste_from_buffer {
     %msgs = &Apache::lonlocal::texthash (      %msgs = &Apache::lonlocal::texthash (
                 notinsupp => 'Paste failed: content type is not supported within Supplemental Content',                  notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
                 notincrs  => 'Paste failed: Item is from a different course which you do not have rights to edit.',                  notincrs  => 'Paste failed: Item is from a different course which you do not have rights to edit.',
                   notindom  => 'Paste failed: Item is an external tool from a course in a different donain.', 
                 duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',                  duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
             );              );
   
Line 1757  sub do_paste_from_buffer { Line 1793  sub do_paste_from_buffer {
         if ($is_map{$suffix}) {          if ($is_map{$suffix}) {
 # If pasting a map, check if map contains other maps  # If pasting a map, check if map contains other maps
             my (%hierarchy,%titles);              my (%hierarchy,%titles);
             &contained_map_check($url,$folder,\%removefrommap,\%removeparam,              &contained_map_check($url,$folder,$coursenum,$coursedom,
                                  \%addedmaps,\%hierarchy,\%titles,$allmaps);                                   \%removefrommap,\%removeparam,\%addedmaps,
                                    \%hierarchy,\%titles,$allmaps);
             if ($url=~ m{^/uploaded/}) {              if ($url=~ m{^/uploaded/}) {
                 my $newurl;                  my $newurl;
                 unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {                  unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
Line 1811  sub do_paste_from_buffer { Line 1848  sub do_paste_from_buffer {
                 }                  }
             }              }
         }          }
         if ($url=~ m{/(bulletinboard|smppg)$}) {          if ($url=~ m{/(bulletinboard|smppg|ext\.tool)$}) {
             my $prefix = $1;              my $prefix = $1;
             my $fromothercrs;               my $fromothercrs; 
             #need to copy the db contents to a new one, unless this is a move.              #need to copy the db contents to a new one, unless this is a move.
Line 1839  sub do_paste_from_buffer { Line 1876  sub do_paste_from_buffer {
                         $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;                          $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
                     } elsif ($prefix eq 'bulletinboard') {                      } elsif ($prefix eq 'bulletinboard') {
                         $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext;                          $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext;
                       } elsif ($prefix eq 'ext.tool') {
                           $msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext;
                     }                      }
                     $results{$suffix} = $result;                      $results{$suffix} = $result;
                     $msgerrs{$suffix} = $msg;                      $msgerrs{$suffix} = $msg;
Line 2098  sub dbcopy { Line 2137  sub dbcopy {
     my ($url,$result,$errtext);      my ($url,$result,$errtext);
     if (ref($dbref) eq 'HASH') {      if (ref($dbref) eq 'HASH') {
         $url = $dbref->{'src'};          $url = $dbref->{'src'};
         if ($url =~ m{/(smppg|bulletinboard)$}) {          if ($url =~ m{/(smppg|bulletinboard|ext\.tool)$}) {
             my $prefix = $1;              my $prefix = $1;
               if ($prefix eq 'ext.tool') {
                   $prefix = 'exttool';
               }
             if (($dbref->{'cdom'} =~ /^$match_domain$/) &&               if (($dbref->{'cdom'} =~ /^$match_domain$/) && 
                 ($dbref->{'cnum'} =~ /^$match_courseid$/)) {                  ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
                 my $db_name;                  my $db_name;
Line 2110  sub dbcopy { Line 2152  sub dbcopy {
                         &Apache::lonsimplepage::get_db_name($url,$marker,                          &Apache::lonsimplepage::get_db_name($url,$marker,
                                                             $dbref->{'cdom'},                                                              $dbref->{'cdom'},
                                                             $dbref->{'cnum'});                                                              $dbref->{'cnum'});
                   } elsif ($dbref->{'src'} =~ m{/ext\.tool$}) {
                       $db_name = 'exttool_'.$marker;
                 } else {                  } else {
                     $db_name = 'bulletinpage_'.$marker;                      $db_name = 'bulletinpage_'.$marker;
                 }                  }
Line 2153  sub dbcopy { Line 2197  sub dbcopy {
                     $result=&Apache::lonnet::put($db_name,\%contents,                      $result=&Apache::lonnet::put($db_name,\%contents,
                                                  $coursedom,$coursenum);                                                   $coursedom,$coursenum);
                     if ($result eq 'ok') {                      if ($result eq 'ok') {
                         $url =~ s{/(\d*)/(smppg|bulletinboard)$}{/$suffix/$2}x;                          $url =~ s{/(\d*)/(smppg|bulletinboard|ext\.tool)$}{/$suffix/$2}x;
                     }                      }
                 }                  }
                 if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {                  if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
Line 2163  sub dbcopy { Line 2207  sub dbcopy {
                     if ($prefix eq 'smppg') {                      if ($prefix eq 'smppg') {
                         $lockerrorsref->{$prefix} .=                          $lockerrorsref->{$prefix} .=
                             ' '.&mt('This will prevent creation of additional simple pages in this course.');                              ' '.&mt('This will prevent creation of additional simple pages in this course.');
                       } elsif ($prefix eq 'exttool') {
                           $lockerrorsref->{$prefix} .=
                               ' '.&mt('This will prevent addition of more external tools to this course.');
                     } else {                      } else {
                         $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');                          $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
                     }                      }
Line 2292  sub uniqueness_check { Line 2339  sub uniqueness_check {
 }  }
   
 sub contained_map_check {  sub contained_map_check {
     my ($url,$folder,$removefrommap,$removeparam,$addedmaps,$hierarchy,$titles,      my ($url,$folder,$coursenum,$coursedom,$removefrommap,$removeparam,$addedmaps,
         $allmaps) = @_;          $hierarchy,$titles,$allmaps) = @_;
     my $content = &Apache::lonnet::getfile($url);      my $content = &Apache::lonnet::getfile($url);
     unless ($content eq '-1') {      unless ($content eq '-1') {
         my $parser = HTML::TokeParser->new(\$content);          my $parser = HTML::TokeParser->new(\$content);
Line 2303  sub contained_map_check { Line 2350  sub contained_map_check {
             if ($token->[1] eq 'resource') {              if ($token->[1] eq 'resource') {
                 next if ($token->[2]->{'type'} eq 'zombie');                  next if ($token->[2]->{'type'} eq 'zombie');
                 my $ressrc = $token->[2]->{'src'};                  my $ressrc = $token->[2]->{'src'};
                 if ($folder =~ /^supplemental/) {                  if ($ressrc =~ m{^/adm/($match_domain)/$match_courseid/\d+/ext\.tool$}) {
                       my $srcdom = $1;
                       unless ($srcdom eq $coursedom) {
                           $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
                           next;
                       }
                   } elsif ($folder =~ /^supplemental/) {
                     unless (&supp_pasteable($ressrc)) {                      unless (&supp_pasteable($ressrc)) {
                         $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;                          $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
                         next;                          next;
Line 2322  sub contained_map_check { Line 2375  sub contained_map_check {
                             $addedmaps->{$ressrc} = [$url];                              $addedmaps->{$ressrc} = [$url];
                         }                          }
                     }                      }
                     &contained_map_check($ressrc,$folder,$removefrommap,$removeparam,                      &contained_map_check($ressrc,$folder,$coursenum,$coursedom,$removefrommap,
                                          $addedmaps,$hierarchy,$titles,$allmaps);                                           $removeparam,$addedmaps,$hierarchy,$titles,$allmaps);
                 }                  }
             } elsif ($token->[1] eq 'param') {              } elsif ($token->[1] eq 'param') {
                 if ($folder =~ /^supplemental/) {                  if ($folder =~ /^supplemental/) {
Line 3009  sub handle_edit_cmd { Line 3062  sub handle_edit_cmd {
 sub editor {  sub editor {
     my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,      my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
         $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref,          $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref,
         $canedit,$navmapref,$hiddentop)=@_;          $canedit,$hostname,$navmapref,$hiddentop)=@_;
     my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);      my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
     if ($allowed) {      if ($allowed) {
         (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,          (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
Line 3220  sub editor { Line 3273  sub editor {
                         } else {                          } else {
                             return $errortxt;                              return $errortxt;
                         }                          }
                     } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/exttool}) {                      } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/ext\.tool}) {
                         my ($suffix,$errortxt,$locknotfreed) =                          my ($suffix,$errortxt,$locknotfreed) =
                             &new_timebased_suffix($coursedom,$coursenum,'exttool');                              &new_timebased_suffix($coursedom,$coursenum,'exttool');
                         if ($locknotfreed) {                          if ($locknotfreed) {
Line 3339  sub editor { Line 3392  sub editor {
         $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,$isencrypted,$navmapref);                                \%filters,\%curr_groups,$ltitoolsref,$canedit,
                                 $isencrypted,$navmapref,$hostname);
         $idx++;          $idx++;
         $shown++;          $shown++;
     }      }
Line 3720  sub is_supplemental_title { Line 3774  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)=@_;          $ltitoolsref,$canedit,$isencrypted,$navmapref,$hostname)=@_;
     my ($foldertitle,$renametitle,$oldtitle);      my ($foldertitle,$renametitle,$oldtitle);
     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);
Line 3823  END Line 3877  END
                 'sv' => 'Save',                  'sv' => 'Save',
                 'ul' => 'URL',                  'ul' => 'URL',
                 'ti' => 'Title',                  'ti' => 'Title',
                 'er' => 'Editing rights unavailable for your current role',                   'er' => 'Editing rights unavailable for your current role.', 
                 );                  );
  my %denied = &action_restrictions($coursenum,$coursedom,$url,   my %denied = &action_restrictions($coursenum,$coursedom,$url,
                                           $env{'form.folderpath'},                                            $env{'form.folderpath'},
Line 3837  END Line 3891  END
     |/aboutme$      |/aboutme$
     |/navmaps$      |/navmaps$
     |/bulletinboard$      |/bulletinboard$
                             |/exttools?$                              |/ext\.tool$
     |\.html$)}x)      |\.html$)}x)
              || $isexternal) {               || $isexternal) {
     $skip_confirm = 1;      $skip_confirm = 1;
Line 3969  END Line 4023  END
  }   }
     }      }
   
     my ($editlink,$extresform,$anchor,$hiddenres);      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/};      $url=~s{^http(|s)(&colon;|:)//}{/adm/wrapper/ext/};
Line 3987  END Line 4041  END
         } elsif ($url!~/\.(sequence|page)$/) {          } elsif ($url!~/\.(sequence|page)$/) {
     $url='/adm/coursedocs/showdoc'.$url;      $url='/adm/coursedocs/showdoc'.$url;
         }          }
     } elsif ($url=~m|^/ext/|) {      } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
         $url='/adm/wrapper'.$url;                  my $wrapped = $1;
     } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) {                  my $exturl = $2;
                   if ($wrapped eq '') {
                       $url='/adm/wrapper'.$url;
                   }
                   if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
                       $nomodal = 1;
                   }
       } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
  $url='/adm/wrapper'.$url;   $url='/adm/wrapper'.$url;
               } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
                   if (($ENV{'SERVER_PORT'} == 443) &&
                       ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
                       $url .= '?usehttp=1';
                       $nomodal = 1;
                   }
             }              }
             if (&Apache::lonnet::symbverify($symb,$url)) {              if (&Apache::lonnet::symbverify($symb,$url)) {
                 my $shownsymb = $symb;                  my $shownsymb = $symb;
Line 4020  END Line 4087  END
                 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;
                 } else {                  } elsif (ref($navmapref)) {
                     unless (ref($$navmapref)) {                      unless (ref($$navmapref)) {
                         $$navmapref = Apache::lonnavmaps::navmap->new();                          $$navmapref = Apache::lonnavmaps::navmap->new();
                     }                      }
Line 4048  END Line 4115  END
                 $url='';                  $url='';
             }              }
  }   }
     } elsif ($supplementalflag) {       } elsif ($supplementalflag) {
         if ($isexternal) {          if ($isexternal) {
             if ($url =~ /^([^#]+)#([^#]+)$/) {              if ($url =~ /^([^#]+)#([^#]+)$/) {
                 $url = $1;                  $url = $1;
                 $anchor = $2;                  $anchor = $2;
                   if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
                       if ($hostname ne '') {
                           $url = 'http://'.$hostname.$url;
                       }
                       $nomodal = 1;
                   }
               }
           } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
               if (($ENV{'SERVER_PORT'} == 443) &&
                   ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
                   if ($hostname ne '') {
                       $url = 'http://'.$hostname.$url;
                   }
                   $url .= (($url =~ /\?/) ? '&amp;':'?').'usehttp=1';
                   $nomodal = 1;
             }              }
         }          }
     }      }
Line 4075  END Line 4157  END
             my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,              my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
                                               'parameter_encrypturl'))[0]=~/^yes$/i);                                                'parameter_encrypturl'))[0]=~/^yes$/i);
             unless ($hiddenmap) {              unless ($hiddenmap) {
                 unless (ref($$navmapref)) {                  if (ref($navmapref)) {
                     $$navmapref = Apache::lonnavmaps::navmap->new();                      unless (ref($$navmapref)) {
                 }                          $$navmapref = Apache::lonnavmaps::navmap->new();
                 if (ref($$navmapref)) {                      }
                     if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {                      if (ref($$navmapref)) {
                         my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);                          if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
                         unless (@resources) {                              my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
                             $hiddenmap = 1;                              unless (@resources) {
                             unless ($env{'request.role.adv'}) {                                    $hiddenmap = 1;
                                 $url = '';                                  unless ($env{'request.role.adv'}) {  
                                 $hiddenfolder = 1;                                      $url = '';
                                       $hiddenfolder = 1;
                                   }
                             }                              }
                         }                          }
                     }                      }
                 }                  }
             }              }
             unless ($encryptmap) {              unless ($encryptmap) {
                 if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {                  if ((ref($navmapref)) && (ref($$navmapref))) {
                     $encryptmap = 1;                      if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
                           $encryptmap = 1;
                       }
                 }                  }
             }              }
                           
Line 4139  $form_end; Line 4225  $form_end;
         }          }
     } elsif ($supplementalflag && !$allowed) {      } elsif ($supplementalflag && !$allowed) {
         my $isexttool;          my $isexttool;
         if ($url=~m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) {          if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
             $url='/adm/wrapper'.$url;              $url='/adm/wrapper'.$url;
             $isexttool = 1;              $isexttool = 1;
         }          }
Line 4164  $form_end; Line 4250  $form_end;
                 &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,                  &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
                                                      undef,undef,undef,undef,undef,undef,                                                       undef,undef,undef,undef,undef,undef,
                                                      undef,$disabled);                                                       undef,$disabled);
         } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) {          } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
             ($editlink,$extresform) =              ($editlink,$extresform) =
                 &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,                  &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
                                                      undef,undef,undef,'tool',$coursedom,                                                       undef,undef,undef,'tool',$coursedom,
Line 4183  $form_end; Line 4269  $form_end;
                                                             $forceedit,                                                              $forceedit,
                                                             undef,$symb,                                                              undef,$symb,
                                                             &escape($env{'form.folderpath'}),                                                              &escape($env{'form.folderpath'}),
                                                             $renametitle,'','',1,$suppanchor);                                                              $renametitle,$hostname,
                                                               '','',1,$suppanchor);
                 if ($jscall) {                  if ($jscall) {
                     $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.                      $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
                                 $jscall.'" >'.&mt('Edit').'</a>&nbsp;'."\n";                                  $jscall.'" >'.&mt('Edit').'</a>&nbsp;'."\n";
Line 4200  $form_end; Line 4287  $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;
     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>';         $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
     } elsif ($url) {      } elsif ($url) {
Line 4210  $form_end; Line 4298  $form_end;
                $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');                 $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
            }             }
        }         }
        $line.=&Apache::loncommon::modal_link(&js_escape($url.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes'.         if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) {
                                              (($anchor ne '')?$anchor:'')),             $link = 'http://'.$hostname.$url;
                                              '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);         } else {
              $link = $url;
          }
          $link = &js_escape($link.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes'.
                                                  (($anchor ne '')?$anchor:''));
          if ($nomodal) {
              $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>';
          } else {
              $line.=&Apache::loncommon::modal_link($link,
                                                    '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
          }
     } else {      } else {
        $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';         $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
     }      }
Line 4220  $form_end; Line 4319  $form_end;
     if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {      if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
        $line.='<a href="'.$url.'">'.$title.'</a>';         $line.='<a href="'.$url.'">'.$title.'</a>';
     } elsif ($url) {      } elsif ($url) {
        $line.=&Apache::loncommon::modal_link(&js_escape($url.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes'.         if ($nomodal) {
                                              (($anchor ne '')?$anchor:'')),             $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
                                              $title,600,500);                    $title.'</a>';
          } else {
              $line.=&Apache::loncommon::modal_link($link,$title,600,500);
          }
     } elsif (($hiddenfolder) || ($hiddenres)) {      } elsif (($hiddenfolder) || ($hiddenres)) {
        $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">'.&mt('(Hidden)').'</span>';         $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">'.&mt('(Hidden)').'</span>';
     } else {      } else {
Line 4363  sub new_timebased_suffix { Line 4465  sub new_timebased_suffix {
             $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');              $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
         } elsif ($type eq 'smppg') {          } elsif ($type eq 'smppg') {
             $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');              $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
           } elsif ($type eq 'exttool') {
               $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.');
         } else {          } else {
             $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');              $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
         }          }
Line 4391  sub new_timebased_suffix { Line 4495  sub new_timebased_suffix {
         } elsif ($type eq 'smppg') {          } elsif ($type eq 'smppg') {
             $locknotfreed .=              $locknotfreed .=
                 &mt('This will prevent creation of additional simple pages in this course.');                  &mt('This will prevent creation of additional simple pages in this course.');
           } elsif ($type eq 'exttool') {
               $locknotfreed .=
                   &mt('This will prevent creation of additional external tools in this course.');
         } else {          } else {
             $locknotfreed .=              $locknotfreed .=
                 &mt('This will prevent creation of additional discussion boards in this course.');                  &mt('This will prevent creation of additional discussion boards in this course.');
Line 5016  sub handler { Line 5123  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','Navigate_Content',                 'Adding_External_Resource','Adding_External_Tool',
                'Adding_Folders','Docs_Overview', 'Load_Map',                         'Navigate_Content','Adding_Folders','Docs_Overview',
                'Supplemental','Score_Upload_Form','Adding_Pages',                 'Load_Map','Supplemental','Score_Upload_Form',
                'Importing_LON-CAPA_Resource','Importing_IMS_Course',                 'Adding_Pages','Importing_LON-CAPA_Resource',
                        'Uploading_From_Harddrive','Course_Roster','Web_Page',                 'Importing_IMS_Course','Uploading_From_Harddrive',
                        '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);
     }      }
     # Composite help files      # Composite help files
Line 5343  sub handler { Line 5450  sub handler {
             my $tabidstr = join("','",@tabids);              my $tabidstr = join("','",@tabids);
             %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom);              %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom);
             my $posslti = keys(%ltitools);              my $posslti = keys(%ltitools);
               my $hostname = $r->hostname();
     $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,      $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
                                    $londocroot,$canedit,\$navmap).                                     $londocroot,$canedit,$hostname,\$navmap).
                        &history_tab_js().                         &history_tab_js().
                        &inject_data_js().                         &inject_data_js().
                        &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).                         &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
Line 5527  sub handler { Line 5635  sub handler {
                 'webctce4' => 'WebCT 4 Campus Edition',                  'webctce4' => 'WebCT 4 Campus Edition',
                 'yes'      => 'Yes',                  'yes'      => 'Yes',
                 'no'       => 'No',                  'no'       => 'No',
                 'er' => 'Editing rights unavailable for your current role',                  'er' => 'Editing rights unavailable for your current role.',
         );          );
 # -----------------------------------------------------------------------------  # -----------------------------------------------------------------------------
   
Line 5557  sub handler { Line 5665  sub handler {
     if ($disk_quota == 0) {      if ($disk_quota == 0) {
         $percent = 100.0;          $percent = 100.0;
     } else {      } else {
         $percent = 100*($current_disk_usage/$disk_quota);          $percent = 100*($usage/$disk_quota);
     }      }
     $usage = sprintf("%.2f",$usage);      $usage = sprintf("%.2f",$usage);
     $quota = sprintf("%.2f",$quota);      $quota = sprintf("%.2f",$quota);
Line 5746  HIDDENFORM Line 5854  HIDDENFORM
     }      }
   
 #  #
       my $hostname = $r->hostname();
     my $savefolderpath;      my $savefolderpath;
   
     if ($allowed) {      if ($allowed) {
Line 6158  NSYLFORM Line 6266  NSYLFORM
 NGFFORM  NGFFORM
  @specialdocumentsforma=(   @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="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},
Line 6171  NGFFORM Line 6279  NGFFORM
         );          );
         if (keys(%ltitools)) {          if (keys(%ltitools)) {
             push(@importdoc,              push(@importdoc,
                 {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},                  {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},
         );          );
         }          }
         unless ($container eq 'page') {          unless ($container eq 'page') {
Line 6216  unless ($container eq 'page') { Line 6324  unless ($container eq 'page') {
        unless (($supplementalflag || $toolsflag)) {         unless (($supplementalflag || $toolsflag)) {
           my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,            my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
                               $supplementalflag,\%orderhash,$iconpath,$pathitem,                                $supplementalflag,\%orderhash,$iconpath,$pathitem,
                               \%ltitools,$canedit,\$navmap,$hiddentop);                                \%ltitools,$canedit,$hostname,\$navmap,$hiddentop);
           undef($navmap);            undef($navmap);
           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 6336  SWEBFORM Line 6444  SWEBFORM
   
   
 my @specialdocs = (  my @specialdocs = (
  {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="makenew(document.supnewsyl);" />'   {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
             =>$supnewsylform},              =>$supnewsylform},
  {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'   {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
             =>$supnewaboutmeform},              =>$supnewaboutmeform},
Line 6348  my @supimportdoc = ( Line 6456  my @supimportdoc = (
             =>$supextform});              =>$supextform});
         if (keys(%ltitools)) {          if (keys(%ltitools)) {
             push(@supimportdoc,              push(@supimportdoc,
                 {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'                  {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'
             =>$supexttoolform});              =>$supexttoolform});
         }          }
         push(@supimportdoc,           push(@supimportdoc, 
Line 6365  my %suporderhash = ( Line 6473  my %suporderhash = (
         if ($supplementalflag) {          if ($supplementalflag) {
            my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,             my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
                                $supplementalflag,\%suporderhash,$iconpath,$pathitem,                                 $supplementalflag,\%suporderhash,$iconpath,$pathitem,
                                \%ltitools,$canedit);                                 \%ltitools,$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>');
            } else {             } else {
Line 6385  my %suporderhash = ( Line 6493  my %suporderhash = (
         }          }
     } 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);                              $supplementalflag,'',$iconpath,$pathitem,'','',$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 6759  END Line 6867  END
 }  }
   
 sub editing_js {  sub editing_js {
     my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,$londocroot,$canedit,$navmapref) = @_;      my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
           $londocroot,$canedit,$hostname,$navmapref) = @_;
     my %js_lt = &Apache::lonlocal::texthash(      my %js_lt = &Apache::lonlocal::texthash(
                                           p_mnf => 'Name of New Folder',                                            p_mnf => 'Name of New Folder',
                                           t_mnf => 'New Folder',                                            t_mnf => 'New Folder',
Line 6803  sub editing_js { Line 6912  sub editing_js {
                                           nofi    => 'No file selected',                                            nofi    => 'No file selected',
                                           tinc    => 'Title in course',                                            tinc    => 'Title in course',
                                           sunm    => 'Sub-directory name',                                            sunm    => 'Sub-directory name',
                                           edri    => 'Editing rights unavailable for your current role',                                            edri    => 'Editing rights unavailable for your current role.',
                                         );                                          );
     &js_escape(\%js_lt);      &js_escape(\%js_lt);
     my $crstype = &Apache::loncommon::course_type();      my $crstype = &Apache::loncommon::course_type();
Line 6836  sub editing_js { Line 6945  sub editing_js {
                 }                  }
                 $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='.                  $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='.
                              &HTML::Entities::encode($caller,'<>&"');                               &HTML::Entities::encode($caller,'<>&"');
                   if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
                       if (($ENV{'SERVER_PORT'} == 443) &&
                           ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
                           if ($hostname ne '') {
                               $backtourl = 'http://'.$hostname.$backtourl;
                           }
                           $backtourl .= (($backtourl =~ /\?/) ? '&amp;':'?').'usehttp=1';
                       }
                   } elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) {
                       if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) {
                           $backtourl = 'http://'.$hostname.$backtourl;
                       }
                   }
                 if ($anchor ne '') {                  if ($anchor ne '') {
                     $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');                      $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
                 }                  }

Removed from v.1.617  
changed lines
  Added in v.1.629


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