Diff for /loncom/interface/londocs.pm between versions 1.626 and 1.627

version 1.626, 2017/05/08 14:20:20 version 1.627, 2017/05/10 00:03:08
Line 761  sub group_import { Line 761  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 1213  sub update_paste_buffer { Line 1213  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 1326  sub print_paste_buffer { Line 1326  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.');
Line 1342  sub print_paste_buffer { Line 1347  sub print_paste_buffer {
                 }                    }  
             }              }
             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 1625  sub do_paste_from_buffer { Line 1633  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 1654  sub do_paste_from_buffer { Line 1662  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 1664  sub do_paste_from_buffer { Line 1673  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 1672  sub do_paste_from_buffer { Line 1685  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 1717  sub do_paste_from_buffer { Line 1729  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 1770  sub do_paste_from_buffer { Line 1783  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 1824  sub do_paste_from_buffer { Line 1838  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 1852  sub do_paste_from_buffer { Line 1866  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 2111  sub dbcopy { Line 2127  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 2123  sub dbcopy { Line 2142  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 2166  sub dbcopy { Line 2187  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 2176  sub dbcopy { Line 2197  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 2305  sub uniqueness_check { Line 2329  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 2316  sub contained_map_check { Line 2340  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 2335  sub contained_map_check { Line 2365  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 5083  sub handler { Line 5113  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 6239  NGFFORM Line 6269  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 6416  my @supimportdoc = ( Line 6446  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 6911  sub editing_js { Line 6941  sub editing_js {
                         if ($hostname ne '') {                          if ($hostname ne '') {
                             $backtourl = 'http://'.$hostname.$backtourl;                              $backtourl = 'http://'.$hostname.$backtourl;
                         }                          }
                         $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';                          $backtourl .= (($backtourl =~ /\?/) ? '&amp;':'?').'usehttp=1';
                     }                      }
                 } 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 '')) {

Removed from v.1.626  
changed lines
  Added in v.1.627


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