[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm lonuserutils.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Wed, 05 Dec 2007 21:23:15 -0000


This is a MIME encoded message

--raeburn1196889795
Content-Type: text/plain

raeburn		Wed Dec  5 16:23:15 2007 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm lonuserutils.pm 
  Log:
  bugs 1902, 2337, 3033
  
  - Use checkboxes to select one or more users from a listing of users to apply access date changes, or (in course context) section additions/changes to particular roles.
  
  - separate window is opened to (a) allow specification of access dates if re-enabling expired roles, activating future roles, or changing starting/ending dates when displaying "Any Access Status", and (b) allow specification of new section affilation(s) with/without expiration of existing sections.
  
  - no window to set dates provided when action is to revoke or delete roles. 
  
  
--raeburn1196889795
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20071205162315.txt"

Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.201 loncom/interface/loncreateuser.pm:1.202
--- loncom/interface/loncreateuser.pm:1.201	Wed Dec  5 12:40:29 2007
+++ loncom/interface/loncreateuser.pm	Wed Dec  5 16:23:14 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.201 2007/12/05 17:40:29 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.202 2007/12/05 21:23:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -627,7 +627,7 @@
     }
 ENDSCRIPT
     } else {
-        $nondc_setsection_code =
+        $nondc_setsection_code = 
             &Apache::lonuserutils::setsections_javascript('cu',$groupslist);
     }
     my $js = &user_modification_js($pjump_def,$dc_setcourse_code,
@@ -1198,7 +1198,7 @@
         }
     } else { # Authentication type is valid
         &initialize_authen_forms($ccdomain,$currentauth);
-        my $authformnop_row;
+        my $authformnop_row;      
         if (&Apache::lonnet::allowed('mau',$ccdomain)) {
             $authformnop_row = &Apache::loncommon::start_data_table_row();
         }
@@ -1816,10 +1816,10 @@
 	        $r->print(&mt('Revoking [_1] in [_2]: [_3]',
 			      $role,$scope,'<b>'.$result.'</b>').'<br />');
 		if ($role eq 'st') {
-                    my $result =
+		    my $result = 
                         &Apache::lonuserutils::classlist_drop($scope,
                             $env{'form.ccuname'},$env{'form.ccdomain'},
-                            $now);
+			    $now);
 		    $r->print($result);
 		}
 	    }
@@ -1843,10 +1843,10 @@
 	        $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope,
 			      '<b>'.$result.'</b>').'<br />');
 		if ($role eq 'st') {
-                    my $result =
+		    my $result = 
                         &Apache::lonuserutils::classlist_drop($scope,
                             $env{'form.ccuname'},$env{'form.ccdomain'},
-                            $now);
+			    $now);
 		    $r->print($result);
 		}
             }
@@ -2393,11 +2393,13 @@
         $context = 'domain';
     }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
-                                            ['action','state']);
+        ['action','state','callingform','roletype','showrole','bulkaction']);
     &Apache::lonhtmlcommon::clear_breadcrumbs();
-    &Apache::lonhtmlcommon::add_breadcrumb
-        ({href=>"/adm/createuser",
-          text=>"User Management"});
+    if ($env{'form.action'} ne 'dateselect') {
+        &Apache::lonhtmlcommon::add_breadcrumb
+            ({href=>"/adm/createuser",
+              text=>"User Management"});
+    }
     my ($permission,$allowed) = &get_permission($context);
     if (!$allowed) {
         $env{'user.error.msg'}=
@@ -2447,7 +2449,7 @@
         if (! exists($env{'form.state'})) {
             &Apache::lonuserutils::print_expire_menu($r,$context);
         } elsif ($env{'form.state'} eq 'done') {
-            &Apache::lonuserutils::expire_user_list($r);
+            &Apache::lonuserutils::expire_user_list($r,$context);
         } else {
             &Apache::lonuserutils::print_expire_menu($r,$context);
         }
@@ -2512,31 +2514,46 @@
             &custom_role_editor($r);
         }
     } elsif ($env{'form.action'} eq 'listusers' && $permission->{'view'}) {
-        my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
-        my $formname = 'studentform';
-        if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
-            ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) = 
-                &Apache::lonuserutils::courses_selector($env{'request.role.domain'},
-                                                        $formname);
-            my $js = &add_script($jscript).$cb_jscript;
-            my $loadcode = 
-                &Apache::lonuserutils::course_selector_loadcode($formname);
-            if ($loadcode ne '') {
-                $r->print(&header($js,{'onload' => $loadcode,}));
+        if ($env{'form.phase'} eq 'bulkchange') {
+            &Apache::lonhtmlcommon::add_breadcrumb
+                ({href=>'backPage(document.studentform)',
+                  text=>"List Users"});
+            my $setting = $env{'form.roletype'};
+            my $choice = $env{'form.bulkaction'};
+            $r->print(&header());
+            $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users",
+                                                          'User_Management_List'));
+            if ($permission->{'cusr'}) {
+                &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice);
+            }
+        } else {
+            &Apache::lonhtmlcommon::add_breadcrumb
+                ({href=>'/adm/createuser?action=listusers',
+                  text=>"List Users"});
+            my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
+            my $formname = 'studentform';
+            if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
+                ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) = 
+                    &Apache::lonuserutils::courses_selector($env{'request.role.domain'},
+                                                            $formname);
+                $jscript .= &verify_user_display();
+                my $js = &add_script($jscript).$cb_jscript;
+                my $loadcode = 
+                    &Apache::lonuserutils::course_selector_loadcode($formname);
+                if ($loadcode ne '') {
+                    $r->print(&header($js,{'onload' => $loadcode,}));
+                } else {
+                    $r->print(&header($js));
+                }
             } else {
-                $r->print(&header($js));
+                $r->print(&header(&add_script(&verify_user_display())));
             }
-        } else {
-            $r->print(&header());
+            $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users",
+                                                          'User_Management_List'));
+            &Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
+                         $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
+            $r->print(&Apache::loncommon::end_page());
         }
-        &Apache::lonhtmlcommon::add_breadcrumb
-            ({href=>'/adm/createuser?action=listusers',
-              text=>"List Users"});
-        $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users",
-                                                      'User_Management_List'));
-        &Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
-                     $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
-        $r->print(&Apache::loncommon::end_page());
     } elsif ($env{'form.action'} eq 'expire' && $permission->{'cusr'}) {
         $r->print(&header());
         &Apache::lonhtmlcommon::add_breadcrumb
@@ -2547,26 +2564,37 @@
         if (! exists($env{'form.state'})) {
             &Apache::lonuserutils::print_expire_menu($r,$context);
         } elsif ($env{'form.state'} eq 'done') {
-            &Apache::lonuserutiles::expire_user_list($r);
+            &Apache::lonuserutiles::expire_user_list($r,$context);
         } else {
             &print_expire_menu($r,$context);
         }
         $r->print(&Apache::loncommon::end_page());
+    } elsif ($env{'form.action'} eq 'dateselect') {
+        if ($permission->{'cusr'}) {
+            $r->print(&header(undef,undef,{'no_nav_bar' => 1}).
+                      &Apache::lonuserutils::date_section_selector($context).
+                      &Apache::loncommon::end_page());
+        } else {
+            $r->print(&header().
+                     '<span class="LC_error">'.&mt('You do not have permission to modify dates or sections for users').'</span>'. 
+                     &Apache::loncommon::end_page());
+        }
     } else {
         $r->print(&header());
-        $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));            $r->print(&print_main_menu($permission));
+        $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
+        $r->print(&print_main_menu($permission));
         $r->print(&Apache::loncommon::end_page());
     }
     return OK;
 }
 
 sub header {
-    my ($jscript,$loaditems) = @_;
+    my ($jscript,$loaditems,$args) = @_;
     my $start_page;
     if (ref($loaditems) eq 'HASH') {
-        $start_page=&Apache::loncommon::start_page('User Management',$jscript,{'add_entries' => $loaditems,});
+        $start_page=&Apache::loncommon::start_page('User Management',$jscript,{'add_entries' => $loaditems});
     } else {
-        $start_page=&Apache::loncommon::start_page('User Management',$jscript);
+        $start_page=&Apache::loncommon::start_page('User Management',$jscript,$args);
     }
     return $start_page;
 }
@@ -2576,6 +2604,20 @@
     return '<script type="text/javascript">'."\n".$js."\n".'</script>';
 }
 
+sub verify_user_display {
+    my $output = <<"END";
+
+function display_update() {
+    document.studentform.action.value = 'listusers';
+    document.studentform.phase.value = 'display';
+    document.studentform.submit();
+}
+
+END
+    return $output;
+
+}
+
 ###############################################################
 ###############################################################
 #  Menu Phase One
@@ -3150,9 +3192,9 @@
 <td>'.$area.'<br />Domain: '.$domain.'</td>'."\n";
 	        if ($role ne 'cc') {
                     if (%sections_count) {
-                        my $currsec =
+                        my $currsec = 
                             &Apache::lonuserutils::course_sections(\%sections_count,
-                                                       $protectedcourse.'_'.$role);
+                                                        $protectedcourse.'_'.$role);
                         $table .= 
                     '<td><table class="LC_createuser">'.
                      '<tr class="LC_section_row">
@@ -3192,7 +3234,7 @@
 <td>'.$plrole.'</td>
 <td>'.$area.'</td>'."\n";
                 if (%sections_count) {
-                    my $currsec =
+                    my $currsec = 
                         &Apache::lonuserutils::course_sections(\%sections_count,
                                                                $customrole);
                     $table.=
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.10 loncom/interface/lonuserutils.pm:1.11
--- loncom/interface/lonuserutils.pm:1.10	Wed Dec  5 14:11:37 2007
+++ loncom/interface/lonuserutils.pm	Wed Dec  5 16:23:14 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA user accounts
 #
-# $Id: lonuserutils.pm,v 1.10 2007/12/05 19:11:37 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.11 2007/12/05 21:23:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -846,7 +846,7 @@
 }
 
 sub setup_date_selectors {
-    my ($starttime,$endtime,$mode) = @_;
+    my ($starttime,$endtime,$mode,$nolink) = @_;
     if (! defined($starttime)) {
         $starttime = time;
         unless ($mode eq 'create_enrolldates' || $mode eq 'create_defaultdates') {
@@ -867,12 +867,15 @@
             }
         }
     }
-    my $startdateform = &Apache::lonhtmlcommon::date_setter('studentform',
-                                                            'startdate',
-                                                            $starttime);
-    my $enddateform = &Apache::lonhtmlcommon::date_setter('studentform',
-                                                          'enddate',
-                                                          $endtime);
+
+    my $startdateform = 
+        &Apache::lonhtmlcommon::date_setter('studentform','startdate',$starttime,
+            undef,undef,undef,undef,undef,undef,undef,$nolink);
+
+    my $enddateform = 
+        &Apache::lonhtmlcommon::date_setter('studentform','enddate',$endtime,
+            undef,undef,undef,undef,undef,undef,undef,$nolink);
+
     if ($mode eq 'create_enrolldates') {
         $startdateform = &Apache::lonhtmlcommon::date_setter('ccrs',
                                                             'startenroll',
@@ -903,35 +906,44 @@
 }
 
 sub date_setting_table {
-    my ($starttime,$endtime,$mode) = @_;
-    my ($startform,$endform)=&setup_date_selectors($starttime,$endtime,$mode);
+    my ($starttime,$endtime,$mode,$bulkaction) = @_;
+    my $nolink;
+    if ($bulkaction) {
+        $nolink = 1;
+    }
+    my ($startform,$endform) = 
+        &setup_date_selectors($starttime,$endtime,$mode,$nolink);
     my $dateDefault;
     if ($mode eq 'create_enrolldates' || $mode eq 'create_defaultdates') {
         $dateDefault = '&nbsp;';
     } elsif ($mode ne 'construction_space' && $mode ne 'domain') {
-        $dateDefault = '<nobr>'.
-        '<label><input type="checkbox" name="makedatesdefault" /> '.
-        &mt('make these dates the default for future enrollment').
-        '</label></nobr>';
+        if (($bulkaction eq 'reenable') || 
+            ($bulkaction eq 'activate') || 
+            ($bulkaction eq 'chgdates')) { 
+            $dateDefault = '<span class="LC_nobreak">'.
+                '<label><input type="checkbox" name="makedatesdefault" /> '.
+                &mt('make these dates the default for future enrollment').
+                '</label></span>';
+        }
     }
-    my $perpetual = '<nobr><label><input type="checkbox" name="no_end_date"';
+    my $perpetual = '<span class="LC_nobreak"><label><input type="checkbox" name="no_end_date"';
     if (defined($endtime) && $endtime == 0) {
         $perpetual .= ' checked';
     }
-    $perpetual.= ' /> '.&mt('no ending date').'</label></nobr>';
+    $perpetual.= ' /> '.&mt('no ending date').'</label></span>';
     if ($mode eq 'create_enrolldates') {
         $perpetual = '&nbsp;';
     }
-    my $result = &Apache::lonhtmlcommon::start_pick_box()."\n".
-                 &Apache::lonhtmlcommon::row_title(&mt('Starting Date'),
-                                                   'LC_oddrow_value')."\n".
-                 $startform."\n".
-                 &Apache::lonhtmlcommon::row_closure(1).
-                 &Apache::lonhtmlcommon::row_title(&mt('Ending Date'),
-                                                   'LC_oddrow_value')."\n".
-                 $endform.'&nbsp;'.$perpetual.
-                 &Apache::lonhtmlcommon::row_closure(1).
-                 &Apache::lonhtmlcommon::end_pick_box().'<br />';
+    my $result = &Apache::lonhtmlcommon::start_pick_box()."\n";
+    $result .= &Apache::lonhtmlcommon::row_title(&mt('Starting Date'),
+                                                     'LC_oddrow_value')."\n".
+               $startform."\n".
+               &Apache::lonhtmlcommon::row_closure(1).
+               &Apache::lonhtmlcommon::row_title(&mt('Ending Date'), 
+                                                     'LC_oddrow_value')."\n".
+               $endform.'&nbsp;'.$perpetual.
+               &Apache::lonhtmlcommon::row_closure(1).
+               &Apache::lonhtmlcommon::end_pick_box().'<br />';
     if ($dateDefault) {
         $result .=  $dateDefault.'<br />'."\n";
     }
@@ -948,7 +960,8 @@
                 {'default_enrollment_start_date'=>$startdate,
                  'default_enrollment_end_date'  =>$enddate},$dom,$crs);
         if ($put_result eq 'ok') {
-            $result .= "Set default start and end dates for course<br />";
+            $result .= &mt('Set default start and end dates for course').
+                       '<br />'."\n";
             #
             # Refresh the course environment
             &Apache::lonnet::coursedescription($env{'request.course.id'},
@@ -1240,8 +1253,12 @@
                   &Apache::lonhtmlcommon::end_pick_box().'</p>'.
                   '<p>'.&list_submit_button(&mt('Update Display')).
                   "\n</p>\n");
+        if ($env{'form.coursepick'}) {
+            $r->print('<hr />'.&mt('Searching').' ...<br />&nbsp;<br />');
+        }
+    } else {
+        $r->print('<hr />'.&mt('Searching').' ...<br />&nbsp;<br />');
     }
-    $r->print('<hr />'.&mt('Searching').' ...<br />&nbsp;<br />');
     $r->rflush();
     if ($context eq 'course') {
         my $classlist = &Apache::loncoursedata::get_classlist();
@@ -1269,7 +1286,7 @@
         my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
                                                         \@statuses,$showroles);
         &gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo,
-                         \%advrolehash);
+                         \%advrolehash,$permission);
     } else {
         my (%cstr_roles,%dom_roles);
         if ($context eq 'construction_space') {
@@ -1278,14 +1295,14 @@
             %cstr_roles = &Apache::lonnet::get_my_roles(undef,undef,undef,
                                               \@statuses,\@possroles);
             &gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo,
-                             \%cstr_roles);
+                             \%cstr_roles,$permission);
         } elsif ($context eq 'domain') {
             if ($env{'form.roletype'} eq 'domain') {
                 %dom_roles = &Apache::lonnet::get_domain_roles($env{'request.role.domain'});
                 foreach my $key (keys(%dom_roles)) {
                     if (ref($dom_roles{$key}) eq 'HASH') {
                         &gather_userinfo($context,$format,\%userlist,$indexhash,
-                                         \%userinfo,$dom_roles{$key});
+                                         \%userinfo,$dom_roles{$key},$permission);
                     }
                 }
             } elsif ($env{'form.roletype'} eq 'construction_space') {
@@ -1295,7 +1312,7 @@
                     if (ref($dom_roles{$key}) eq 'HASH') {
                         if ($env{'form.showrole'} eq 'au') {
                             &gather_userinfo($context,$format,\%userlist,$indexhash,
-                                             \%userinfo,$dom_roles{$key});
+                                             \%userinfo,$dom_roles{$key},$permission);
                         } else {
                             my @possroles;
                             if ($env{'form.showrole'} eq 'Any') {
@@ -1311,7 +1328,7 @@
                                        $authordom,undef,\@statuses,\@possroles);
                             }
                             &gather_userinfo($context,$format,\%userlist,
-                                             $indexhash,\%userinfo,\%coauthors);
+                                     $indexhash,\%userinfo,\%coauthors,$permission);
                         }
                     }
                 }
@@ -1324,6 +1341,7 @@
                             &Apache::lonnet::coursedescription($cid,{'one_time' => 1});
                         my $cdom = $coursehash{'domain'};
                         my $cnum = $coursehash{'num'};
+                        next if ($cnum eq '' || $cdom eq '');
                         my $cdesc = $coursehash{'description'};
                         my (@roles,@sections,%access,%users,%userdata,
                             %statushash);
@@ -1356,7 +1374,7 @@
                         }
                     }
                     &gather_userinfo($context,$format,\%userlist,$indexhash,
-                                     \%userinfo,\%allusers);
+                                     \%userinfo,\%allusers,$permission);
                 } else {
                     $r->print('<input type="hidden" name="phase" value="'.
                               $env{'form.phase'}.'" /></form>');
@@ -1399,11 +1417,11 @@
 
 sub list_submit_button {
     my ($text) = @_;
-    return '<input type="submit" value="'.$text.'" />';
+    return '<input type="button" name="updatedisplay" value="'.$text.'" onclick="javascript:display_update()" />';
 }
 
 sub gather_userinfo {
-    my ($context,$format,$userlist,$indexhash,$userinfo,$rolehash) = @_;
+    my ($context,$format,$userlist,$indexhash,$userinfo,$rolehash,$permission) = @_;
     foreach my $item (keys(%{$rolehash})) {
         @{$userlist->{$item}} = ();
         my %userdata;
@@ -1433,6 +1451,7 @@
                 ($userdata{'username'},$userdata{'domain'},$userdata{'role'}) =
                     split(/:/,$item);
                 if (ref($rolehash->{$item}) eq 'HASH') {
+                    my $numcids = keys(%{$rolehash->{$item}});
                     foreach my $cid (sort(keys(%{$rolehash->{$item}}))) {
                         if (ref($rolehash->{$item}{$cid}) eq 'HASH') {
                             my $spanstart = '';
@@ -1440,6 +1459,13 @@
                             my $space = ', ';
                             if ($format eq 'html' || $format eq 'view') {
                                 $spanstart = '<span class="LC_nobreak">';
+                                if ($permission->{'cusr'}) {
+                                    if ($numcids > 1) {
+                                        $spanstart .= '<input type="radio" name="'.$item.'" value="'.$cid.'" &nbsp; />';
+                                    } else {
+                                        $spanstart .= '<input type="hidden" name="'.$item.'" value="'.$cid.'" &nbsp; />';
+                                    }
+                                }
                                 $spanend = '</span><br />';
                                 $space = ',&nbsp;';
                             }
@@ -1462,6 +1488,7 @@
 
 sub build_user_record {
     my ($userdata,$userinfo,$indexhash,$record_key,$userlist) = @_;
+    next if ($userdata->{'start'} eq '-1' && $userdata->{'end'} eq '-1');
     &process_date_info($userdata);
     my $username = $userdata->{'username'};
     my $domain = $userdata->{'domain'};
@@ -1717,6 +1744,7 @@
     if (!grep(/^\Q$sortby\E$/,@sortable)) {
         $sortby = 'username';
     }
+    my $setting = $env{'form.roleaction'};
     my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers);
     if ($context eq 'course') {
         $cid=$env{'request.course.id'};
@@ -1751,9 +1779,48 @@
 END
     }
     unless ($mode eq 'autoenroll') {
+        my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript();
+        my $alert = &mt("You must select at least one user by checking a user's 'Select' checkbox");
+        my $singconfirm = &mt(' for a single user');
+        my $multconfirm = &mt(' for multiple users');
+        my $date_sec_selector = &date_section_javascript($context,$setting,$statusmode); 
         $r->print(<<END);
 
 <script type="text/javascript" language="Javascript">
+$check_uncheck_js
+
+function verify_action (field) {
+    var numchecked = 0;
+    var singconf = '$singconfirm';
+    var multconf = '$multconfirm';
+    if (field.length > 0) {
+        for (i = 0; i < field.length; i++) {
+            if (field[i].checked == true) {
+               numchecked ++;
+            }
+        }
+    } else {
+        if (field.checked == true) {
+            numchecked ++;
+        }
+    }
+    if (numchecked == 0) {
+        alert("$alert");
+    } 
+    else {
+        var message = document.studentform.bulkaction[document.studentform.bulkaction.selectedIndex].text;
+        if (numchecked == 1) { 
+            message += singconf;
+        } 
+        else {
+            message += multconf; 
+        }
+        if (confirm(message)) {
+            document.studentform.phase.value = 'bulkchange';
+            document.studentform.submit();
+        }
+    }
+}
 
 function username_display_launch(username,domain) {
     var target;
@@ -1774,7 +1841,7 @@
     }
 }
 </script>
-
+$date_sec_selector
 <input type="hidden" name="state" value="$env{'form.state'}" />
 END
     }
@@ -1798,6 +1865,10 @@
                        'clicker'    => "clicker id",
                        'photo'      => "photo",
                        'extent'     => "extent",
+                       'pr'         => "Proceed",
+                       'ca'         => "check all",
+                       'ua'         => "uncheck all",
+                       'ac'         => "Action to take for selected users",
                        'link'       => "Behavior of username links",
                        'aboutme'    => "Display a user's personal page",
                        'modify'     => "Modify a user's information",
@@ -1839,14 +1910,17 @@
     my $results_description = &results_header_row($rolefilter,$statusmode,
                                                   $context);
     $r->print('<b>'.$results_description.'</b><br />');
-    my $output;
+    my ($output,$actionselect);
     if ($mode eq 'html' || $mode eq 'view') {
+        if ($permission->{'cusr'}) {
+            $actionselect = &select_actions($context,$setting,$statusmode);
+        }
         $r->print(<<END);
 <input type="hidden" name="srchby"  value="uname" />
 <input type="hidden" name="srchin"   value="dom" />
 <input type="hidden" name="srchtype" value="exact" />
 <input type="hidden" name="srchterm" value="" />
-<input type="hidden" name="srchdomain" value="" />
+<input type="hidden" name="srchdomain" value="" /> 
 END
          if ($mode ne 'autoenroll') {
              $output = '<p>';
@@ -1869,6 +1943,13 @@
              } else {
                  $output .= &mt("Click on a username to view the user's personal page.").'<br />';
              }
+             if ($actionselect) {
+                 $output .= <<"END"; 
+$lt{'ac'}:&nbsp;$actionselect <input type="button" value="$lt{'pr'}" onclick="javascript:verify_action(document.studentform.actionlist)" /></p>
+<p><input type="button" value="$lt{'ca'}" onclick="javascript:checkAll(document.studentform.actionlist)" /> &nbsp;
+<input type="button" value="$lt{'ua'}" onclick="javascript:uncheckAll(document.studentform.actionlist)" />
+END
+             }
         }
         $output .= "\n<p>\n".
                   &Apache::loncommon::start_data_table().
@@ -1878,9 +1959,10 @@
  <th><a href=\"javascript:document.studentform.sortby.value='type';document.studentform.submit();\">$lt{'type'}</a></th>
             ";
         } else {
-            $output .= "
-<th>Count</th>
-            ";
+            $output .= "\n".'<th>'.&mt('Count').'</th>'."\n";
+            if ($actionselect) {
+                $output .= '<th>'.&mt('Select').'</th>'."\n";
+            }
         }
         foreach my $item (@cols) {
             $output .= "<th><a href=\"javascript:document.studentform.sortby.value='$item';document.studentform.submit();\">$lt{$item}</a></th>\n";
@@ -1965,6 +2047,10 @@
     # Get groups, role, permanent e-mail so we can sort on them if
     # necessary.
     foreach my $user (keys(%{$userlist})) {
+        if ($context eq 'domain' &&  $user eq $env{'request.role.domain'}.'-domainconfig:'.$env{'request.role.domain'}) {
+            delete($userlist->{$user});
+            next;
+        }
         my ($uname,$udom,$role,$groups,$email);
         if (($statusmode ne 'Any') && 
                  ($userlist->{$user}->[$index{'status'}] ne $statusmode)) {
@@ -1974,7 +2060,11 @@
         if ($context eq 'domain') {
             if ($env{'form.roletype'} eq 'domain') {
                 ($role,$uname,$udom) = split(/:/,$user);
-               
+                if (($uname eq $env{'request.role.domain'}.'-domainconfig') &&
+                    ($udom eq $env{'request.role.domain'})) {
+                    delete($userlist->{$user});
+                    next;
+                }
             } elsif ($env{'form.roletype'} eq 'construction_space') {
                 ($uname,$udom,$role) = split(/:/,$user,-1);
             } elsif ($env{'form.roletype'} eq 'course') {
@@ -2035,6 +2125,7 @@
         foreach my $item (@{$keylist}) {
             $in{$item} = $sdata->[$index{$item}];
         }
+        my $role = $in{'role'};
         $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}]); 
         if (! defined($in{'start'}) || $in{'start'} == 0) {
             $in{'start'} = &mt('none');
@@ -2049,9 +2140,26 @@
         if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') {
             $r->print(&Apache::loncommon::start_data_table_row());
             $r->print("<td>$rowcount</td>\n");
+            my $checkval;
+            if ($mode ne 'autoenroll' && $actionselect) {
+                $checkval = $user; 
+                if ($context eq 'course') {
+                    if ($role eq 'st') {
+                        $checkval .= ':st';
+                    }
+                    $checkval .= ':'.$in{'section'};
+                    if ($role eq 'st') {
+                        $checkval .= ':'.$in{'type'}.':'.$in{'lockedtype'};
+                    }
+                }
+                $r->print('<td><input type="checkbox" name="actionlist" value="'.
+                          $checkval.'"></td>');
+            }
             foreach my $item (@cols) {
                 if ($item eq 'username') {
                     $r->print('<td>'.&print_username_link($permission,\%in).'</td>');
+                } elsif (($item eq 'start' || $item eq 'end') && ($mode ne 'autoeroll') && ($actionselect)) {
+                    $r->print('<td>'.$in{$item}.'<input type="hidden" name="'.$checkval.'_'.$item.'" value="'.$sdata->[$index{$item}].'" /></td>'."\n");
                 } else {
                     $r->print('<td>'.$in{$item}.'</td>'."\n");
                 }
@@ -2159,6 +2267,254 @@
     return %lt;
 }
 
+sub select_actions {
+    my ($context,$setting,$statusmode) = @_;
+    my %lt = &Apache::lonlocal::texthash(
+                revoke   => "Revoke user roles",
+                delete   => "Delete user roles",
+                reenable => "Re-enable expired user roles",
+                activate => "Make future user roles active now",
+                chgdates  => "Change starting/ending dates",
+                chgsec   => "Change section associated with user roles",
+    );
+    my ($output,$options,%choices);
+    if ($statusmode eq 'Any') {
+        $options .= '
+<option value="chgdates">'.$lt{'chgdates'}.'</option>';
+        $choices{'dates'} = 1;
+    } else {
+        if ($statusmode eq 'Active' || $statusmode eq 'Future') {
+            $options .= '
+<option value="revoke">'.$lt{'revoke'}.'</option>';
+        }
+        if ($statusmode eq 'Future') {
+            $options .= '
+<option value="activate">'.$lt{'activate'}.'</option>';
+            $choices{'dates'} = 1;
+        } elsif ($statusmode eq 'Expired') {
+            $options .= '
+<option value="reenable">'.$lt{'reenable'}.'</option>';
+            $choices{'dates'} = 1;
+        }
+    }
+    if ($context eq 'domain') {
+        $options .= '
+<option value="delete">'.$lt{'delete'}.'</option>';
+    }
+    if (($context eq 'course') || ($context eq 'domain' && $setting eq 'course')) {
+        if ($statusmode ne 'Expired') {
+            $options .= '
+<option value="chgsec">'.$lt{'chgsec'}.'</option>';
+            $choices{'sections'} = 1;
+        }
+    }
+    if ($options) {
+        $output = '<select name="bulkaction" onchange="javascript:opendatebrowser(this.form,'."'studentform'".')" />'."\n".
+                  '<option value="" selected="selected">'.
+                  &mt('Please select').'</option>'."\n".$options."\n".'</select>';
+        if ($choices{'dates'}) {
+            $output .= 
+                '<input type="hidden" name="startdate_month" value="" />'."\n".
+                '<input type="hidden" name="startdate_day" value="" />'."\n".
+                '<input type="hidden" name="startdate_year" value="" />'."\n".
+                '<input type="hidden" name="startdate_hour" value="" />'."\n".
+                '<input type="hidden" name="startdate_minute" value="" />'."\n".
+                '<input type="hidden" name="startdate_second" value="" />'."\n".
+                '<input type="hidden" name="enddate_month" value="" />'."\n".
+                '<input type="hidden" name="enddate_day" value="" />'."\n".
+                '<input type="hidden" name="enddate_year" value="" />'."\n".
+                '<input type="hidden" name="enddate_hour" value="" />'."\n".
+                '<input type="hidden" name="enddate_minute" value="" />'."\n".
+                '<input type="hidden" name="enddate_second" value="" />'."\n";
+            if ($context eq 'course') {
+                $output .= '<input type="hidden" name="makedatesdefault" value="" />'."\n";
+            }
+        }
+        if ($choices{'sections'}) {
+            $output .= '<input type="hidden" name="retainsec" value= "" />'."\n".
+                       '<input type="hidden" name="newsecs" value= "" />'."\n";
+        }
+    }
+    return $output;
+}
+
+sub date_section_javascript {
+    my ($context,$setting) = @_;
+    my $title;
+    if (($context eq 'course') || ($context eq 'domain' && $setting eq 'course'))  {
+        $title = &mt('Date and Section selector');
+    } else {
+        $title = &mt('Date selector');
+    }
+    my $output = '
+<script type="text/javascript">
+    var stdeditbrowser;'."\n";
+    $output .= <<"ENDONE";
+    function opendatebrowser(callingform,formname) {
+        var bulkaction = callingform.bulkaction.options[callingform.bulkaction.selectedIndex].value;
+        if (bulkaction == 'revoke' || bulkaction == 'delete' || bulkaction == '') {
+            return;
+        }
+        var url = '/adm/createuser?';
+        var type = '';
+        var showrole = callingform.showrole.options[callingform.showrole.selectedIndex].value;
+ENDONE
+    if ($context eq 'domain') {
+        $output .= '
+        type = callingform.roletype.options[callingform.roletype.selectedIndex].value;
+';
+    }
+    my $width= '700';
+    my $height = '400';
+    $output .= <<"ENDTWO";
+        url += 'action=dateselect&callingform=' + formname + 
+               '&roletype='+type+'&showrole='+showrole +'&bulkaction='+bulkaction;
+        var title = '$title';
+        var options = 'scrollbars=1,resizable=1,menubar=0';
+        options += ',width=$width,height=$height';
+        stdeditbrowser = open(url,title,options,'1');
+        stdeditbrowser.focus();
+    }
+</script>
+ENDTWO
+    return $output;
+}
+
+sub date_section_selector {
+    my ($context) = @_;
+    my $callingform = $env{'form.callingform'};
+    my $formname = 'dateselect';  
+    my $groupslist = &get_groupslist();
+    my $sec_js = &setsections_javascript($formname,$groupslist);
+    my $output = <<"END";
+<script type="text/javascript">
+
+$sec_js
+
+function saveselections(formname) {
+
+END
+    if ($env{'form.bulkaction'} eq 'chgsec') {
+        $output .= <<"END";
+        opener.document.$callingform.retainsec.value = formname.retainsec.value;
+        setSections(formname);
+        if (seccheck == 'ok') {
+            opener.document.$callingform.newsecs.value = formname.sections.value;
+            window.close();
+        }
+        return;
+END
+    } else {
+        if ($context eq 'course') {
+            if (($env{'form.bulkaction'} eq 'reenable') || 
+                ($env{'form.bulkaction'} eq 'activate') || 
+                ($env{'form.bulkaction'} eq 'chgdates')) {
+                $output .= <<"END";
+ 
+        if (formname.makedatesdefault.checked == true) {
+            opener.document.$callingform.makedatesdefault.value = 1;
+        }
+        else {
+            opener.document.$callingform.makedatesdefault.value = 0;
+        }
+
+END
+            }
+        }
+        $output .= <<"END";
+    opener.document.$callingform.startdate_month.value =  formname.startdate_month.options[formname.startdate_month.selectedIndex].value;
+    opener.document.$callingform.startdate_day.value =  formname.startdate_day.value;
+    opener.document.$callingform.startdate_year.value = formname.startdate_year.value;
+    opener.document.$callingform.startdate_hour.value =  formname.startdate_hour.options[formname.startdate_hour.selectedIndex].value;
+    opener.document.$callingform.startdate_minute.value =  formname.startdate_minute.value;
+    opener.document.$callingform.startdate_second.value = formname.startdate_second.value;
+    opener.document.$callingform.enddate_month.value =  formname.enddate_month.options[formname.enddate_month.selectedIndex].value;
+    opener.document.$callingform.enddate_day.value =  formname.enddate_day.value;
+    opener.document.$callingform.enddate_year.value = formname.enddate_year.value;
+    opener.document.$callingform.enddate_hour.value =  formname.enddate_hour.options[formname.enddate_hour.selectedIndex].value;
+    opener.document.$callingform.enddate_minute.value =  formname.enddate_minute.value;
+    opener.document.$callingform.enddate_second.value = formname.enddate_second.value;
+    window.close();
+END
+    }
+    $output .= '
+}
+</script>
+';
+    my %lt = &Apache::lonlocal::texthash (
+                 chac => 'Access dates to apply for selected users',
+                 chse => 'Changes in section affiliation to apply to selected users',
+                 fors => 'For student roles changing the section, will result in a section switch as students may only be in one section of a course at a time.',
+                 forn => 'For a role in a course that is not a student role, a user may have roles in more than one section of a course at a time.',
+                 reta => "Retain each user's current section affiliations?", 
+                 dnap => '(Does not apply to student roles).', 
+            );
+    my ($date_items,$headertext);
+    if ($env{'form.bulkaction'} eq 'chgsec') {
+        $headertext = $lt{'chse'};
+    } else {
+        $headertext = $lt{'chac'};
+        my $starttime;
+        if (($env{'form.bulkaction'} eq 'activate') || 
+            ($env{'form.bulkaction'} eq 'reenable')) {
+            $starttime = time;
+        }
+        $date_items = &date_setting_table($starttime,undef,$context,
+                                          $env{'form.bulkaction'});
+    }
+    $output .= '<h3>'.$headertext.'</h3>'.
+               '<form name="'.$formname.'" method="post">'."\n".
+                $date_items;
+    if ($context eq 'course' && $env{'form.bulkaction'} eq 'chgsec') {
+        my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+        my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+        my %sections_count =
+            &Apache::loncommon::get_sections($cdom,$cnum);
+        my $info;
+        if ($env{'form.showrole'} eq 'st') {
+            $output .= '<p>'.$lt{'fors'}.'</p>'; 
+        } elsif ($env{'form.shorole'} eq 'Any') {
+            $output .= '<p>'.$lt{'fors'}.'</p>'.
+                       '<p>'.$lt{'forn'}.'&nbsp;';
+            $info = $lt{'reta'};
+        } else {
+            $output .= '<p>'.$lt{'forn'}.'&nbsp;';
+            $info = $lt{'reta'};
+        }
+        if ($info) {
+            $info .= '<span class="LC_nobreak">'.
+                     '<label><input type="radio" name="retainsec" value="1" '.
+                     'checked="checked" />'.&mt('Yes').'</label>&nbsp;&nbsp;'.
+                     '<label><input type="radio" name="retainsec" value="0" />'.
+                     &mt('No').'</label></span>';
+            if ($env{'form.showrole'} eq 'Any') {
+                $info .= '<br />'.$lt{'dnap'};
+            }
+            $info .= '</p>';
+        } else {
+            $info = '<input type="hidden" name="retainsec" value="0" />'; 
+        }
+        my $sections_select .= &course_sections(\%sections_count,$env{'form.showrole'});
+        my $secbox = '<p>'.&Apache::lonhtmlcommon::start_pick_box()."\n".
+                     &Apache::lonhtmlcommon::row_title(&mt('New section to assign'),'LC_oddrow_value')."\n".
+                     '<table class="LC_createuser"><tr class="LC_section_row">'."\n".
+                     '<td align="center">'.&mt('Existing sections')."\n".
+                     '<br />'.$sections_select.'</td><td align="center">'.
+                     &mt('New section').'<br />'."\n".
+                     '<input type="text" name="newsec" size="15" />'."\n".
+                     '<input type="hidden" name="sections" value="" />'."\n".
+                     '</td></tr></table>'."\n".
+                     &Apache::lonhtmlcommon::row_closure(1)."\n".
+                     &Apache::lonhtmlcommon::end_pick_box().'</p>';
+        $output .= $info.$secbox;
+    }
+    $output .= '<p>'.
+&mt('Use "Save" to update the main window with your selections.').'<br /><br />'.
+'<input type="button" name="dateselection" value="'.&mt('Save').'" onclick="javascript:saveselections(this.form)" /></p>'."\n".
+'</form>';
+    return $output;
+}
+
 sub results_header_row {
     my ($rolefilter,$statusmode,$context) = @_;
     my ($description,$showfilter);
@@ -2169,8 +2525,7 @@
         $description = &mt('Course - ').$env{'course.'.$env{'request.course.id'}.'.description'}.': ';
         if ($statusmode eq 'Expired') {
             $description .= &mt('Users in course with expired [_1] roles',$showfilter);
-        }
-        if ($statusmode eq 'Future') {
+        } elsif ($statusmode eq 'Future') {
             $description .= &mt('Users in course with future [_1] roles',$showfilter);
         } elsif ($statusmode eq 'Active') {
             $description .= &mt('Users in course with active [_1] roles',$showfilter);
@@ -2907,25 +3262,193 @@
 
 # ================================================================== Phase four
 
-sub expire_user_list {
-    my ($r,$context) = @_;
+sub update_user_list {
+    my ($r,$context,$setting,$choice) = @_;
+    my $now = time;
     my $count=0;
-    my @droplist = &Apache::loncommon::get_env_multiple('form.droplist');
-    foreach (@droplist) {
-        my ($uname,$udom)=split(/\:/,$_);
-        # drop student
-        my $result = &modifystudent($udom,$uname,$env{'request.course.id'});
+    my @changelist;
+    if ($choice ne '') {
+        @changelist = &Apache::loncommon::get_env_multiple('form.actionlist');
+    } else {
+        @changelist = &Apache::loncommon::get_env_multiple('form.droplist');
+    }
+    my %result_text = ( ok    => { 'revoke'   => 'Revoked',
+                                   'delete'   => 'Deleted',
+                                   'reenable' => 'Re-enabled',
+                                   'activate' => 'Activated', 
+                                 },
+                        error => {'revoke'    => 'revoking',
+                                  'delete'    => 'deleting',
+                                  'reenable'  => 're-enabling',
+                                  'activate'  => 'activating',
+                                 },
+                      );
+    my ($startdate,$enddate);
+    if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') {
+        ($startdate,$enddate) = &get_dates_from_form();
+    }
+    foreach my $item (@changelist) {
+        my ($role,$uname,$udom,$cid,$sec,$scope,$result,$type,$locktype,@sections,
+            $scopestem);
+        if ($context eq 'course') {
+            ($uname,$udom,$role,$sec,$type,$locktype) = split(/\:/,$item,-1);
+            $cid = $env{'request.course.id'};
+            $scopestem = '/'.$cid;
+            $scopestem =~s/\_/\//g;
+            if ($sec eq '') {
+                $scope = $scopestem;
+            } else {
+                $scope = $scopestem.'/'.$sec;
+            }
+        } elsif ($context eq 'construction_space') {
+            ($uname,$udom,$role) = split(/\:/,$item,-1);
+            $scope = '/'.$env{'user.domain'}.'/'.$env{'user.name'};
+        } elsif ($context eq 'domain') {
+            if ($setting eq 'domain') {
+                ($role,$uname,$udom) = split(/\:/,$item,-1);
+                $scope = '/'.$env{'request.role.domain'}.'/';
+            } elsif ($setting eq 'construction_space') { 
+                ($uname,$udom,$role,$scope) = split(/\:/,$item);
+            } elsif ($setting eq 'course') {
+                ($uname,$udom,$role,$cid,$sec,$type,$locktype) = 
+                    split(/\:/,$item);
+                $scope = '/'.$cid;
+                $scope =~s/\_/\//g;
+                if ($sec ne '') {
+                    $scope .= '/'.$sec;
+                }
+            }
+        }
+        my $plrole = &Apache::lonnet::plaintext($role);
+        my ($uid,$first,$middle,$last,$gene,$sec);
+        my $start = $env{'form.'.$item.'_start'};
+        my $end = $env{'form.'.$item.'_end'};
+        # revoke or delete user role
+        if ($choice eq 'revoke') {
+            $end = $now; 
+            if ($role eq 'st') {
+                $result = 
+                    &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+            } else {
+                $result = 
+                    &Apache::lonnet::revokerole($udom,$uname,$scope,$role);
+            }
+        } elsif ($choice eq 'delete') {
+            $start = -1;
+            $end = -1;
+            if ($role eq 'st') {
+# FIXME - how does role deletion affect classlist?
+                &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+            } else {
+                $result =
+                    &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$now,
+                                                0,1);
+             }
+        } else {
+            #reenable, activate, change access dates or change section
+            if ($choice ne 'chgsec') {
+                $start = $startdate; 
+                $end = $enddate;
+            }
+            if ($choice eq 'reenable') {
+                if ($role eq 'st') {
+                    $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+                } else {
+                    $result = 
+                        &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end,
+                                                    $now);
+                }
+            } elsif ($choice eq 'activate') {
+                if ($role eq 'st') {
+                    $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+                } else {
+                    $result = &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end,
+                                            $now);
+                }
+            } elsif ($choice eq 'chgdates') {
+                if ($role eq 'st') {
+                    $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid);
+                } else {
+                    $result = &Apache::lonnet::assignrole($udom,$uname,$scope,$role,$end,
+                                                $start);
+                }
+            } elsif ($choice eq 'chgsec') {
+                my (@newsecs,$revresult,$nochg,@retained);
+                if ($role ne 'cc') {
+                    @newsecs = split(/,/,$env{'form.newsecs'});
+                }
+                # remove existing section if not to be retained.   
+                if (!$env{'form.retainsec'}) {
+                    if ($sec eq '') {
+                        if (@newsecs == 0) {
+                            $result = &mt('No change in section assignment (none)');
+                            $nochg = 1;
+                        }
+                    } else {
+                        if (!grep(/^\Q$sec\E$/,@newsecs)) {
+                            $revresult =
+                               &Apache::lonnet::revokerole($udom,$uname,$scope,$role);
+                        } else {
+                            push(@retained,$sec);
+                        }
+                    }
+                } else {
+                    push(@retained,$sec);
+                }
+                # add new sections
+                if (@newsecs == 0) {
+                    if (!$nochg) {
+                        if ($sec ne '') {
+                            if ($role eq 'st') {
+                                $result = 
+                                    &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid);
+                            } else {
+                                my $newscope = $scopestem;
+                                $result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start);
+                            }
+                        }
+                    }
+                } else {
+                    foreach my $newsec (@newsecs) { 
+                        if (!grep(/^\Q$newsec\E$/,@retained)) {
+                            if ($role eq 'st') {
+                                $result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$newsec,$end,$start,$type,$locktype,$cid);
+                            } else {
+                                my $newscope = $scopestem;
+                                if ($newsec ne '') {
+                                   $newscope .= '/'.$newsec;
+                                }
+                                $result = &Apache::lonnet::assignrole($udom,$uname,
+                                                        $newscope,$role,$end,$start);
+                            }
+                        }
+                    }
+                }
+            }
+        }
         if ($result eq 'ok' || $result eq 'ok:') {
-            $r->print(&mt('Dropped [_1]',$uname.'@'.$udom).'<br>');
+            $r->print(&mt("$result_text{'ok'}{$choice} role of '[_1]' in [_2] for [_3]",
+                          $plrole,$scope,$uname.':'.$udom).'<br />');
             $count++;
         } else {
             $r->print(
-          &mt('Error dropping [_1]:[_2]',$uname.'@'.$udom,$result).
-                      '<br />');
+                &mt("Error $result_text{'error'}{$choice} [_1] in [_2] for [_3]:[_4]",
+                    $plrole,$scope,$uname.':'.$udom,$result).'<br />');
+        }
+    }
+    $r->print('<p><b>'.&mt("$result_text{'ok'}{$choice} role(s) for [quant,_1,user,users,users].",$count).'</b></p>');
+    if ($count > 0) {
+        if ($choice eq 'revoke') {
+            $r->print('<p>'.&mt('Re-enabling will re-activate data for the role.</p>'));
+        }
+        # Flush the course logs so reverse user roles immediately updated
+        &Apache::lonnet::flushcourselogs();
+    }
+    if ($env{'form.makedatesdefault'}) {
+        if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') {
+            $r->print(&make_dates_default($startdate,$enddate));
         }
     }
-    $r->print('<p><b>'.&mt('Dropped [_1] user(s).',$count).'</b></p>');
-    $r->print('<p>'.&mt('Re-enrollment will re-activate data.')) if ($count);
 }
 
 sub classlist_drop {
@@ -3034,7 +3557,7 @@
         $groupslist = join('","',sort(keys(%curr_groups)));
         $groupslist = '"'.$groupslist.'"';
     }
-    return $groupslist;
+    return $groupslist; 
 }
 
 sub setsections_javascript {
@@ -3045,10 +3568,10 @@
         $finish = 'formname.submit()';
         $roleplace = 3;
     } else {
-        $checkincluded = 'formname.name == "'.$form.'"';
+        $checkincluded = 'formname.name == "'.$form.'"'; 
         $finish = "seccheck = 'ok';";
         $roleplace = 1;
-        $setsection_js = "var seccheck = 'alert';";
+        $setsection_js = "var seccheck = 'alert';"; 
     }
     my %alerts = &Apache::lonlocal::texthash(
                     secd => 'Section designations do not apply to Course Coordinator roles.',
@@ -3061,7 +3584,7 @@
                     plch => 'Please choose a different section name.',
                     mnot => 'may not be used as a section name, as it is the name of a course group.',
                     secn => 'Section names and group names must be distinct. Please choose a different section name.',
-                 );
+                 );                
     $setsection_js .= <<"ENDSECCODE";
 
 function setSections(formname) {
@@ -3141,7 +3664,7 @@
     $finish
 }
 ENDSECCODE
-    return $setsection_js;
+    return $setsection_js; 
 }
 
 1;

--raeburn1196889795--