--- loncom/interface/loncreateuser.pm	2010/11/08 19:52:01	1.329.2.6
+++ loncom/interface/loncreateuser.pm	2012/08/21 15:43:27	1.365
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.329.2.6 2010/11/08 19:52:01 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.365 2012/08/21 15:43:27 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -70,7 +70,6 @@ use Apache::lonlocal;
 use Apache::longroup;
 use Apache::lonuserutils;
 use Apache::loncoursequeueadmin;
-use Apache::lonrequestcourse;
 use LONCAPA qw(:DEFAULT :match);
 
 my $loginscript; # piece of javascript used in two separate instances
@@ -220,10 +219,11 @@ END_SCRIPT
 sub build_tools_display {
     my ($ccuname,$ccdomain,$context) = @_;
     my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay,
-        $colspan);
+        $colspan,$isadv,%domconfig);
     my %lt = &Apache::lonlocal::texthash (
                    'blog'       => "Personal User Blog",
                    'aboutme'    => "Personal Information Page",
+                   'webdav'     => "WebDAV access to authoring spaces (if SSL and author/co-author)",
                    'portfolio'  => "Personal User Portfolio",
                    'avai'       => "Available",
                    'cusa'       => "availability",
@@ -233,6 +233,7 @@ sub build_tools_display {
                    'official'   => 'Can request creation of official courses',
                    'unofficial' => 'Can request creation of unofficial courses',
                    'community'  => 'Can request creation of communities',
+                   'requestauthor'  => 'Can request author space',
     );
     if ($context eq 'requestcourses') {
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
@@ -244,10 +245,24 @@ sub build_tools_display {
         %reqtitles = &courserequest_titles();
         %reqdisplay = &courserequest_display();
         $colspan = ' colspan="2"';
+        %domconfig =
+            &Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain);
+        $isadv = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
+    } elsif ($context eq 'requestauthor') {
+        %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
+                                                    'requestauthor');
+        @usertools = ('requestauthor');
+        @options =('norequest','approval','automatic');
+        %reqtitles = &requestauthor_titles();
+        %reqdisplay = &requestauthor_display();
+        $colspan = ' colspan="2"';
+        %domconfig =
+            &Apache::lonnet::get_dom('configuration',['requestauthor'],$ccdomain);
     } else {
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
-                          'tools.aboutme','tools.portfolio','tools.blog');
-        @usertools = ('aboutme','blog','portfolio');
+                          'tools.aboutme','tools.portfolio','tools.blog',
+                          'tools.webdav');
+        @usertools = ('aboutme','blog','webdav','portfolio');
     }
     foreach my $item (@usertools) {
         my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off,
@@ -257,7 +272,12 @@ sub build_tools_display {
         $curr_access =  
             &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef,
                                               $context);
-        if ($userenv{$context.'.'.$item} ne '') {
+        if ($context eq 'requestauthor') {
+            if ($userenv{$context} ne '') {
+                $cust_on = ' checked="checked" ';
+                $cust_off = '';
+            }  
+        } elsif ($userenv{$context.'.'.$item} ne '') {
             $cust_on = ' checked="checked" ';
             $cust_off = '';
         }
@@ -267,6 +287,12 @@ sub build_tools_display {
             } else {
                 $custom_access = &mt('Currently from custom setting.');
             }
+        } elsif ($context eq 'requestauthor') {
+            if ($userenv{$context} eq '') {
+                $custom_access = &mt('Currently from default setting.');
+            } else {
+                $custom_access = &mt('Currently from custom setting.');
+            }
         } else {
             if ($userenv{$context.'.'.$item} eq '') {
                 $custom_access =
@@ -288,9 +314,28 @@ sub build_tools_display {
                    '   <td'.$colspan.'>'.$lt{$item}.'</td>'."\n".
                    '  </tr>'."\n".
                    &Apache::loncommon::start_data_table_row()."\n";
-        if ($context eq 'requestcourses') {
+        if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
             my ($curroption,$currlimit);
-            $curroption = $userenv{$context.'.'.$item};
+            my $envkey = $context.'.'.$item;
+            if ($context eq 'requestauthor') {
+                $envkey = $context;
+            }
+            if ($userenv{$envkey} ne '') {
+                $curroption = $userenv{$envkey};
+            } else {
+                my (@inststatuses);
+                if ($context eq 'requestcourses') {
+                    $curroption =
+                        &Apache::loncoursequeueadmin::get_processtype('course',$ccuname,$ccdomain,
+                                                                      $isadv,$ccdomain,$item,
+                                                                      \@inststatuses,\%domconfig);
+                } else {
+                     $curroption = 
+                         &Apache::loncoursequeueadmin::get_processtype('requestauthor',$ccuname,$ccdomain,
+                                                                       $isadv,$ccdomain,undef,
+                                                                       \@inststatuses,\%domconfig);
+                }
+            }
             if (!$curroption) {
                 $curroption = 'norequest';
             }
@@ -327,28 +372,36 @@ sub build_tools_display {
                         $checked = ' checked="checked"';
                     }
                 }
+                my $name = 'crsreq_'.$item;
+                if ($context eq 'requestauthor') {
+                    $name = $item;
+                }
                 $custdisp .= '<tr><td><span class="LC_nobreak"><label>'.
-                             '<input type="radio" name="crsreq_'.$item.
-                             '" value="'.$val.'"'.$checked.' />'.
+                             '<input type="radio" name="'.$name.'" '.
+                             'value="'.$val.'"'.$checked.' />'.
                              $reqtitles{$option}.'</label>&nbsp;';
                 if ($option eq 'autolimit') {
-                    $custdisp .= '<input type="text" name="crsreq_'.
-                                 $item.'_limit" size="1" '.
+                    $custdisp .= '<input type="text" name="'.$name.
+                                 '_limit" size="1" '.
                                  'value="'.$currlimit.'" /></span><br />'.
                                  $reqtitles{'unlimited'};
-                 } else {
-                     $custdisp .= '</span>';
-                 }
-                 $custdisp .= '</td></tr>';
+                } else {
+                    $custdisp .= '</span>';
+                }
+                $custdisp .= '</td></tr>';
             }
             $custdisp .= '</table>';
             $custradio = '</span></td><td>'.&mt('Custom setting').'<br />'.$custdisp;
         } else {
             $currdisp = ($curr_access?&mt('Yes'):&mt('No'));
+            my $name = $context.'_'.$item;
+            if ($context eq 'requestauthor') {
+                $name = $context;
+            }
             $custdisp = '<span class="LC_nobreak"><label>'.
-                        '<input type="radio" name="'.$context.'_'.$item.'"'.
-                        ' value="1"'. $tool_on.'/>'.&mt('On').'</label>&nbsp;<label>'.
-                        '<input type="radio" name="'.$context.'_'.$item.'" value="0" '.
+                        '<input type="radio" name="'.$name.'"'.
+                        ' value="1" '.$tool_on.'/>'.&mt('On').'</label>&nbsp;<label>'.
+                        '<input type="radio" name="'.$name.'" value="0" '.
                         $tool_off.'/>'.&mt('Off').'</label></span>';
             $custradio = ('&nbsp;'x2).'--'.$lt{'cusa'}.':&nbsp;'.$custdisp.
                           '</span>';
@@ -444,6 +497,17 @@ sub coursereq_externaluser {
     return $output;
 }
 
+sub domainrole_req {
+    my ($ccuname,$ccdomain) = @_;
+    return '<br /><h3>'.
+           &mt('User Can Request Assignment of Domain Roles?').
+           '</h3>'."\n".
+           &Apache::loncommon::start_data_table().
+           &build_tools_display($ccuname,$ccdomain,
+                                'requestauthor').
+           &Apache::loncommon::end_data_table();
+}
+
 sub courserequest_titles {
     my %titles = &Apache::lonlocal::texthash (
                                    official   => 'Official',
@@ -467,13 +531,86 @@ sub courserequest_display {
    return %titles;
 }
 
+sub requestauthor_titles {
+    my %titles = &Apache::lonlocal::texthash (
+                                   norequest  => 'Not allowed',
+                                   approval   => 'Approval by Dom. Coord.',
+                                   automatic  => 'Automatic approval',
+                 );
+    return %titles;
+
+}
+
+sub requestauthor_display {
+    my %titles = &Apache::lonlocal::texthash (
+                                   approval   => 'Yes, need approval',
+                                   automatic  => 'Yes, automatic approval',
+                                   norequest  => 'No',
+   );
+   return %titles;
+}
+
+sub curr_requestauthor {
+    my ($uname,$udom,$isadv,$inststatuses,$domconfig) = @_;
+    return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
+    if ($uname eq '' || $udom eq '') {
+        $uname = $env{'user.name'};
+        $udom = $env{'user.domain'};
+        $isadv = $env{'user.adv'};
+    }
+    my (%userenv,%settings,$val);
+    my @options = ('automatic','approval');
+    %userenv =
+        &Apache::lonnet::userenvironment($udom,$uname,'requestauthor','inststatus');
+    if ($userenv{'requestauthor'}) {
+        $val = $userenv{'requestauthor'};
+        @{$inststatuses} = ('_custom_');
+    } else {
+        my %alltasks;
+        if (ref($domconfig->{'requestauthor'}) eq 'HASH') {
+            %settings = %{$domconfig->{'requestauthor'}};
+            if (($isadv) && ($settings{'_LC_adv'} ne '')) {
+                $val = $settings{'_LC_adv'};
+                @{$inststatuses} = ('_LC_adv_');
+            } else {
+                if ($userenv{'inststatus'} ne '') {
+                    @{$inststatuses} = split(',',$userenv{'inststatus'});
+                } else {
+                    @{$inststatuses} = ('default');
+                }
+                foreach my $status (@{$inststatuses}) {
+                    if (exists($settings{$status})) {
+                        my $value = $settings{$status};
+                        next unless ($value);
+                        unless (exists($alltasks{$value})) {
+                            if (ref($alltasks{$value}) eq 'ARRAY') {
+                                unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) {
+                                    push(@{$alltasks{$value}},$status);
+                                }
+                            } else {
+                                @{$alltasks{$value}} = ($status);
+                            }
+                        }
+                    }
+                }
+                foreach my $option (@options) {
+                    if ($alltasks{$option}) {
+                        $val = $option;
+                        last;
+                    }
+                }
+            }
+        }
+    }
+    return $val;
+}
+
 # =================================================================== Phase one
 
 sub print_username_entry_form {
     my ($r,$context,$response,$srch,$forcenewuser,$crstype,$brcrum) = @_;
     my $defdom=$env{'request.role.domain'};
     my $formtoset = 'crtuser';
-    my $is_custom = &Apache::loncommon::needs_gci_custom();
     if (exists($env{'form.startrolename'})) {
         $formtoset = 'docustom';
         $env{'form.rolename'} = $env{'form.startrolename'};
@@ -495,12 +632,6 @@ sub print_username_entry_form {
         && (&Apache::lonnet::allowed('mcr','/'))) {
         $jscript .= &customrole_javascript();
     }
-    my $title = 'User Management';
-    if ($context eq 'course') {
-        if ($is_custom) {
-            $title = 'Enrollment and Student Activity';
-        }
-    }
     my $helpitem = 'Course_Change_Privileges';
     if ($env{'form.action'} eq 'custom') {
         $helpitem = 'Course_Editing_Custom_Roles';
@@ -529,7 +660,7 @@ sub print_username_entry_form {
     my $args = {bread_crumbs           => $brcrum,
                 bread_crumbs_component => 'User Management',
                 add_entries            => \%loaditems,};
-    $r->print(&Apache::loncommon::start_page($title,$jscript,$args));
+    $r->print(&Apache::loncommon::start_page('User Management',$jscript,$args));
 
     my %lt=&Apache::lonlocal::texthash(
                     'srst' => 'Search for a user and enroll as a student',
@@ -541,6 +672,7 @@ sub print_username_entry_form {
                     'nr'   => "role name",
                     'cre'  => "Next",
 				       );
+
     if ($env{'form.action'} eq 'custom') {
         if (&Apache::lonnet::allowed('mcr','/')) {
             my $newroletext = &mt('Define new custom role:');
@@ -635,7 +767,6 @@ END
 
 sub entry_form {
     my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype) = @_;
-    my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
     my ($usertype,$inexact);
     if (ref($srch) eq 'HASH') {
         if (($srch->{'srchin'} eq 'dom') &&
@@ -643,9 +774,10 @@ sub entry_form {
             ($srch->{'srchtype'} eq 'exact') &&
             ($srch->{'srchdomain'} ne '') &&
             ($srch->{'srchterm'} ne '')) {
+            my (%curr_rules,%got_rules);
             my ($rules,$ruleorder) =
                 &Apache::lonnet::inst_userrules($srch->{'srchdomain'},'username');
-            $usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules);
+            $usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules,\%curr_rules,\%got_rules);
         } else {
             $inexact = 1;
         }
@@ -671,7 +803,7 @@ $userpicker
 ENDBLOCK
     if ($env{'form.phase'} eq '') {
         my $defdom=$env{'request.role.domain'};
-        my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain','',1);
+        my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
         my %lt=&Apache::lonlocal::texthash(
                   'enro' => 'Enroll one student',
                   'enrm' => 'Enroll one member',
@@ -720,7 +852,7 @@ $showresponse
 <table>
  <tr>
   <td>$lt{'usr'}:</td>
-  <td><input type="text" size="25" name="srchterm" /></td>
+  <td><input type="text" size="15" name="srchterm" /></td>
   <td>&nbsp;$lt{'dom'}:</td><td>$domform</td>
   <td>&nbsp;$sellink&nbsp;</td>
   <td>&nbsp;<input name="userrole" type="submit" value="$buttontext" /></td>
@@ -739,19 +871,13 @@ sub user_modification_js {
 <script type="text/javascript" language="Javascript">
 // <![CDATA[
 
-    function pclose() {
-        parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
-                 "height=350,width=350,scrollbars=no,menubar=no");
-        parmwin.close();
-    }
-
     $pjump_def
     $dc_setcourse_code
 
     function dateset() {
         eval("document.cu."+document.cu.pres_marker.value+
             ".value=document.cu.pres_value.value");
-        pclose();
+        modalWindow.close();
     }
 
     $nondc_setsection_code
@@ -765,7 +891,6 @@ sub print_user_selection_page {
     my ($r,$response,$srch,$srch_results,$srcharray,$context,$opener_elements,$crstype,$brcrum) = @_;
     my @fields = ('username','domain','lastname','firstname','permanentemail');
     my $sortby = $env{'form.sortby'};
-    my $is_custom = &Apache::loncommon::needs_gci_custom();
 
     if (!grep(/^\Q$sortby\E$/,@fields)) {
         $sortby = 'lastname';
@@ -804,12 +929,6 @@ ENDSCRIPT
     if ($context eq 'requestcrs') {
         $r->print('<div>');
     } else {
-        my $title = 'User Management';
-        if ($context eq 'course') {
-            if ($is_custom) {
-                $title = 'Enrollment and Student Activity';
-            }
-        }
         my %breadcrumb_text = &singleuser_breadcrumb($crstype);
         my $helpitem;
         if ($env{'form.action'} eq 'singleuser') {
@@ -828,7 +947,7 @@ ENDSCRIPT
                    bug  => 'Instructor Interface',
                    help => $helpitem}
                   );
-        $r->print(&Apache::loncommon::start_page($title,$jscript,{bread_crumbs => $brcrum}));
+        $r->print(&Apache::loncommon::start_page('User Management',$jscript,{bread_crumbs => $brcrum}));
         if ($env{'form.action'} eq 'singleuser') {
             $r->print("<b>$lt{'usrch'}</b><br />");
             $r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context,undef,$crstype));
@@ -910,7 +1029,7 @@ ENDSCRIPT
     if ($context eq 'requestcrs') {
         $r->print($opener_elements.'</form></div>');
     } else {
-        $r->print($response.'</form>'.&Apache::loncommon::end_page());
+        $r->print($response.'</form>');
     }
 }
 
@@ -941,21 +1060,13 @@ sub print_user_modification_page {
     my %abv_auth = &auth_abbrev();
     my (%rulematch,%inst_results,$newuser,%alerts,%curr_rules,%got_rules);
     my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
-    my $is_custom = &Apache::loncommon::needs_gci_custom();
-    if ($is_custom) {
-        if ($uhome eq 'no_host') {
-            my $lc_ccuname = lc($ccuname);
-            if ($lc_ccuname ne $ccuname) {
-                $uhome = &Apache::lonnet::homeserver($lc_ccuname,$ccdomain);
-                $ccuname = $lc_ccuname;
-            }
-        }
-    }
     if ($uhome eq 'no_host') {
+        my $usertype;
         my ($rules,$ruleorder) =
             &Apache::lonnet::inst_userrules($ccdomain,'username');
-        my $usertype =
-            &Apache::lonuserutils::check_usertype($ccdomain,$ccuname,$rules);
+            $usertype =
+                &Apache::lonuserutils::check_usertype($ccdomain,$ccuname,$rules,
+                                                      \%curr_rules,\%got_rules);
         my $cancreate =
             &Apache::lonuserutils::can_create_user($ccdomain,$context,
                                                    $usertype);
@@ -965,26 +1076,19 @@ sub print_user_modification_page {
                 official   => 'institutional',
                 unofficial => 'non-institutional',
             );
-            if ($ccdomain eq 'gci') {
-                $usertypetext{'unofficial'} = 'institutional',
-            }
             my $response;
             if ($env{'form.origform'} eq 'crtusername') {
-                if ($is_custom) {
-                    $response = '<span class="LC_warning">'.&mt('Invalid format for username for new user: [_1]','<b>'.$ccuname.'</b>').
-                                '</span><br />';
-                } else {
-                    $response =  '<span class="LC_warning">'.&mt('No match was found for the username ([_1]) in LON-CAPA domain: [_2]',$ccuname,$ccdomain).'</span><br />';
-                }
+                $response = '<span class="LC_warning">'.
+                            &mt('No match found for the username [_1] in LON-CAPA domain: [_2]',
+                                '<b>'.$ccuname.'</b>',$ccdomain).
+                            '</span><br />';
             }
             $response .= '<p class="LC_warning">'
                         .&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.")
-                        .'<br />';
-            if ($ccdomain eq 'gcitest') {
-                $response .= &mt('Enter a valid e-mail address as the username for the new user.').' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.'
-                             ,'<a href="'.$helplink.'">','</a>')
-                             .'</p><br />';
-            }
+                        .' '
+                        .&mt('Please contact the [_1]helpdesk[_2] for assistance.'
+                            ,'<a href="'.$helplink.'">','</a>')
+                        .'</p><br />';
             $env{'form.phase'} = '';
             &print_username_entry_form($r,$context,$response,undef,undef,$crstype,$brcrum);
             return;
@@ -1031,12 +1135,6 @@ sub print_user_modification_page {
 
     my $js = &validation_javascript($context,$ccdomain,$pjump_def,
                                $groupslist,$newuser,$formname,\%loaditem);
-    my $title = 'User Management';
-    if ($context eq 'course') {
-        if ($is_custom) {
-            $title = 'Enrollment and Student Activity';
-        }
-    }
     my %breadcrumb_text = &singleuser_breadcrumb($crstype);
     my $helpitem = 'Course_Change_Privileges';
     if ($env{'form.action'} eq 'singlestudent') {
@@ -1067,7 +1165,7 @@ sub print_user_modification_page {
         $args->{'no_nav_bar'} = 1;
     }
     my $start_page =
-        &Apache::loncommon::start_page($title,$js,$args);
+        &Apache::loncommon::start_page('User Management',$js,$args);
 
     my $forminfo =<<"ENDFORMINFO";
 <form action="/adm/createuser" method="post" name="$formname">
@@ -1099,12 +1197,15 @@ ENDFORMINFO
         }
     }
     if ($newuser) {
-        my $portfolioform;
+        my ($portfolioform,$domroleform);
         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);
         }
+        if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) {
+            $domroleform = '<br />'.&domainrole_req($ccuname,$ccdomain);
+        }
         &initialize_authen_forms($ccdomain,$formname);
         my %lt=&Apache::lonlocal::texthash(
                 'cnu'            => 'Create New User',
@@ -1150,7 +1251,8 @@ $lt{'hs'}: $home_server_pick
             $r->print($home_server_pick);
         }
         if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
-            $r->print('<br /><h3>'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'</h3>'.
+            $r->print('<br /><h3>'.
+                      &mt('User Can Request Creation of Courses/Communities in this Domain?').'</h3>'.
                       &Apache::loncommon::start_data_table().
                       &build_tools_display($ccuname,$ccdomain,
                                            'requestcourses').
@@ -1214,7 +1316,7 @@ ENDAUTH
         } else {
             $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); 
         }
-        $r->print($portfolioform);
+        $r->print($portfolioform.$domroleform);
         if ($env{'form.action'} eq 'singlestudent') {
             $r->print(&date_sections_select($context,$newuser,$formname,
                                             $permission));
@@ -1248,10 +1350,10 @@ ENDCHANGEUSER
                                    $inst_results{$ccuname.':'.$ccdomain});
         $r->print($personal_table);
         if ($showforceid) {
-            $r->print(&Apache::lonuserutils::forceid_change($context));
+            $r->print('<table>'.&Apache::lonuserutils::forceid_change($context).'</table>');
         }
         if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
-            $r->print('<h3>'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'</h3>'.
+            $r->print('<br /><h3>'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'</h3>'.
                       &Apache::loncommon::start_data_table());
             if ($env{'request.role.domain'} eq $ccdomain) {
                 $r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses'));
@@ -1262,12 +1364,19 @@ ENDCHANGEUSER
             $r->print(&Apache::loncommon::end_data_table());
         }
         $r->print('</div>');
-        my $user_auth_text =  &user_authentication($ccuname,$ccdomain,$formname);
-        my ($user_quota_text,$user_tools_text,$user_reqcrs_text);
+        my @order = ('auth','quota','tools','requestauthor');
+        my %user_text;
+        my ($isadv,$isauthor) = 
+            &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
+        if ((!$isauthor) && 
+            (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {
+            $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_quota_text = &portfolio_quota($ccuname,$ccdomain);
+            $user_text{'quota'} = &portfolio_quota($ccuname,$ccdomain);
         }
         if (!&Apache::lonnet::allowed('mpq',$ccdomain)) {
             if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
@@ -1279,7 +1388,7 @@ ENDCHANGEUSER
                     'youd'  => "You do not have privileges to modify the portfolio quota for this user.",
                     'ichr'  => "If a change is required, contact a domain coordinator for the domain",
                 );
-                $user_quota_text = <<ENDNOPORTPRIV;
+                $user_text{'quota'} = <<ENDNOPORTPRIV;
 <h3>$lt{'dska'}</h3>
 $lt{'youd'} $lt{'ichr'}: $ccdomain
 ENDNOPORTPRIV
@@ -1289,46 +1398,34 @@ ENDNOPORTPRIV
             if (&Apache::lonnet::allowed('mut',$env{'request.role.domain'})) {
                 my %lt=&Apache::lonlocal::texthash(
                     'utav'  => "User Tools Availability",
-                    'yodo'  => "You do not have privileges to modify Portfolio, Blog or Personal Information Page settings for this user.",
+                    'yodo'  => "You do not have privileges to modify Portfolio, Blog, WebDAV, or Personal Information Page settings for this user.",
                     'ifch'  => "If a change is required, contact a domain coordinator for the domain",
                 );
-                $user_tools_text = <<ENDNOTOOLSPRIV;
+                $user_text{'tools'} = <<ENDNOTOOLSPRIV;
 <h3>$lt{'utav'}</h3>
 $lt{'yodo'} $lt{'ifch'}: $ccdomain
 ENDNOTOOLSPRIV
             }
         }
-        if ($user_auth_text ne '') {
-            $r->print('<div class="LC_left_float">'.$user_auth_text);
-            if ($user_quota_text ne '') {
-                $r->print($user_quota_text);
-            }
-            if ($user_tools_text ne '') {
-                $r->print($user_tools_text);
-            }
-            if ($env{'form.action'} eq 'singlestudent') {
-                $r->print(&date_sections_select($context,$newuser,$formname));
-            }
-        } elsif ($user_quota_text ne '') {
-            $r->print('<div class="LC_left_float">'.$user_quota_text);
-            if ($user_tools_text ne '') {
-                $r->print($user_tools_text);
-            }
-            if ($env{'form.action'} eq 'singlestudent') {
-                $r->print(&date_sections_select($context,$newuser,$formname));
-            }
-        } elsif ($user_tools_text ne '') {
-            $r->print('<div class="LC_left_float">'.$user_tools_text);
-            if ($env{'form.action'} eq 'singlestudent') {
-                $r->print(&date_sections_select($context,$newuser,$formname));
-            }
-        } else {
-            if ($env{'form.action'} eq 'singlestudent') {
-                $r->print('<div class="LC_left_float">'.
-                          &date_sections_select($context,$newuser,$formname));
+        my $gotdiv = 0; 
+        foreach my $item (@order) {
+            if ($user_text{$item} ne '') {
+                unless ($gotdiv) {
+                    $r->print('<div class="LC_left_float">');
+                    $gotdiv = 1;
+                }
+                $r->print('<br />'.$user_text{$item});
             }
         }
-        $r->print('</div><div class="LC_clear_float_footer"></div>');
+        if ($env{'form.action'} eq 'singlestudent') {
+            unless ($gotdiv) {
+                $r->print('<div class="LC_left_float">');
+            }
+            $r->print(&date_sections_select($context,$newuser,$formname));
+        } 
+        if ($gotdiv) {
+            $r->print('</div><div class="LC_clear_float_footer"></div>');
+        }
         if ($env{'form.action'} ne 'singlestudent') {
             &display_existing_roles($r,$ccuname,$ccdomain,\%inccourses,$context,
                                     $roledom,$crstype);
@@ -1349,7 +1446,7 @@ ENDNOTOOLSPRIV
             $addrolesdisplay = &new_coauthor_roles($r,$ccuname,$ccdomain);
         }
         if ($context eq 'domain') {
-            my $add_domainroles = &new_domain_roles($r);
+            my $add_domainroles = &new_domain_roles($r,$ccdomain);
             if (!$addrolesdisplay) {
                 $addrolesdisplay = $add_domainroles;
             }
@@ -1492,6 +1589,8 @@ sub display_existing_roles {
             $newkey .= '_'.$newrole;
             if ($start ne '' && $end ne '') {
                 $newvalue .= '_'.$end.'_'.$start;
+            } elsif ($end ne '') {
+                $newvalue .= '_'.$end;
             }
             $rolesdump{$newkey} = $newvalue;
         }
@@ -1552,7 +1651,7 @@ sub display_existing_roles {
                 $allowed=1;
             }
             unless ($allowed) {
-                my $isowner = &is_courseowner($cid,$coursedata{'internal.courseowner'});
+                my $isowner = &Apache::lonuserutils::is_courseowner($cid,$coursedata{'internal.courseowner'});
                 if ($isowner) {
                     if (($role_code eq 'co') && ($class eq 'Community')) {
                         $allowed = 1;
@@ -1602,7 +1701,7 @@ sub display_existing_roles {
                     $allowed=1;
                 }
             }
-            if ($role_code eq 'ca' || $role_code eq 'au') {
+            if ($role_code eq 'ca' || $role_code eq 'au' || $role_code eq 'aa') {
                 $class='Construction Space';
             } elsif ($role_code eq 'su') {
                 $class='System';
@@ -1648,7 +1747,10 @@ sub display_existing_roles {
             $plaintext=&Apache::lonnet::plaintext($role_code,$class)
         } else {
             $plaintext=
-        "Customrole '$croletitle'<br />defined by $croleuname\@$croleudom";
+                &mt('Customrole [_1][_2]defined by [_3]',
+                        '"'.$croletitle.'"',
+                        '<br />',
+                        $croleuname.':'.$croleudom);
         }
         $row.= '</td><td>'.$plaintext.
                '</td><td>'.$area.
@@ -1786,7 +1888,7 @@ sub new_coauthor_roles {
 }
 
 sub new_domain_roles {
-    my ($r) = @_;
+    my ($r,$ccdomain) = @_;
     my $addrolesdisplay = 0;
     #
     # Domain level
@@ -1804,6 +1906,7 @@ sub new_domain_roles {
     foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) {
         foreach my $role (@allroles) {
             next if ($role eq 'ad');
+            next if (($role eq 'au') && ($ccdomain ne $thisdomain));
             if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) {
                my $plrole=&Apache::lonnet::plaintext($role);
                my %lt=&Apache::lonlocal::texthash(
@@ -2100,9 +2203,22 @@ sub personal_data_display {
                 if ($canmodify_status{'inststatus'}) {
                     $shown = &pick_inst_statuses($userenv{'inststatus'},$usertypes,$types);
                 } else {
-                    $shown .= $userenv{'inststatus'};
                     if ($userenv{'inststatus'} eq '') {
                         $hiderow = 1;
+                    } else {
+                        my @showitems;
+                        foreach my $item ( map { &unescape($_); } split(':',$userenv{'inststatus'})) {
+                            if (exists($usertypes->{$item})) {
+                                push(@showitems,$usertypes->{$item});
+                            } else {
+                                push(@showitems,$item);
+                            }
+                        }
+                        if (@showitems) {
+                            $shown = join(', ',@showitems);
+                        } else {
+                            $hiderow = 1;
+                        }
                     }
                 }
                 if (!$hiderow) {
@@ -2198,8 +2314,7 @@ sub get_inststatuses {
 
 # ================================================================= Phase Three
 sub update_user_data {
-    my ($r,$context,$crstype,$brcrum) = @_;
-    my $is_custom = &Apache::loncommon::needs_gci_custom();
+    my ($r,$context,$crstype,$brcrum) = @_; 
     my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
                                           $env{'form.ccdomain'});
     # Error messages
@@ -2224,16 +2339,23 @@ sub update_user_data {
                   '// ]]>'."\n".
                   '</script>'."\n";
     my %breadcrumb_text = &singleuser_breadcrumb($crstype);
+    push (@{$brcrum},
+             {href => "javascript:backPage(document.userupdate)",
+              text => $breadcrumb_text{'search'},
+              faq  => 282,
+              bug  => 'Instructor Interface',}
+             );
+    if ($env{'form.prevphase'} eq 'userpicked') {
+        push(@{$brcrum},
+               {href => "javascript:backPage(document.userupdate,'get_user_info','select')",
+                text => $breadcrumb_text{'userpicked'},
+                faq  => 282,
+                bug  => 'Instructor Interface',});
+    }
     my $helpitem = 'Course_Change_Privileges';
     if ($env{'form.action'} eq 'singlestudent') {
         $helpitem = 'Course_Add_Student';
     }
-    my $bread_crumbs_component = 'User Management';
-    if ($context eq 'course') {
-        if ($is_custom) {
-            $bread_crumbs_component = 'Enrollment and Student Activity';
-        }
-    }
     push(@{$brcrum}, 
             {href => "javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')",
              text => $breadcrumb_text{'modify'},
@@ -2244,13 +2366,12 @@ sub update_user_data {
              faq  => 282,
              bug  => 'Instructor Interface',
              help => $helpitem});
-    my $args = {bread_crumbs           => $brcrum,
-                bread_crumbs_component => $bread_crumbs_component};
+    my $args = {bread_crumbs          => $brcrum,
+                bread_crumbs_component => 'User Management'};
     if ($env{'form.popup'}) {
         $args->{'no_nav_bar'} = 1;
     }
     $r->print(&Apache::loncommon::start_page($title,$jscript,$args));
-
     $r->print(&update_result_form($uhome));
     # Check Inputs
     if (! $env{'form.ccuname'} ) {
@@ -2317,11 +2438,18 @@ sub update_user_data {
 
     $r->print('<h3>'.&mt('User [_1] in domain [_2]',
 			 $env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>');
+    $r->print('<p class="LC_info">'.&mt('Please be patient').'</p>');
+
     my (%alerts,%rulematch,%inst_results,%curr_rules);
-    my @usertools = ('aboutme','blog','portfolio');
+    my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
+    my @usertools = ('aboutme','blog','webdav','portfolio');
     my @requestcourses = ('official','unofficial','community');
+    my @requestauthor = ('requestauthor');
     my ($othertitle,$usertypes,$types) = 
         &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
+    my %canmodify_status =
+        &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},
+                                                   ['inststatus']);
     if ($env{'form.makeuser'}) {
 	$r->print('<h3>'.&mt('Creating new account.').'</h3>');
         # Check for the authentication mode and password
@@ -2381,49 +2509,58 @@ sub update_user_data {
 	$r->print(&mt('Generating user').': '.$result);
         $uhome = &Apache::lonnet::homeserver($env{'form.ccuname'},
                                                $env{'form.ccdomain'});
-        my (%changeHash,%newcustom,%changed);
+        my (%changeHash,%newcustom,%changed,%changedinfo);
         if ($uhome ne 'no_host') {
-            if ($env{'form.customquota'} == 1) {
-                if ($env{'form.portfolioquota'} eq '') {
-                    $newcustom{'quota'} = 0;
-                } else {
-                    $newcustom{'quota'} = $env{'form.portfolioquota'};
-                    $newcustom{'quota'} =~ s/[^\d\.]//g;
+            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;
+                    }
+                    $changed{'quota'} = &quota_admin($newcustom{'quota'},\%changeHash);
                 }
-                $changed{'quota'} = &quota_admin($newcustom{'quota'},\%changeHash);
-            }
-            foreach my $item (@usertools) {
-                if ($env{'form.custom'.$item} == 1) {
-                    $newcustom{$item} = $env{'form.tools_'.$item};
-                    $changed{$item} = &tool_admin($item,$newcustom{$item},
-                                                 \%changeHash,'tools');
+                foreach my $item (@usertools) {
+                    if ($env{'form.custom'.$item} == 1) {
+                        $newcustom{$item} = $env{'form.tools_'.$item};
+                        $changed{$item} = &tool_admin($item,$newcustom{$item},
+                                                     \%changeHash,'tools');
+                    }
                 }
-            }
-            foreach my $item (@requestcourses) {
-                $newcustom{$item} = $env{'form.crsreq_'.$item};
-                if ($env{'form.crsreq_'.$item} eq 'autolimit') {
-                    $newcustom{$item} .= '=';
-                    unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) {
-                        $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
+                foreach my $item (@requestcourses) {
+                    if ($env{'form.custom'.$item} == 1) {
+                        $newcustom{$item} = $env{'form.crsreq_'.$item};
+                        if ($env{'form.crsreq_'.$item} eq 'autolimit') {
+                            $newcustom{$item} .= '=';
+                            unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) {
+                                $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
+                            }
+                        }
+                        $changed{$item} = &tool_admin($item,$newcustom{$item},
+                                                      \%changeHash,'requestcourses');
                     }
                 }
-                $changed{$item} = &tool_admin($item,$newcustom{$item},
-                                              \%changeHash,'requestcourses');
-            }
-            if (exists($env{'form.inststatus'})) {
-                my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
-                if (@inststatuses > 0) {
-                    $changeHash{'inststatus'} = join(',',@inststatuses);
-                    $changed{'inststatus'} = $changeHash{'inststatus'};
+                if ($env{'form.customrequestauthor'} == 1) {
+                    $newcustom{'requestauthor'} = $env{'form.requestauthor'};
+                    $changed{'requestauthor'} = &tool_admin('requestauthor',
+                                                    $newcustom{'requestauthor'},
+                                                    \%changeHash,'requestauthor');
+                }
+            }
+            if ($canmodify_status{'inststatus'}) {
+                if (exists($env{'form.inststatus'})) {
+                    my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
+                    if (@inststatuses > 0) {
+                        $changeHash{'inststatus'} = join(',',@inststatuses);
+                        $changed{'inststatus'} = $changeHash{'inststatus'};
+                    }
                 }
             }
             if (keys(%changed)) {
-                $changeHash{'firstname'}  = $env{'form.cfirstname'};
-                $changeHash{'middlename'} = $env{'form.cmiddlename'};
-                $changeHash{'lastname'}   = $env{'form.clastname'};
-                $changeHash{'generation'} = $env{'form.cgeneration'};
-                $changeHash{'id'}         = $env{'form.cid'};
-                $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
+                foreach my $item (@userinfo) {
+                    $changeHash{$item}  = $env{'form.c'.$item};
+                }
                 my $chgresult =
                      &Apache::lonnet::put('environment',\%changeHash,
                                           $env{'form.ccdomain'},$env{'form.ccuname'});
@@ -2451,8 +2588,11 @@ sub update_user_data {
 	    $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);    
 	}
     }
+
+    $r->rflush(); # Finish display of header before time consuming actions start
+
     ##
-    my (@userroles,%userupdate,$cnum,$cdom,$crstype,$namechanged);
+    my (@userroles,%userupdate,$cnum,$cdom,%namechanged);
     if ($context eq 'course') {
         ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity();
         $crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum);
@@ -2462,10 +2602,11 @@ sub update_user_data {
         my %userenv = &Apache::lonnet::get
             ('environment',['firstname','middlename','lastname','generation',
              'id','permanentemail','portfolioquota','inststatus','tools.aboutme',
-             'tools.blog','tools.portfolio','requestcourses.official',
-             'requestcourses.unofficial','requestcourses.community',
-             'reqcrsotherdom.official','reqcrsotherdom.unofficial',
-             'reqcrsotherdom.community'],
+             'tools.blog','tools.webdav','tools.portfolio',
+             'requestcourses.official','requestcourses.unofficial',
+             'requestcourses.community','reqcrsotherdom.official',
+             'reqcrsotherdom.unofficial','reqcrsotherdom.community',
+             'requestauthor'],
               $env{'form.ccdomain'},$env{'form.ccuname'});
         my ($tmp) = keys(%userenv);
         if ($tmp =~ /^(con_lost|error)/i) { 
@@ -2542,7 +2683,6 @@ sub update_user_data {
                 push(@longroles,&Apache::lonnet::plaintext($role,$crstype)); 
             }
         }
-        my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
         my %canmodify = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},\@userinfo,\@userroles);
         foreach my $item (@userinfo) {
             # Strip leading and trailing whitespace
@@ -2589,40 +2729,51 @@ sub update_user_data {
             }
         }
         my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus,
-            $inststatus,$newinststatus,$oldisdefault,$newisdefault,$olddefquotatext,
-            $newdefquotatext,%oldaccess,%oldaccesstext,%newaccess,%newaccesstext,
-            $oldinststatuses,$newinststatuses);
-        my ($defquota,$settingstatus) = 
-            &Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus);
-        my ($showquota,$showtools,$showrequestcourses,$showinststatus,$showreqotherdom);
+            $newinststatus,$oldisdefault,$newisdefault,%oldsettings,
+            %oldsettingstext,%newsettings,%newsettingstext,@disporder,
+            $olddefquota,$oldsettingstatus,$newdefquota,$newsettingstatus);
+        @disporder = ('inststatus');
+        if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) {
+            push(@disporder,'requestcourses','requestauthor');
+        } else {
+            push(@disporder,'reqcrsotherdom');
+        }
+        push(@disporder,('quota','tools'));
+        $oldinststatus = $userenv{'inststatus'};
+        ($olddefquota,$oldsettingstatus) = 
+            &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus);
+        ($newdefquota,$newsettingstatus) = ($olddefquota,$oldsettingstatus);
+        my %canshow;
         if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
-            $showquota = 1;
+            $canshow{'quota'} = 1;
         }
         if (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
-            $showtools = 1;
+            $canshow{'tools'} = 1;
         }
         if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) {
-            $showrequestcourses = 1;
+            $canshow{'requestcourses'} = 1;
         } elsif (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
-            $showreqotherdom = 1;
+            $canshow{'reqcrsotherdom'} = 1;
         }
         if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
-            $showinststatus = 1;
+            $canshow{'inststatus'} = 1;
+        }
+        if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) {
+            $canshow{'requestauthor'} = 1;
         }
         my (%changeHash,%changed);
-        $oldinststatus = $userenv{'inststatus'};
         if ($oldinststatus eq '') {
-            $oldinststatuses = $othertitle; 
+            $oldsettings{'inststatus'} = $othertitle; 
         } else {
             if (ref($usertypes) eq 'HASH') {
-                $oldinststatuses = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
+                $oldsettings{'inststatus'} = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
             } else {
-                $oldinststatuses = join(', ',map{ &unescape($_); } (split(/:/,$userenv{'inststatus'})));
+                $oldsettings{'inststatus'} = join(', ',map{ &unescape($_); } (split(/:/,$userenv{'inststatus'})));
             }
         }
         $changeHash{'inststatus'} = $userenv{'inststatus'};
-        my %canmodify_inststatus = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},['inststatus'],\@userroles);
-        if ($canmodify_inststatus{'inststatus'}) {
+        if ($canmodify_status{'inststatus'}) {
+            $canshow{'inststatus'} = 1;
             if (exists($env{'form.inststatus'})) {
                 my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
                 if (@inststatuses > 0) {
@@ -2630,86 +2781,89 @@ sub update_user_data {
                     $changeHash{'inststatus'} = $newinststatus;
                     if ($newinststatus ne $oldinststatus) {
                         $changed{'inststatus'} = $newinststatus;
+                        ($newdefquota,$newsettingstatus) =
+                            &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus);
                     }
                     if (ref($usertypes) eq 'HASH') {
-                        $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses)); 
+                        $newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses)); 
                     } else {
-                        $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
-                    }
-                } else {
-                    $newinststatus = '';
-                    $changeHash{'inststatus'} = $newinststatus;
-                    $newinststatuses = $othertitle;
-                    if ($newinststatus ne $oldinststatus) {
-                        $changed{'inststatus'} = $changeHash{'inststatus'};
+                        $newsettings{'inststatus'} = join(', ',@inststatuses);
                     }
                 }
+            } else {
+                $newinststatus = '';
+                $changeHash{'inststatus'} = $newinststatus;
+                $newsettings{'inststatus'} = $othertitle;
+                if ($newinststatus ne $oldinststatus) {
+                    $changed{'inststatus'} = $changeHash{'inststatus'};
+                    ($newdefquota,$newsettingstatus) =
+                        &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus);
+                }
             }
+        } elsif ($context ne 'selfcreate') {
+            $canshow{'inststatus'} = 1;
+            $newsettings{'inststatus'} = $oldsettings{'inststatus'};
         }
         $changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
-        if ($userenv{'portfolioquota'} ne '') {
-            $oldportfolioquota = $userenv{'portfolioquota'};
-            if ($env{'form.customquota'} == 1) {
-                if ($env{'form.portfolioquota'} eq '') {
-                    $newportfolioquota = 0;
+        if ($context eq 'domain') {
+            if ($userenv{'portfolioquota'} ne '') {
+                $oldportfolioquota = $userenv{'portfolioquota'};
+                if ($env{'form.customquota'} == 1) {
+                    if ($env{'form.portfolioquota'} eq '') {
+                        $newportfolioquota = 0;
+                    } else {
+                        $newportfolioquota = $env{'form.portfolioquota'};
+                        $newportfolioquota =~ s/[^\d\.]//g;
+                    }
+                    if ($newportfolioquota != $oldportfolioquota) {
+                        $changed{'quota'} = &quota_admin($newportfolioquota,\%changeHash);
+                    }
                 } else {
-                    $newportfolioquota = $env{'form.portfolioquota'};
-                    $newportfolioquota =~ s/[^\d\.]//g;
-                }
-                if ($newportfolioquota != $oldportfolioquota) {
-                    $changed{'quota'} = &quota_admin($newportfolioquota,\%changeHash);
+                    $changed{'quota'} = &quota_admin('',\%changeHash);
+                    $newportfolioquota = $newdefquota;
+                    $newisdefault = 1;
                 }
             } else {
-                $changed{'quota'} = &quota_admin('',\%changeHash);
-                $newportfolioquota = $defquota;
-                $newisdefault = 1;
-            }
-        } else {
-            $oldisdefault = 1;
-            $oldportfolioquota = $defquota;
-            if ($env{'form.customquota'} == 1) {
-                if ($env{'form.portfolioquota'} eq '') {
-                    $newportfolioquota = 0;
+                $oldisdefault = 1;
+                $oldportfolioquota = $olddefquota;
+                if ($env{'form.customquota'} == 1) {
+                    if ($env{'form.portfolioquota'} eq '') {
+                        $newportfolioquota = 0;
+                    } else {
+                        $newportfolioquota = $env{'form.portfolioquota'};
+                        $newportfolioquota =~ s/[^\d\.]//g;
+                    }
+                    $changed{'quota'} = &quota_admin($newportfolioquota,\%changeHash);
                 } else {
-                    $newportfolioquota = $env{'form.portfolioquota'};
-                    $newportfolioquota =~ s/[^\d\.]//g;
+                    $newportfolioquota = $newdefquota;
+                    $newisdefault = 1;
                 }
-                $changed{'quota'} = &quota_admin($newportfolioquota,\%changeHash);
+            }
+            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'}) {
+                &tool_changes('requestcourses',\@requestcourses,\%oldsettings,\%oldsettingstext,
+                              \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
+                &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext,\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
             } else {
-                $newportfolioquota = $defquota;
-                $newisdefault = 1;
+                &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,
+                              \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
             }
         }
-        if ($oldisdefault) {
-            $olddefquotatext = &get_defaultquota_text($settingstatus);
-        }
-        if ($newisdefault) {
-            $newdefquotatext = &get_defaultquota_text($settingstatus);
-        }
-        &tool_changes('tools',\@usertools,\%oldaccess,\%oldaccesstext,\%userenv,
-                      \%changeHash,\%changed,\%newaccess,\%newaccesstext);
-        if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
-            &tool_changes('requestcourses',\@requestcourses,\%oldaccess,\%oldaccesstext,
-                          \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext);
-        } else {
-            &tool_changes('reqcrsotherdom',\@requestcourses,\%oldaccess,\%oldaccesstext,
-                          \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext);
-        }
-        if ($env{'form.cfirstname'}  ne $userenv{'firstname'}  ||
-            $env{'form.cmiddlename'} ne $userenv{'middlename'} ||
-            $env{'form.clastname'}   ne $userenv{'lastname'}   ||
-            $env{'form.cgeneration'} ne $userenv{'generation'} ||
-            $env{'form.cid'} ne $userenv{'id'}                 ||
-            $env{'form.cpermanentemail'} ne $userenv{'permanentemail'} ) {
-            $namechanged = 1;
-        }
-        if (($namechanged) || (keys(%changed) > 0)) {
-            $changeHash{'firstname'}  = $env{'form.cfirstname'};
-            $changeHash{'middlename'} = $env{'form.cmiddlename'};
-            $changeHash{'lastname'}   = $env{'form.clastname'};
-            $changeHash{'generation'} = $env{'form.cgeneration'};
-            $changeHash{'id'}         = $env{'form.cid'};
-            $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
+        foreach my $item (@userinfo) {
+            if ($env{'form.c'.$item} ne $userenv{$item}) {
+                $namechanged{$item} = 1;
+            }
+        }
+        $oldsettings{'quota'} = $oldportfolioquota.' Mb';
+        $newsettings{'quota'} = $newportfolioquota.' Mb';
+        if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) {
             my ($chgresult,$namechgresult);
             if (keys(%changed) > 0) {
                 $chgresult = 
@@ -2724,14 +2878,22 @@ sub update_user_data {
                                 || ($key eq 'community')) {
                                 $newenvhash{'environment.requestcourses.'.$key} =
                                     $changeHash{'requestcourses.'.$key};
-                                if ($changeHash{'requestcourses.'.$key} ne '') {
-                                    $newenvhash{'environment.canrequest.'.$key} =
-                                        $changeHash{'requestcourses.'.$key};
+                                if ($changeHash{'requestcourses.'.$key}) {
+                                    $newenvhash{'environment.canrequest.'.$key} = 1;
                                 } else {
                                     $newenvhash{'environment.canrequest.'.$key} =
           &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
                                             $key,'reload','requestcourses');
                                 }
+                            } elsif ($key eq 'requestauthor') {
+                                $newenvhash{'environment.'.$key} = $changeHash{$key};
+                                if ($changeHash{$key}) {
+                                    $newenvhash{'environment.canrequest.author'} = 1;
+                                } else {
+                                    $newenvhash{'environment.canrequest.author'} =
+          &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
+                                            $key,'reload','requestauthor');
+                                }
                             } elsif ($key ne 'quota') {
                                 $newenvhash{'environment.tools.'.$key} = 
                                     $changeHash{'tools.'.$key};
@@ -2740,8 +2902,7 @@ sub update_user_data {
                                         $changeHash{'tools.'.$key};
                                 } else {
                                     $newenvhash{'environment.availabletools.'.$key} =
-          &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
-                                            $key,'reload','tools');
+          &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},                                            $key,'reload','tools');
                                 }
                             }
                         }
@@ -2751,14 +2912,17 @@ sub update_user_data {
                     }
                 }
             }
-            if ($namechanged) {
-            # Make the change
+            if (keys(%namechanged) > 0) {
+                foreach my $field (@userinfo) {
+                    $changeHash{$field}  = $env{'form.c'.$field};
+                }
+# Make the change
                 $namechgresult =
                     &Apache::lonnet::modifyuser($env{'form.ccdomain'},
                         $env{'form.ccuname'},$changeHash{'id'},undef,undef,
                         $changeHash{'firstname'},$changeHash{'middlename'},
                         $changeHash{'lastname'},$changeHash{'generation'},
-                        $changeHash{'id'},undef,$changeHash{'permanentemail'});
+                        $changeHash{'id'},undef,$changeHash{'permanentemail'},undef,\@userinfo);
                 %userupdate = (
                                lastname   => $env{'form.clastname'},
                                middlename => $env{'form.cmiddlename'},
@@ -2767,139 +2931,13 @@ sub update_user_data {
                                id         => $env{'form.cid'},
                              );
             }
-            if (($namechanged && $namechgresult eq 'ok') || 
+            if (((keys(%namechanged) > 0) && $namechgresult eq 'ok') || 
                 ((keys(%changed) > 0) && $chgresult eq 'ok')) {
             # Tell the user we changed the name
-		my %lt=&Apache::lonlocal::texthash(
-                             'uic'        => 'User Information Changed',
-                             'frst'       => 'First Name',
-                             'mddl'       => 'Middle Name',
-                             'lst'        => 'Last Name',
-                             'gen'        => 'Generation',
-                             'id'         => 'Student/Employee ID',
-                             'mail'       => 'Permanent e-mail address',
-                             'disk'       => 'Disk space allocated to portfolio files',
-                             'blog'       => 'Blog Availability',
-                             'aboutme'    => 'Personal Information Page Availability',
-                             'portfolio'  => 'Portfolio Availability',
-                             'official'   => 'Can Request Official Courses',
-                             'unofficial' => 'Can Request Unofficial Courses',
-                             'community'  => 'Can Request Communities',
-                             'inststatus' => "Affiliation",
-                             'prvs'       => 'Previous Value:',
-                             'chto'       => 'Changed To:'
-						   );
-                $r->print('<h4>'.$lt{'uic'}.'</h4>'.
-                          &Apache::loncommon::start_data_table().
-                          &Apache::loncommon::start_data_table_header_row());
-                $r->print(<<"END");
-    <th>&nbsp;</th>
-    <th>$lt{'frst'}</th>
-    <th>$lt{'mddl'}</th>
-    <th>$lt{'lst'}</th>
-    <th>$lt{'gen'}</th>
-    <th>$lt{'id'}</th>
-    <th>$lt{'mail'}</th>
-END
-                if ($showinststatus) {
-                    $r->print("
-    <th>$lt{'inststatus'}</th>\n");
-                }
-                if ($showrequestcourses) {
-                    foreach my $item (@requestcourses) {
-                        $r->print("
-    <th>$lt{$item}</th>\n");
-                    }
-                } elsif ($showreqotherdom) {
-                    foreach my $item (@requestcourses) {
-                        $r->print("
-    <th>$lt{$item}</th>\n");
-                    }
-                }
-                if ($showquota) {
-                    $r->print("
-    <th>$lt{'disk'}</th>\n");
-                }
-                if ($showtools) {
-                    foreach my $item (@usertools) {
-                        $r->print("
-    <th>$lt{$item}</th>\n");
-                    }
-                }
-                $r->print(&Apache::loncommon::end_data_table_header_row().
-                          &Apache::loncommon::start_data_table_row());
-                $r->print(<<"END");
-    <td><b>$lt{'prvs'}</b></td>
-    <td>$userenv{'firstname'}  </td>
-    <td>$userenv{'middlename'} </td>
-    <td>$userenv{'lastname'}   </td>
-    <td>$userenv{'generation'} </td>
-    <td>$userenv{'id'}</td>
-    <td>$userenv{'permanentemail'} </td>
-END
-                if ($showinststatus) {
-                    $r->print("
-    <td>$oldinststatuses</td>\n");
-                }  
-                if ($showrequestcourses) {
-                    foreach my $item (@requestcourses) {
-                        $r->print("
-    <td>$oldaccess{$item} $oldaccesstext{$item}</td>\n");
-                    }
-                } elsif ($showreqotherdom) {
-                    foreach my $item (@requestcourses) {
-                        $r->print("
-    <td>$oldaccess{$item} $oldaccesstext{$item}</td>\n");
-                    }
-                }
-                if ($showquota) {
-                    $r->print("
-    <td>$oldportfolioquota Mb $olddefquotatext </td>\n");
-                }
-                if ($showtools) {
-                    foreach my $item (@usertools) {
-                        $r->print("
-    <td>$oldaccess{$item} $oldaccesstext{$item} </td>\n");
-                    }
-                }
-                $r->print(&Apache::loncommon::end_data_table_row().
-                          &Apache::loncommon::start_data_table_row());
-                $r->print(<<"END");
-    <td><span class="LC_nobreak"><b>$lt{'chto'}</b></span></td>
-    <td>$env{'form.cfirstname'}  </td>
-    <td>$env{'form.cmiddlename'} </td>
-    <td>$env{'form.clastname'}   </td>
-    <td>$env{'form.cgeneration'} </td>
-    <td>$env{'form.cid'} </td>
-    <td>$env{'form.cpermanentemail'} </td>
-END
-                if ($showinststatus) {
-                    $r->print("
-    <td>$newinststatuses</td>\n");
-                }
-                if ($showrequestcourses) {
-                    foreach my $item (@requestcourses) {
-                        $r->print("
-    <td>$newaccess{$item} $newaccesstext{$item} </td>\n");
-                    }
-                } elsif ($showreqotherdom) {
-                    foreach my $item (@requestcourses) {
-                        $r->print("
-    <td>$newaccess{$item} $newaccesstext{$item} </td>\n");
-                    }
-                }
-                if ($showquota) {
-                    $r->print("
-    <td>$newportfolioquota Mb $newdefquotatext </td>\n");
-                }
-                if ($showtools) {
-                    foreach my $item (@usertools) {
-                        $r->print("
-    <td>$newaccess{$item} $newaccesstext{$item} </td>\n");
-                    }
-                }
-                $r->print(&Apache::loncommon::end_data_table_row().
-                          &Apache::loncommon::end_data_table().'<br />');
+                &display_userinfo($r,1,\@disporder,\%canshow,\@requestcourses,
+                                  \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged,
+                                  \%oldsettings, \%oldsettingstext,\%newsettings,
+                                  \%newsettingstext);
                 if ($env{'form.cid'} ne $userenv{'id'}) {
                     &Apache::lonnet::idput($env{'form.ccdomain'},
                          ($env{'form.ccuname'} => $env{'form.cid'}));
@@ -2925,54 +2963,13 @@ END
                       $env{'form.ccuname'}.' '.&mt('in domain').' '.
                       $env{'form.ccdomain'}.'</span><br />');
             }
-        }  else { # End of if ($env ... ) logic
+        } else { # End of if ($env ... ) logic
             # They did not want to change the users name, quota, tool availability,
             # or ability to request creation of courses, 
             # but we can still tell them what the name and quota and availabilities are  
-	    my %lt=&Apache::lonlocal::texthash(
-                           'id'         => "Student/Employee ID",
-                           'mail'       => "Permanent e-mail address",
-                           'disk'       => "Disk space allocated to user's portfolio files",
-                           'blog'       => "Blog Availability",
-                           'aboutme'    => "Personal Information Page Availability",
-                           'portfolio'  => "Portfolio Availability",
-                           'official'   => "Can Request Official Courses",
-                           'unofficial' => "Can Request Unofficial Courses",
-                           'community'  => "Can Request Communities",
-                           'inststatus' => "Affiliation",
-					       );
-            $r->print(<<"END");
-<h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
-END
-            if ($userenv{'permanentemail'} ne '') {
-                $r->print('<br />['.$lt{'mail'}.': '.
-                          $userenv{'permanentemail'}.']');
-            }
-            if ($showinststatus) {
-                $r->print('<br />['.$lt{'inststatus'}.': '.$oldinststatuses.']');
-            }
-            if ($showrequestcourses) {
-                foreach my $item (@requestcourses) {
-                    $r->print('<br />['.$lt{$item}.': '.$newaccess{$item}.' '.
-                              $newaccesstext{$item}.']'."\n");
-                }
-            } elsif ($showreqotherdom) {
-                foreach my $item (@requestcourses) {
-                    $r->print('<br />['.$lt{$item}.': '.$newaccess{$item}.' '.
-                              $newaccesstext{$item}.']'."\n");
-                }
-            }
-            if ($showtools) {
-                foreach my $item (@usertools) {
-                    $r->print('<br />['.$lt{$item}.': '.$newaccess{$item}.' '.
-                              $newaccesstext{$item}.']'."\n");
-                }
-            }
-            if ($showquota) {
-                $r->print('<br />['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '.
-                          $olddefquotatext.']');
-            }
-            $r->print('</h4>');
+            &display_userinfo($r,undef,\@disporder,\%canshow,\@requestcourses,
+                              \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged,\%oldsettings,
+                              \%oldsettingstext,\%newsettings,\%newsettingstext);
         }
         if (@mod_disallowed) {
             my ($rolestr,$contextname);
@@ -3019,7 +3016,7 @@ END
         $r->print('</a></p>');
     } else {
         my @rolechanges = &update_roles($r,$context);
-        if ($namechanged) {
+        if (keys(%namechanged) > 0) {
             if ($context eq 'course') {
                 if (@userroles > 0) {
                     if ((@rolechanges == 0) || 
@@ -3047,6 +3044,139 @@ END
     }
 }
 
+sub display_userinfo {
+    my ($r,$changed,$order,$canshow,$requestcourses,$usertools,$requestauthor,
+        $userenv,$changedhash,$namechangedhash,$oldsetting,$oldsettingtext,
+        $newsetting,$newsettingtext) = @_;
+    return unless (ref($order) eq 'ARRAY' &&
+                   ref($canshow) eq 'HASH' && 
+                   ref($requestcourses) eq 'ARRAY' && 
+                   ref($requestauthor) eq 'ARRAY' &&
+                   ref($usertools) eq 'ARRAY' && 
+                   ref($userenv) eq 'HASH' &&
+                   ref($changedhash) eq 'HASH' &&
+                   ref($oldsetting) eq 'HASH' &&
+                   ref($oldsettingtext) eq 'HASH' &&
+                   ref($newsetting) eq 'HASH' &&
+                   ref($newsettingtext) eq 'HASH');
+    my %lt=&Apache::lonlocal::texthash(
+         'ui'             => 'User Information (unchanged)',
+         'uic'            => 'User Information Changed',
+         'firstname'      => 'First Name',
+         'middlename'     => 'Middle Name',
+         'lastname'       => 'Last Name',
+         'generation'     => 'Generation',
+         'id'             => 'Student/Employee ID',
+         'permanentemail' => 'Permanent e-mail address',
+         'quota'          => 'Disk space allocated to portfolio files',
+         'blog'           => 'Blog Availability',
+         'webdav'         => 'WebDAV Availability',
+         'aboutme'        => 'Personal Information Page Availability',
+         'portfolio'      => 'Portfolio Availability',
+         'official'       => 'Can Request Official Courses',
+         'unofficial'     => 'Can Request Unofficial Courses',
+         'community'      => 'Can Request Communities',
+         'requestauthor'  => 'Can Request Author Role',
+         'inststatus'     => "Affiliation",
+         'prvs'           => 'Previous Value:',
+         'chto'           => 'Changed To:'
+    );
+    my $title = $lt{'ui'}; 
+    if ($changed) {
+        $title = $lt{'uic'};
+    }
+    $r->print('<h4>'.$title.'</h4>'.
+              &Apache::loncommon::start_data_table().
+              &Apache::loncommon::start_data_table_header_row());
+    if ($changed) {
+        $r->print("<th>&nbsp;</th>\n");
+    }
+    my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
+    foreach my $item (@userinfo) {
+        $r->print("<th>$lt{$item}</th>\n");
+    }
+    foreach my $entry (@{$order}) {
+        if ($canshow->{$entry}) {
+            if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {
+                foreach my $item (@{$requestcourses}) {
+                    $r->print("<th>$lt{$item}</th>\n");
+                }
+            } elsif ($entry eq 'tools') {
+                foreach my $item (@{$usertools}) {
+                    $r->print("<th>$lt{$item}</th>\n");
+                }
+            } else {
+                $r->print("<th>$lt{$entry}</th>\n");
+            }
+        }
+    }
+    $r->print(&Apache::loncommon::end_data_table_header_row().
+             &Apache::loncommon::start_data_table_row());
+    if ($changed) {
+        $r->print('<td><b>'.$lt{'prvs'}.'</b></td>'."\n");
+    }
+    foreach my $item (@userinfo) {
+        $r->print('<td>'.$userenv->{$item}.' </td>'."\n");
+    }
+    foreach my $entry (@{$order}) {
+        if ($canshow->{$entry}) {
+            if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {
+                foreach my $item (@{$requestcourses}) {
+                    $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");
+                }
+            } elsif ($entry eq 'tools') {
+                foreach my $item (@{$usertools}) {
+                    $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");
+                }
+            } else {
+                $r->print("<td>$oldsetting->{$entry} $oldsettingtext->{$entry} </td>\n");
+            }
+        }
+    }
+    $r->print(&Apache::loncommon::end_data_table_row());
+    if ($changed) {
+        $r->print(&Apache::loncommon::start_data_table_row().
+                  '<td><span class="LC_nobreak"><b>'.$lt{'chto'}.'</b></span></td>'."\n");
+        foreach my $item (@userinfo) {
+            my $value = $env{'form.c'.$item};
+            if ($namechangedhash->{$item}) {
+                $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+            }
+            $r->print("<td>$value </td>\n");
+        }
+        foreach my $entry (@{$order}) {
+            if ($canshow->{$entry}) {
+                if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {
+                    foreach my $item (@{$requestcourses}) {
+                        my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
+                        if ($changedhash->{$item}) {
+                            $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+                        }
+                        $r->print("<td>$value </td>\n");
+                    }
+                } elsif ($entry eq 'tools') {
+                    foreach my $item (@{$usertools}) {
+                        my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
+                        if ($changedhash->{$item}) {
+                            $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+                        }
+                        $r->print("<td>$value </td>\n");
+                    }
+                } else {
+                    my $value = $newsetting->{$entry}.' '.$newsettingtext->{$entry};
+                    if ($changedhash->{$entry}) {
+                        $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+                    }
+                    $r->print("<td>$value </td>\n");
+                }
+            }
+        }
+        $r->print(&Apache::loncommon::end_data_table_row());
+    }
+    $r->print(&Apache::loncommon::end_data_table().'<br />');
+    return;
+}
+
 sub tool_changes {
     my ($context,$usertools,$oldaccess,$oldaccesstext,$userenv,$changeHash,
         $changed,$newaccess,$newaccesstext) = @_;
@@ -3142,25 +3272,29 @@ sub tool_changes {
         return;
     }
     foreach my $tool (@{$usertools}) {
-        my $newval;
+        my ($newval,$envkey);
+        $envkey = $context.'.'.$tool;
         if ($context eq 'requestcourses') {
             $newval = $env{'form.crsreq_'.$tool};
             if ($newval eq 'autolimit') {
                 $newval .= '='.$env{'form.crsreq_'.$tool.'_limit'};
             }
+        } elsif ($context eq 'requestauthor') {
+            $newval = $env{'form.'.$context};
+            $envkey = $context;
         } else {
             $newval = $env{'form.'.$context.'_'.$tool};
         }
-        if ($userenv->{$context.'.'.$tool} ne '') {
+        if ($userenv->{$envkey} ne '') {
             $oldaccess->{$tool} = &mt('custom');
-            if ($userenv->{$context.'.'.$tool}) {
+            if ($userenv->{$envkey}) {
                 $oldaccesstext->{$tool} = &mt("availability set to 'on'");
             } else {
                 $oldaccesstext->{$tool} = &mt("availability set to 'off'");
             }
-            $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
+            $changeHash->{$envkey} = $userenv->{$envkey};
             if ($env{'form.custom'.$tool} == 1) {
-                if ($newval ne $userenv->{$context.'.'.$tool}) {
+                if ($newval ne $userenv->{$envkey}) {
                     $changed->{$tool} = &tool_admin($tool,$newval,$changeHash,
                                                     $context);
                     if ($changed->{$tool}) {
@@ -3476,7 +3610,7 @@ sub update_roles {
 	}
     } # End of foreach (keys(%env))
 # Flush the course logs so reverse user roles immediately updated
-    &Apache::lonnet::flushcourselogs();
+    $r->register_cleanup(\&Apache::lonnet::flushcourselogs);
     if (@rolechanges == 0) {
         $r->print(&mt('No roles to modify'));
     }
@@ -3604,6 +3738,10 @@ sub tool_admin {
         if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
             $canchange = 1;
         }
+    } elsif ($context eq 'requestauthor') {
+        if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) {
+            $canchange = 1;
+        }
     } elsif (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
         # Current user has quota modification privileges
         $canchange = 1;
@@ -3612,7 +3750,11 @@ sub tool_admin {
     if ($canchange) {
         if (ref($changeHash) eq 'HASH') {
             $toolchanged = 1;
-            $changeHash->{$context.'.'.$tool} = $settool;
+            if ($tool eq 'requestauthor') {
+                $changeHash->{$context} = $settool;
+            } else {
+                $changeHash->{$context.'.'.$tool} = $settool;
+            }
         }
     }
     return $toolchanged;
@@ -3677,13 +3819,7 @@ sub custom_role_editor {
 	&print_username_entry_form($r,undef,undef,undef,undef,$crstype,$brcrum);
         return;
     }
-    my $is_custom = &Apache::loncommon::needs_gci_custom();
-    my $title = 'User Management';
-    if ($context eq 'course') {
-        if ($is_custom) {
-            $title = 'Enrollment and Student Activity';
-        }
-    }
+
 # ------------------------------------------------------- What can be assigned?
     my %full=();
     my %courselevel=();
@@ -3954,14 +4090,6 @@ sub set_custom_role {
                  .$jsback."\n"
                  .'// ]]>'."\n"
                  .'</script>'."\n";
-    my $bread_crumbs_component = 'User Management';
-    my $is_custom = &Apache::loncommon::needs_gci_custom();
-    if ($context eq 'course') {
-        if ($is_custom) {
-            $bread_crumbs_component = 'Enrollment and Student Activity';
-        }
-    }
-
     push(@{$brcrum},
         {href => "javascript:backPage(document.customresult,'pickrole','')",
          text => "Pick custom role",
@@ -3978,7 +4106,7 @@ sub set_custom_role {
          help => 'Course_Editing_Custom_Roles'},
         );
     my $args = { bread_crumbs           => $brcrum,
-                 bread_crumbs_component => $bread_crumbs_component };
+                 bread_crumbs_component => 'User Management'}; 
     $r->print(&Apache::loncommon::start_page('Save Custom Role',$jscript,$args));
 
     my ($rdummy,$roledef)=
@@ -4055,101 +4183,68 @@ sub handler {
     } else {
         $context = 'domain';
     }
-    my ($permission,$allowed) =
-        &Apache::lonuserutils::get_permission($context,$crstype);
-    if (!$allowed) {
-        $env{'user.error.msg'}=
-            "/adm/createuser:cst:0:0:Cannot create/modify user data ".
-                                 "or view user status.";
-        return HTTP_NOT_ACCEPTABLE;
-    }
-
-    &Apache::loncommon::content_type($r,'text/html');
-    $r->send_http_header;
-
-    my $title = 'User Management';
-    my $is_custom = &Apache::loncommon::needs_gci_custom();
-    if ($context eq 'course') {
-        if ($is_custom) {
-            $title = 'Enrollment and Student Activity';
-        }
-    }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
         ['action','state','callingform','roletype','showrole','bulkaction','popup','phase',
          'username','domain','srchterm','srchdomain','srchin','srchby','srchtype']);
     &Apache::lonhtmlcommon::clear_breadcrumbs();
     my $args;
     my $brcrum = [];
-    my $bread_crumbs_component = $title;
-    if ($env{'form.context'} eq 'requestcrs') {
-        my $reqstate = 'uploadroster';
-        if ($env{'form.state'} eq 'enrolling') {
-            $reqstate = 'enrolling';
-        }
-        unless (&Apache::lonrequestcourse::generate_page($r,'new',$reqstate)) {
-            return OK;
-        }
-    } elsif ($env{'form.action'} ne 'dateselect') {
+    my $bread_crumbs_component = 'User Management';
+    if ($env{'form.action'} ne 'dateselect') {
         $brcrum = [{href=>"/adm/createuser",
-                    text=>$title,
+                    text=>"User Management",
                     help=>'Course_Create_Class_List,Course_Change_Privileges,Course_View_Class_List,Course_Editing_Custom_Roles,Course_Add_Student,Course_Drop_Student,Course_Automated_Enrollment,Course_Self_Enrollment,Course_Manage_Group'}
                   ];
     }
     #SD Following files not added to help, because the corresponding .tex-files seem to
     #be missing: Course_Approve_Selfenroll,Course_User_Logs,
+    my ($permission,$allowed) = 
+        &Apache::lonuserutils::get_permission($context,$crstype);
+    if (!$allowed) {
+        if ($context eq 'course') {
+            $r->internal_redirect('/adm/viewclasslist');
+            return OK;
+        }
+        $env{'user.error.msg'}=
+            "/adm/createuser:cst:0:0:Cannot create/modify user data ".
+                                 "or view user status.";
+        return HTTP_NOT_ACCEPTABLE;
+    }
+
+    &Apache::loncommon::content_type($r,'text/html');
+    $r->send_http_header;
 
     # Main switch on form.action and form.state, as appropriate
     if (! exists($env{'form.action'})) {
         $args = {bread_crumbs => $brcrum,
-                 bread_crumbs_component => $bread_crumbs_component};
+                 bread_crumbs_component => $bread_crumbs_component}; 
         $r->print(&header(undef,$args));
         $r->print(&print_main_menu($permission,$context,$crstype));
     } elsif ($env{'form.action'} eq 'upload' && $permission->{'cusr'}) {
-        unless ($env{'form.context'} eq 'requestcrs') {
-            push(@{$brcrum},
-                  { href => '/adm/createuser?action=upload&state=',
-                    text => 'Upload Users List',
-                    help => 'Course_Create_Class_List',
-                  });
-            $bread_crumbs_component = 'Upload Users List';
-            $args = {bread_crumbs           => $brcrum,
-                     bread_crumbs_component => $bread_crumbs_component};
-            $r->print(&header(undef,$args));
-        }
-        unless (($env{'form.context'} eq 'requestcrs') && ($env{'form.state'} eq 'enrolling')) {
-            $r->print('<form name="studentform" method="post" '.
-                      'enctype="multipart/form-data" '.
-                      ' action="/adm/createuser">'."\n");
-        }
+        push(@{$brcrum},
+              { href => '/adm/createuser?action=upload&state=',
+                text => 'Upload Users List',
+                help => 'Course_Create_Class_List',
+              });
+        $bread_crumbs_component = 'Upload Users List';
+        $args = {bread_crumbs           => $brcrum,
+                 bread_crumbs_component => $bread_crumbs_component};
+        $r->print(&header(undef,$args));
+        $r->print('<form name="studentform" method="post" '.
+                  'enctype="multipart/form-data" '.
+                  ' action="/adm/createuser">'."\n");
         if (! exists($env{'form.state'})) {
             &Apache::lonuserutils::print_first_users_upload_form($r,$context);
         } elsif ($env{'form.state'} eq 'got_file') {
-            my $formname;
-            if ($env{'form.context'} eq 'requestcrs') {
-                $formname = 'studentform';
-            }
             &Apache::lonuserutils::print_upload_manager_form($r,$context,
-                                                             $permission,$crstype,$formname);
-            if ($env{'form.context'} eq 'requestcrs') {
-                $r->print('<input type="hidden" name="concepttest" value="'.$env{'form.concepttest'}.'" />');
-            }
+                                                             $permission,$crstype);
         } elsif ($env{'form.state'} eq 'enrolling') {
             if ($env{'form.datatoken'}) {
                 &Apache::lonuserutils::upfile_drop_add($r,$context,$permission);
-                if ($env{'form.context'} eq 'requestcrs') {
-                    $r->print('<br /><hr />'.
-                              '<form name="requestcrs" method="post" action="/adm/requestcourse">'.
-                              '<input type="hidden" name="context" value="'.$env{'form.context'}.'" />'.
-                              '<input type="hidden" name="concepttest" value="'.$env{'form.concepttest'}.'" />'.
-                              '<input type="hidden" name="reqaction" value="new" />'.
-                              '<input type="hidden" name="state" value="'.$env{'form.state'}.'" />'.
-                              &Apache::lonrequestcourse::done_display());
-                }
             }
         } else {
             &Apache::lonuserutils::print_first_users_upload_form($r,$context);
         }
-        $r->print('</form>');
     } elsif ((($env{'form.action'} eq 'singleuser') || ($env{'form.action'}
              eq 'singlestudent')) && ($permission->{'cusr'})) {
         my $phase = $env{'form.phase'};
@@ -4164,7 +4259,7 @@ sub handler {
             if ($env{'form.phase'} eq 'createnewuser') {
                 my $response;
                 if ($env{'form.srchterm'} !~ /^$match_username$/) {
-                    my $response = '<p class="LC_warning">'.&mt('You must specify a valid username. Only the following are allowed: letters numbers - . @').'</p>';
+                    my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');
                     $env{'form.phase'} = '';
                     &print_username_entry_form($r,$context,$response,$srch,undef,$crstype,$brcrum);
                 } else {
@@ -4172,7 +4267,7 @@ sub handler {
                     my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'});
                     &print_user_modification_page($r,$ccuname,$ccdomain,
                                                   $srch,$response,$context,
-                                                  $permission,$crstype);
+                                                  $permission,$crstype,$brcrum);
                 }
             } elsif ($env{'form.phase'} eq 'get_user_info') {
                 my ($currstate,$response,$forcenewuser,$results) = 
@@ -4182,7 +4277,8 @@ sub handler {
                 }
                 if ($currstate eq 'select') {
                     &print_user_selection_page($r,$response,$srch,$results,
-                                               \@search,$context,undef,$crstype);
+                                               \@search,$context,undef,$crstype,
+                                               $brcrum);
                 } elsif ($currstate eq 'modify') {
                     my ($ccuname,$ccdomain);
                     if (($srch->{'srchby'} eq 'uname') && 
@@ -4212,12 +4308,14 @@ sub handler {
                 my $ccuname = &LONCAPA::clean_username($env{'form.seluname'});
                 my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'});
                 &print_user_modification_page($r,$ccuname,$ccdomain,$srch,'',
-                                              $context,$permission,$crstype,$brcrum);
+                                              $context,$permission,$crstype,
+                                              $brcrum);
             }
         } elsif ($env{'form.phase'} eq 'update_user_data') {
             &update_user_data($r,$context,$crstype,$brcrum);
         } else {
-            &print_username_entry_form($r,$context,undef,$srch,undef,$crstype,$brcrum);
+            &print_username_entry_form($r,$context,undef,$srch,undef,$crstype,
+                                       $brcrum);
         }
     } elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) {
         if ($env{'form.phase'} eq 'set_custom_roles') {
@@ -4225,6 +4323,32 @@ sub handler {
         } else {
             &custom_role_editor($r,$brcrum);
         }
+    } elsif (($env{'form.action'} eq 'processauthorreq') &&
+             ($permission->{'cusr'}) && 
+             (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {
+        push(@{$brcrum},
+                 {href => '/adm/createuser?action=processauthorreq',
+                  text => 'Authoring space requests',
+                  help => 'Domain_Role_Approvals'});
+        $bread_crumbs_component = 'Authoring requests';
+        if ($env{'form.state'} eq 'done') {
+            push(@{$brcrum},
+                     {href => '/adm/createuser?action=authorreqqueue',
+                      text => 'Result',
+                      help => 'Domain_Role_Approvals'});
+            $bread_crumbs_component = 'Authoring request result';
+        }
+        $args = { bread_crumbs           => $brcrum,
+                  bread_crumbs_component => $bread_crumbs_component};
+        $r->print(&header(undef,$args));
+        if (!exists($env{'form.state'})) {
+            $r->print(&Apache::loncoursequeueadmin::display_queued_requests('requestauthor',
+                                                                            $env{'request.role.domain'}));
+        } elsif ($env{'form.state'} eq 'done') {
+            $r->print('<h3>'.&mt('Authoring request processing').'</h3>'."\n");
+            $r->print(&Apache::loncoursequeueadmin::update_request_queue('requestauthor',
+                                                                         $env{'request.role.domain'}));
+        }
     } elsif (($env{'form.action'} eq 'listusers') && 
              ($permission->{'view'} || $permission->{'cusr'})) {
         if ($env{'form.phase'} eq 'bulkchange') {
@@ -4240,11 +4364,8 @@ sub handler {
             $r->print(&header(undef,$args));
             my $setting = $env{'form.roletype'};
             my $choice = $env{'form.bulkaction'};
-            $r->print(&Apache::lonhtmlcommon::breadcrumbs("Update Users",
-                                                          'Course_View_Class_List'));
             if ($permission->{'cusr'}) {
-                &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice);
-                $r->print(&Apache::loncommon::end_page());
+                &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice,$crstype);
             } else {
                 $r->print(&mt('You are not authorized to make bulk changes to user roles'));
                 $r->print('<p><a href="/adm/createuser?action=listusers">'.&mt('Display User Lists').'</a>');
@@ -4259,6 +4380,7 @@ sub handler {
                      bread_crumbs_component => $bread_crumbs_component};
             my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
             my $formname = 'studentform';
+            my $hidecall = "hide_searching();";
             if (($context eq 'domain') && (($env{'form.roletype'} eq 'course') ||
                 ($env{'form.roletype'} eq 'community'))) {
                 if ($env{'form.roletype'} eq 'course') {
@@ -4275,16 +4397,22 @@ sub handler {
                                    );
                     $jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements);
                 }
-                $jscript .= &verify_user_display();
+                $jscript .= &verify_user_display($context)."\n".
+                            &Apache::loncommon::check_uncheck_jscript();
                 my $js = &add_script($jscript).$cb_jscript;
-                my $loadcode =
+                my $loadcode = 
                     &Apache::lonuserutils::course_selector_loadcode($formname);
                 if ($loadcode ne '') {
-                    $args->{add_entries} = {onload => $loadcode};
+                    $args->{add_entries} = {onload => "$loadcode;$hidecall"};
+                } else {
+                    $args->{add_entries} = {onload => $hidecall};
                 }
                 $r->print(&header($js,$args));
             } else {
-                $r->print(&header(&add_script(&verify_user_display()),$args));
+                $args->{add_entries} = {onload => $hidecall};
+                $jscript = &verify_user_display($context).
+                           &Apache::loncommon::check_uncheck_jscript(); 
+                $r->print(&header(&add_script($jscript),$args));
             }
             &Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
                          $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
@@ -4307,7 +4435,7 @@ sub handler {
         }
         $bread_crumbs_component = $brtext;
         $args = {bread_crumbs           => $brcrum,
-                 bread_crumbs_component => $bread_crumbs_component};
+                 bread_crumbs_component => $bread_crumbs_component}; 
         $r->print(&header(undef,$args));
         if (!exists($env{'form.state'})) {
             &Apache::lonuserutils::print_drop_menu($r,$context,$permission,$crstype);
@@ -4317,12 +4445,12 @@ sub handler {
         }
     } elsif ($env{'form.action'} eq 'dateselect') {
         if ($permission->{'cusr'}) {
-            $r->print(&header(undef,undef,{'no_nav_bar' => 1}).
+            $r->print(&header(undef,{'no_nav_bar' => 1}).
                       &Apache::lonuserutils::date_section_selector($context,
                                                                    $permission,$crstype));
         } else {
-            $r->print(&header().
-                     '<span class="LC_error">'.&mt('You do not have permission to modify dates or sections for users').'</span>');
+            $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>'); 
         }
     } elsif ($env{'form.action'} eq 'selfenroll') {
         push(@{$brcrum},
@@ -4375,16 +4503,21 @@ sub handler {
                           $cdom,$cnum,$coursedesc));
         }
     } elsif ($env{'form.action'} eq 'changelogs') {
+        my $helpitem;
+        if ($context eq 'course') {
+            $helpitem = 'Course_User_Logs';
+        }
         push (@{$brcrum},
                  {href => '/adm/createuser?action=changelogs',
                   text => 'User Management Logs',
-                  help => 'Course_User_Logs'});
+                  help => $helpitem});
         $bread_crumbs_component = 'User Changes';
         $args = { bread_crumbs           => $brcrum,
                   bread_crumbs_component => $bread_crumbs_component};
         $r->print(&header(undef,$args));
         &print_userchangelogs_display($r,$context,$permission);
     } else {
+        $bread_crumbs_component = 'User Management';
         $args = { bread_crumbs           => $brcrum,
                   bread_crumbs_component => $bread_crumbs_component};
         $r->print(&header(undef,$args));
@@ -4396,18 +4529,11 @@ sub handler {
 
 sub header {
     my ($jscript,$args) = @_;
-    my $title = 'User Management';
-    my $is_custom = &Apache::loncommon::needs_gci_custom();
-    if ($env{'request.course.id'}) {
-        if ($is_custom) {
-            $title = 'Enrollment and Student Activity';
-        }
-    }
     my $start_page;
     if (ref($args) eq 'HASH') {
-        $start_page=&Apache::loncommon::start_page($title,$jscript,$args);
+        $start_page=&Apache::loncommon::start_page('User Management',$jscript,$args);
     } else {
-        $start_page=&Apache::loncommon::start_page($title,$jscript);
+        $start_page=&Apache::loncommon::start_page('User Management',$jscript);
     }
     return $start_page;
 }
@@ -4422,14 +4548,68 @@ sub add_script {
 }
 
 sub verify_user_display {
+    my ($context) = @_;
+    my $photos;
+    if (($context eq 'course') && $env{'request.course.id'}) {
+        $photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'};
+    }
     my $output = <<"END";
 
+function hide_searching() {
+    if (document.getElementById('searching')) {
+        document.getElementById('searching').style.display = 'none';
+    }
+    return;
+}
+
 function display_update() {
     document.studentform.action.value = 'listusers';
     document.studentform.phase.value = 'display';
     document.studentform.submit();
 }
 
+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 {
+            document.getElementById('showcolstatus').checked = false;
+            document.getElementById('showcolstatus').disabled = 'disabled';
+            document.getElementById('showcolstart').checked = false;
+            document.getElementById('showcolend').checked = false;
+        }
+    }
+    if (caller == 'output') {
+        if (photos == 1) {
+            if (document.getElementById('showcolphoto')) {
+                var photoitem = document.getElementById('showcolphoto');
+                if (document.studentform.output.options[document.studentform.output.selectedIndex].value == 'html') {
+                    photoitem.checked = true;
+                    photoitem.disabled = '';
+                } else {
+                    photoitem.checked = false;
+                    photoitem.disabled = 'disabled';
+                }
+            }
+        }
+    }
+    if (caller == 'showrole') {
+        if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') {
+            document.getElementById('showcolrole').checked = true;
+            document.getElementById('showcolrole').disabled = '';
+        } else {
+            document.getElementById('showcolrole').checked = false;
+            document.getElementById('showcolrole').disabled = 'disabled';
+        }
+    }
+    return;
+}
+
 END
     return $output;
 
@@ -4440,10 +4620,6 @@ END
 #  Menu Phase One
 sub print_main_menu {
     my ($permission,$context,$crstype) = @_;
-    my $is_custom = &Apache::loncommon::needs_gci_custom();
-    if (($context eq 'course') && ($is_custom)) {
-        return &print_gci_main_menu($permission,$context,$crstype)
-    }
     my $linkcontext = $context;
     my $stuterm = lc(&Apache::lonnet::plaintext('st',$crstype));
     if (($context eq 'course') && ($crstype eq 'Community')) {
@@ -4464,12 +4640,12 @@ sub print_main_menu {
                 course => {
                             upload     => 'Upload a File of Course Users',
                             singleuser => 'Add/Modify a Course User',
-                            listusers  => 'Manage Course Users',
+                            listusers  => 'List and Modify Multiple Course Users',
                             },
                 community => {
                             upload     => 'Upload a File of Community Users',
                             singleuser => 'Add/Modify a Community User',
-                            listusers  => 'Manage Community Users',
+                            listusers  => 'List and Modify Multiple Community Users',
                            },
                 );
      my %linktitles = (
@@ -4508,7 +4684,7 @@ sub print_main_menu {
          [
             {
              linktext => $links{$linkcontext}{'upload'},
-             icon => 'sctr.png',
+             icon => 'uplusr.png',
              #help => 'Course_Create_Class_List',
              url => '/adm/createuser?action=upload',
              permission => $permission->{'cusr'},
@@ -4516,7 +4692,7 @@ sub print_main_menu {
             },
             {
              linktext => $links{$linkcontext}{'listusers'},
-             icon => 'edit-find.png',
+             icon => 'mngcu.png',
              #help => 'Course_View_Class_List',
              url => '/adm/createuser?action=listusers',
              permission => ($permission->{'view'} || $permission->{'cusr'}),
@@ -4540,6 +4716,22 @@ sub print_main_menu {
              permission => $permission->{'custom'},
              linktitle => 'Configure a custom role.',
             },
+            {
+             linktext => 'Authoring Space Requests',
+             icon => 'selfenrl-queue.png',
+             #help => 'Domain_Role_Approvals',
+             url => '/adm/createuser?action=processauthorreq',
+             permission => $permission->{'cusr'},
+             linktitle => 'Approve or reject author role requests',
+            },
+            {
+             linktext => 'Change Log',
+             icon => 'document-properties.png',
+             #help => 'Course_User_Logs',
+             url => '/adm/createuser?action=changelogs',
+             permission => $permission->{'cusr'},
+             linktitle => 'View change log.',
+            },
         );
         
     }elsif ($context eq 'course'){
@@ -4603,7 +4795,7 @@ sub print_main_menu {
             },
             {
              linktext => $linktext{$crstype}{'groups'},
-             icon => 'conf.png',
+             icon => 'grps.png',
              #help => 'Course_Manage_Group',
              url => '/adm/coursegroups?refpage=cusr',
              permission => $permission->{'grp_manage'},
@@ -4648,7 +4840,7 @@ sub print_main_menu {
             push(@{ $menu[2]->{items} }, 
                 {
                  linktext => 'User Self-Enrollment',
-                 icon => 'cstr.png',
+                 icon => 'self_enroll.png',
                  #help => 'Course_Self_Enrollment',
                  url => '/adm/createuser?action=selfenroll',
                  permission => $permission->{'cusr'},
@@ -4656,8 +4848,17 @@ sub print_main_menu {
                 },
             );
         }
-    };
-return Apache::lonhtmlcommon::generate_menu(@menu);
+    } elsif ($context eq 'author') {
+            {
+             linktext => 'Change Log',
+             icon => 'document-properties.png',
+             #help => 'Course_User_Logs',
+             url => '/adm/createuser?action=changelogs',
+             permission => $permission->{'cusr'},
+             linktitle => 'View change log.',
+            },
+    }
+    return Apache::lonhtmlcommon::generate_menu(@menu);
 #               { text => 'View Log-in History',
 #                 help => 'Course_User_Logins',
 #                 action => 'logins',
@@ -4665,82 +4866,6 @@ return Apache::lonhtmlcommon::generate_m
 #               });
 }
 
-sub print_gci_main_menu {
-    my ($permission,$context,$crstype) = @_;
-    my $stuterm = lc(&Apache::lonnet::plaintext('st',$crstype));
-    my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity();
-    my %links = (
-        course => {
-                    single     => 'Add/Modify a Student',
-                    drop       => 'Drop Students',
-                    upload     => 'Upload a File of Course Users',
-                    singleuser => 'Add/Modify a Course User',
-                    listusers  => 'Concept Test Roster and Student Activity',
-                  },
-     );
-     my %linktitles = (
-        course => {
-                    singleuser => 'Add a user with a certain role to this course.',
-                    listusers  => 'Show and manage users in this course.',
-                    single     => 'Add a user with the role of student to this course',
-                    drop       => 'Remove a student from this course.',
-                    upload     => 'Upload a CSV or a text file containing users.', 
-                  },
-    );
-    my @menu = ( {categorytitle => 'Manage Users',
-         items =>
-         [
-            {
-             linktext => $links{$context}{'single'},
-             #help => 'Course_Add_Student',
-             icon => 'list-add.png',
-             url => '/adm/createuser?action=singlestudent',
-             permission => $permission->{'cusr'},
-             linktitle => $linktitles{$context}{'single'},
-
-            },
-            {
-             linktext => $links{$context}{'drop'},
-             icon => 'edit-undo.png',
-             #help => 'Course_Drop_Student',
-             url => '/adm/createuser?action=drop',
-             permission => $permission->{'cusr'},
-             linktitle => $linktitles{$context}{'drop'},
-            },
-            {
-             linktext => $links{$context}{'upload'},
-             icon => 'sctr.png',
-             #help => 'Course_Create_Class_List',
-             url => '/adm/createuser?action=upload',
-             permission => $permission->{'cusr'},
-             linktitle => $linktitles{$context}{'upload'},
-            },
-            {
-             linktext => $links{$context}{'listusers'},
-             icon => 'edit-find.png',
-             #help => 'Course_View_Class_List',
-             url => '/adm/createuser?action=listusers',
-             permission => ($permission->{'view'} || $permission->{'cusr'}),
-             linktitle => $linktitles{$context}{'listusers'},
-            },
-         ]},
-         {categorytitle => 'Administration',
-         items => [ ]},
-    );
-
-    push(@{ $menu[1]->{items} }, #Category: Administration
-        {
-           linktext => 'Change Log',
-           icon => 'document-properties.png',
-           #help => 'Course_User_Logs',
-           url => '/adm/createuser?action=changelogs',
-           permission => $permission->{'cusr'},
-           linktitle => 'View change log.',
-         },
-    );
-    return Apache::lonhtmlcommon::generate_menu(@menu);
-}
-
 sub restore_prev_selections {
     my %saveable_parameters = ('srchby'   => 'scalar',
 			       'srchin'   => 'scalar',
@@ -5150,7 +5275,7 @@ ENDSCRIPT
                                    '<input type="checkbox" name="selfenroll_notify"'.$notifyon.' value="'.$cc.'" />'.
                                    &Apache::loncommon::plainname($ccuname,$ccudom).
                                    '</label></span></td>';
-                        $count;
+                        $count ++;
                     }
                     my $rem = $count%$numcols;
                     if ($rem) {
@@ -5167,7 +5292,7 @@ ENDSCRIPT
                 my $cid = $env{'request.course.id'};
                 my $currlim = $env{'course.'.$cid.'.internal.selfenroll_limit'};
                 my $currcap = $env{'course.'.$cid.'.internal.selfenroll_cap'};
-                my $nolimit = ' checked="checked" ';
+                $nolimit = ' checked="checked" ';
                 if ($currlim eq 'allstudents') {
                     $crslimit = ' checked="checked" ';
                     $selflimit = ' ';
@@ -5223,9 +5348,9 @@ sub visible_in_cat {
                    dc_chgcat => 'Ask a domain coordinator to change the category assigned to the course, as the one currently assigned is no longer used in the domain',
                    dc_addcat => 'Ask a domain coordinator to assign a category to the course.',
     );
-    $visactions{'unhide'} = &mt('Use [_1]Set course environment[_2] to change the "Exclude from course catalog" setting.','"<a href="/adm/parmset?action=crsenv">','</a>"');
-    $visactions{'chgcat'} = &mt('Use [_1]Set course environment[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','"<a href="/adm/parmset?action=crsenv">','</a>"');
-    $visactions{'addcat'} = &mt('Use [_1]Set course environment[_2] to assign a category to the course.','"<a href="/adm/parmset?action=crsenv">','</a>"');
+    $visactions{'unhide'} = &mt('Use [_1]Categorize course[_2] to change the "Exclude from course catalog" setting.','<a href="/adm/courseprefs?phase=display&actions=courseinfo">','</a>"');
+    $visactions{'chgcat'} = &mt('Use [_1]Categorize course[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','"<a href="/adm/courseprefs?phase=display&actions=courseinfo">','</a>"');
+    $visactions{'addcat'} = &mt('Use [_1]Categorize course[_2] to assign a category to the course.','"<a href="/adm/courseprefs?phase=display&actions=courseinfo">','</a>"');
     if (ref($domconf{'coursecategories'}) eq 'HASH') {
         if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
             $settable{'togglecats'} = 1;
@@ -5423,18 +5548,35 @@ sub selfenroll_date_forms {
 
 sub print_userchangelogs_display {
     my ($r,$context,$permission) = @_;
-    my $formname = 'roleslog';
-    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-    my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-    my $crstype = &Apache::loncommon::course_type();
-    my %roleslog=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
+    my $formname = 'rolelog';
+    my ($username,$domain,$crstype,%roleslog);
+    if ($context eq 'domain') {
+        $domain = $env{'request.role.domain'};
+        %roleslog=&Apache::lonnet::dump_dom('nohist_rolelog',$domain);
+    } else {
+        if ($context eq 'course') { 
+            $domain = $env{'course.'.$env{'request.course.id'}.'.domain'};
+            $username = $env{'course.'.$env{'request.course.id'}.'.num'};
+            $crstype = &Apache::loncommon::course_type();
+            my %saveable_parameters = ('show' => 'scalar',);
+            &Apache::loncommon::store_course_settings('roles_log',
+                                                      \%saveable_parameters);
+            &Apache::loncommon::restore_course_settings('roles_log',
+                                                        \%saveable_parameters);
+        } elsif ($context eq 'author') {
+            $domain = $env{'user.domain'}; 
+            if ($env{'request.role'} =~ m{^au\./\Q$domain\E/$}) {
+                $username = $env{'user.name'};
+            } else {
+                undef($domain);
+            }
+        }
+        if ($domain ne '' && $username ne '') { 
+            %roleslog=&Apache::lonnet::dump('nohist_rolelog',$domain,$username);
+        }
+    }
     if ((keys(%roleslog))[0]=~/^error\:/) { undef(%roleslog); }
 
-    my %saveable_parameters = ('show' => 'scalar',);
-    &Apache::loncommon::store_course_settings('roles_log',
-                                              \%saveable_parameters);
-    &Apache::loncommon::restore_course_settings('roles_log',
-                                                \%saveable_parameters);
     # set defaults
     my $now = time();
     my $defstart = $now - (7*24*3600); #7 days ago 
@@ -5476,7 +5618,8 @@ sub print_userchangelogs_display {
 
     # Form Header
     $r->print('<form action="/adm/createuser" method="post" name="'.$formname.'">'.
-              &role_display_filter($formname,$cdom,$cnum,\%curr,$version,$crstype));
+              &role_display_filter($context,$formname,$domain,$username,\%curr,
+                                   $version,$crstype));
 
     # Create navigation
     my ($nav_script,$nav_links) = &userlogdisplay_nav($formname,\%curr,$more_records);
@@ -5489,9 +5632,13 @@ sub print_userchangelogs_display {
        .'<th>'.&mt('When').'</th>'
        .'<th>'.&mt('Who made the change').'</th>'
        .'<th>'.&mt('Changed User').'</th>'
-       .'<th>'.&mt('Role').'</th>'
-       .'<th>'.&mt('Section').'</th>'
-       .'<th>'.&mt('Context').'</th>'
+       .'<th>'.&mt('Role').'</th>';
+
+    if ($context eq 'course') {
+        $tableheader .= '<th>'.&mt('Section').'</th>';
+    }
+    $tableheader .=
+        '<th>'.&mt('Context').'</th>'
        .'<th>'.&mt('Start').'</th>'
        .'<th>'.&mt('End').'</th>'
        .&Apache::loncommon::end_data_table_header_row();
@@ -5560,7 +5707,7 @@ sub print_userchangelogs_display {
         if ($roleslog{$id}{'logentry'}{'selfenroll'}) {
             $chgcontext = 'selfenroll';
         }
-        my %lt = &rolechg_contexts($crstype);
+        my %lt = &rolechg_contexts($context,$crstype);
         if ($chgcontext ne '' && $lt{$chgcontext} ne '') {
             $chgcontext = $lt{$chgcontext};
         }
@@ -5570,9 +5717,12 @@ sub print_userchangelogs_display {
            .'<td>'.&Apache::lonlocal::locallocaltime($roleslog{$id}{'exe_time'}).'</td>'
            .'<td>'.$whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}}.'</td>'
            .'<td>'.$changed{$roleslog{$id}{'uname'}.':'.$roleslog{$id}{'udom'}}.'</td>'
-           .'<td>'.&Apache::lonnet::plaintext($roleslog{$id}{'logentry'}{'role'},$crstype).'</td>'
-           .'<td>'.$sec.'</td>'
-           .'<td>'.$chgcontext.'</td>'
+           .'<td>'.&Apache::lonnet::plaintext($roleslog{$id}{'logentry'}{'role'},$crstype).'</td>');
+        if ($context eq 'course') { 
+            $r->print('<td>'.$sec.'</td>');
+        }
+        $r->print(
+            '<td>'.$chgcontext.'</td>'
            .'<td>'.$rolestart.'</td>'
            .'<td>'.$roleend.'</td>'
            .&Apache::loncommon::end_data_table_row()."\n");
@@ -5640,9 +5790,11 @@ ENDSCRIPT
 }
 
 sub role_display_filter {
-    my ($formname,$cdom,$cnum,$curr,$version,$crstype) = @_;
-    my $context = 'course';
-    my $lctype = lc($crstype);
+    my ($context,$formname,$cdom,$cnum,$curr,$version,$crstype) = @_;
+    my $lctype;
+    if ($context eq 'course') {
+        $lctype = lc($crstype);
+    }
     my $nolink = 1;
     my $output = '<table><tr><td valign="top">'.
                  '<span class="LC_nobreak"><b>'.&mt('Changes/page:').'</b></span><br />'.
@@ -5657,7 +5809,7 @@ sub role_display_filter {
         &Apache::lonhtmlcommon::date_setter($formname,'rolelog_end_date',
                                             $curr->{'rolelog_end_date'},undef,
                                             undef,undef,undef,undef,undef,undef,$nolink);
-    my %lt = &rolechg_contexts($crstype);
+    my %lt = &rolechg_contexts($context,$crstype);
     $output .= '<td valign="top"><b>'.&mt('Window during which changes occurred:').'</b><br />'.
                '<table><tr><td>'.&mt('After:').
                '</td><td>'.$startform.'</td></tr>'.
@@ -5671,7 +5823,7 @@ sub role_display_filter {
         $output .= ' selected="selected"';
     }
     $output .=  '>'.&mt('Any').'</option>'."\n";
-    my @roles = &Apache::lonuserutils::course_roles($context,undef,1,$lctype);
+    my @roles = &Apache::lonuserutils::roles_by_context($context,1,$crstype);
     foreach my $role (@roles) {
         my $plrole;
         if ($role eq 'cr') {
@@ -5689,13 +5841,23 @@ sub role_display_filter {
                '<td>&nbsp;&nbsp;</td>'.
                '<td valign="top"><b>'.
                &mt('Context:').'</b><br /><select name="chgcontext">';
-    foreach my $chgtype ('any','auto','updatenow','createcourse','course','domain','selfenroll','requestcourses') {
+    my @posscontexts;
+    if ($context eq 'course') {
+        @posscontexts = ('any','auto','updatenow','createcourse','course','domain','selfenroll','requestcourses');
+    } elsif ($context eq 'domain') {
+        @posscontexts = ('any','domain','requestauthor','domconfig','server');
+    } else {
+        @posscontexts = ('any','author','domain');
+    } 
+    foreach my $chgtype (@posscontexts) {
         my $selstr = '';
         if ($curr->{'chgcontext'} eq $chgtype) {
             $selstr = ' selected="selected"';
         }
-        if (($chgtype eq 'auto') || ($chgtype eq 'updatenow')) {
-            next if (!&Apache::lonnet::auto_run($cnum,$cdom));
+        if ($context eq 'course') {
+            if (($chgtype eq 'auto') || ($chgtype eq 'updatenow')) {
+                next if (!&Apache::lonnet::auto_run($cnum,$cdom));
+            }
         }
         $output .= '<option value="'.$chgtype.'"'.$selstr.'>'.$lt{$chgtype}.'</option>'."\n";
     }
@@ -5705,13 +5867,29 @@ sub role_display_filter {
     # Update Display button
     $output .= '<p>'
               .'<input type="submit" value="'.&mt('Update Display').'" />'
-              .'</p><hr />';
+              .'</p>';
+
+    # Server version info
+    my $needsrev = '2.11.0';
+    if ($context eq 'course') {
+        $needsrev = '2.7.0';
+    }
+    
+    $output .= '<p class="LC_info">'
+              .&mt('Only changes made from servers running LON-CAPA [_1] or later are displayed.'
+                  ,$needsrev);
+    if ($version) {
+        $output .= ' '.&mt('This LON-CAPA server is version [_1]',$version);
+    }
+    $output .= '</p><hr />';
     return $output;
 }
 
 sub rolechg_contexts {
-    my ($crstype) = @_;
-    my %lt = &Apache::lonlocal::texthash (
+    my ($context,$crstype) = @_;
+    my %lt;
+    if ($context eq 'course') {
+        %lt = &Apache::lonlocal::texthash (
                                              any          => 'Any',
                                              auto         => 'Automated enrollment',
                                              updatenow    => 'Roster Update',
@@ -5721,11 +5899,26 @@ sub rolechg_contexts {
                                              selfenroll   => 'Self-enrolled',
                                              requestcourses => 'Course Request',
                                          );
-    if ($crstype eq 'Community') {
-        $lt{'createcourse'} = &mt('Community Creation');
-        $lt{'course'} = &mt('User Management in community');
-        $lt{'requestcourses'} = &mt('Community Request');
-    }
+        if ($crstype eq 'Community') {
+            $lt{'createcourse'} = &mt('Community Creation');
+            $lt{'course'} = &mt('User Management in community');
+            $lt{'requestcourses'} = &mt('Community Request');
+        }
+    } elsif ($context eq 'domain') {
+        %lt = &Apache::lonlocal::texthash (
+                                             any           => 'Any',
+                                             domain        => 'User Management in domain',
+                                             requestauthor => 'Authoring Request',
+                                             server        => 'Command line script (DC role)',
+                                             domconfig     => 'Self-enrolled',
+                                         );
+    } else {
+        %lt = &Apache::lonlocal::texthash (
+                                             any    => 'Any',
+                                             domain => 'User Management in domain',
+                                             author => 'User Management by author',
+                                         );
+    } 
     return %lt;
 }
 
@@ -5755,7 +5948,7 @@ sub user_search_result {
     if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'instd')) {
         if (($srch->{'srchdomain'} eq '') || 
 	    ! (&Apache::lonnet::domain($srch->{'srchdomain'}))) {
-            $response = '<p class="LC_warning">'.&mt('You must specify a valid domain when searching in a domain or institutional directory.').'</p>';
+            $response = &mt('You must specify a valid domain when searching in a domain or institutional directory.')
         }
     }
     if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs') ||
@@ -5768,7 +5961,7 @@ sub user_search_result {
                 }
             }
             if ($unamecheck !~ /^$match_username$/) {
-                $response = '<p class="LC_warning">'.&mt('You must specify a valid username. Only the following are allowed: letters numbers - . @').'</p>';
+                $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');
             }
         }
     }
@@ -5943,8 +6136,7 @@ sub user_search_result {
                 ($currstate,$response,$forcenewuser) = 
                     &build_search_response($context,$srch,%srch_results);
             } else {
-                my $showdom = &display_domain_info($srch->{'srchdomain'});
-                $response = '<span class="LC_warning">'.
+                my $showdom = &display_domain_info($srch->{'srchdomain'});                $response = '<span class="LC_warning">'.
                     &mt('Institutional directory search is not available in domain: [_1]',$showdom).
                     '</span><br />'.
                     &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').
@@ -6055,12 +6247,12 @@ sub build_search_response {
     my ($context,$srch,%srch_results) = @_;
     my ($currstate,$response,$forcenewuser);
     my %names = (
-          'uname' => 'username',
-          'lastname' => 'last name',
+          'uname'     => 'username',
+          'lastname'  => 'last name',
           'lastfirst' => 'last name, first name',
-          'crs' => 'this course',
-          'dom' => 'LON-CAPA domain: ',
-          'instd' => 'the institutional directory for domain: ',
+          'crs'       => 'this course',
+          'dom'       => 'LON-CAPA domain',
+          'instd'     => 'the institutional directory for domain',
     );
 
     my %single = (
@@ -6080,14 +6272,20 @@ sub build_search_response {
             $currstate = 'modify';
             $response = &mt("$single{$srch->{'srchtype'}} was found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}.",$srch->{'srchterm'});
             if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
-                $response .= &display_domain_info($srch->{'srchdomain'});
+                $response .= ': '.&display_domain_info($srch->{'srchdomain'});
             }
-        } else {
-            $response = '<span class="LC_warning">'.&mt("$nomatch{$srch->{'srchtype'}} found for the $names{$srch->{'srchby'}} ([_1]) in $names{$srch->{'srchin'}}",$srch->{'srchterm'});
+        } else { # Search has nothing found. Prepare message to user.
+            $response = '<span class="LC_warning">';
             if ($srch->{'srchin'} eq 'dom' || $srch->{'srchin'} eq 'instd') {
-                $response .= &display_domain_info($srch->{'srchdomain'});
+                $response .= &mt("$nomatch{$srch->{'srchtype'}} found for the $names{$srch->{'srchby'}} [_1] in $names{$srch->{'srchin'}}: [_2]",
+                                 '<b>'.$srch->{'srchterm'}.'</b>',
+                                 &display_domain_info($srch->{'srchdomain'}));
+            } else {
+                $response .= &mt("$nomatch{$srch->{'srchtype'}} found for the $names{$srch->{'srchby'}} [_1] in $names{$srch->{'srchin'}}.",
+                                 '<b>'.$srch->{'srchterm'}.'</b>');
             }
             $response .= '</span>';
+
             if ($srch->{'srchin'} ne 'alc') {
                 $forcenewuser = 1;
                 my $cansrchinst = 0; 
@@ -6241,7 +6439,7 @@ sub course_level_table {
 	my $thiscourse=$protectedcourse;
 	$thiscourse=~s:_:/:g;
 	my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
-        my $isowner = &is_courseowner($protectedcourse,$coursedata{'internal.courseowner'});
+        my $isowner = &Apache::lonuserutils::is_courseowner($protectedcourse,$coursedata{'internal.courseowner'});
 	my $area=$coursedata{'description'};
         my $crstype=$coursedata{'type'};
 	if (!defined($area)) { $area=&mt('Unavailable course').': '.$protectedcourse; }
@@ -6348,8 +6546,8 @@ sub course_level_dc {
     my $hiddenitems = '<input type="hidden" name="dcdomain" value="'.$dcdom.'" />'.
                       '<input type="hidden" name="origdom" value="'.$dcdom.'" />'.
                       '<input type="hidden" name="dccourse" value="" />';
-    my $courseform='<b>'.&Apache::loncommon::selectcourse_link
-            ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course/Community','crstype').'</b>';
+    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 %lt=&Apache::lonlocal::texthash(
                     'rol'  => "Role",
@@ -6359,15 +6557,17 @@ sub course_level_dc {
                     'sta'  => "Start",
                     'end'  => "End",
                     'ssd'  => "Set Start Date",
-                    'sed'  => "Set End Date"
+                    'sed'  => "Set End Date",
+                    'scc'  => "Course/Community"
                   );
     my $header = '<h4>'.&mt('Course/Community Level').'</h4>'.
                  &Apache::loncommon::start_data_table().
                  &Apache::loncommon::start_data_table_header_row().
-                 '<th>'.$courseform.'</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><th>'.$lt{'grs'}.'</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'.
                  &Apache::loncommon::end_data_table_header_row();
     my $otheritems = &Apache::loncommon::start_data_table_row()."\n".
-                     '<td><br /><input type="text" name="coursedesc" value="" onfocus="this.blur();opencrsbrowser('."'cu','dccourse','dcdomain','coursedesc','','','','crstype'".')" /></td>'."\n".
+                     '<td><br /><span class="LC_nobreak"><input type="text" name="coursedesc" value="" onfocus="this.blur();opencrsbrowser('."'cu','dccourse','dcdomain','coursedesc','','','','crstype'".')" />'.
+                     $courseform.('&nbsp;' x4).'</span></td>'."\n".
                      '<td valign><br /><select name="role">'."\n";
     foreach my $role (@roles) {
         my $plrole=&Apache::lonnet::plaintext($role);
@@ -6459,7 +6659,8 @@ sub update_selfenroll_config {
                             $newnum ++;
                         }
                     }
-                    for (my $j=0; $j<$env{'form.selfenroll_types_total'}; $j++) {                        if ((!grep(/^$j$/,@deletedoms)) && (!grep(/^$j$/,@activations))) {
+                    for (my $j=0; $j<$env{'form.selfenroll_types_total'}; $j++) {
+                        if ((!grep(/^$j$/,@deletedoms)) && (!grep(/^$j$/,@activations))) {
                             my @types = &Apache::loncommon::get_env_multiple('form.selfenroll_types_'.$j);
                             if (@types > 0) {
                                 @types = sort(@types);
@@ -6762,21 +6963,6 @@ sub get_selfenroll_titles {
     return (\@row,\%lt);
 }
 
-sub is_courseowner {
-    my ($thiscourse,$courseowner) = @_;
-    if ($courseowner eq '') {
-        if ($env{'request.course.id'} eq $thiscourse) {
-            $courseowner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
-        }
-    }
-    if ($courseowner ne '') {
-        if ($courseowner eq $env{'user.name'}.':'.$env{'user.domain'}) {
-                return 1;
-        }
-    }
-    return;
-}
-
 #---------------------------------------------- end functions for &phase_two
 
 #--------------------------------- functions for &phase_two and &phase_three