Diff for /loncom/interface/londocs.pm between versions 1.599 and 1.605

version 1.599, 2016/03/18 21:59:42 version 1.605, 2016/06/10 22:31:27
Line 619  sub group_import { Line 619  sub group_import {
                 $url = $1;                  $url = $1;
                 my $marker = $2;                  my $marker = $2;
                 my $info = $3;                  my $info = $3;
                 my ($toolid,%toolhash);                  my ($toolid,%toolhash,%toolsettings);
                 my @toolinfo = split(/:/,$info);                  my @toolinfo = split(/:/,$info);
                 if ($residx) {                  if ($residx) {
                     my %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);                      %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
                     $toolid = $toolsettings{'id'};                      $toolid = $toolsettings{'id'};
                 } else {                  } else {
                     $toolid = shift(@toolinfo);                        $toolid = shift(@toolinfo);
                 }                  }
                 $toolid =~ s/\D//g;                  $toolid =~ s/\D//g;
                 ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'}) = @toolinfo;                  ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
                    $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;
                   $toolhash{'crslabel'} = &unescape($toolhash{'crslabel'});
                   $toolhash{'crstitle'} = &unescape($toolhash{'crstitle'});
                 if (ref($ltitoolsref) eq 'HASH') {                  if (ref($ltitoolsref) eq 'HASH') {
                       my @deleted;
                     if (ref($ltitoolsref->{$toolid}) eq 'HASH') {                      if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
                         if ($ltitoolsref->{$toolid}->{'url'} =~ m{^https://}) {                          if ($ltitoolsref->{$toolid}->{'url'} =~ m{^https://}) {
                             $url =~ s/exttool$/exttools/;                              $url =~ s/exttool$/exttools/;
                         }                          }
                         $toolhash{'id'} = $toolid;                          $toolhash{'id'} = $toolid;
                           if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'window')) {
                               if ($toolhash{'target'} eq 'window') {
                                   foreach my $item ('width','height') {
                                       $toolhash{$item} =~ s/^\s+//;
                                       $toolhash{$item} =~ s/\s+$//;
                                   }
                               }
                           } elsif ($residx) {
                               $toolhash{'target'} = $toolsettings{'target'};
                               if ($toolhash{'target'} eq 'window') {
                                   $toolhash{'width'} = $toolsettings{'width'};
                                   $toolhash{'height'} = $toolsettings{'height'};  
                               }
                           } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {
                               $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};
                               if ($toolhash{'target'} eq 'window') {
                                   $toolhash{'width'} = $ltitoolsref->{$toolid}->{'display'}->{'width'};
                                   $toolhash{'height'} = $ltitoolsref->{$toolid}->{'display'}->{'height'};
                               }
                           }
                         if ($toolhash{'target'} eq 'iframe') {                          if ($toolhash{'target'} eq 'iframe') {
                             delete($toolhash{'width'});                              delete($toolhash{'width'});
                             delete($toolhash{'height'});                              delete($toolhash{'height'});
                         } elsif ($toolhash{'target'} eq 'window') {                              if ($residx) {
                             foreach my $item ('width','height') {                                  if ($toolsettings{'width'}) {
                                 $toolhash{$item} =~ s/^\s+//;                                      push(@deleted,'width');
                                 $toolhash{$item} =~ s/\s+$//;                                  }
                                   if ($toolsettings{'height'}) {
                                       push(@deleted,'height');
                                   }
                               }
                           }
                           if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
                               foreach my $item ('label','title') { 
                                   if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {
                                       $toolhash{'crs'.$item} =~ s/^\s+//;
                                       $toolhash{'crs'.$item} =~ s/\s+$//;
                                       if ($toolhash{'crs'.$item} eq '') {
                                           delete($toolhash{'crs'.$item});
                                       }
                                   } else {
                                       delete($toolhash{'crs'.$item});
                                   }
                                   if (($residx) && (exists($toolsettings{'crs'.$item}))) {
                                       unless (exists($toolhash{'crs'.$item})) {
                                           push(@deleted,'crs'.$item);
                                       }
                                   }
                             }                              }
                         }                          }
                         my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);                          my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
                           if ($putres eq 'ok') {
                               if (@deleted) {
                                   &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
                               } 
                           }
                     }                      }
                 }                  }
             }              }
Line 3020  sub editor { Line 3070  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 3429  sub process_file_upload { Line 3479  sub process_file_upload {
     }      }
     my $quotatype = 'unofficial';      my $quotatype = 'unofficial';
     if ($crstype eq 'Community') {      if ($crstype eq 'Community') {
         $quotatype = 'community';              $quotatype = 'community';
       } elsif ($crstype eq 'Placement') {
           $quotatype = 'placement';
     } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {      } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
         $quotatype = 'official';          $quotatype = 'official';
     } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {      } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
Line 3703  END Line 3755  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 3714  END Line 3767  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 3756  ENDCUT Line 3813  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 4990  sub handler { Line 5048  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 $exttoolurl = "/adm/$coursedom/$coursenum/new/exttool";              my $posslti = keys(%ltitools);
     $script .= &editing_js($udom,$uname,$supplementalflag).      $script .= &editing_js($udom,$uname,$supplementalflag,$posslti).
                        &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 5150  sub handler { Line 5208  sub handler {
     # file size to determine if upload should be allowed.      # file size to determine if upload should be allowed.
     my $quotatype = 'unofficial';      my $quotatype = 'unofficial';
     if ($crstype eq 'Community') {      if ($crstype eq 'Community') {
         $quotatype = 'community';              $quotatype = 'community';
       } elsif ($crstype eq 'Placement') {
           $quotatype = 'placement';
     } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {      } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
         $quotatype = 'official';          $quotatype = 'official';
     } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {      } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
Line 5164  sub handler { Line 5224  sub handler {
                                "userfiles/$subdir",1); # expressed in kB                                 "userfiles/$subdir",1); # expressed in kB
     }      }
     my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);      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" class="flUpload" size="40" />   <input type="file" name="uploaddoc" class="flUpload" size="40" />
     <input type="hidden" id="free_space" value="$free_space" />      <input type="hidden" id="free_space" value="$free_space" />
Line 5440  NROSTFORM Line 5514  NROSTFORM
         $help{'Web_Page'}          $help{'Web_Page'}
         </form>          </form>
 NWEBFORM  NWEBFORM
    
   
 my $specialdocumentsform;  my $specialdocumentsform;
 my @specialdocumentsforma;  my @specialdocumentsforma;
Line 6087  END Line 6161  END
 }  }
   
 sub editing_js {  sub editing_js {
     my ($udom,$uname,$supplementalflag) = @_;      my ($udom,$uname,$supplementalflag,$posslti) = @_;
     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 6098  sub editing_js { Line 6172  sub editing_js {
                                           p_msb => 'Title for the Problem',                                            p_msb => 'Title for the Problem',
                                           p_mdb => 'Title for the Drop Box',                                            p_mdb => 'Title for the Drop Box',
                                           p_mbb => 'Title for the Discussion Board',                                            p_mbb => 'Title for the Discussion Board',
                                           p_mwp => 'Title for Web Page',                                             p_mwp => 'Title for Web Page',
                                           p_mab => "Enter user:domain for User's Personal Information Page",                                            p_mab => "Enter user:domain for User's Personal Information Page",
                                           p_mab2 => 'Personal Information Page of ',                                            p_mab2 => 'Personal Information Page of ',
                                           p_mab_alrt1 => 'Not a valid user:domain',                                            p_mab_alrt1 => 'Not a valid user:domain',
                                           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 6161  sub editing_js { Line 6237  sub editing_js {
         $backtourl = '/adm/navmaps';          $backtourl = '/adm/navmaps';
     }      }
   
     my $fieldsets = "'ext','tool','doc'";      my $fieldsets = "'ext','doc'";
       if ($posslti) {
           $fieldsets .= ",'tool'";
       }
     unless ($main_container_page) {      unless ($main_container_page) {
         $fieldsets .=",'ims'";          $fieldsets .=",'ims'";
     }      }
     if ($supplementalflag) {      if ($supplementalflag) {
         $fieldsets = "'suppext','supptool','suppdoc'";          $fieldsets = "'suppext','suppdoc'";
           if ($posslti) {
               $fieldsets .= ",'supptool'";
           }
     }      }
   
     return <<ENDNEWSCRIPT;      return <<ENDNEWSCRIPT;
Line 6497  function propagateState(form,param) { Line 6579  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 6535  function checkForSubmit(targetform,param Line 6617  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 6792  function checkSubmits() { Line 6888  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 6806  function checkSubmits() { Line 6903  function checkSubmits() {
                                 remwarnings ++;                                  remwarnings ++;
                             }                              }
                         }                          }
                           if (document.getElementById('confirm_removal_'+remidxs[i])) {
                               if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
                                   removalinfo ++;
                               }
                           }
                     }                      }
                 }                  }
             }              }
Line 6904  function checkSubmits() { Line 7006  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.599  
changed lines
  Added in v.1.605


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