Diff for /loncom/interface/londocs.pm between versions 1.484.2.61 and 1.484.2.66

version 1.484.2.61, 2016/08/04 17:20:44 version 1.484.2.66, 2016/10/31 20:48:30
Line 652  sub group_import { Line 652  sub group_import {
                 } else {                  } else {
                     $fname =~ s/\W/_/g;                      $fname =~ s/\W/_/g;
                 }                  }
                 if (length($fname > 15)) {                  if (length($fname) > 15) {
                     $fname = substr($fname,0,14);                      $fname = substr($fname,0,14);
                 }                  }
                 my $initialtext = &mt('Replace with your own content.');                  my $initialtext = &mt('Replace with your own content.');
Line 2810  sub editor { Line 2810  sub editor {
  $r->print($upload_output);   $r->print($upload_output);
   
 # Rename, cut, copy or remove a single resource  # Rename, cut, copy or remove a single resource
  if (&handle_edit_cmd()) {   if (&handle_edit_cmd($coursenum,$coursedom)) {
             my $contentchg;              my $contentchg;
             if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {              if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {
                 $contentchg = 1;                  $contentchg = 1;
Line 3480  END Line 3480  END
                                           $currgroups);                                            $currgroups);
         my ($copylink,$cutlink,$removelink);          my ($copylink,$cutlink,$removelink);
  my $skip_confirm = 0;   my $skip_confirm = 0;
           my $confirm_removal = 0;
  if ( $folder =~ /^supplemental/   if ( $folder =~ /^supplemental/
      || ($url =~ m{( /smppg$       || ($url =~ m{( /smppg$
     |/syllabus$      |/syllabus$
Line 3490  END Line 3491  END
              || $isexternal) {               || $isexternal) {
     $skip_confirm = 1;      $skip_confirm = 1;
  }   }
           if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
               ($url!~/$LONCAPA::assess_page_seq_re/)) {
               $confirm_removal = 1;
           }
   
  if ($denied{'copy'}) {   if ($denied{'copy'}) {
             $copylink=(<<ENDCOPY)              $copylink=(<<ENDCOPY)
Line 3532  ENDCUT Line 3537  ENDCUT
 ENDREM  ENDREM
         } else {          } else {
             my $formname = 'edit_remove_'.$orderidx;              my $formname = 'edit_remove_'.$orderidx;
             my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm);";              my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder',$confirm_removal);";
             $removelink=(<<ENDREM);              $removelink=(<<ENDREM);
 <form name="$formname" method="post" action="/adm/coursedocs">  <form name="$formname" method="post" action="/adm/coursedocs">
 $form_common  $form_common
 <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />  <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
   <input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" />
 <input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>  <input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>
 $form_end  $form_end
 ENDREM  ENDREM
Line 3602  END Line 3608  END
  }   }
     }      }
   
     my ($editlink,$extresform);      my ($editlink,$extresform,$anchor);
     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 3624  END Line 3630  END
         $url='/adm/wrapper'.$url;          $url='/adm/wrapper'.$url;
     }      }
             if (&Apache::lonnet::symbverify($symb,$url)) {              if (&Apache::lonnet::symbverify($symb,$url)) {
         $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);                  my $shownsymb = $symb;
                   if ($isexternal) {
                       if ($url =~ /^([^#]+)#([^#]+)$/) {
                           $url = $1;
                           $anchor = $2;
                           if ($symb =~ m{^([^#]+)\Q#$anchor\E$}) {
                               $shownsymb = $1.&escape('#').$anchor;
                           }
                       }
                   }
           $url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
             } else {              } else {
                 $url='';                  $url='';
             }              }
  }   }
       } elsif ($supplementalflag) {
           if ($isexternal) {
               if ($url =~ /^([^#]+)#([^#]+)$/) {
                   $url = $1;
                   $anchor = $2;
               }
           }
     }      }
     my ($rand_pick_text,$rand_order_text);      my ($rand_pick_text,$rand_order_text);
     if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {      if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
Line 3696  $form_end; Line 3719  $form_end;
         if ($isexternal && $orderidx) {          if ($isexternal && $orderidx) {
             $url .= '&amp;idx='.$orderidx;              $url .= '&amp;idx='.$orderidx;
         }          }
           if ($anchor ne '') {
               $url .= '&amp;anchor='.&HTML::Entities::encode($anchor,'"<>&');
           }
     }      }
     my ($tdalign,$tdwidth);      my ($tdalign,$tdwidth);
     if ($allowed) {      if ($allowed) {
Line 3708  $form_end; Line 3734  $form_end;
             my ($cfile,$home,$switchserver,$forceedit,$forceview) =               my ($cfile,$home,$switchserver,$forceedit,$forceview) = 
                 &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);                  &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
             if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {              if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
                   my $suppanchor;
                   if ($supplementalflag) {
                       $suppanchor = $anchor;
                   }
                 my $jscall =                   my $jscall = 
                     &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,                      &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
                                                             $switchserver,                                                              $switchserver,
                                                             $forceedit,                                                              $forceedit,
                                                             undef,$symb,                                                              undef,$symb,
                                                             &escape($env{'form.folderpath'}),                                                              &escape($env{'form.folderpath'}),
                                                             $renametitle,'','',1);                                                              $renametitle,'','',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 3734  $form_end; Line 3764  $form_end;
     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.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes',         if ($anchor ne '') {
              if ($supplementalflag) {
                  $anchor = '&amp;anchor='.&HTML::Entities::encode($anchor,'"<>&');
              } else {
                  $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
              }
          }
          $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes'.
                                                (($anchor ne '')?$anchor:''),
                                              '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);                                               '<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 3743  $form_end; Line 3781  $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($url.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes',         $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&amp;':'?').'inhibitmenu=yes'.
                                                (($anchor ne '')?$anchor:''),
                                              $title,600,500);                                               $title,600,500);
     } else {      } else {
        $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';         $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
Line 4899  sub handler { Line 4938  sub handler {
                 'webctce4' => 'WebCT 4 Campus Edition',                  'webctce4' => 'WebCT 4 Campus Edition',
         );          );
 # -----------------------------------------------------------------------------  # -----------------------------------------------------------------------------
       # Calculate free quota space for a user or course.
       my $quotatype = 'unofficial';
       if ($crstype eq 'Community') {
           $quotatype = 'community';
       } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
           $quotatype = 'official';
       } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
           $quotatype = 'textbook';
       }
       my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
                        'course',$quotatype); # expressed in MB
       my $current_disk_usage = 0;
       foreach my $subdir ('docs','supplemental') {
           $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
                                  "userfiles/$subdir",1); # expressed in kB
       }
       my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
       my $usage = $current_disk_usage/1024; # in MB
       my $quota = $disk_quota;
       my $percent;
       if ($disk_quota == 0) {
           $percent = 100.0;
       } else {
           $percent = 100*($current_disk_usage/$disk_quota);
       }
       $usage = sprintf("%.2f",$usage);
       $quota = sprintf("%.2f",$quota);
       $percent = sprintf("%.0f",$percent);
       my $quotainfo = '<p>'.&mt('Currently using [_1] of the [_2] available.',
                                 $percent.'%',$quota.' MB').'</p>';
   
  my $fileupload=(<<FIUP);   my $fileupload=(<<FIUP);
           $quotainfo
  $lt{'file'}:<br />   $lt{'file'}:<br />
  <input type="file" name="uploaddoc" size="40" />   <input type="file" name="uploaddoc" size="40" />
 FIUP  FIUP
Line 5816  sub editing_js { Line 5887  sub editing_js {
                                           p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',                                            p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
                                           p_chn => 'New Title',                                            p_chn => 'New Title',
                                           p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',                                            p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
                                           p_rmr2a => 'Remove[_99]',                                            p_rmr2a => 'Remove',
                                           p_rmr2b => '?[_99]',                                            p_rmr2b => '?',
                                           p_rmr3a => 'Remove those [_2]',                                            p_rmr3a => 'Remove those',
                                           p_rmr3b => 'items?[_2]',                                            p_rmr3b => 'items?',
                                             p_rmr4  => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".',
                                             p_rmr5  => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.',
                                           p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',                                            p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
                                           p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',                                            p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
                                           p_ctr2a => 'Cut[_98]',                                            p_ctr2a => 'Cut',
                                           p_ctr2b => '?[_98]',                                            p_ctr2b => '?',
                                           p_ctr3a => 'Cut those[_2]',                                            p_ctr3a => 'Cut those',
                                           p_ctr3b => 'items?[_2]',                                            p_ctr3b => 'items?',
                                           rpck    => 'Enter number to pick (e.g., 3)',                                            rpck    => 'Enter number to pick (e.g., 3)',
                                           imsfile => 'You must choose an IMS package for import',                                            imsfile => 'You must choose an IMS package for import',
                                           imscms  => 'You must select which Course Management System was the source of the IMS package',                                            imscms  => 'You must select which Course Management System was the source of the IMS package',
Line 5858  sub editing_js { Line 5931  sub editing_js {
             my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);              my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
             $res = &Apache::lonnet::clutter($res);              $res = &Apache::lonnet::clutter($res);
             if (&Apache::lonnet::is_on_map($res)) {              if (&Apache::lonnet::is_on_map($res)) {
                 $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.                  my ($url,$anchor);
                   if ($res =~ /^([^#]+)#([^#]+)$/) {
                       $url = $1;
                       $anchor = $2;
                       if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
                           $caller = $1.&escape('#').$anchor;
                       }
                   }
                   $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='.
                              &HTML::Entities::encode($caller,'<>&"');                               &HTML::Entities::encode($caller,'<>&"');
                   if ($anchor ne '') {
                       $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
                   }
                 $backtourl = &Apache::loncommon::escape_single($backtourl);                   $backtourl = &Apache::loncommon::escape_single($backtourl); 
             } else {              } else {
                 $backtourl = '/adm/navmaps';                  $backtourl = '/adm/navmaps';
Line 5883  sub editing_js { Line 5967  sub editing_js {
   
     return <<ENDNEWSCRIPT;      return <<ENDNEWSCRIPT;
 function makenewfolder(targetform,folderseq) {  function makenewfolder(targetform,folderseq) {
     var foldername=prompt('$js_lt{{"p_mnf"}','$js_lt{{"t_mnf"}');      var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
     if (foldername) {      if (foldername) {
        targetform.importdetail.value=escape(foldername)+"="+folderseq;         targetform.importdetail.value=escape(foldername)+"="+folderseq;
         targetform.submit();          targetform.submit();
Line 6196  function propagateState(form,param) { Line 6280  function propagateState(form,param) {
     return;      return;
 }  }
   
 function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder) {  function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
     var dosettings;      var dosettings;
     var doaction;      var doaction;
     var control = document.togglemultsettings;      var control = document.togglemultsettings;
Line 6234  function checkForSubmit(targetform,param Line 6318  function checkForSubmit(targetform,param
             targetform.markcopy.value=idx+':'+param;              targetform.markcopy.value=idx+':'+param;
             targetform.copyfolder.value=folder+'.'+container;              targetform.copyfolder.value=folder+'.'+container;
             if (param == 'remove') {              if (param == 'remove') {
                 if (skip_confirm || confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {                  var doremove = 0;
                   if (skip_confirm) {
                       if (confirm_removal) {
                           if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) {
                               doremove = 1;
                           }
                       } else {
                           doremove = 1;
                       }
                   } else {
                       if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
                           doremove = 1;
                       }
                   }
                   if (doremove) {
                     targetform.markcopy.value='';                      targetform.markcopy.value='';
                     targetform.copyfolder.value='';                      targetform.copyfolder.value='';
                     targetform.submit();                      targetform.submit();
Line 6491  function checkSubmits() { Line 6589  function checkSubmits() {
     var doactions = multiActions();      var doactions = multiActions();
     var cutwarnings = 0;      var cutwarnings = 0;
     var remwarnings = 0;      var remwarnings = 0;
       var removalinfo = 0;
     if (doactions == 1) {      if (doactions == 1) {
         var remidxlist = document.cumulativeactions.allremoveidx.value;          var remidxlist = document.cumulativeactions.allremoveidx.value;
         if ((remidxlist != '') && (remidxlist != null)) {          if ((remidxlist != '') && (remidxlist != null)) {
Line 6505  function checkSubmits() { Line 6604  function checkSubmits() {
                                 remwarnings ++;                                  remwarnings ++;
                             }                              }
                         }                          }
                           if (document.getElementById('confirm_removal_'+remidxs[i])) {
                               if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
                                   removalinfo ++;
                               }
                           }
                     }                      }
                 }                  }
             }              }
Line 6603  function checkSubmits() { Line 6707  function checkSubmits() {
     }      }
     if (doactions == 1) {      if (doactions == 1) {
         if (numchanges > 0) {          if (numchanges > 0) {
             if ((cutwarnings > 0) || (remwarnings > 0)) {              if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
                 if (remwarnings > 0) {                  if (remwarnings > 0) {
                     if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {                      if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
                         return false;                          return false;
                     }                      }
                 }                  }
                   if (removalinfo > 0) {
                       if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
                           return false;
                       }
                   }
                 if (cutwarnings > 0) {                  if (cutwarnings > 0) {
                     if (!confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr3a"} '+cutwarnings+' $js_lt{"p_ctr3b"}')) {                      if (!confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr3a"} '+cutwarnings+' $js_lt{"p_ctr3b"}')) {
                         return false;                          return false;

Removed from v.1.484.2.61  
changed lines
  Added in v.1.484.2.66


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