[LON-CAPA-cvs] cvs: loncom /imspackages imsimport.pm /interface domainprefs.pm loncommon.pm loncreateuser.pm lonhtmlcommon.pm portfolio.pm /lonnet/perl lonnet.pm /publisher lonpubdir.pm lonupload.pm testbankimport.pm

raeburn raeburn at source.lon-capa.org
Tue Jul 2 15:04:56 EDT 2013


raeburn		Tue Jul  2 19:04:56 2013 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm loncommon.pm loncreateuser.pm 
                     	lonhtmlcommon.pm portfolio.pm 
    /loncom/imspackages	imsimport.pm 
    /loncom/publisher	lonupload.pm lonpubdir.pm testbankimport.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Disk quotas for authoring spaces.
    - Default is 500 MB, unless set at domain level, or individual user level. 
    - Domain default set via "Blogs, personal web pages, webDAV/quotas, portfolio" in
      "Set domain configuration" by DC.
    - Quota for individual user's authoring space set via: 
      "Create users or modify the roles and privileges of users" by DC
    - &display_usage() moved from portfolio.pm to lonhtmlcommon.pm to
      facilitate re-use. In portfolio.pm &display_portfolio_usage() now calls
      lonhtmlcommon::display_usage().
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.196 loncom/interface/domainprefs.pm:1.197
--- loncom/interface/domainprefs.pm:1.196	Tue Jun  4 23:12:08 2013
+++ loncom/interface/domainprefs.pm	Tue Jul  2 19:04:36 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.196 2013/06/04 23:12:08 raeburn Exp $
+# $Id: domainprefs.pm,v 1.197 2013/07/02 19:04:36 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -94,7 +94,8 @@
 institutional affiliation in the domain (e.g., Faculty, Staff, Student etc.), 
 but is now also used to manage availability of user tools: 
 i.e., blogs, aboutme page, and portfolios, and the course request tool,
-used by course owners to request creation of a course.
+used by course owners to request creation of a course, and to display/store
+default quota sizes for authoring spaces.
 
 Outputs: 1
 
@@ -254,11 +255,11 @@
                                   col2 => 'Value'}],
                     },
         'quotas' => 
-                    { text => 'Blogs, personal web pages, webDAV, portfolios',
+                    { text => 'Blogs, personal web pages, webDAV/quotas, portfolios',
                       help => 'Domain_Configuration_Quotas',
                       header => [{col1 => 'User affiliation',
                                   col2 => 'Available tools',
-                                  col3 => 'Portfolio quota',}],
+                                  col3 => 'Quotas, Mb; (Authoring requires role)',}],
                     },
         'autoenroll' =>
                    { text => 'Auto-enrollment settings',
@@ -1524,7 +1525,7 @@
     } else {
         $context = $action;
     }
-    my ($datatable,$defaultquota, at usertools, at options,%validations);
+    my ($datatable,$defaultquota,$authorquota, at usertools, at options,%validations);
     my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
     my $typecount = 0;
     my ($css_class,%titles);
@@ -1543,15 +1544,18 @@
     }
     if (ref($types) eq 'ARRAY') {
         foreach my $type (@{$types}) {
-            my $currdefquota;
+            my ($currdefquota,$currauthorquota);
             unless (($context eq 'requestcourses') ||
                     ($context eq 'requestauthor')) {
                 if (ref($settings) eq 'HASH') {
                     if (ref($settings->{defaultquota}) eq 'HASH') {
-                        $currdefquota = $settings->{defaultquota}->{$type}; 
+                        $currdefquota = $settings->{defaultquota}->{$type};
                     } else {
                         $currdefquota = $settings->{$type};
                     }
+                    if (ref($settings->{authorquota}) eq 'HASH') {
+                        $currauthorquota = $settings->{authorquota}->{$type};
+                    }
                 }
             }
             if (defined($usertypes->{$type})) {
@@ -1665,10 +1669,15 @@
                 unless (($context eq 'requestcourses') ||
                         ($context eq 'requestauthor')) {
                     $datatable .= 
-                              '<td class="LC_right_item"><span class="LC_nobreak">'.
+                              '<td class="LC_right_item">'.
+                              '<span class="LC_nobreak">'.&mt('Portfolio').': '.
                               '<input type="text" name="quota_'.$type.
                               '" value="'.$currdefquota.
-                              '" size="5" /> Mb</span></td>';
+                              '" size="5" /></span>'.(' ' x 2).
+                              '<span class="LC_nobreak">'.&mt('Authoring').': '.
+                              '<input type="text" name="authorquota_'.$type.
+                              '" value="'.$currauthorquota.
+                              '" size="5" /></span></td>';
                 }
                 $datatable .= '</tr>';
             }
@@ -1676,12 +1685,16 @@
     }
     unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
         $defaultquota = '20';
+        $authorquota = '500';
         if (ref($settings) eq 'HASH') {
             if (ref($settings->{'defaultquota'}) eq 'HASH') {
                 $defaultquota = $settings->{'defaultquota'}->{'default'};
             } elsif (defined($settings->{'default'})) {
                 $defaultquota = $settings->{'default'};
             }
+            if (ref($settings->{'authorquota'}) eq 'HASH') {
+                $authorquota = $settings->{'authorquota'}->{'default'};
+            }
         }
     }
     $typecount ++;
@@ -1792,15 +1805,19 @@
     }
     $datatable .= '</td>';
     unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
-        $datatable .= '<td class="LC_right_item"><span class="LC_nobreak">'.
+        $datatable .= '<td class="LC_right_item">'.
+                      '<span class="LC_nobreak">'.&mt('Portfolio').': '.
                       '<input type="text" name="defaultquota" value="'.
-                      $defaultquota.'" size="5" /> Mb</span></td>';
+                      $defaultquota.'" size="5" /></span>'.(' ' x2).
+                      '<span class="LC_nobreak">'.&mt('Authoring').': '.
+                      '<input type="text" name="authorquota" value="'.
+                      $authorquota.'" size="5" /></span></td>';
     }
     $datatable .= '</tr>';
     $typecount ++;
     $css_class = $typecount%2?' class="LC_odd_row"':'';
     $datatable .= '<tr'.$css_class.'>'.
-                  '<td>'.&mt('LON-CAPA Advanced Users').' ';
+                  '<td>'.&mt('LON-CAPA Advanced Users').'<br />';
     if ($context eq 'requestcourses') {
         $datatable .= &mt('(overrides affiliation, if set)').
                       '</td>'.
@@ -5740,8 +5757,9 @@
         } else {
             if ($key =~ /^form\.quota_(.+)$/) {
                 $confhash{'defaultquota'}{$1} = $env{$key};
-            }
-            if ($key =~ /^form\.\Q$context\E_(.+)$/) {
+            } elsif ($key =~ /^form\.authorquota_(.+)$/) {
+                $confhash{'authorquota'}{$1} = $env{$key};
+            } elsif ($key =~ /^form\.\Q$context\E_(.+)$/) {
                 @{$toolshash{$1}} = &Apache::loncommon::get_env_multiple($key);
             }
         }
@@ -5767,6 +5785,7 @@
         }
     } else {
         $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
+        $confhash{'authorquota'}{'default'} = $env{'form.authorquota'};
     }
     foreach my $item (@usertools) {
         foreach my $type (@{$types},'default','_LC_adv') {
@@ -5854,6 +5873,17 @@
                     }
                 }
             }
+            if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') {
+                foreach my $key (keys(%{$domconfig{'quotas'}{'authorquota'}})) {
+                    if (exists($confhash{'authorquota'}{$key})) {
+                        if ($confhash{'authorquota'}{$key} ne $domconfig{'quotas'}{'authorquota'}{$key}) {
+                            $changes{'authorquota'}{$key} = 1;
+                        }
+                    } else {
+                        $confhash{'authorquota'}{$key} = $domconfig{'quotas'}{'authorquota'}{$key};
+                    }
+                }
+            }
         }
         if (ref($confhash{'defaultquota'}) eq 'HASH') {
             foreach my $key (keys(%{$confhash{'defaultquota'}})) {
@@ -5872,6 +5902,21 @@
                 }
             }
         }
+        if (ref($confhash{'authorquota'}) eq 'HASH') {
+            foreach my $key (keys(%{$confhash{'authorquota'}})) {
+                if (ref($domconfig{'quotas'}) eq 'HASH') {
+                    if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') {
+                        if (!exists($domconfig{'quotas'}{'authorquota'}{$key})) {
+                            $changes{'authorquota'}{$key} = 1;
+                        }
+                    } else {
+                        $changes{'authorquota'}{$key} = 1;
+                    }
+                } else {
+                    $changes{'authorquota'}{$key} = 1;
+                }
+            }
+        }
     }
 
     if ($context eq 'requestauthor') {
@@ -5908,6 +5953,19 @@
                     }
                     $resulttext .= '</ul></li>';
                 }
+                if (ref($changes{'authorquota'}) eq 'HASH') {
+                    $resulttext .= '<li>'.&mt('Authoring space default quotas').'<ul>';
+                    foreach my $type (@{$types},'default') {
+                        if (defined($changes{'authorquota'}{$type})) {
+                            my $typetitle = $usertypes->{$type};
+                            if ($type eq 'default') {
+                                $typetitle = $othertitle;
+                            }
+                            $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$confhash{'authorquota'}{$type}).'</li>';
+                        }
+                    }
+                    $resulttext .= '</ul></li>';
+                }
             }
             my %newenv;
             foreach my $item (@usertools) {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1133 loncom/interface/loncommon.pm:1.1134
--- loncom/interface/loncommon.pm:1.1133	Wed Jun  5 12:39:34 2013
+++ loncom/interface/loncommon.pm	Tue Jul  2 19:04:36 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1133 2013/06/05 12:39:34 raeburn Exp $
+# $Id: loncommon.pm,v 1.1134 2013/07/02 19:04:36 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -8561,11 +8561,14 @@
 
 =item * &get_user_quota()
 
-Retrieves quota assigned for storage of portfolio files for a user  
+Retrieves quota assigned for storage of user files.
+Default is to report quota for portfolio files.
 
 Incoming parameters:
 1. user's username
 2. user's domain
+3. quota name - portfolio, author, or course
+   (if no quota name provided, defaults to portfolio).  
 
 Returns:
 1. Disk quota (in Mb) assigned to student.
@@ -8579,7 +8582,7 @@
 
 If a value has been stored in the user's environment, 
 it will return that, otherwise it returns the maximal default
-defined for the user's instituional status(es) in the domain.
+defined for the user's institutional status(es) in the domain.
 
 =cut
 
@@ -8587,7 +8590,7 @@
 
 
 sub get_user_quota {
-    my ($uname,$udom) = @_;
+    my ($uname,$udom,$quotaname) = @_;
     my ($quota,$quotatype,$settingstatus,$defquota);
     if (!defined($udom)) {
         $udom = $env{'user.domain'};
@@ -8602,27 +8605,52 @@
         $defquota = 0; 
     } else {
         my $inststatus;
-        if ($udom eq $env{'user.domain'} && $uname eq $env{'user.name'}) {
-            $quota = $env{'environment.portfolioquota'};
-            $inststatus = $env{'environment.inststatus'};
-        } else {
-            my %userenv = 
-                &Apache::lonnet::get('environment',['portfolioquota',
-                                     'inststatus'],$udom,$uname);
-            my ($tmp) = keys(%userenv);
-            if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
-                $quota = $userenv{'portfolioquota'};
-                $inststatus = $userenv{'inststatus'};
-            } else {
-                undef(%userenv);
-            }
-        }
-        ($defquota,$settingstatus) = &default_quota($udom,$inststatus);
-        if ($quota eq '') {
-            $quota = $defquota;
-            $quotatype = 'default';
+        if ($quotaname eq 'course') {
+            if (($env{'course.'.$udom.'_'.$uname.'.num'} eq $uname) &&
+                ($env{'course.'.$udom.'_'.$uname.'.domain'} eq $udom)) {
+                $quota = $env{'course.'.$udom.'_'.$uname.'.internal.uploadquota'};
+            } else {
+                my %cenv = &Apache::lonnet::coursedescription("$udom/$uname");
+                $quota = $cenv{'internal.uploadquota'};
+            }
         } else {
-            $quotatype = 'custom';
+            if ($udom eq $env{'user.domain'} && $uname eq $env{'user.name'}) {
+                if ($quotaname eq 'author') {
+                    $quota = $env{'environment.authorquota'};
+                } else {
+                    $quota = $env{'environment.portfolioquota'};
+                }
+                $inststatus = $env{'environment.inststatus'};
+            } else {
+                my %userenv = 
+                    &Apache::lonnet::get('environment',['portfolioquota',
+                                         'authorquota','inststatus'],$udom,$uname);
+                my ($tmp) = keys(%userenv);
+                if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
+                    if ($quotaname eq 'author') {
+                        $quota = $userenv{'authorquota'};
+                    } else {
+                        $quota = $userenv{'portfolioquota'};
+                    }
+                    $inststatus = $userenv{'inststatus'};
+                } else {
+                    undef(%userenv);
+                }
+            }
+        }
+        if ($quota eq '' || wantarray) {
+            if ($quotaname eq 'course') {
+                my %domdefs = &Apache::lonnet::get_domain_defaults($udom);
+                $defquota = $domdefs{'uploadquota'};
+            } else {
+                ($defquota,$settingstatus) = &default_quota($udom,$inststatus,$quotaname);
+            }
+            if ($quota eq '') {
+                $quota = $defquota;
+                $quotatype = 'default';
+            } else {
+                $quotatype = 'custom';
+            }
         }
     }
     if (wantarray) {
@@ -8647,7 +8675,9 @@
    status types (e.g., faculty, staff, student etc.)
    which apply to the user for whom the default is being retrieved.
    If the institutional status string in undefined, the domain
-   default quota will be returned. 
+   default quota will be returned.
+3.  quota name - portfolio, author, or course
+   (if no quota name provided, defaults to portfolio).
 
 Returns:
 1. Default disk quota (in Mb) for user portfolios in the domain.
@@ -8671,25 +8701,29 @@
 
 
 sub default_quota {
-    my ($udom,$inststatus) = @_;
+    my ($udom,$inststatus,$quotaname) = @_;
     my ($defquota,$settingstatus);
     my %quotahash = &Apache::lonnet::get_dom('configuration',
                                             ['quotas'],$udom);
+    my $key = 'defaultquota';
+    if ($quotaname eq 'author') {
+        $key = 'authorquota';
+    }
     if (ref($quotahash{'quotas'}) eq 'HASH') {
         if ($inststatus ne '') {
             my @statuses = map { &unescape($_); } split(/:/,$inststatus);
             foreach my $item (@statuses) {
-                if (ref($quotahash{'quotas'}{'defaultquota'}) eq 'HASH') {
-                    if ($quotahash{'quotas'}{'defaultquota'}{$item} ne '') {
+                if (ref($quotahash{'quotas'}{$key}) eq 'HASH') {
+                    if ($quotahash{'quotas'}{$key}{$item} ne '') {
                         if ($defquota eq '') {
-                            $defquota = $quotahash{'quotas'}{'defaultquota'}{$item};
+                            $defquota = $quotahash{'quotas'}{$key}{$item};
                             $settingstatus = $item;
-                        } elsif ($quotahash{'quotas'}{'defaultquota'}{$item} > $defquota) {
-                            $defquota = $quotahash{'quotas'}{'defaultquota'}{$item};
+                        } elsif ($quotahash{'quotas'}{$key}{$item} > $defquota) {
+                            $defquota = $quotahash{'quotas'}{$key}{$item};
                             $settingstatus = $item;
                         }
                     }
-                } else {
+                } elsif ($key eq 'defaultquota') {
                     if ($quotahash{'quotas'}{$item} ne '') {
                         if ($defquota eq '') {
                             $defquota = $quotahash{'quotas'}{$item};
@@ -8703,16 +8737,20 @@
             }
         }
         if ($defquota eq '') {
-            if (ref($quotahash{'quotas'}{'defaultquota'}) eq 'HASH') {
-                $defquota = $quotahash{'quotas'}{'defaultquota'}{'default'};
-            } else {
+            if (ref($quotahash{'quotas'}{$key}) eq 'HASH') {
+                $defquota = $quotahash{'quotas'}{$key}{'default'};
+            } elsif ($key eq 'defaultquota') {
                 $defquota = $quotahash{'quotas'}{'default'};
             }
             $settingstatus = 'default';
         }
     } else {
         $settingstatus = 'default';
-        $defquota = 20;
+        if ($quotaname eq 'author') {
+            $defquota = 500;
+        } else {
+            $defquota = 20;
+        }
     }
     if (wantarray) {
         return ($defquota,$settingstatus);
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.377 loncom/interface/loncreateuser.pm:1.378
--- loncom/interface/loncreateuser.pm:1.377	Tue Jun  4 23:12:08 2013
+++ loncom/interface/loncreateuser.pm	Tue Jul  2 19:04:37 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.377 2013/06/04 23:12:08 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.378 2013/07/02 19:04:37 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -122,66 +122,42 @@
 
 # ====================================================
 
-sub portfolio_quota {
+sub user_quotas {
     my ($ccuname,$ccdomain) = @_;
     my %lt = &Apache::lonlocal::texthash(
                    'usrt'      => "User Tools",
-                   'disk'      => "Disk space allocated to user's portfolio files",
                    'cuqu'      => "Current quota",
                    'cust'      => "Custom quota",
                    'defa'      => "Default",
                    'chqu'      => "Change quota",
     );
-    my ($currquota,$quotatype,$inststatus,$defquota) = 
-        &Apache::loncommon::get_user_quota($ccuname,$ccdomain);
-    my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain);
-    my ($longinsttype,$showquota,$custom_on,$custom_off,$defaultinfo);
-    if ($inststatus ne '') {
-        if ($usertypes->{$inststatus} ne '') {
-            $longinsttype = $usertypes->{$inststatus};
-        }
-    }
-    $custom_on = ' ';
-    $custom_off = ' checked="checked" ';
+   
     my $quota_javascript = <<"END_SCRIPT";
 <script type="text/javascript">
 // <![CDATA[
-function quota_changes(caller) {
+function quota_changes(caller,context) {
+    var customoff = document.getElementById('custom_'+context+'quota_off');
+    var customon = document.getElementById('custom_'+context+'quota_on');
+    var number = document.getElementById(context+'quota');
     if (caller == "custom") {
-        if (document.cu.customquota[0].checked) {
-            document.cu.portfolioquota.value = "";
+        if (customoff) {
+            if (customoff.checked) {
+                number.value = "";
+            }
         }
     }
     if (caller == "quota") {
-        document.cu.customquota[1].checked = true;
+        if (customon) {
+            customon.checked = true;
+        }
     }
+    return;
 }
 // ]]>
 </script>
 END_SCRIPT
-    if ($quotatype eq 'custom') {
-        $custom_on = $custom_off;
-        $custom_off = ' ';
-        $showquota = $currquota;
-        if ($longinsttype eq '') {
-            $defaultinfo = &mt('For this user, the default quota would be [_1]'
-                            .' Mb.',$defquota);
-        } else {
-            $defaultinfo = &mt("For this user, the default quota would be [_1]".
-                               " Mb, as determined by the user's institutional".
-                               " affiliation ([_2]).",$defquota,$longinsttype);
-        }
-    } else {
-        if ($longinsttype eq '') {
-            $defaultinfo = &mt('For this user, the default quota is [_1]'
-                            .' Mb.',$defquota);
-        } else {
-            $defaultinfo = &mt("For this user, the default quota of [_1]".
-                               " Mb, is determined by the user's institutional".
-                               " affiliation ([_2]).",$defquota,$longinsttype);
-        }
-    }
-
+    my $longinsttype;
+    my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain);
     my $output = $quota_javascript."\n".
                  '<h3>'.$lt{'usrt'}.'</h3>'."\n".
                  &Apache::loncommon::start_data_table();
@@ -189,29 +165,71 @@
     if (&Apache::lonnet::allowed('mut',$ccdomain)) {
         $output .= &build_tools_display($ccuname,$ccdomain,'tools');
     }
-    if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
-        $output .= '<tr class="LC_info_row">'."\n".
-                   '    <td>'.$lt{'disk'}.'</td>'."\n".
-                   '  </tr>'."\n".
-                   &Apache::loncommon::start_data_table_row()."\n".
-                   '  <td>'.$lt{'cuqu'}.': '.
-                   $currquota.' Mb.  '.
-                   $defaultinfo.'</td>'."\n".
-                   &Apache::loncommon::end_data_table_row()."\n".
-                   &Apache::loncommon::start_data_table_row()."\n".
-                   '  <td><span class="LC_nobreak">'.$lt{'chqu'}.
-                   ': <label>'.
-                   '<input type="radio" name="customquota" value="0" '.
-                   $custom_off.' onchange="javascript:quota_changes('."'custom'".')"'.
-                   ' />'.$lt{'defa'}.' ('.$defquota.' Mb).</label> '.
-                   ' <label><input type="radio" name="customquota" value="1" '. 
-                   $custom_on.'  onchange="javascript:quota_changes('."'custom'".')" />'.
-                   $lt{'cust'}.':</label> '.
-                   '<input type="text" name="portfolioquota" size ="5" value="'.
-                   $showquota.'" onfocus="javascript:quota_changes('."'quota'".')" '.
-                   '/> Mb</span></td>'."\n".
-                   &Apache::loncommon::end_data_table_row()."\n";
-    }  
+
+    my %titles = &Apache::lonlocal::texthash (
+                    portfolio => "Disk space allocated to user's portfolio files",
+                    author    => "Disk space allocated to user's authoring space (if role assigned)",
+                 );
+    foreach my $name ('portfolio','author') {
+        my ($currquota,$quotatype,$inststatus,$defquota) =
+            &Apache::loncommon::get_user_quota($ccuname,$ccdomain,$name);
+        if ($longinsttype eq '') { 
+            if ($inststatus ne '') {
+                if ($usertypes->{$inststatus} ne '') {
+                    $longinsttype = $usertypes->{$inststatus};
+                }
+            }
+        }
+        my ($showquota,$custom_on,$custom_off,$defaultinfo);
+        $custom_on = ' ';
+        $custom_off = ' checked="checked" ';
+        if ($quotatype eq 'custom') {
+            $custom_on = $custom_off;
+            $custom_off = ' ';
+            $showquota = $currquota;
+            if ($longinsttype eq '') {
+                $defaultinfo = &mt('For this user, the default quota would be [_1]'
+                              .' Mb.',$defquota);
+            } else {
+                $defaultinfo = &mt("For this user, the default quota would be [_1]".
+                                   " Mb, as determined by the user's institutional".
+                                   " affiliation ([_2]).",$defquota,$longinsttype);
+            }
+        } else {
+            if ($longinsttype eq '') {
+                $defaultinfo = &mt('For this user, the default quota is [_1]'
+                              .' Mb.',$defquota);
+            } else {
+                $defaultinfo = &mt("For this user, the default quota of [_1]".
+                                   " Mb, is determined by the user's institutional".
+                                   " affiliation ([_2]).",$defquota,$longinsttype);
+            }
+        }
+
+        if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
+            $output .= '<tr class="LC_info_row">'."\n".
+                       '    <td>'.$titles{$name}.'</td>'."\n".
+                       '  </tr>'."\n".
+                       &Apache::loncommon::start_data_table_row()."\n".
+                       '  <td>'.$lt{'cuqu'}.': '.
+                       $currquota.' Mb.  '.
+                       $defaultinfo.'</td>'."\n".
+                       &Apache::loncommon::end_data_table_row()."\n".
+                       &Apache::loncommon::start_data_table_row()."\n".
+                       '  <td><span class="LC_nobreak">'.$lt{'chqu'}.
+                       ': <label>'.
+                       '<input type="radio" name="custom_'.$name.'quota" id="custom_'.$name.'quota_off" '.
+                       'value="0" '.$custom_off.' onchange="javascript:quota_changes('."'custom','$name'".')"'.
+                       ' />'.$lt{'defa'}.' ('.$defquota.' Mb).</label> '.
+                       ' <label><input type="radio" name="custom_'.$name.'quota" id="custom_'.$name.'quota_on" '.
+                       'value="1" '.$custom_on.'  onchange="javascript:quota_changes('."'custom'".')";'.
+                       ' />'.$lt{'cust'}.':</label> '.
+                       '<input type="text" name="'.$name.'quota" size ="5" value="'.
+                       $showquota.'" onfocus="javascript:quota_changes('."'quota','$name'".')"'.
+                       ' /> Mb</span></td>'."\n".
+                       &Apache::loncommon::end_data_table_row()."\n";
+        }
+    }
     $output .= &Apache::loncommon::end_data_table();
     return $output;
 }
@@ -1205,7 +1223,7 @@
         if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||
             (&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) {
             # Current user has quota or user tools modification privileges
-            $portfolioform = '<br />'.&portfolio_quota($ccuname,$ccdomain);
+            $portfolioform = '<br />'.&user_quotas($ccuname,$ccdomain);
         }
         if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) {
             $domroleform = '<br />'.&domainrole_req($ccuname,$ccdomain);
@@ -1381,16 +1399,13 @@
         if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
             (&Apache::lonnet::allowed('mut',$ccdomain))) {
             # Current user has quota modification privileges
-            $user_text{'quota'} = &portfolio_quota($ccuname,$ccdomain);
+            $user_text{'quota'} = &user_quotas($ccuname,$ccdomain);
         }
         if (!&Apache::lonnet::allowed('mpq',$ccdomain)) {
             if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
-                # Get the user's portfolio information
-                my %portq = &Apache::lonnet::get('environment',['portfolioquota'],
-                                                 $ccdomain,$ccuname);
                 my %lt=&Apache::lonlocal::texthash(
-                    'dska'  => "Disk space allocated to user's portfolio files",
-                    'youd'  => "You do not have privileges to modify the portfolio quota for this user.",
+                    'dska'  => "Disk quotas for user's portfolio and authoring space",
+                    'youd'  => "You do not have privileges to modify the portfolio and/or authoring space quotas for this user.",
                     'ichr'  => "If a change is required, contact a domain coordinator for the domain",
                 );
                 $user_text{'quota'} = <<ENDNOPORTPRIV;
@@ -2557,14 +2572,18 @@
         my (%changeHash,%newcustom,%changed,%changedinfo);
         if ($uhome ne 'no_host') {
             if ($context eq 'domain') {
-                if ($env{'form.customquota'} == 1) {
-                    if ($env{'form.portfolioquota'} eq '') {
-                        $newcustom{'quota'} = 0;
-                    } else {
-                        $newcustom{'quota'} = $env{'form.portfolioquota'};
-                        $newcustom{'quota'} =~ s/[^\d\.]//g;
+                foreach my $name ('portfolio','author') {
+                    if ($env{'form.custom_'.$name.'quota'} == 1) {
+                        if ($env{'form.'.$name.'quota'} eq '') {
+                            $newcustom{$name.'quota'} = 0;
+                        } else {
+                            $newcustom{$name.'quota'} = $env{'form.'.$name.'quota'};
+                            $newcustom{$name.'quota'} =~ s/[^\d\.]//g;
+                        }
+                        if (&quota_admin($newcustom{$name.'quota'},\%changeHash,$name)) {
+                            $changed{$name.'quota'} = 1;
+                        }
                     }
-                    $changed{'quota'} = &quota_admin($newcustom{'quota'},\%changeHash);
                 }
                 foreach my $item (@usertools) {
                     if ($env{'form.custom'.$item} == 1) {
@@ -2649,8 +2668,8 @@
         # Check for need to change
         my %userenv = &Apache::lonnet::get
             ('environment',['firstname','middlename','lastname','generation',
-             'id','permanentemail','portfolioquota','inststatus','tools.aboutme',
-             'tools.blog','tools.webdav','tools.portfolio',
+             'id','permanentemail','portfolioquota','authorquota','inststatus',
+             'tools.aboutme','tools.blog','tools.webdav','tools.portfolio',
              'requestcourses.official','requestcourses.unofficial',
              'requestcourses.community','reqcrsotherdom.official',
              'reqcrsotherdom.unofficial','reqcrsotherdom.community',
@@ -2776,10 +2795,10 @@
                 }
             }
         }
-        my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus,
-            $newinststatus,$oldisdefault,$newisdefault,%oldsettings,
+        my (%quotachanged,%oldquota,%newquota,%olddefquota,%newdefquota, 
+            $oldinststatus,$newinststatus,%oldisdefault,%newisdefault,%oldsettings,
             %oldsettingstext,%newsettings,%newsettingstext, at disporder,
-            $olddefquota,$oldsettingstatus,$newdefquota,$newsettingstatus);
+            %oldsettingstatus,%newsettingstatus);
         @disporder = ('inststatus');
         if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) {
             push(@disporder,'requestcourses','requestauthor');
@@ -2788,9 +2807,11 @@
         }
         push(@disporder,('quota','tools'));
         $oldinststatus = $userenv{'inststatus'};
-        ($olddefquota,$oldsettingstatus) = 
-            &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus);
-        ($newdefquota,$newsettingstatus) = ($olddefquota,$oldsettingstatus);
+        foreach my $name ('portfolio','author') {
+            ($olddefquota{$name},$oldsettingstatus{$name}) = 
+                &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus,$name);
+            ($newdefquota{$name},$newsettingstatus{$name}) = ($olddefquota{$name},$oldsettingstatus{$name});
+        }
         my %canshow;
         if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
             $canshow{'quota'} = 1;
@@ -2829,8 +2850,10 @@
                     $changeHash{'inststatus'} = $newinststatus;
                     if ($newinststatus ne $oldinststatus) {
                         $changed{'inststatus'} = $newinststatus;
-                        ($newdefquota,$newsettingstatus) =
-                            &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus);
+                        foreach my $name ('portfolio','author') {
+                            ($newdefquota{$name},$newsettingstatus{$name}) =
+                                &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name);
+                        }
                     }
                     if (ref($usertypes) eq 'HASH') {
                         $newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses)); 
@@ -2844,54 +2867,66 @@
                 $newsettings{'inststatus'} = $othertitle;
                 if ($newinststatus ne $oldinststatus) {
                     $changed{'inststatus'} = $changeHash{'inststatus'};
-                    ($newdefquota,$newsettingstatus) =
-                        &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus);
+                    foreach my $name ('portfolio','author') {
+                        ($newdefquota{$name},$newsettingstatus{$name}) =
+                            &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name);
+                    }
                 }
             }
         } elsif ($context ne 'selfcreate') {
             $canshow{'inststatus'} = 1;
             $newsettings{'inststatus'} = $oldsettings{'inststatus'};
         }
-        $changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
+        foreach my $name ('portfolio','author') {
+            $changeHash{$name.'quota'} = $userenv{$name.'quota'};
+        }
         if ($context eq 'domain') {
-            if ($userenv{'portfolioquota'} ne '') {
-                $oldportfolioquota = $userenv{'portfolioquota'};
-                if ($env{'form.customquota'} == 1) {
-                    if ($env{'form.portfolioquota'} eq '') {
-                        $newportfolioquota = 0;
+            foreach my $name ('portfolio','author') {
+                if ($userenv{$name.'quota'} ne '') {
+                    $oldquota{$name} = $userenv{$name.'quota'};
+                    if ($env{'form.custom_'.$name.'quota'} == 1) {
+                        if ($env{'form.'.$name.'quota'} eq '') {
+                            $newquota{$name} = 0;
+                        } else {
+                            $newquota{$name} = $env{'form.'.$name.'quota'};
+                            $newquota{$name} =~ s/[^\d\.]//g;
+                        }
+                        if ($newquota{$name} != $oldquota{$name}) {
+                            if (&quota_admin($newquota{$name},\%changeHash,$name)) {
+                                $changed{$name.'quota'} = 1;
+                            }
+                        }
                     } else {
-                        $newportfolioquota = $env{'form.portfolioquota'};
-                        $newportfolioquota =~ s/[^\d\.]//g;
-                    }
-                    if ($newportfolioquota != $oldportfolioquota) {
-                        $changed{'quota'} = &quota_admin($newportfolioquota,\%changeHash);
+                        if (&quota_admin('',\%changeHash,$name)) {
+                            $changed{$name.'quota'} = 1;
+                            $newquota{$name} = $newdefquota{$name};
+                            $newisdefault{$name} = 1;
+                        }
                     }
                 } else {
-                    $changed{'quota'} = &quota_admin('',\%changeHash);
-                    $newportfolioquota = $newdefquota;
-                    $newisdefault = 1;
-                }
-            } else {
-                $oldisdefault = 1;
-                $oldportfolioquota = $olddefquota;
-                if ($env{'form.customquota'} == 1) {
-                    if ($env{'form.portfolioquota'} eq '') {
-                        $newportfolioquota = 0;
+                    $oldisdefault{$name} = 1;
+                    $oldquota{$name} = $olddefquota{$name};
+                    if ($env{'form.custom_'.$name.'quota'} == 1) {
+                        if ($env{'form.'.$name.'quota'} eq '') {
+                            $newquota{$name} = 0;
+                        } else {
+                            $newquota{$name} = $env{'form.'.$name.'quota'};
+                            $newquota{$name} =~ s/[^\d\.]//g;
+                        }
+                        if (&quota_admin($newquota{$name},\%changeHash,$name)) {
+                            $changed{$name.'quota'} = 1;
+                        }
                     } else {
-                        $newportfolioquota = $env{'form.portfolioquota'};
-                        $newportfolioquota =~ s/[^\d\.]//g;
+                        $newquota{$name} = $newdefquota{$name};
+                        $newisdefault{$name} = 1;
                     }
-                    $changed{'quota'} = &quota_admin($newportfolioquota,\%changeHash);
-                } else {
-                    $newportfolioquota = $newdefquota;
-                    $newisdefault = 1;
                 }
-            }
-            if ($oldisdefault) {
-                $oldsettingstext{'quota'} = &get_defaultquota_text($oldsettingstatus);
-            }
-            if ($newisdefault) {
-                $newsettingstext{'quota'} = &get_defaultquota_text($newsettingstatus);
+                if ($oldisdefault{$name}) {
+                    $oldsettingstext{'quota'}{$name} = &get_defaultquota_text($oldsettingstatus{$name});
+                }
+                if ($newisdefault{$name}) {
+                    $newsettingstext{'quota'}{$name} = &get_defaultquota_text($newsettingstatus{$name});
+                }
             }
             &tool_changes('tools',\@usertools,\%oldsettings,\%oldsettingstext,\%userenv,
                           \%changeHash,\%changed,\%newsettings,\%newsettingstext);
@@ -2909,8 +2944,10 @@
                 $namechanged{$item} = 1;
             }
         }
-        $oldsettings{'quota'} = $oldportfolioquota.' Mb';
-        $newsettings{'quota'} = $newportfolioquota.' Mb';
+        foreach my $name ('portfolio','author') {
+            $oldsettings{'quota'}{$name} = $oldquota{$name}.' Mb';
+            $newsettings{'quota'}{$name} = $newquota{$name}.' Mb';
+        }
         if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) {
             my ($chgresult,$namechgresult);
             if (keys(%changed) > 0) {
@@ -3118,7 +3155,8 @@
          'generation'     => 'Generation',
          'id'             => 'Student/Employee ID',
          'permanentemail' => 'Permanent e-mail address',
-         'quota'          => 'Disk space allocated to portfolio files',
+         'portfolioquota' => 'Disk space allocated to portfolio files',
+         'authorquota'    => 'Disk space allocated to authoring space',
          'blog'           => 'Blog Availability',
          'webdav'         => 'WebDAV Availability',
          'aboutme'        => 'Personal Information Page Availability',
@@ -3178,6 +3216,19 @@
                         }
                         $r->print("<td>$value </td>\n");
                     }
+                } elsif ($entry eq 'quota') {
+                    if ((ref($oldsetting->{$entry}) eq 'HASH') && (ref($oldsettingtext->{$entry}) eq 'HASH') &&
+                        (ref($newsetting->{$entry}) eq 'HASH') && (ref($newsettingtext->{$entry}) eq 'HASH')) {
+                        foreach my $name ('portfolio','author') {
+                            $r->print("<td>$lt{$name.$entry}</td>\n");
+                            $r->print("<td>$oldsetting->{$entry}->{$name} $oldsettingtext->{$entry}->{$name} </td>\n");
+                            my $value = $newsetting->{$entry}->{$name}.' '.$newsettingtext->{$entry}->{$name};
+                            if ($changedhash->{$entry}) {
+                                $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+                            }
+                             $r->print("<td>$value </td>\n");
+                        }
+                    }
                 } else {
                     $r->print("<td>$lt{$entry}</td>\n");
                     $r->print("<td>$oldsetting->{$entry} $oldsettingtext->{$entry} </td>\n");
@@ -3822,13 +3873,13 @@
 }
 
 sub quota_admin {
-    my ($setquota,$changeHash) = @_;
+    my ($setquota,$changeHash,$name) = @_;
     my $quotachanged;
     if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
         # Current user has quota modification privileges
         if (ref($changeHash) eq 'HASH') {
             $quotachanged = 1;
-            $changeHash->{'portfolioquota'} = $setquota;
+            $changeHash->{$name.'quota'} = $setquota;
         }
     }
     return $quotachanged;
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.347 loncom/interface/lonhtmlcommon.pm:1.348
--- loncom/interface/lonhtmlcommon.pm:1.347	Sun Jun  9 02:59:04 2013
+++ loncom/interface/lonhtmlcommon.pm	Tue Jul  2 19:04:37 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.347 2013/06/09 02:59:04 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.348 2013/07/02 19:04:37 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2400,6 +2400,49 @@
     return $return;
 }
 
+# display_usage
+# 
+# Generates a div containing a block, filled to show percentage of current quota used
+#
+# Quotas available for user portfolios, group portfolios, authoring spaces, and course
+# content stored directly within a course (i.e., excluding published content).
+#
+
+sub display_usage {
+    my ($current_disk_usage,$disk_quota) = @_;
+    my $usage = $current_disk_usage/1000;
+    my $quota = $disk_quota/1000;
+    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 ($color,$cssclass);
+    if ($percent <= 60) {
+        $color = '#00A000';
+    } elsif ($percent > 60 && $percent < 90) {
+        $color = '#FFD300';
+        $cssclass = 'class="LC_warning"';
+    } elsif( $percent >= 90) {
+        $color = '#FF0000';
+        $cssclass = 'class="LC_error"';
+    }
+    my $prog_width = $percent;
+    if ($prog_width > 100) {
+        $prog_width = 100;
+    }
+    return '
+  <div id="meter1" align="left" '.$cssclass.'>'.&mt('Currently using [_1] of the [_2] available.',$usage.' MB <span style="font-weight:bold;">('.$percent.'%)</span>',$quota.' MB')."\n".
+'   <div id="meter2" style="display:block; margin-top:5px; margin-bottom:5px; margin-left:0px; margin-right:0px; width:400px; border:1px solid #000000; height:10px;">'."\n".
+'    <div id="meter3" style="display:block; background-color:'.$color.'; width:'.$prog_width.'%; height:10px; color:#000000; margin:0px;"></div>'."\n".
+'   </div>'."\n".
+'  </div>';
+}
+
 ##############################################
 ##############################################
 
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.245 loncom/interface/portfolio.pm:1.246
--- loncom/interface/portfolio.pm:1.245	Fri May  3 17:53:02 2013
+++ loncom/interface/portfolio.pm	Tue Jul  2 19:04:37 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # portfolio browser
 #
-# $Id: portfolio.pm,v 1.245 2013/05/03 17:53:02 bisitz Exp $
+# $Id: portfolio.pm,v 1.246 2013/07/02 19:04:37 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -98,7 +98,7 @@
 	my $help_fileupload = &Apache::loncommon::help_open_topic('Portfolio AddFiles');
 	my $help_createdir = &Apache::loncommon::help_open_topic('Portfolio CreateDirectory');
         my $help_portfolio = &Apache::loncommon::help_open_topic('Portfolio About', &mt('Help on the portfolio'));
-        $r->print(&display_usage($group));
+        $r->print(&display_portfolio_usage($group));
         my $parse_check;
         if (!&suppress_embed_prompt()) {
             $parse_check = <<"END";
@@ -188,7 +188,7 @@
     $r->print("</form>");
 }
 
-sub display_usage {
+sub display_portfolio_usage {
     my ($group) = @_;
     my $disk_quota = &get_quota($group);
     my $getpropath = 1;
@@ -196,38 +196,8 @@
     my ($uname,$udom) = &get_name_dom($group);
     my $current_disk_usage =
          &Apache::lonnet::diskusage($udom,$uname,$portfolio_root,$getpropath);
-    my $usage = $current_disk_usage/1000;
-    my $quota = $disk_quota/1000;
-    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 ($color,$cssclass);
-    if ($percent <= 60) {
-        $color = '#00A000';
-    } elsif ($percent > 60 && $percent < 90) {
-        $color = '#FFD300';
-        $cssclass = 'class="LC_warning"';
-    } elsif( $percent >= 90) {
-        $color = '#FF0000';
-        $cssclass = 'class="LC_error"';
-    }
-    my $prog_width = $percent;
-    if ($prog_width > 100) {
-        $prog_width = 100;
-    }
-    my $disk_meter = '
-  <div id="meter1" align="left" '.$cssclass.'>'.&mt('Currently using [_1] of the [_2] available.',$usage.' MB <span style="font-weight:bold;">('.$percent.'%)</span>',$quota.' MB')."\n".
-'   <div id="meter2" style="display:block; margin-top:5px; margin-bottom:5px; margin-left:0px; margin-right:0px; width:400px; border:1px solid #000000; height:10px;">'."\n".
-'    <div id="meter3" style="display:block; background-color:'.$color.'; width:'.$prog_width.'%; height:10px; color:#000000; margin:0px;"></div>'."\n".
-'   </div>'."\n".
-'  </div>';
-    return &Apache::loncommon::head_subbox($disk_meter);
+    return &Apache::loncommon::head_subbox(
+               &Apache::lonhtmlcommon::display_usage($current_disk_usage,$disk_quota));
 }
 
 sub display_directory_line {
Index: loncom/imspackages/imsimport.pm
diff -u loncom/imspackages/imsimport.pm:1.39 loncom/imspackages/imsimport.pm:1.40
--- loncom/imspackages/imsimport.pm:1.39	Tue Jun  4 22:20:28 2013
+++ loncom/imspackages/imsimport.pm	Tue Jul  2 19:04:42 2013
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 # 
-# $Id: imsimport.pm,v 1.39 2013/06/04 22:20:28 raeburn Exp $
+# $Id: imsimport.pm,v 1.40 2013/07/02 19:04:42 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -751,7 +751,7 @@
             &display_three($r,$uname,$udom,\@areas,\%areaname,\%cmsmap,$destdir,$dirpath);
         }
     } else {
-        &Apache::lonupload::phaseone($r,$fn,'imsimport');
+        &Apache::lonupload::phaseone($r,$fn,'imsimport',$uname,$udom);
     }
     $r->print(&Apache::loncommon::end_page());
     return OK;
Index: loncom/publisher/lonupload.pm
diff -u loncom/publisher/lonupload.pm:1.62 loncom/publisher/lonupload.pm:1.63
--- loncom/publisher/lonupload.pm:1.62	Tue Jun  4 22:20:16 2013
+++ loncom/publisher/lonupload.pm	Tue Jul  2 19:04:49 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to upload files into construction space
 #
-# $Id: lonupload.pm,v 1.62 2013/06/04 22:20:16 raeburn Exp $
+# $Id: lonupload.pm,v 1.63 2013/07/02 19:04:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -161,7 +161,7 @@
 }
 
 sub phaseone {
-    my ($r,$fn,$mode)=@_;
+    my ($r,$fn,$mode,$uname,$udom)=@_;
     my $action = '/adm/upload';
     if ($mode eq 'testbank') {
         $action = '/adm/testbank';
@@ -173,7 +173,8 @@
     $env{'form.upfile.filename'}=~s/\\/\//g;
     $env{'form.upfile.filename'}=~s/^.*\/([^\/]+)$/$1/;
     if (!$env{'form.upfile.filename'}) {
-        $r->print('<p class="LC_warning">'.&mt('No upload file specified.').'</p>');
+        $r->print('<p class="LC_warning">'.&mt('No upload file specified.').'</p>'.
+                  &earlyout($fn,$uname,$udom));
         return;
     }
 
@@ -187,6 +188,32 @@
         $r->print('<p class="LC_warning">'.&mt('Illegal filename.').'</p>');
         return;
     }
+    # Check if quota exceeded
+    my $filesize = length($env{'form.upfile'});
+    if (!$filesize) {
+        $r->print('<p class="LC_warning">'.
+                  &mt('Unable to upload [_1]. (size = [_2] bytes)',
+                      '<span class="LC_filename">'.$env{'form.upfile.filename'}.'</span>',
+                      $filesize).'<br />'.
+                  &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
+                  '</p>'.
+                  &earlyout($fn,$uname,$udom));
+        return;
+    }
+    $filesize = int($filesize/1000); #expressed in kb
+    my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,'author'); #expressed in Mb
+    $disk_quota = int($disk_quota * 1000);
+    my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
+    my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,"$londocroot/priv/$udom/$uname");
+    if (($current_disk_usage + $filesize) > $disk_quota){
+        $r->print('<span class="LC_warning">'.
+                  &mt('Unable to upload [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.','<span class="LC_filename">'.$env{'form.upfile.filename'}.'</span>',$filesize).'</span>'.
+                  '<br />'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.',$disk_quota,$current_disk_usage).
+                  '</p>'.
+                  &earlyout($fn,$uname,$udom));
+        return;
+    }
+    
 # Split part that I can change from the part that I cannot change
     my ($fn1,$fn2)=($fn=~/^(\/priv\/[^\/]+\/[^\/]+\/)(.*)$/);
     # Display additional options for upload
@@ -457,6 +484,15 @@
     return $result;
 }
 
+sub earlyout {
+    my ($fn,$uname,$udom) = @_;
+    if ($fn =~ m{^(/priv/$udom/$uname(?:.*)/)[^/]*}) {
+        return &Apache::lonhtmlcommon::actionbox(
+               ['<a href="'.$1.'">'.&mt('Return to Directory').'</a>']);
+    }
+    return;
+}
+
 # ---------------------------------------------------------------- Main Handler
 sub handler {
 
@@ -544,7 +580,7 @@
 	my ($output,$returnflag) = &phasetwo($r,$fn);
         $r->print($output);
     } else {
-	&phaseone($r,$fn);
+	&phaseone($r,$fn,undef,$uname,$udom);
     }
 
     $r->print(&Apache::loncommon::end_page());
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.146 loncom/publisher/lonpubdir.pm:1.147
--- loncom/publisher/lonpubdir.pm:1.146	Mon Jul  1 01:44:29 2013
+++ loncom/publisher/lonpubdir.pm	Tue Jul  2 19:04:49 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Authoring Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.146 2013/07/01 01:44:29 raeburn Exp $
+# $Id: lonpubdir.pm,v 1.147 2013/07/02 19:04:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -152,8 +152,16 @@
     $env{'request.noversionuri'}=$formaction;
     $r->print(&Apache::loncommon::start_page('Authoring Space',undef));
 
+    my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
+    my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,"$londocroot/priv/$udom/$uname");
+    my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,'author'); #expressed in Mb
+    $disk_quota = 1000 * $disk_quota; # convert from Mb to kb
+
     $r->print(&Apache::loncommon::head_subbox(
-                &Apache::loncommon::CSTR_pageheader()));
+                     '<div style="float:right;padding-top:0;margin-top;0">'
+                    .&Apache::lonhtmlcommon::display_usage($current_disk_usage,$disk_quota)
+                    .'</div>'
+                    .&Apache::loncommon::CSTR_pageheader()));
 
     my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn);
     my $doctitle = 'LON-CAPA '.&mt('Authoring Space');
Index: loncom/publisher/testbankimport.pm
diff -u loncom/publisher/testbankimport.pm:1.40 loncom/publisher/testbankimport.pm:1.41
--- loncom/publisher/testbankimport.pm:1.40	Fri Jun  7 16:07:49 2013
+++ loncom/publisher/testbankimport.pm	Tue Jul  2 19:04:49 2013
@@ -1,5 +1,5 @@
 # Handler for parsing text upload problem descriptions into .problems
-# $Id: testbankimport.pm,v 1.40 2013/06/07 16:07:49 bisitz Exp $
+# $Id: testbankimport.pm,v 1.41 2013/07/02 19:04:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1947,7 +1947,7 @@
                       &page_footer('',$fn).'</form>');
         }
     } else {
-        &Apache::lonupload::phaseone($r,$fn,'testbank');
+        &Apache::lonupload::phaseone($r,$fn,'testbank',$uname,$udom);
     }
     $r->print(&Apache::loncommon::end_page());
     return OK;
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1228 loncom/lonnet/perl/lonnet.pm:1.1229
--- loncom/lonnet/perl/lonnet.pm:1.1228	Wed Jun 26 21:22:51 2013
+++ loncom/lonnet/perl/lonnet.pm	Tue Jul  2 19:04:56 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1228 2013/06/26 21:22:51 raeburn Exp $
+# $Id: lonnet.pm,v 1.1229 2013/07/02 19:04:56 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1985,13 +1985,16 @@
             $domdefaults{'defaultquota'} = $domconfig{'quotas'}{'defaultquota'};
         } else {
             $domdefaults{'defaultquota'} = $domconfig{'quotas'};
-        } 
+        }
         my @usertools = ('aboutme','blog','webdav','portfolio');
         foreach my $item (@usertools) {
             if (ref($domconfig{'quotas'}{$item}) eq 'HASH') {
                 $domdefaults{$item} = $domconfig{'quotas'}{$item};
             }
         }
+        if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') {
+            $domdefaults{'authorquota'} = $domconfig{'quotas'}{'authorquota'};
+        }
     }
     if (ref($domconfig{'requestcourses'}) eq 'HASH') {
         foreach my $item ('official','unofficial','community') {
@@ -2007,7 +2010,7 @@
         }
     }
     if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
-        foreach my $item ('canuse_pdfforms') {
+        foreach my $item ('canuse_pdfforms','uploadquota') {
             $domdefaults{$item} = $domconfig{'coursedefaults'}{$item};
         }
         if (ref($domconfig{'coursedefaults'}{'coursecredits'}) eq 'HASH') {


More information about the LON-CAPA-cvs mailing list