Diff for /loncom/interface/londocs.pm between versions 1.484.2.67 and 1.484.2.77

version 1.484.2.67, 2016/11/30 00:41:24 version 1.484.2.77, 2018/04/29 17:29:23
Line 1203  sub print_paste_buffer { Line 1203  sub print_paste_buffer {
                     if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {                      if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
                         $othercourse = 1;                          $othercourse = 1;
                         if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {                          if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
                             if ($canpaste) {                              $othercrs = '<br />'.&mt('(from another course)');
                                 $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 1219  sub print_paste_buffer { Line 1217  sub print_paste_buffer {
                         }                          }
                         $is_uploaded_map = 1;                          $is_uploaded_map = 1;
                     }                      }
                   } elsif ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg)$}) {
                       if ($cid ne $env{'request.course.id'}) {
                           my ($srcdom,$srcnum) = split(/_/,$cid);
                           if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
                               $othercrs = '<br />'.&mt('(from another course)');
                           } else {
                               $canpaste = 0;
                               $nopaste = &mt('Paste from another course unavailable.');
                           }
                       }
                   }
                   if ($canpaste) {
                       push(@pasteable,$suffix);
                 }                  }
             }  
             if ($canpaste) {  
                push(@pasteable,$suffix);  
             }              }
             my $buffer;              my $buffer;
             if ($is_external) {              if ($is_external) {
Line 1512  sub do_paste_from_buffer { Line 1520  sub do_paste_from_buffer {
   
     foreach my $suffix (@topaste) {      foreach my $suffix (@topaste) {
         my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});          my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
           my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
 # Supplemental content may only include certain types of content  # Supplemental content may only include certain types of content
 # Early out if pasted content is not supported in Supplemental area  # Early out if pasted content is not supported in Supplemental area
         if ($folder =~ /^supplemental/) {          if ($folder =~ /^supplemental/) {
Line 1533  sub do_paste_from_buffer { Line 1542  sub do_paste_from_buffer {
             }              }
             $srcdom{$suffix} = $srcd;              $srcdom{$suffix} = $srcd;
             $srcnum{$suffix} = $srcn;              $srcnum{$suffix} = $srcn;
           } elsif ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$}) {
               my ($srcd,$srcn) = split(/_/,$cid);
   # 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
               if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
                   unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
                       $notincrs{$suffix} = 1;
                       next;
                   }
               }
               $srcdom{$suffix} = $srcd;
               $srcnum{$suffix} = $srcn;
         }          }
   
         push(@dopaste,$suffix);          push(@dopaste,$suffix);
         if ($url=~/\.(page|sequence)$/) {          if ($url=~/\.(page|sequence)$/) {
             $is_map{$suffix} = 1;               $is_map{$suffix} = 1; 
Line 1632  sub do_paste_from_buffer { Line 1652  sub do_paste_from_buffer {
         }          }
         my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});          my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
         my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});          my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
           my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
         my $oldurl = $url;          my $oldurl = $url;
         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
Line 1692  sub do_paste_from_buffer { Line 1713  sub do_paste_from_buffer {
         }          }
         if ($url=~ m{/(bulletinboard|smppg)$}) {          if ($url=~ m{/(bulletinboard|smppg)$}) {
             my $prefix = $1;              my $prefix = $1;
               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.
             my %info = (              my %info = (
                          src  => $url,                           src  => $url,
                          cdom => $coursedom,                           cdom => $coursedom,
                          cnum => $coursenum,                           cnum => $coursenum,
             );                         );
             unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {              if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
                   unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
                       $fromothercrs = 1;
                       $info{'cdom'} = $srcdom{$suffix};
                       $info{'cnum'} = $srcnum{$suffix};
                   }
               }
               unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
                 my (%lockerr,$msg);                   my (%lockerr,$msg); 
                 my ($newurl,$result,$errtext) =                  my ($newurl,$result,$errtext) =
                     &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);                      &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
Line 1959  sub get_newmap_url { Line 1988  sub get_newmap_url {
 sub dbcopy {  sub dbcopy {
     my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;      my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
     my ($url,$result,$errtext);      my ($url,$result,$errtext);
     $url = $dbref->{'src'};  
     if (ref($dbref) eq 'HASH') {      if (ref($dbref) eq 'HASH') {
           $url = $dbref->{'src'};
         if ($url =~ m{/(smppg|bulletinboard)$}) {          if ($url =~ m{/(smppg|bulletinboard)$}) {
             my $prefix = $1;              my $prefix = $1;
             if (($dbref->{'cdom'} =~ /^$match_domain$/) &&              if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
Line 2434  sub apply_fixups { Line 2463  sub apply_fixups {
                     }                      }
                 }                  }
             }              }
             for (my $i=0; $i<@LONCAPA::map::order; $i++) {              my $total = scalar(@LONCAPA::map::order) - 1;
               for (my $i=$total; $i>=0; $i--) {
                 my $idx = $LONCAPA::map::order[$i];                  my $idx = $LONCAPA::map::order[$i];
                 if (defined($LONCAPA::map::resources[$idx])) {                  if (defined($LONCAPA::map::resources[$idx])) {
                     my $changed;                      my $changed;
Line 2444  sub apply_fixups { Line 2474  sub apply_fixups {
                         splice(@LONCAPA::map::order,$i,1);                          splice(@LONCAPA::map::order,$i,1);
                         if (ref($currparam{$idx}) eq 'ARRAY') {                          if (ref($currparam{$idx}) eq 'ARRAY') {
                             foreach my $name (@{$currparam{$idx}}) {                              foreach my $name (@{$currparam{$idx}}) {
                                 &LONCAPA::map::delparameter($idx,'parameter_'.$name);                                  &LONCAPA::map::delparameter($idx,$name);
                             }                              }
                         }                          }
                         next;                          next;
Line 2486  sub apply_fixups { Line 2516  sub apply_fixups {
             foreach my $idx (keys(%remparam)) {              foreach my $idx (keys(%remparam)) {
                 if (ref($remparam{$idx}) eq 'ARRAY') {                  if (ref($remparam{$idx}) eq 'ARRAY') {
                     foreach my $name (@{$remparam{$idx}}) {                         foreach my $name (@{$remparam{$idx}}) {   
                         &LONCAPA::map::delparameter($idx,'parameter_'.$name);                          &LONCAPA::map::delparameter($idx,$name);
                     }                      }
                 }                  }
             }              }
Line 3065  sub editor { Line 3095  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,$canedit,$isencrypted,$navmapref);                                \%filters,\%curr_groups,$canedit,
                                 $isencrypted,$navmapref);
         $idx++;          $idx++;
         $shown++;          $shown++;
     }      }
Line 3180  sub editor { Line 3211  sub editor {
         my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";          my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
         $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,          $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
                                        $jumpto,$readfile,$need_save,"$folder.$container",$canedit));                                         $jumpto,$readfile,$need_save,"$folder.$container",$canedit));
         if ($canedit)           if ($canedit) {
             &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);              &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
         }          }
     } else {      } else {
Line 3691  END Line 3722  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 3709  END Line 3740  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;
                   my $exturl = $2;
                   if ($wrapped eq '') {
                       $url='/adm/wrapper'.$url;
                   }
                   if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
                       $nomodal = 1;
                   }
               } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
                   if (($ENV{'SERVER_PORT'} == 443) &&
                       ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
                       $nomodal = 1;
                   }
     }      }
             if (&Apache::lonnet::symbverify($symb,$url)) {              if (&Apache::lonnet::symbverify($symb,$url)) {
                 my $shownsymb = $symb;                  my $shownsymb = $symb;
Line 3733  END Line 3776  END
                     }                      }
                 }                  }
                 if ($url ne '') {                  if ($url ne '') {
                     $url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');                      $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
                 }                  }
             } elsif (!$env{'request.role.adv'}) {              } elsif (!$env{'request.role.adv'}) {
                 my $checkencrypt;                  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;
                 } else {                  } elsif (ref($navmapref)) {
                     unless (ref($$navmapref)) {                      unless (ref($$navmapref)) {
                         $$navmapref = Apache::lonnavmaps::navmap->new();                          $$navmapref = Apache::lonnavmaps::navmap->new();
                     }                      }
Line 3773  END Line 3816  END
             if ($url =~ /^([^#]+)#([^#]+)$/) {              if ($url =~ /^([^#]+)#([^#]+)$/) {
                 $url = $1;                  $url = $1;
                 $anchor = $2;                  $anchor = $2;
                   if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
                       $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://})) {
                   $nomodal = 1;
             }              }
         }          }
     }      }
Line 3795  END Line 3846  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 3909  $form_end; Line 3964  $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 3919  $form_end; Line 3975  $form_end;
                $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');                 $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
            }             }
        }         }
        $line.=&Apache::loncommon::modal_link(&js_escape($url.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes'.         $link = &js_escape($url.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes'.
                                              (($anchor ne '')?$anchor:'')),                                                 (($anchor ne '')?$anchor:''));
                                              '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);         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 3929  $form_end; Line 3991  $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.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';         $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
     }      }
Line 4994  sub handler { Line 5059  sub handler {
                 }                  }
             }              }
             my $tabidstr = join("','",@tabids);              my $tabidstr = join("','",@tabids);
     $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum      $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,
                                    $canedit,\$navmap).                                     $canedit,\$navmap).
                        &history_tab_js().                         &history_tab_js().
                        &inject_data_js().                         &inject_data_js().
Line 5077  sub handler { Line 5142  sub handler {
   undef($hadchanges);    undef($hadchanges);
           $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,            $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
                                               \%allfiles,\%codebase,$context,$crstype);                                                \%allfiles,\%codebase,$context,$crstype);
             undef($navmap);
   if ($hadchanges) {    if ($hadchanges) {
       &mark_hash_old();        &mark_hash_old();
   }    }
Line 5187  sub handler { Line 5253  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 5592  unless ($container eq 'page') { Line 5658  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,
                               $canedit,\$navmap,$hiddentop));                                $canedit,\$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>');
           }            }
           if ($hadchanges) {            if ($hadchanges) {
              &mark_hash_old();               unless (&is_hash_old()) {
                    &mark_hash_old();
                }
           }            }
   
           &changewarning($r,'');            &changewarning($r,'');

Removed from v.1.484.2.67  
changed lines
  Added in v.1.484.2.77


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