--- loncom/interface/loncommon.pm	2013/05/21 18:54:15	1.1129
+++ loncom/interface/loncommon.pm	2013/07/02 19:04:36	1.1134
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1129 2013/05/21 18:54:15 raeburn Exp $
+# $Id: loncommon.pm,v 1.1134 2013/07/02 19:04:36 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4932,7 +4932,7 @@ sub designparm {
 
 Inputs: $url (usually will be undef).
 
-Returns: Path to Construction Space containing the resource or 
+Returns: Path to Authoring Space containing the resource or 
          directory being viewed (or for which action is being taken). 
          If $url is provided, and begins /priv/<domain>/<uname>
          the path will be that portion of the $context argument.
@@ -4995,7 +4995,7 @@ Input: (optional) filename from which br
        is appropriate for use in building the breadcrumb trail.
 
 Returns: HTML div with CSTR path and recent box
-         To be included on Construction Space pages
+         To be included on Authoring Space pages
 
 =cut
 
@@ -5026,7 +5026,7 @@ sub CSTR_pageheader {
     my $output =
          '<div>'
         .&Apache::loncommon::help_open_menu('','',3,'Authoring') #FIXME: Broken? Where is it?
-        .'<b>'.&mt('Construction Space:').'</b> '
+        .'<b>'.&mt('Authoring Space:').'</b> '
         .'<form name="dirs" method="post" action="'.$formaction
         .'" target="_top">' #FIXME lonpubdir: target="_parent"
         .&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,'_top','/priv/'.$udom,undef,undef);
@@ -5155,16 +5155,14 @@ sub bodytag {
     my $bodytag = "<body $extra_body_attr>".
 	&Apache::lontexconvert::init_math_support($args->{'inherit_jsmath'});
 
-    if ($bodyonly) {
+    &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']);
+
+    if (($bodyonly) || ($no_nav_bar) || ($env{'form.inhibitmenu'} eq 'yes')) {
         return $bodytag;
-    } 
+    }
 
-    my $name = &plainname($env{'user.name'},$env{'user.domain'});
     if ($public) {
 	undef($role);
-    } else {
-	$name = &aboutmewrapper($name,$env{'user.name'},$env{'user.domain'},
-                                undef,'LC_menubuttons_link');
     }
     
     my $titleinfo = '<h1>'.$title.'</h1>';
@@ -5180,11 +5178,6 @@ sub bodytag {
     }
 
     $role = '<span class="LC_nobreak">('.$role.')</span>' if $role;
-    &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']);
-
-        if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') { 
-            return $bodytag; 
-        } 
 
         if ($env{'request.state'} eq 'construct') { $forcereg=1; }
 
@@ -5192,25 +5185,25 @@ sub bodytag {
         #        $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls
         #    }
 
+        $bodytag .= Apache::lonhtmlcommon::scripttag(
+            Apache::lonmenu::utilityfunctions(), 'start');
 
+        my ($left,$right) = Apache::lonmenu::primary_menu();
 
         if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) {
              if ($dc_info) {
                  $dc_info = qq|<span class="LC_cusr_subheading">$dc_info</span>|;
              }
-             $bodytag .= qq|<div id="LC_nav_bar">$name $role<br />
+             $bodytag .= qq|<div id="LC_nav_bar">$left $role<br />
                 <em>$realm</em> $dc_info</div>|;
             return $bodytag;
         }
 
         unless ($env{'request.symb'} =~ m/\.page___\d+___/) {
-            $bodytag .= qq|<div id="LC_nav_bar">$name $role</div>|;
+            $bodytag .= qq|<div id="LC_nav_bar">$left $role</div>|;
         }
 
-        $bodytag .= Apache::lonhtmlcommon::scripttag(
-            Apache::lonmenu::utilityfunctions(), 'start');
-
-        $bodytag .= Apache::lonmenu::primary_menu();
+        $bodytag .= $right;
 
         if ($dc_info) {
             $dc_info = &dc_courseid_toggle($dc_info);
@@ -5410,6 +5403,14 @@ form, .inline {
   vertical-align:middle;
 }
 
+.LC_floatleft {
+  float: left;
+}
+
+.LC_floatright {
+  float: right;
+}
+
 .LC_400Box {
   width:400px;
 }
@@ -6499,6 +6500,7 @@ div.LC_createcourse {
 }
 
 .LC_dccid {
+  float: right;
   margin: 0.2em 0 0 0;
   padding: 0;
   font-size: 90%;
@@ -6596,7 +6598,6 @@ fieldset > legend {
 }
 
 ol.LC_primary_menu {
-  float: right;
   margin: 0;
   padding: 0;
   background-color: $pgbg_or_bgcolor;
@@ -8560,11 +8561,14 @@ sub get_user_info {
 
 =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.
@@ -8578,7 +8582,7 @@ Returns:
 
 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
 
@@ -8586,7 +8590,7 @@ defined for the user's instituional stat
 
 
 sub get_user_quota {
-    my ($uname,$udom) = @_;
+    my ($uname,$udom,$quotaname) = @_;
     my ($quota,$quotatype,$settingstatus,$defquota);
     if (!defined($udom)) {
         $udom = $env{'user.domain'};
@@ -8601,27 +8605,52 @@ sub get_user_quota {
         $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) {
@@ -8646,7 +8675,9 @@ Incoming parameters:
    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.
@@ -8670,25 +8701,29 @@ default quota returned.
 
 
 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};
@@ -8702,16 +8737,20 @@ sub default_quota {
             }
         }
         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);
@@ -14566,7 +14605,7 @@ sub create_recaptcha {
     return $captcha->get_options_setter({theme => 'white'})."\n".
            $captcha->get_html($pubkey).
            &mt('If either word is hard to read, [_1] will replace them.',
-               '<image src="/res/adm/pages/refresh.gif" alt="reCAPTCHA refresh" />').
+               '<img src="/res/adm/pages/refresh.gif" alt="reCAPTCHA refresh" />').
            '<br /><br />';
 }