--- loncom/interface/loncreateuser.pm	2013/02/06 16:10:27	1.373
+++ loncom/interface/loncreateuser.pm	2013/12/17 06:41:44	1.383
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.373 2013/02/06 16:10:27 bisitz Exp $
+# $Id: loncreateuser.pm,v 1.383 2013/12/17 06:41:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -122,66 +122,42 @@ sub auth_abbrev {
 
 # ====================================================
 
-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 @@ END_SCRIPT
     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.'&nbsp;Mb.&nbsp;&nbsp;'.
-                   $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'}.'&nbsp;('.$defquota.' Mb).</label>&nbsp;'.
-                   '&nbsp;<label><input type="radio" name="customquota" value="1" '. 
-                   $custom_on.'  onchange="javascript:quota_changes('."'custom'".')" />'.
-                   $lt{'cust'}.':</label>&nbsp;'.
-                   '<input type="text" name="portfolioquota" size ="5" value="'.
-                   $showquota.'" onfocus="javascript:quota_changes('."'quota'".')" '.
-                   '/>&nbsp;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.'&nbsp;MB.&nbsp;&nbsp;'.
+                       $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'}.'&nbsp;('.$defquota.' MB).</label>&nbsp;'.
+                       '&nbsp;<label><input type="radio" name="custom_'.$name.'quota" id="custom_'.$name.'quota_on" '.
+                       'value="1" '.$custom_on.'  onchange="javascript:quota_changes('."'custom','$name'".');"'.
+                       ' />'.$lt{'cust'}.':</label>&nbsp;'.
+                       '<input type="text" name="'.$name.'quota" id="'.$name.'quota" size ="5" '.
+                       'value="'.$showquota.'" onfocus="javascript:quota_changes('."'quota','$name'".');"'.
+                       ' />&nbsp;MB</span></td>'."\n".
+                       &Apache::loncommon::end_data_table_row()."\n";
+        }
+    }
     $output .= &Apache::loncommon::end_data_table();
     return $output;
 }
@@ -550,6 +568,15 @@ sub requestauthor_display {
    return %titles;
 }
 
+sub requestchange_display {
+    my %titles = &Apache::lonlocal::texthash (
+                                   approval   => "availability set to 'on' (approval required)", 
+                                   automatic  => "availability set to 'on' (automatic approval)",
+                                   norequest  => "availability set to 'off'",
+   );
+   return %titles;
+}
+
 sub curr_requestauthor {
     my ($uname,$udom,$isadv,$inststatuses,$domconfig) = @_;
     return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
@@ -970,7 +997,7 @@ ENDSCRIPT
             $r->print('</h3>');
         }
     }
-    $r->print('<form name="usersrchform" method="post">'.
+    $r->print('<form name="usersrchform" method="post" action="">'.
               &Apache::loncommon::start_data_table()."\n".
               &Apache::loncommon::start_data_table_header_row()."\n".
               ' <th> </th>'."\n");
@@ -1042,7 +1069,8 @@ sub print_user_query_page {
 }
 
 sub print_user_modification_page {
-    my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission,$crstype,$brcrum) = @_;
+    my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission,$crstype,
+        $brcrum,$showcredits) = @_;
     if (($ccuname eq '') || ($ccdomain eq '')) {
         my $usermsg = &mt('No username and/or domain provided.');
         $env{'form.phase'} = '';
@@ -1133,7 +1161,7 @@ sub print_user_modification_page {
 
     my $groupslist = &Apache::lonuserutils::get_groupslist();
 
-    my $js = &validation_javascript($context,$ccdomain,$pjump_def,
+    my $js = &validation_javascript($context,$ccdomain,$pjump_def,$crstype,
                                $groupslist,$newuser,$formname,\%loaditem);
     my %breadcrumb_text = &singleuser_breadcrumb($crstype);
     my $helpitem = 'Course_Change_Privileges';
@@ -1176,10 +1204,13 @@ sub print_user_modification_page {
 <input type="hidden" name="pres_type"   value="" />
 <input type="hidden" name="pres_marker" value="" />
 ENDFORMINFO
-    my (%inccourses,$roledom);
+    my (%inccourses,$roledom,$defaultcredits);
     if ($context eq 'course') {
         $inccourses{$env{'request.course.id'}}=1;
         $roledom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+        if ($showcredits) {
+            $defaultcredits = &Apache::lonuserutils::get_defaultcredits();
+        }
     } elsif ($context eq 'author') {
         $roledom = $env{'request.role.domain'};
     } elsif ($context eq 'domain') {
@@ -1201,9 +1232,10 @@ ENDFORMINFO
         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'})) {
+        if ((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) &&
+            ($ccdomain eq $env{'request.role.domain'})) {
             $domroleform = '<br />'.&domainrole_req($ccuname,$ccdomain);
         }
         &initialize_authen_forms($ccdomain,$formname);
@@ -1319,7 +1351,8 @@ ENDAUTH
         $r->print($portfolioform.$domroleform);
         if ($env{'form.action'} eq 'singlestudent') {
             $r->print(&date_sections_select($context,$newuser,$formname,
-                                            $permission));
+                                            $permission,$crstype,$ccuname,
+                                            $ccdomain,$showcredits));
         }
         $r->print('</div><div class="LC_clear_float_footer"></div>');
     } else { # user already exists
@@ -1369,23 +1402,21 @@ ENDCHANGEUSER
         my ($isadv,$isauthor) = 
             &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
         if ((!$isauthor) && 
-            (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {
+            (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))
+            && ($env{'request.role.domain'} eq $ccdomain)) {
             $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);
         }
         $user_text{'auth'} =  &user_authentication($ccuname,$ccdomain,$formname);
         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;
@@ -1421,8 +1452,17 @@ ENDNOTOOLSPRIV
             unless ($gotdiv) {
                 $r->print('<div class="LC_left_float">');
             }
-            $r->print(&date_sections_select($context,$newuser,$formname));
-        } 
+            my $credits;
+            if ($showcredits) {
+                $credits = &get_user_credits($ccuname,$ccdomain,$defaultcredits);
+                if ($credits eq '') {
+                    $credits = $defaultcredits;
+                }
+            }
+            $r->print(&date_sections_select($context,$newuser,$formname,
+                                            $permission,$crstype,$ccuname,
+                                            $ccdomain,$showcredits));
+        }
         if ($gotdiv) {
             $r->print('</div><div class="LC_clear_float_footer"></div>');
         }
@@ -1440,7 +1480,7 @@ ENDNOTOOLSPRIV
         }
         $r->print('<br /><input type="button" value="'.$btntxt.'" onclick="setSections(this.form)" />'."\n");
     } else {
-        $r->print('<h3>'.&mt('Add Roles').'</h3>');
+        $r->print('<fieldset><legend>'.&mt('Add Roles').'</legend>');
         my $addrolesdisplay = 0;
         if ($context eq 'domain' || $context eq 'author') {
             $addrolesdisplay = &new_coauthor_roles($r,$ccuname,$ccdomain);
@@ -1450,23 +1490,23 @@ ENDNOTOOLSPRIV
             if (!$addrolesdisplay) {
                 $addrolesdisplay = $add_domainroles;
             }
-            $r->print(&course_level_dc($env{'request.role.domain'},'Course'));
-            $r->print('<br /><input type="button" value="'.&mt('Save').'" onclick="setCourse()" />'."\n");
+            $r->print(&course_level_dc($env{'request.role.domain'},$showcredits));
+            $r->print('</fieldset><br /><input type="button" value="'.&mt('Save').'" onclick="setCourse()" />'."\n");
         } elsif ($context eq 'author') {
             if ($addrolesdisplay) {
-                $r->print('<br /><input type="button" value="'.&mt('Save').'"');
+                $r->print('</fieldset><br /><input type="button" value="'.&mt('Save').'"');
                 if ($newuser) {
                     $r->print(' onclick="auth_check()" \>'."\n");
                 } else {
                     $r->print('onclick="this.form.submit()" \>'."\n");
                 }
             } else {
-                $r->print('<br /><a href="javascript:backPage(document.cu)">'.
+                $r->print('</fieldset><br /><a href="javascript:backPage(document.cu)">'.
                           &mt('Back to previous page').'</a>');
             }
         } else {
-            $r->print(&course_level_table(%inccourses));
-            $r->print('<br /><input type="button" value="'.&mt('Save').'" onclick="setSections(this.form)" />'."\n");
+            $r->print(&course_level_table(\%inccourses,$showcredits,$defaultcredits));
+            $r->print('</fieldset><br /><input type="button" value="'.&mt('Save').'" onclick="setSections(this.form)" />'."\n");
         }
     }
     $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain']));
@@ -1495,22 +1535,32 @@ sub singleuser_breadcrumb {
 }
 
 sub date_sections_select {
-    my ($context,$newuser,$formname,$permission) = @_;
+    my ($context,$newuser,$formname,$permission,$crstype,$ccuname,$ccdomain,
+        $showcredits) = @_;
+    my $credits;
+    if ($showcredits) {
+        my $defaultcredits = &Apache::lonuserutils::get_defaultcredits();
+        $credits = &get_user_credits($ccuname,$ccdomain,$defaultcredits);
+        if ($credits eq '') {
+            $credits = $defaultcredits;
+        }
+    }
     my $cid = $env{'request.course.id'};
     my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity($cid);
     my $date_table = '<h3>'.&mt('Starting and Ending Dates').'</h3>'."\n".
         &Apache::lonuserutils::date_setting_table(undef,undef,$context,
                                                   undef,$formname,$permission);
     my $rowtitle = 'Section';
-    my $secbox = '<h3>'.&mt('Section').'</h3>'."\n".
+    my $secbox = '<h3>'.&mt('Section and Credits').'</h3>'."\n".
         &Apache::lonuserutils::section_picker($cdom,$cnum,'st',$rowtitle,
-                                              $permission);
+                                              $permission,$context,'',$crstype,
+                                              $showcredits,$credits);
     my $output = $date_table.$secbox;
     return $output;
 }
 
 sub validation_javascript {
-    my ($context,$ccdomain,$pjump_def,$groupslist,$newuser,$formname,
+    my ($context,$ccdomain,$pjump_def,$crstype,$groupslist,$newuser,$formname,
         $loaditem) = @_;
     my $dc_setcourse_code = '';
     my $nondc_setsection_code = '';
@@ -1527,7 +1577,8 @@ sub validation_javascript {
         if ($context eq 'course') {
             $nondc_setsection_code =
                 &Apache::lonuserutils::setsections_javascript($formname,$groupslist,
-                                                              undef,$checkauth);
+                                                              undef,$checkauth,
+                                                              $crstype);
         }
         if ($checkauth) {
             $nondc_setsection_code .= 
@@ -1547,7 +1598,8 @@ sub validation_javascript {
 }
 
 sub display_existing_roles {
-    my ($r,$ccuname,$ccdomain,$inccourses,$context,$roledom,$crstype) = @_;
+    my ($r,$ccuname,$ccdomain,$inccourses,$context,$roledom,$crstype,
+        $showcredits) = @_;
     my $now=time;
     my %lt=&Apache::lonlocal::texthash(
                     'rer'  => "Existing Roles",
@@ -1556,6 +1608,7 @@ sub display_existing_roles {
                     'ren'  => "Re-Enable",
                     'rol'  => "Role",
                     'ext'  => "Extent",
+                    'crd'  => "Credits",
                     'sta'  => "Start",
                     'end'  => "End",
                                        );
@@ -1618,6 +1671,7 @@ sub display_existing_roles {
         my $delallowed=0;
         my $sortkey=$role_code;
         my $class='Unknown';
+        my $credits='';
         if ($area =~ m{^/($match_domain)/($match_courseid)} ) {
             $class='Course';
             my ($coursedom,$coursedir) = ($1,$2);
@@ -1646,6 +1700,15 @@ sub display_existing_roles {
             }
             $sortkey.="\0$coursedir";
             $inccourses->{$cid}=1;
+            if (($showcredits) && ($class eq 'Course') && ($role_code eq 'st')) {
+                my $defaultcredits = $coursedata{'internal.defaultcredits'};
+                $credits =
+                    &get_user_credits($ccuname,$ccdomain,$defaultcredits,
+                                      $coursedom,$coursedir);
+                if ($credits eq '') {
+                    $credits = $defaultcredits;
+                }
+            }
             if ((&Apache::lonnet::allowed('c'.$role_code,$coursedom.'/'.$coursedir)) ||
                 (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
                 $allowed=1;
@@ -1702,7 +1765,7 @@ sub display_existing_roles {
                 }
             }
             if ($role_code eq 'ca' || $role_code eq 'au' || $role_code eq 'aa') {
-                $class='Construction Space';
+                $class='Authoring Space';
             } elsif ($role_code eq 'su') {
                 $class='System';
             } else {
@@ -1744,7 +1807,13 @@ sub display_existing_roles {
         }
         my $plaintext='';
         if (!$croletitle) {
-            $plaintext=&Apache::lonnet::plaintext($role_code,$class)
+            $plaintext=&Apache::lonnet::plaintext($role_code,$class);
+            if (($showcredits) && ($credits ne '')) {
+                $plaintext .= '<br/ ><span class="LC_nobreak">'.
+                              '<span class="LC_fontsize_small">'.
+                              &mt('Credits: [_1]',$credits).
+                              '</span></span>';
+            }
         } else {
             $plaintext=
                 &mt('Customrole [_1][_2]defined by [_3]',
@@ -1767,7 +1836,7 @@ sub display_existing_roles {
 
     my $rolesdisplay = 0;
     my %output = ();
-    foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
+    foreach my $type ('Authoring Space','Course','Community','Domain','System','Unknown') {
         $output{$type} = '';
         foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
             if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {
@@ -1793,25 +1862,25 @@ sub display_existing_roles {
                 $contextrole = &mt('Existing Roles in this Course');
             }
         } elsif ($env{'request.role'} =~ /^au\./) {
-            $contextrole = &mt('Existing Co-Author Roles in your Construction Space');
+            $contextrole = &mt('Existing Co-Author Roles in your Authoring Space');
         } else {
             $contextrole = &mt('Existing Roles in this Domain');
         }
-        $r->print('
-<h3>'.$lt{'rer'}.'</h3>'.
-'<div>'.$contextrole.'</div>'.
+        $r->print('<div>'.
+'<fieldset><legend>'.$contextrole.'</legend>'.
 &Apache::loncommon::start_data_table("LC_createuser").
 &Apache::loncommon::start_data_table_header_row().
 '<th>'.$lt{'rev'}.'</th><th>'.$lt{'ren'}.'</th><th>'.$lt{'del'}.
 '</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'ext'}.
 '</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'.
 &Apache::loncommon::end_data_table_header_row());
-        foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
+        foreach my $type ('Authoring Space','Course','Community','Domain','System','Unknown') {
             if ($output{$type}) {
                 $r->print($output{$type}."\n");
             }
         }
-        $r->print(&Apache::loncommon::end_data_table());
+        $r->print(&Apache::loncommon::end_data_table().
+                  '</fieldset></div>');
     }
     return;
 }
@@ -1830,7 +1899,7 @@ sub new_coauthor_roles {
         my $cuname=$env{'user.name'};
         my $cudom=$env{'request.role.domain'};
         my %lt=&Apache::lonlocal::texthash(
-                    'cs'   => "Construction Space",
+                    'cs'   => "Authoring Space",
                     'act'  => "Activate",
                     'rol'  => "Role",
                     'ext'  => "Extent",
@@ -1881,7 +1950,7 @@ sub new_coauthor_roles {
                       '</span>');
         } elsif (($env{'user.name'} eq $ccuname) &&
              ($env{'user.domain'} eq $ccdomain)) {
-            $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted'));
+            $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Authoring Space is not permitted'));
         }
     }
     return $addrolesdisplay;;
@@ -2314,7 +2383,7 @@ sub get_inststatuses {
 
 # ================================================================= Phase Three
 sub update_user_data {
-    my ($r,$context,$crstype,$brcrum) = @_; 
+    my ($r,$context,$crstype,$brcrum,$showcredits) = @_; 
     my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
                                           $env{'form.ccdomain'});
     # Error messages
@@ -2514,14 +2583,18 @@ sub update_user_data {
         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) {
@@ -2535,7 +2608,8 @@ sub update_user_data {
                         $newcustom{$item} = $env{'form.crsreq_'.$item};
                         if ($env{'form.crsreq_'.$item} eq 'autolimit') {
                             $newcustom{$item} .= '=';
-                            unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) {
+                            $env{'form.crsreq_'.$item.'_limit'} =~ s/\D+//g;
+                            if ($env{'form.crsreq_'.$item.'_limit'}) {
                                 $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
                             }
                         }
@@ -2593,17 +2667,21 @@ sub update_user_data {
     $r->rflush(); # Finish display of header before time consuming actions start
     &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state);
     ##
-    my (@userroles,%userupdate,$cnum,$cdom,%namechanged);
+    my (@userroles,%userupdate,$cnum,$cdom,$defaultcredits,%namechanged);
     if ($context eq 'course') {
-        ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity();
+        ($cnum,$cdom) =
+            &Apache::lonuserutils::get_course_identity();
         $crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum);
+        if ($showcredits) {
+           $defaultcredits = &Apache::lonuserutils::get_defaultcredits($cdom,$cnum);
+        }
     }
     if (! $env{'form.makeuser'} ) {
         # 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',
@@ -2729,10 +2807,10 @@ sub update_user_data {
                 }
             }
         }
-        my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus,
-            $newinststatus,$oldisdefault,$newisdefault,%oldsettings,
+        my (%quotachanged,%oldquota,%newquota,%olddefquota,%newdefquota, 
+            $oldinststatus,$newinststatus,%oldisdefault,%newisdefault,%oldsettings,
             %oldsettingstext,%newsettings,%newsettingstext,@disporder,
-            $olddefquota,$oldsettingstatus,$newdefquota,$newsettingstatus);
+            %oldsettingstatus,%newsettingstatus);
         @disporder = ('inststatus');
         if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) {
             push(@disporder,'requestcourses','requestauthor');
@@ -2741,9 +2819,11 @@ sub update_user_data {
         }
         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;
@@ -2782,8 +2862,10 @@ sub update_user_data {
                     $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)); 
@@ -2797,55 +2879,71 @@ sub update_user_data {
                 $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);
+                }
+                if ($oldisdefault{$name}) {
+                    $oldsettingstext{'quota'}{$name} = &get_defaultquota_text($oldsettingstatus{$name});
+                }  else {
+                    $oldsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$oldquota{$name});
+                }
+                if ($newisdefault{$name}) {
+                    $newsettingstext{'quota'}{$name} = &get_defaultquota_text($newsettingstatus{$name});
                 } else {
-                    $newportfolioquota = $newdefquota;
-                    $newisdefault = 1;
+                    $newsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$newquota{$name});
                 }
             }
-            if ($oldisdefault) {
-                $oldsettingstext{'quota'} = &get_defaultquota_text($oldsettingstatus);
-            }
-            if ($newisdefault) {
-                $newsettingstext{'quota'} = &get_defaultquota_text($newsettingstatus);
-            }
             &tool_changes('tools',\@usertools,\%oldsettings,\%oldsettingstext,\%userenv,
                           \%changeHash,\%changed,\%newsettings,\%newsettingstext);
             if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
@@ -2862,8 +2960,10 @@ sub update_user_data {
                 $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) {
@@ -3009,7 +3109,8 @@ sub update_user_data {
     }
     &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
     if ($env{'form.action'} eq 'singlestudent') {
-        &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype);
+        &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,
+                               $crstype,$showcredits,$defaultcredits);
         $r->print('<p><a href="javascript:backPage(document.userupdate)">');
         if ($crstype eq 'Community') {
             $r->print(&mt('Enroll Another Member'));
@@ -3018,7 +3119,7 @@ sub update_user_data {
         }
         $r->print('</a></p>');
     } else {
-        my @rolechanges = &update_roles($r,$context);
+        my @rolechanges = &update_roles($r,$context,$showcredits);
         if (keys(%namechanged) > 0) {
             if ($context eq 'course') {
                 if (@userroles > 0) {
@@ -3070,7 +3171,8 @@ sub display_userinfo {
          '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',
@@ -3092,54 +3194,83 @@ sub display_userinfo {
         $r->print('<th><span class="LC_nobreak"><b>'.$lt{'chto'}.'</b></span></th>');
         $r->print(&Apache::loncommon::end_data_table_header_row());
         my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
-        
 
         foreach my $item (@userinfo) {
             my $value = $env{'form.c'.$item};
             #show changes only:
-            unless($value eq $userenv->{$item}){
+            unless ($value eq $userenv->{$item}){
                 $r->print(&Apache::loncommon::start_data_table_row());
-
                 $r->print("<td>$lt{$item}</td>\n");
-                $r->print('<td>'.$userenv->{$item}.' </td>');
+                $r->print("<td>".$userenv->{$item}."</td>\n");
                 $r->print("<td>$value </td>\n");
-
                 $r->print(&Apache::loncommon::end_data_table_row());
             }
         }
         foreach my $entry (@{$order}) {
-            if ($canshow->{$entry} && ($newsetting->{$entry} ne $newsetting->{$entry})) {
-                $r->print(&Apache::loncommon::start_data_table_row());
-                if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {
-                    foreach my $item (@{$requestcourses}) {
-                        $r->print("<td>$lt{$item}</td>\n");
-                        $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");
-                        my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
-                        if ($changedhash->{$item}) {
-                            $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+            if ($canshow->{$entry}) {
+                if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom') || ($entry eq 'requestauthor')) {
+                    my @items;
+                    if ($entry eq 'requestauthor') {
+                        @items = ($entry);
+                    } else {
+                        @items = @{$requestcourses};
+                    } 
+                    foreach my $item (@items) {
+                        if (($newsetting->{$item} ne $oldsetting->{$item}) || 
+                            ($newsettingtext->{$item} ne $oldsettingtext->{$item})) {
+                            $r->print(&Apache::loncommon::start_data_table_row()."\n");  
+                            $r->print("<td>$lt{$item}</td>\n");
+                            $r->print("<td>".$oldsetting->{$item});
+                            if ($oldsettingtext->{$item}) {
+                                if ($oldsetting->{$item}) {
+                                    $r->print(' -- ');
+                                }
+                                $r->print($oldsettingtext->{$item});
+                            }
+                            $r->print("</td>\n");
+                            $r->print("<td>".$newsetting->{$item});
+                            if ($newsettingtext->{$item}) {
+                                if ($newsetting->{$item}) {
+                                    $r->print(' -- ');
+                                }
+                                $r->print($newsettingtext->{$item});
+                            }
+                            $r->print("</td>\n");
+                            $r->print(&Apache::loncommon::end_data_table_row()."\n");
                         }
-                        $r->print("<td>$value </td>\n");
                     }
                 } elsif ($entry eq 'tools') {
                     foreach my $item (@{$usertools}) {
-                        $r->print("<td>$lt{$item}</td>\n");
-                        $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");
-                        my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
-                        if ($changedhash->{$item}) {
-                            $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+                        if ($newsetting->{$item} ne $oldsetting->{$item}) {
+                            $r->print(&Apache::loncommon::start_data_table_row()."\n");
+                            $r->print("<td>$lt{$item}</td>\n");
+                            $r->print("<td>".$oldsetting->{$item}.' '.$oldsettingtext->{$item}."</td>\n");
+                            $r->print("<td>".$newsetting->{$item}.' '.$newsettingtext->{$item}."</td>\n");
+                            $r->print(&Apache::loncommon::end_data_table_row()."\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') {
+                            if ($newsetting->{$entry}->{$name} ne $oldsetting->{$entry}->{$name}) {
+                                $r->print(&Apache::loncommon::start_data_table_row()."\n");
+                                $r->print("<td>$lt{$name.$entry}</td>\n");
+                                $r->print("<td>".$oldsettingtext->{$entry}->{$name}."</td>\n");
+                                $r->print("<td>".$newsettingtext->{$entry}->{$name}."</td>\n");
+                                $r->print(&Apache::loncommon::end_data_table_row()."\n");
+                            }
                         }
-                        $r->print("<td>$value </td>\n");
                     }
                 } else {
-                    $r->print("<td>$lt{$entry}</td>\n");
-                    $r->print("<td>$oldsetting->{$entry} $oldsettingtext->{$entry} </td>\n");
-                    my $value = $newsetting->{$entry}.' '.$newsettingtext->{$entry};
-                    if ($changedhash->{$entry}) {
-                        $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+                    if ($newsetting->{$entry} ne $oldsetting->{$entry}) {
+                        $r->print(&Apache::loncommon::start_data_table_row()."\n");
+                        $r->print("<td>$lt{$entry}</td>\n");
+                        $r->print("<td>".$oldsetting->{$entry}.' '.$oldsettingtext->{$entry}."</td>\n");
+                        $r->print("<td>".$newsetting->{$entry}.' '.$newsettingtext->{$entry}."</td>\n");
+                        $r->print(&Apache::loncommon::end_data_table_row()."\n");
                     }
-                    $r->print("<td>$value </td>\n");
                 }
-                $r->print(&Apache::loncommon::end_data_table_row());
             }
         }
         $r->print(&Apache::loncommon::end_data_table().'<br />');
@@ -3159,20 +3290,20 @@ sub tool_changes {
           (ref($newaccess) eq 'HASH') && (ref($newaccesstext) eq 'HASH'))) {
         return;
     }
+    my %reqdisplay = &requestchange_display();
     if ($context eq 'reqcrsotherdom') {
         my @options = ('approval','validate','autolimit');
         my $optregex = join('|',@options);
-        my %reqdisplay = &courserequest_display();
         my $cdom = $env{'request.role.domain'};
         foreach my $tool (@{$usertools}) {
-            $oldaccesstext->{$tool} = &mt('No');
+            $oldaccesstext->{$tool} = &mt("availability set to 'off'");
             $newaccesstext->{$tool} = $oldaccesstext->{$tool};
             $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
-            my $newop;
+            my ($newop,$limit);
             if ($env{'form.'.$context.'_'.$tool}) {
                 $newop = $env{'form.'.$context.'_'.$tool};
                 if ($newop eq 'autolimit') {
-                    my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
+                    $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
                     $limit =~ s/\D+//g;
                     $newop .= '='.$limit;
                 }
@@ -3182,7 +3313,15 @@ sub tool_changes {
                     $changed->{$tool}=&tool_admin($tool,$cdom.':'.$newop,
                                                   $changeHash,$context);
                     if ($changed->{$tool}) {
-                        $newaccesstext->{$tool} = &mt('Yes');
+                        if ($newop =~ /^autolimit/) {
+                            if ($limit) {
+                                $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+                            } else {
+                                $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+                            }
+                        } else {
+                            $newaccesstext->{$tool} = $reqdisplay{$newop};
+                        }
                     } else {
                         $newaccesstext->{$tool} = $oldaccesstext->{$tool};
                     }
@@ -3193,8 +3332,17 @@ sub tool_changes {
                 my $changedoms;
                 foreach my $req (@curr) {
                     if ($req =~ /^\Q$cdom\E\:($optregex\=?\d*)$/) {
-                        $oldaccesstext->{$tool} = &mt('Yes');
                         my $oldop = $1;
+                        if ($oldop =~ /^autolimit=(\d*)/) {
+                            my $limit = $1;
+                            if ($limit) {
+                                $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+                            } else {
+                                $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+                            }
+                        } else {
+                            $oldaccesstext->{$tool} = $reqdisplay{$oldop};
+                        }
                         if ($oldop ne $newop) {
                             $changedoms = 1;
                             foreach my $item (@curr) {
@@ -3228,15 +3376,15 @@ sub tool_changes {
                                 my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
                                 $limit =~ s/\D+//g;
                                 if ($limit) {
-                                    $newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user.',$limit);
+                                    $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
                                 } else {
-                                    $newaccesstext->{$tool} = &mt('Yes, processed automatically');
+                                    $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
                                 }
                             } else {
                                 $newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}};
                             }
                         } else {
-                            $newaccesstext->{$tool} = &mt('No');
+                            $newaccesstext->{$tool} = &mt("availability set to 'off'");
                         }
                     }
                 }
@@ -3245,12 +3393,14 @@ sub tool_changes {
         return;
     }
     foreach my $tool (@{$usertools}) {
-        my ($newval,$envkey);
+        my ($newval,$limit,$envkey);
         $envkey = $context.'.'.$tool;
         if ($context eq 'requestcourses') {
             $newval = $env{'form.crsreq_'.$tool};
             if ($newval eq 'autolimit') {
-                $newval .= '='.$env{'form.crsreq_'.$tool.'_limit'};
+                $limit = $env{'form.crsreq_'.$tool.'_limit'};
+                $limit =~ s/\D+//g;
+                $newval .= '='.$limit;
             }
         } elsif ($context eq 'requestauthor') {
             $newval = $env{'form.'.$context};
@@ -3260,10 +3410,25 @@ sub tool_changes {
         }
         if ($userenv->{$envkey} ne '') {
             $oldaccess->{$tool} = &mt('custom');
-            if ($userenv->{$envkey}) {
-                $oldaccesstext->{$tool} = &mt("availability set to 'on'");
+            if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+                if ($userenv->{$envkey} =~ /^autolimit=(\d*)$/) {
+                    my $currlimit = $1;
+                    if ($currlimit eq '') {
+                        $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+                    } else {
+                        $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$currlimit);
+                    }
+                } elsif ($userenv->{$envkey}) {
+                    $oldaccesstext->{$tool} = $reqdisplay{$userenv->{$envkey}};
+                } else {
+                    $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+                }
             } else {
-                $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+                if ($userenv->{$envkey}) {
+                    $oldaccesstext->{$tool} = &mt("availability set to 'on'");
+                } else {
+                    $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+                }
             }
             $changeHash->{$envkey} = $userenv->{$envkey};
             if ($env{'form.custom'.$tool} == 1) {
@@ -3272,17 +3437,45 @@ sub tool_changes {
                                                     $context);
                     if ($changed->{$tool}) {
                         $newaccess->{$tool} = &mt('custom');
-                        if ($newval) {
-                            $newaccesstext->{$tool} = &mt("availability set to 'on'");
+                        if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+                            if ($newval =~ /^autolimit/) {
+                                if ($limit) {
+                                    $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+                                } else {
+                                    $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+                                }
+                            } elsif ($newval) {
+                                $newaccesstext->{$tool} = $reqdisplay{$newval};
+                            } else {
+                                $newaccesstext->{$tool} = &mt("availability set to 'off'");
+                            }
                         } else {
-                            $newaccesstext->{$tool} = &mt("availability set to 'off'");
+                            if ($newval) {
+                                $newaccesstext->{$tool} = &mt("availability set to 'on'");
+                            } else {
+                                $newaccesstext->{$tool} = &mt("availability set to 'off'");
+                            }
                         }
                     } else {
                         $newaccess->{$tool} = $oldaccess->{$tool};
-                        if ($userenv->{$context.'.'.$tool}) {
-                            $newaccesstext->{$tool} = &mt("availability set to 'on'");
+                        if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+                            if ($newval =~ /^autolimit/) {
+                                if ($limit) {
+                                    $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+                                } else {
+                                    $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+                                }
+                            } elsif ($newval) {
+                                $newaccesstext->{$tool} = $reqdisplay{$newval};
+                            } else {
+                                $newaccesstext->{$tool} = &mt("availability set to 'off'");
+                            }
                         } else {
-                            $newaccesstext->{$tool} = &mt("availability set to 'off'");
+                            if ($userenv->{$context.'.'.$tool}) {
+                                $newaccesstext->{$tool} = &mt("availability set to 'on'");
+                            } else {
+                                $newaccesstext->{$tool} = &mt("availability set to 'off'");
+                            }
                         }
                     }
                 } else {
@@ -3295,10 +3488,24 @@ sub tool_changes {
                     $newaccess->{$tool} = &mt('default');
                 } else {
                     $newaccess->{$tool} = $oldaccess->{$tool};
-                    if ($userenv->{$context.'.'.$tool}) {
-                        $newaccesstext->{$tool} = &mt("availability set to 'on'");
+                    if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+                        if ($newval =~ /^autolimit/) {
+                            if ($limit) {
+                                $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+                            } else {
+                                $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+                            }
+                        } elsif ($newval) {
+                            $newaccesstext->{$tool} = $reqdisplay{$newval};
+                        } else {
+                            $newaccesstext->{$tool} = &mt("availability set to 'off'");
+                        }
                     } else {
-                        $newaccesstext->{$tool} = &mt("availability set to 'off'");
+                        if ($userenv->{$context.'.'.$tool}) {
+                            $newaccesstext->{$tool} = &mt("availability set to 'on'");
+                        } else {
+                            $newaccesstext->{$tool} = &mt("availability set to 'off'");
+                        }
                     }
                 }
             }
@@ -3309,10 +3516,24 @@ sub tool_changes {
                                                 $context);
                 if ($changed->{$tool}) {
                     $newaccess->{$tool} = &mt('custom');
-                    if ($newval) {
-                        $newaccesstext->{$tool} = &mt("availability set to 'on'");
+                    if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+                        if ($newval =~ /^autolimit/) {
+                            if ($limit) {
+                                $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+                            } else {
+                                $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+                            }
+                        } elsif ($newval) {
+                            $newaccesstext->{$tool} = $reqdisplay{$newval};
+                        } else {
+                            $newaccesstext->{$tool} = &mt("availability set to 'off'");
+                        }
                     } else {
-                        $newaccesstext->{$tool} = &mt("availability set to 'off'");
+                        if ($newval) {
+                            $newaccesstext->{$tool} = &mt("availability set to 'on'");
+                        } else {
+                            $newaccesstext->{$tool} = &mt("availability set to 'off'");
+                        }
                     }
                 } else {
                     $newaccess->{$tool} = $oldaccess->{$tool};
@@ -3326,7 +3547,7 @@ sub tool_changes {
 }
 
 sub update_roles {
-    my ($r,$context) = @_;
+    my ($r,$context,$showcredits) = @_;
     my $now=time;
     my @rolechanges;
     my %disallowed;
@@ -3435,7 +3656,14 @@ sub update_roles {
                 my $output;
                 if ($role eq 'st') {
                     if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
-                        my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
+                        my ($cdom,$cnum,$csec) = ($1,$2,$3);
+                        my $credits;
+                        if ($showcredits) {
+                            my $defaultcredits = 
+                                &Apache::lonuserutils::get_defaultcredits($cdom,$cnum);
+                            $credits = &get_user_credits($defaultcredits,$cdom,$cnum);
+                        }
+                        my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context,$credits);
                         if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
                             if ($result eq 'refused' && $logmsg) {
                                 $output = $logmsg;
@@ -3534,8 +3762,20 @@ sub update_roles {
                 # split multiple sections
                 my %sections = ();
                 my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
+                my $credits;
+                if ($three eq 'st') {
+                    if ($showcredits) { 
+                        my $defaultcredits = 
+                            &Apache::lonuserutils::get_defaultcredits($one,$two);
+                        $credits = $env{'form.credits_'.$one.'_'.$two.'_'.$three};
+                        $credits =~ s/[^\d\.]//g;
+                        if ($credits eq $defaultcredits) {
+                            undef($credits);
+                        }
+                    }
+                }
                 if ($num_sections == 0) {
-                    $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context));
+                    $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
                 } else {
                     my %curr_groups = 
 			&Apache::longroup::coursegroups($one,$two);
@@ -3549,13 +3789,13 @@ sub update_roles {
                                 next;
                             }
                             my $securl = $url.'/'.$sec;
-                            $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context));
+                            $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context,$credits));
                         } else {
                             $emptysec = 1;
                         }
                     }
                     if ($emptysec) {
-                        $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context));
+                        $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
                     }
                 }
                 if (!grep(/^\Q$three\E$/,@rolechanges)) {
@@ -3622,8 +3862,31 @@ sub update_roles {
     return @rolechanges;
 }
 
+sub get_user_credits {
+    my ($uname,$udom,$defaultcredits,$cdom,$cnum) = @_;
+    if ($cdom eq '' || $cnum eq '') {
+        return unless ($env{'request.course.id'});
+        $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+        $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+    }
+    my $credits;
+    my %currhash =
+        &Apache::lonnet::get('classlist',[$uname.':'.$udom],$cdom,$cnum);
+    if (keys(%currhash) > 0) {
+        my @items = split(/:/,$currhash{$uname.':'.$udom});
+        my $crdidx = &Apache::loncoursedata::CL_CREDITS() - 3;
+        $credits = $items[$crdidx];
+        $credits =~ s/[^\d\.]//g;
+    }
+    if ($credits eq $defaultcredits) {
+        undef($credits);
+    }
+    return $credits;
+}
+
 sub enroll_single_student {
-    my ($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype) = @_;
+    my ($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype,
+        $showcredits,$defaultcredits) = @_;
     $r->print('<h3>');
     if ($crstype eq 'Community') {
         $r->print(&mt('Enrolling Member'));
@@ -3635,6 +3898,17 @@ sub enroll_single_student {
     # Remove non alphanumeric values from section
     $env{'form.sections'}=~s/\W//g;
 
+    my $credits;
+    if (($showcredits) && ($env{'form.credits'} ne '')) {
+        $credits = $env{'form.credits'};
+        $credits =~ s/[^\d\.]//g;
+        if ($credits ne '') {
+            if ($credits eq $defaultcredits) {
+                undef($credits);
+            }
+        }
+    }
+
     # Clean out any old student roles the user has in this class.
     &Apache::lonuserutils::modifystudent($env{'form.ccdomain'},
          $env{'form.ccuname'},$env{'request.course.id'},undef,$uhome);
@@ -3644,9 +3918,10 @@ sub enroll_single_student {
             $env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'},
             $env{'form.cmiddlename'},$env{'form.clastname'},
             $env{'form.generation'},$env{'form.sections'},$enddate,
-            $startdate,'manual',undef,$env{'request.course.id'},'',$context);
+            $startdate,'manual',undef,$env{'request.course.id'},'',$context,
+            $credits);
     if ($enroll_result =~ /^ok/) {
-        $r->print(&mt('<b>[_1]</b> enrolled',$env{'form.ccuname'}.':'.$env{'form.ccdomain'}));
+        $r->print(&mt('[_1] enrolled','<b>'.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.'</b>'));
         if ($env{'form.sections'} ne '') {
             $r->print(' '.&mt('in section [_1]',$env{'form.sections'}));
         }
@@ -3681,14 +3956,14 @@ sub get_defaultquota_text {
     my ($settingstatus) = @_;
     my $defquotatext; 
     if ($settingstatus eq '') {
-        $defquotatext = &mt('(default)');
+        $defquotatext = &mt('default');
     } else {
         my ($usertypes,$order) =
             &Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'});
         if ($usertypes->{$settingstatus} eq '') {
-            $defquotatext = &mt('(default)');
+            $defquotatext = &mt('default');
         } else {
-            $defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus});
+            $defquotatext = &mt('default for [_1]',$usertypes->{$settingstatus});
         }
     }
     return $defquotatext;
@@ -3713,20 +3988,20 @@ sub update_result_form {
         $outcome .= '<input type="hidden" name="forcenewuser" value="1" />'."\n";
     }
     $outcome .= '<input type="hidden" name="phase" value="" />'."\n".
-                '<input type ="hidden" name="currstate" value="" />'."\n".
-                '<input type ="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
+                '<input type="hidden" name="currstate" value="" />'."\n".
+                '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
                 '</form>';
     return $outcome;
 }
 
 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;
@@ -3971,7 +4246,7 @@ sub custom_role_editor {
     $r->print('<br clear="all" />');
 
     $r->print(<<ENDCCF);
-<form name="form1" method="post">
+<form name="form1" method="post" action="">
 <input type="hidden" name="phase" value="set_custom_roles" />
 <input type="hidden" name="rolename" value="$rolename" />
 ENDCCF
@@ -4167,8 +4442,13 @@ sub set_custom_role {
 						$env{'user.name'},
 						$rolename,undef,undef,undef,$context));
     }
-    $r->print('<p><a href="javascript:backPage(document.customresult,'."'pickrole'".')">'.&mt('Create or edit another custom role').'</a></p><form name="customresult" method="post">');
-    $r->print(&Apache::lonhtmlcommon::echo_form_input([]).'</form>');
+    $r->print(
+        '<p><a href="javascript:backPage(document.customresult,'."'pickrole'".')">'
+       .&mt('Create or edit another custom role')
+       .'</a></p>'
+       .'<form name="customresult" method="post" action="">'
+       .&Apache::lonhtmlcommon::echo_form_input([]).'</form>'
+    );
 }
 
 # ================================================================ Main Handler
@@ -4188,6 +4468,7 @@ sub handler {
     } else {
         $context = 'domain';
     }
+
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
         ['action','state','callingform','roletype','showrole','bulkaction','popup','phase',
          'username','domain','srchterm','srchdomain','srchin','srchby','srchtype']);
@@ -4219,6 +4500,16 @@ sub handler {
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
 
+    my $showcredits;
+    if ((($context eq 'course') && ($crstype eq 'Course')) || 
+         ($context eq 'domain')) {
+        my %domdefaults = 
+            &Apache::lonnet::get_domain_defaults($env{'request.role.domain'});
+        if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) {
+            $showcredits = 1;
+        }
+    }
+
     # Main switch on form.action and form.state, as appropriate
     if (! exists($env{'form.action'})) {
         $args = {bread_crumbs => $brcrum,
@@ -4241,11 +4532,12 @@ sub handler {
         if (! exists($env{'form.state'})) {
             &Apache::lonuserutils::print_first_users_upload_form($r,$context);
         } elsif ($env{'form.state'} eq 'got_file') {
-            &Apache::lonuserutils::print_upload_manager_form($r,$context,
-                                                             $permission,$crstype);
+            &Apache::lonuserutils::print_upload_manager_form($r,$context,$permission,
+                                                             $crstype,$showcredits);
         } elsif ($env{'form.state'} eq 'enrolling') {
             if ($env{'form.datatoken'}) {
-                &Apache::lonuserutils::upfile_drop_add($r,$context,$permission);
+                &Apache::lonuserutils::upfile_drop_add($r,$context,$permission,
+                                                       $showcredits);
             }
         } else {
             &Apache::lonuserutils::print_first_users_upload_form($r,$context);
@@ -4270,13 +4562,15 @@ sub handler {
                            .' letters numbers - . @')
                        .'</span>';
                     $env{'form.phase'} = '';
-                    &print_username_entry_form($r,$context,$response,$srch,undef,$crstype,$brcrum);
+                    &print_username_entry_form($r,$context,$response,$srch,undef,
+                                               $crstype,$brcrum,$showcredits);
                 } else {
                     my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'});
                     my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'});
                     &print_user_modification_page($r,$ccuname,$ccdomain,
                                                   $srch,$response,$context,
-                                                  $permission,$crstype,$brcrum);
+                                                  $permission,$crstype,$brcrum,
+                                                  $showcredits);
                 }
             } elsif ($env{'form.phase'} eq 'get_user_info') {
                 my ($currstate,$response,$forcenewuser,$results) = 
@@ -4321,7 +4615,7 @@ sub handler {
                                               $brcrum);
             }
         } elsif ($env{'form.phase'} eq 'update_user_data') {
-            &update_user_data($r,$context,$crstype,$brcrum);
+            &update_user_data($r,$context,$crstype,$brcrum,$showcredits);
         } else {
             &print_username_entry_form($r,$context,undef,$srch,undef,$crstype,
                                        $brcrum);
@@ -4424,7 +4718,8 @@ sub handler {
                 $r->print(&header(&add_script($jscript),$args));
             }
             &Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
-                         $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
+                         $formname,$totcodes,$codetitles,$idlist,$idlist_titles,
+                         $showcredits);
         }
     } elsif ($env{'form.action'} eq 'drop' && $permission->{'cusr'}) {
         my $brtext;
@@ -4455,8 +4750,8 @@ sub handler {
     } elsif ($env{'form.action'} eq 'dateselect') {
         if ($permission->{'cusr'}) {
             $r->print(&header(undef,{'no_nav_bar' => 1}).
-                      &Apache::lonuserutils::date_section_selector($context,
-                                                                   $permission,$crstype));
+                      &Apache::lonuserutils::date_section_selector($context,$permission,
+                                                                   $crstype,$showcredits));
         } else {
             $r->print(&header(undef,{'no_nav_bar' => 1}).
                      '<span class="LC_error">'.&mt('You do not have permission to modify dates or sections for users').'</span>'); 
@@ -4558,6 +4853,11 @@ sub add_script {
 
 sub verify_user_display {
     my ($context) = @_;
+    my %lt = &Apache::lonlocal::texthash (
+        course    => 'course(s): description, section(s), status',
+        community => 'community(s): description, section(s), status',
+        author    => 'author',
+    );
     my $photos;
     if (($context eq 'course') && $env{'request.course.id'}) {
         $photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'};
@@ -4581,16 +4881,25 @@ function updateCols(caller) {
     var context = '$context';
     var photos = '$photos';
     if (caller == 'Status') {
-        if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
-            document.getElementById('showcolstatus').checked = true;
-            document.getElementById('showcolstatus').disabled = '';
-            document.getElementById('showcolstart').checked = true;
-            document.getElementById('showcolend').checked = true;
-        } else {
+        if ((context == 'domain') && 
+            ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
+             (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community'))) {
             document.getElementById('showcolstatus').checked = false;
             document.getElementById('showcolstatus').disabled = 'disabled';
             document.getElementById('showcolstart').checked = false;
             document.getElementById('showcolend').checked = false;
+        } else {
+            if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+                document.getElementById('showcolstatus').checked = true;
+                document.getElementById('showcolstatus').disabled = '';
+                document.getElementById('showcolstart').checked = true;
+                document.getElementById('showcolend').checked = true;
+            } else {
+                document.getElementById('showcolstatus').checked = false;
+                document.getElementById('showcolstatus').disabled = 'disabled';
+                document.getElementById('showcolstart').checked = false;
+                document.getElementById('showcolend').checked = false;
+            }
         }
     }
     if (caller == 'output') {
@@ -4616,6 +4925,66 @@ function updateCols(caller) {
             document.getElementById('showcolrole').checked = false;
             document.getElementById('showcolrole').disabled = 'disabled';
         }
+        if (context == 'domain') {
+            var quotausageshow = 0;
+            if ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
+                (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community')) {
+                document.getElementById('showcolstatus').checked = false;
+                document.getElementById('showcolstatus').disabled = 'disabled';
+                document.getElementById('showcolstart').checked = false;
+                document.getElementById('showcolend').checked = false;
+            } else {
+                if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+                    document.getElementById('showcolstatus').checked = true;
+                    document.getElementById('showcolstatus').disabled = '';
+                    document.getElementById('showcolstart').checked = true;
+                    document.getElementById('showcolend').checked = true;
+                }
+            }
+            if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'domain') {
+                document.getElementById('showcolextent').disabled = 'disabled';
+                document.getElementById('showcolextent').checked = 'false';
+                document.getElementById('showextent').style.display='none';
+                document.getElementById('showcoltextextent').innerHTML = '';
+                if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'au') ||
+                    (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any')) {
+                    if (document.getElementById('showcolauthorusage')) {
+                        document.getElementById('showcolauthorusage').disabled = '';
+                    }
+                    if (document.getElementById('showcolauthorquota')) {
+                        document.getElementById('showcolauthorquota').disabled = '';
+                    }
+                    quotausageshow = 1;
+                }
+            } else {
+                document.getElementById('showextent').style.display='block';
+                document.getElementById('showextent').style.textAlign='left';
+                document.getElementById('showextent').style.textFace='normal';
+                if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'author') {
+                    document.getElementById('showcolextent').disabled = '';
+                    document.getElementById('showcolextent').checked = 'true';
+                    document.getElementById('showcoltextextent').innerHTML="$lt{'author'}";
+                } else {
+                    document.getElementById('showcolextent').disabled = '';
+                    document.getElementById('showcolextent').checked = 'true';
+                    if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community') {
+                        document.getElementById('showcoltextextent').innerHTML="$lt{'community'}";
+                    } else {
+                        document.getElementById('showcoltextextent').innerHTML="$lt{'course'}";
+                    }
+                }
+            }
+            if (quotausageshow == 0)  {
+                if (document.getElementById('showcolauthorusage')) {
+                    document.getElementById('showcolauthorusage').checked = false;
+                    document.getElementById('showcolauthorusage').disabled = 'disabled';
+                }
+                if (document.getElementById('showcolauthorquota')) {
+                    document.getElementById('showcolauthorquota').checked = false;
+                    document.getElementById('showcolauthorquota').disabled = 'disabled';
+                }
+            }
+        }
     }
     return;
 }
@@ -5855,7 +6224,7 @@ sub role_display_filter {
                &mt('Context:').'</b><br /><select name="chgcontext">';
     my @posscontexts;
     if ($context eq 'course') {
-        @posscontexts = ('any','auto','updatenow','createcourse','course','domain','selfenroll','requestcourses');
+        @posscontexts = ('any','automated','updatenow','createcourse','course','domain','selfenroll','requestcourses');
     } elsif ($context eq 'domain') {
         @posscontexts = ('any','domain','requestauthor','domconfig','server');
     } else {
@@ -5867,7 +6236,7 @@ sub role_display_filter {
             $selstr = ' selected="selected"';
         }
         if ($context eq 'course') {
-            if (($chgtype eq 'auto') || ($chgtype eq 'updatenow')) {
+            if (($chgtype eq 'automated') || ($chgtype eq 'updatenow')) {
                 next if (!&Apache::lonnet::auto_run($cnum,$cdom));
             }
         }
@@ -5903,7 +6272,7 @@ sub rolechg_contexts {
     if ($context eq 'course') {
         %lt = &Apache::lonlocal::texthash (
                                              any          => 'Any',
-                                             auto         => 'Automated enrollment',
+                                             automated    => 'Automated Enrollment',
                                              updatenow    => 'Roster Update',
                                              createcourse => 'Course Creation',
                                              course       => 'User Management in course',
@@ -6428,7 +6797,8 @@ function backPage(formname,prevphase,pre
 }
 
 sub course_level_table {
-    my (%inccourses) = @_;
+    my ($inccourses,$showcredits,$defaultcredits) = @_;
+    return unless (ref($inccourses) eq 'HASH');
     my $table = '';
 # Custom Roles?
 
@@ -6443,11 +6813,12 @@ sub course_level_table {
             'rol'  => "Role",
             'ext'  => "Extent",
             'grs'  => "Section",
+            'crd'  => "Credits",
             'sta'  => "Start",
             'end'  => "End"
     );
 
-    foreach my $protectedcourse (sort(keys(%inccourses))) {
+    foreach my $protectedcourse (sort(keys(%{$inccourses}))) {
 	my $thiscourse=$protectedcourse;
 	$thiscourse=~s:_:/:g;
 	my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
@@ -6469,12 +6840,14 @@ sub course_level_table {
 	    if ((&Apache::lonnet::allowed('c'.$role,$thiscourse)) ||
                 ((($role eq 'cc') || ($role eq 'co')) && ($isowner))) {
                 $table .= &course_level_row($protectedcourse,$role,$area,$domain,
-                                            $plrole,\%sections_count,\%lt);
+                                            $plrole,\%sections_count,\%lt,
+                                            $defaultcredits,$crstype);
             } elsif ($env{'request.course.sec'} ne '') {
                 if (&Apache::lonnet::allowed('c'.$role,$thiscourse.'/'.
                                              $env{'request.course.sec'})) {
                     $table .= &course_level_row($protectedcourse,$role,$area,$domain,
-                                                $plrole,\%sections_count,\%lt);
+                                                $plrole,\%sections_count,\%lt,
+                                                $defaultcredits,$crstype);
                 }
             }
         }
@@ -6496,8 +6869,10 @@ sub course_level_table {
     $result .= 
 &Apache::loncommon::start_data_table().
 &Apache::loncommon::start_data_table_header_row().
-'<th>'.$lt{'act'}.'</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'ext'}.'</th>
-<th>'.$lt{'grs'}.'</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'.
+'<th>'.$lt{'act'}.'</th><th>'.$lt{'rol'}.'</th>'."\n".
+'<th>'.$lt{'ext'}.'</th><th>'.$lt{'crd'}.'</th>'."\n".
+'<th>'.$lt{'grs'}.'</th><th>'.$lt{'sta'}.'</th>'."\n".
+'<th>'.$lt{'end'}.'</th>'.
 &Apache::loncommon::end_data_table_header_row().
 $table.
 &Apache::loncommon::end_data_table();
@@ -6505,12 +6880,21 @@ $table.
 }
 
 sub course_level_row {
-    my ($protectedcourse,$role,$area,$domain,$plrole,$sections_count,$lt) = @_;
+    my ($protectedcourse,$role,$area,$domain,$plrole,$sections_count,
+        $lt,$defaultcredits,$crstype) = @_;
+    my $creditem;
     my $row = &Apache::loncommon::start_data_table_row().
               ' <td><input type="checkbox" name="act_'.
               $protectedcourse.'_'.$role.'" /></td>'."\n".
               ' <td>'.$plrole.'</td>'."\n".
               ' <td>'.$area.'<br />Domain: '.$domain.'</td>'."\n";
+    if (($role eq 'st') && ($crstype eq 'Course')) {
+        $row .= 
+            '<td><input type="text" name="credits_'.$protectedcourse.'_'.
+            $role.'" size="3" value="'.$defaultcredits.'" /></td>';
+    } else {
+        $row .= '<td>&nbsp;</td>';
+    }
     if (($role eq 'cc') || ($role eq 'co')) {
         $row .= '<td>&nbsp;</td>';
     } elsif ($env{'request.course.sec'} ne '') {
@@ -6536,7 +6920,7 @@ sub course_level_row {
                      '</tr></table></td>'."\n";
         } else {
             $row .= '<td><input type="text" size="10" '.
-                      'name="sec_'.$protectedcourse.'_'.$role.'" /></td>'."\n";
+                    'name="sec_'.$protectedcourse.'_'.$role.'" /></td>'."\n";
         }
     }
     $row .= <<ENDTIMEENTRY;
@@ -6552,7 +6936,7 @@ ENDTIMEENTRY
 }
 
 sub course_level_dc {
-    my ($dcdom) = @_;
+    my ($dcdom,$showcredits) = @_;
     my %customroles=&Apache::lonuserutils::my_custom_roles();
     my @roles = &Apache::lonuserutils::roles_by_context('course');
     my $hiddenitems = '<input type="hidden" name="dcdomain" value="'.$dcdom.'" />'.
@@ -6560,7 +6944,11 @@ sub course_level_dc {
                       '<input type="hidden" name="dccourse" value="" />';
     my $courseform=&Apache::loncommon::selectcourse_link
             ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Select','crstype');
-    my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser');
+    my $credit_elem;
+    if ($showcredits) {
+        $credit_elem = 'credits';
+    }
+    my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser',$credit_elem);
     my %lt=&Apache::lonlocal::texthash(
                     'rol'  => "Role",
                     'grs'  => "Section",
@@ -6570,12 +6958,15 @@ sub course_level_dc {
                     'end'  => "End",
                     'ssd'  => "Set Start Date",
                     'sed'  => "Set End Date",
-                    'scc'  => "Course/Community"
+                    'scc'  => "Course/Community",
+                    'crd'  => "Credits",
                   );
     my $header = '<h4>'.&mt('Course/Community Level').'</h4>'.
                  &Apache::loncommon::start_data_table().
                  &Apache::loncommon::start_data_table_header_row().
-                 '<th>'.$lt{'scc'}.'</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'grs'}.'</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'.
+                 '<th>'.$lt{'scc'}.'</th><th>'.$lt{'rol'}.'</th>'."\n".
+                 '<th>'.$lt{'grs'}.'</th><th>'.$lt{'crd'}.'</th>'."\n".
+                 '<th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'."\n".
                  &Apache::loncommon::end_data_table_header_row();
     my $otheritems = &Apache::loncommon::start_data_table_row()."\n".
                      '<td><br /><span class="LC_nobreak"><input type="text" name="coursedesc" value="" onfocus="this.blur();opencrsbrowser('."'cu','dccourse','dcdomain','coursedesc','','','','crstype'".')" />'.
@@ -6602,7 +6993,11 @@ sub course_level_dc {
                      '<input type="hidden" name="section" value="" />'.
                      '<input type="hidden" name="groups" value="" />'.
                      '<input type="hidden" name="crstype" value="" /></td>'.
-                     '</tr></table></td>';
+                     '</tr></table></td>'."\n";
+    if ($showcredits) {
+        $otheritems .= '<td><br />'."\n".
+                       '<input type="text" size="3" name="credits" value="" />'."\n";
+    }
     $otheritems .= <<ENDTIMEENTRY;
 <td><br /><input type="hidden" name="start" value='' />
 <a href=