Diff for /loncom/interface/lonmodifycourse.pm between versions 1.60 and 1.61

version 1.60, 2013/03/01 05:01:26 version 1.61, 2013/07/09 00:17:23
Line 219  sub print_course_selection_page { Line 219  sub print_course_selection_page {
 sub print_modification_menu {  sub print_modification_menu {
     my ($r,$cdesc,$domdesc,$dom,$type) = @_;      my ($r,$cdesc,$domdesc,$dom,$type) = @_;
     &print_header($r,$type);      &print_header($r,$type);
     my ($ccrole,$categorytitle,$setquota_text,$setparams_text,$cat_text);      my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$setparams_text,$cat_text);
     if ($type eq 'Community') {      if ($type eq 'Community') {
         $ccrole = 'co';          $ccrole = 'co';
     } else {      } else {
         $ccrole = 'cc';          $ccrole = 'cc';
     }       }
     if ($type eq 'Community') {      if ($type eq 'Community') {
         $categorytitle = 'View/Modify Community Settings';          $categorytitle = 'View/Modify Community Settings';
         $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');          $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');
           $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a community via Content Editor.'); 
         $setparams_text = 'View/Modify community owner';          $setparams_text = 'View/Modify community owner';
         $cat_text = 'View/Modify catalog settings for community';          $cat_text = 'View/Modify catalog settings for community';
     } else {      } else {
         $categorytitle = 'View/Modify Course Settings';          $categorytitle = 'View/Modify Course Settings';
         $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');          $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');
           $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a course via Content Editor.');
         if (&showcredits($dom)) {          if (&showcredits($dom)) {
             $setparams_text = 'View/Modify course owner, institutional code, and default authentication and credits';              $setparams_text = 'View/Modify course owner, institutional code, and default authentication and credits';
         } else {          } else {
Line 261  sub print_modification_menu { Line 263  sub print_modification_menu {
                 linktitle => ''                  linktitle => ''
             },              },
             {              {
                 linktext => 'View/Modify quota for group portfolio files',                  linktext => 'View/Modify quotas for group portfolio files, and for uploaded content.',
                 url => &phaseurl('setquota'),                  url => &phaseurl('setquota'),
                 permission => 1,                  permission => 1,
                 #help => '',                  #help => '',
Line 317  sub print_modification_menu { Line 319  sub print_modification_menu {
         }          }
     }      }
     $menu_html .= '<li>'.$setquota_text.'</li>'.      $menu_html .= '<li>'.$setquota_text.'</li>'.
                     '<li>'.$setuploadquota_text.'</li>'.
                   '<li>'.$anon_text.'</li>'."\n";                    '<li>'.$anon_text.'</li>'."\n";
     foreach my $item (@additional_params) {      foreach my $item (@additional_params) {
         if ($type eq 'Community') {          if ($type eq 'Community') {
Line 420  sub print_settings_display { Line 423  sub print_settings_display {
   
 sub print_setquota {  sub print_setquota {
     my ($r,$cdom,$cnum,$cdesc,$type) = @_;      my ($r,$cdom,$cnum,$cdesc,$type) = @_;
       my $lctype = lc($type);
       my $headline = &mt("Set disk space quotas for $lctype: [_1]",
                        '<span class="LC_nobreak">'.$cdesc.'</span>');
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                 'cquo' => 'Disk space for storage of group portfolio files for:',                  'gpqu' => 'Disk space for storage of group portfolio files',
                 'gpqu' => 'Course portfolio files disk space',                  'upqu' => 'Disk space for storage of content directly uploaded to course via Content Editor',
                 'modi' => 'Save',                  'modi' => 'Save',
                 'back' => 'Pick another action',                  'back' => 'Pick another action',
     );      );
     if ($type eq 'Community') {      my %staticdefaults = (
         $lt{'gpqu'} = &mt('Community portfolio files disk space');                             coursequota   => 20,
     }                             uploadquota   => 500,
     my %settings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);                           );
       my %settings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota','internal.instcode'],
                                           $cdom,$cnum);
     my $coursequota = $settings{'internal.coursequota'};      my $coursequota = $settings{'internal.coursequota'};
       my $uploadquota = $settings{'internal.uploadquota'};
     if ($coursequota eq '') {      if ($coursequota eq '') {
         $coursequota = 20;          $coursequota = $staticdefaults{'coursequota'};
       }
       if ($uploadquota eq '') {
           my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
           if ($type eq 'Community') {
               $uploadquota = $domdefs{$lctype.'quota'};
           } elsif ($settings{'internal.instcode'}) {
               $uploadquota = $domdefs{'officialquota'};
           } else {
               $uploadquota = $domdefs{'unofficialquota'};
           }
           if ($uploadquota eq '') {
               $uploadquota = $staticdefaults{'uploadquota'};
           }
     }      }
     &print_header($r,$type);      &print_header($r,$type);
     my $hidden_elements = &hidden_form_elements();      my $hidden_elements = &hidden_form_elements();
     my $helpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota');      my $porthelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota');
       my $uploadhelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Upload_Quota');
     $r->print(<<ENDDOCUMENT);      $r->print(<<ENDDOCUMENT);
 <form action="/adm/modifycourse" method="post" name="setquota" onsubmit="return verify_quota();">  <form action="/adm/modifycourse" method="post" name="setquota" onsubmit="return verify_quota();">
 <h3>$lt{'cquo'} <span class="LC_nobreak">$cdesc</span></h3>  <h3>$headline</h3>
   <p><span class="LC_nobreak">
   $porthelpitem $lt{'gpqu'}: <input type="text" size="4" name="coursequota" value="$coursequota" /> MB
   </span>
   <br />
   <span class="LC_nobreak">
   $uploadhelpitem $lt{'upqu'}: <input type="text" size="4" name="uploadquota" value="$uploadquota" /> MB
   </span>
   </p>
 <p>  <p>
 $helpitem $lt{'gpqu'}: <input type="text" size="4" name="coursequota" value="$coursequota" /> Mb &nbsp;&nbsp;&nbsp;&nbsp;  
 <input type="submit" value="$lt{'modi'}" />  <input type="submit" value="$lt{'modi'}" />
 </p>  </p>
 $hidden_elements  $hidden_elements
Line 1126  sub update_coowners { Line 1156  sub update_coowners {
 sub modify_quota {  sub modify_quota {
     my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;      my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
     &print_header($r,$type);      &print_header($r,$type);
       my $lctype = lc($type);
       my $headline = &mt("Disk space quotas for $lctype: [_1]",
                        '<span class="LC_nobreak">'.$cdesc.'</span>');
     $r->print('<form action="/adm/modifycourse" method="post" name="processquota">'."\n".      $r->print('<form action="/adm/modifycourse" method="post" name="processquota">'."\n".
               '<h3>'.&mt('Disk space for storage of group portfolio files for:').                '<h3>'.$headline.'</h3>');
               ' <span class="LC_nobreak">'.$cdesc.'</span></h3><br />');      my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
     my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);      my %staticdefaults = (
     my $defaultquota = 20;                             coursequota   => 20,
     if ($env{'form.coursequota'} ne '') {                             uploadquota   => 500,
         my $newquota = $env{'form.coursequota'};                           );
         if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {      my %default;
             $newquota = $1;      $default{'coursequota'} = $staticdefaults{'coursequota'};
             if ($oldsettings{'internal.coursequota'} eq $env{'form.coursequota'}) {      my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
                 $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] Mb.',$env{'form.coursequota'}));      $default{'uploadquota'} = $domdefs{'uploadquota'};
       if ($default{'uploadquota'} eq '') {
           $default{'uploadquota'} = $staticdefaults{'uploadquota'};
       }
       my (%cenv,%showresult);
       foreach my $item ('coursequota','uploadquota') {
           if ($env{'form.'.$item} ne '') {
               my $newquota = $env{'form.'.$item};
               if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
                   $newquota = $1;
                   if ($oldsettings{'internal.'.$item} == $newquota) {
                       if ($item eq 'coursequota') {
                           $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] MB.',$newquota).'<br />');
                       } else {
                           $r->print(&mt('The disk space allocated for files uploaded via the Content Editor remains unchanged as [_1] MB.',$newquota).'<br />');
                       }
                   } else {
                       $cenv{'internal.'.$item} = $newquota;
                       $showresult{$item} = 1;
                   }
             } else {              } else {
                 my %cenv = (                  if ($item eq 'coursequota') { 
                            'internal.coursequota' => $env{'form.coursequota'},                      $r->print(&mt('The proposed group portfolio quota contained invalid characters, so the quota is unchanged.').'<br />');
                            );                  } else {
                 my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,                      $r->print(&mt('The proposed quota for content uploaded via the Content Editor contained invalid characters, so the quota is unchanged.').'<br />');
                                                     $cnum);  
                 if (($oldsettings{'internal.coursequota'} eq '') &&                   }
                     ($env{'form.coursequota'} == $defaultquota)) {              }
           }
       }
       if (keys(%cenv)) {
           my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
                                               $cnum);
           foreach my $key (sort(keys(%showresult))) {
               if (($oldsettings{'internal.'.$key} eq '') && 
                   ($env{'form.'.$key} == $default{$key})) {
                   if ($key eq 'uploadquota') {
                     if ($type eq 'Community') {                      if ($type eq 'Community') {
                          $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] Mb.',$defaultquota));                          $r->print(&mt('The disk space allocated for files uploaded to this community via the Content Editor is the default quota for this domain: [_1] MB.',
                                         $default{$key}).'<br />');
                     } else {                      } else {
                          $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] Mb.',$defaultquota));                          $r->print(&mt('The disk space allocated for files uploaded to this course via the Content Editor is the default quota for this domain: [_1] MB.',
                                         $default{$key}).'<br />');
                     }                      }
                 } else {                  } else { 
                     if ($putreply eq 'ok') {                      if ($type eq 'Community') {
                         my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);                          $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] MB.',
                         $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] Mb.','<b>'.$updatedsettings{'internal.coursequota'}.'</b>'));                                        $default{$key}).'<br />');
                         my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);  
                         if ($usage >= $updatedsettings{'internal.coursequota'}) {  
                             my $newoverquota;  
                             if ($usage < $oldsettings{'internal.coursequota'}) {  
                                 $newoverquota = 'now';  
                             }  
                             $r->print('<p>');  
                             if ($type eq 'Community') {  
                                 $r->print(&mt('Disk usage [_1] exceeds the quota for this community.',$newoverquota).' '.  
                                           &mt('Upload of new portfolio files and assignment of a non-zero Mb quota to new groups in the community will not be possible until some files have been deleted, and total usage is below community quota.'));  
                             } else {  
                                 $r->print(&mt('Disk usage [_1] exceeds the quota for this course.',$newoverquota).' '.  
                                           &mt('Upload of new portfolio files and assignment of a non-zero Mb quota to new groups in the course will not be possible until some files have been deleted, and total usage is below course quota.'));  
                             }  
                             $r->print('</p>');  
                         }  
                     } else {                      } else {
                         $r->print(&mt('An error occurred storing the quota for group portfolio files: ').                          $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] MB.',
                                   $putreply);                                        $default{$key}).'<br />');
                     }                      }
                 }                  }
                   delete($showresult{$key});
               }
           }
           if ($putreply eq 'ok') {
               my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
               if ($showresult{'coursequota'}) {
                   $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] MB.',
                                 '<b>'.$updatedsettings{'internal.coursequota'}.'</b>').'<br />');
                   my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
                   if ($usage >= $updatedsettings{'internal.coursequota'}) {
                       my $newoverquota;
                       if ($usage < $oldsettings{'internal.coursequota'}) {
                           $newoverquota = 'now';
                       }
                       $r->print('<p>');
                       if ($type eq 'Community') {
                           $r->print(&mt('Disk usage [_1] exceeds the quota for this community.',$newoverquota).' '.
                                     &mt('Upload of new portfolio files and assignment of a non-zero MB quota to new groups in the community will not be possible until some files have been deleted, and total usage is below community quota.'));
                       } else {
                           $r->print(&mt('Disk usage [_1] exceeds the quota for this course.',$newoverquota).' '.
                                     &mt('Upload of new portfolio files and assignment of a non-zero MB quota to new groups in the course will not be possible until some files have been deleted, and total usage is below course quota.'));
                       }
                       $r->print('</p>');
                   }
               }
               if ($showresult{'uploadquota'}) {
                   $r->print(&mt('The disk space allocated for content uploaded directly via the Content Editor is now: [_1] MB.',
                                 '<b>'.$updatedsettings{'internal.uploadquota'}.'</b>').'<br />');
             }              }
         } else {          } else {
             $r->print(&mt('The new quota requested contained invalid characters, so the quota is unchanged.'));              $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content.').
                         $putreply);
         }          }
     }      }
     $r->print('<p>'.      $r->print('<p>'.
Line 1552  sub hidden_form_elements { Line 1628  sub hidden_form_elements {
       &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',        &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
           'prevphase','numlocalcc','courseowner','login','coursequota','intarg',            'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
           'locarg','krbarg','krbver','counter','hidefromcat','usecategory',            'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
           'threshold','defaultcredits'])."\n".            'threshold','defaultcredits','uploadquota'])."\n".
           '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';            '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
     return $hidden_elements;      return $hidden_elements;
 }  }

Removed from v.1.60  
changed lines
  Added in v.1.61


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