--- loncom/interface/lonuserutils.pm 2008/01/01 17:24:59 1.37 +++ loncom/interface/lonuserutils.pm 2008/01/05 15:19:32 1.43 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.37 2008/01/01 17:24:59 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.43 2008/01/05 15:19:32 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -450,7 +450,7 @@ END foundatype=1; if (current.argfield == null || current.argfield == '') { var alertmsg = ''; - switch (current.value) { + switch (current.radiovalue) { case 'krb': alertmsg = '$alert{'krb'}'; break; @@ -1308,31 +1308,21 @@ sub print_userlist { $r->rflush(); if ($context eq 'course') { my $classlist = &Apache::loncoursedata::get_classlist(); - my $secidx = &Apache::loncoursedata::CL_SECTION(); - my $viewablesec = &viewable_section($permission); - foreach my $student (keys(%{$classlist})) { - my $section = $classlist->{$student}[$secidx]; - if ($viewablesec ne '') { - if ($section ne $viewablesec) { - next; - } else { - $userlist{$student} = $classlist->{$student}; - } + %userlist = %{$classlist}; + if ($env{'form.showrole'} ne 'st') { + my $showroles; + if ($env{'form.showrole'} ne 'Any') { + $showroles = [$env{'form.showrole'}]; } else { - $userlist{$student} = $classlist->{$student}; + $showroles = undef; } + my $withsec = 1; + my $hidepriv = 1; + my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef, + \@statuses,$showroles,undef,$withsec,$hidepriv); + &gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo, + \%advrolehash,$permission); } - my $showroles; - if ($env{'form.showrole'} ne 'Any') { - $showroles = [$env{'form.showrole'}]; - } else { - $showroles = undef; - } - my $withsec = 1; - my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef, - \@statuses,$showroles,undef,$withsec); - &gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo, - \%advrolehash,$permission); } else { my (%cstr_roles,%dom_roles); if ($context eq 'author') { @@ -1381,7 +1371,8 @@ sub print_userlist { } elsif ($env{'form.roletype'} eq 'course') { if ($env{'form.coursepick'}) { my %courses = &process_coursepick(); - my %allusers; + my %allusers; + my $hidepriv = 1; foreach my $cid (keys(%courses)) { my ($cnum,$cdom,$cdesc) = &get_course_identity($cid); next if ($cnum eq '' || $cdom eq ''); @@ -1399,7 +1390,7 @@ sub print_userlist { foreach my $type (@statuses) { $access{$type} = $type; } - &Apache::loncommon::get_course_users($cdom,$cnum,\%access,\@roles,\@sections,\%users,\%userdata,\%statushash); + &Apache::loncommon::get_course_users($cdom,$cnum,\%access,\@roles,\@sections,\%users,\%userdata,\%statushash,$hidepriv); foreach my $user (keys(%userdata)) { next if (ref($userinfo{$user}) eq 'HASH'); foreach my $item ('fullname','id') { @@ -1905,7 +1896,19 @@ END 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); + my $date_sec_selector = &date_section_javascript($context,$setting,$statusmode); + my %lt = &Apache::lonlocal::texthash( + acwi => 'Access will be set to start immediately', + asyo => 'as you did not select an end date in the pop-up window', + accw => 'Access will be set to continue indefinitely', + asyd => 'as you did not select an end date in the pop-up window', + sewi => "Sections will be switched to 'No section'", + ayes => "as you either selected the 'No section' option", + oryo => 'or you did not select a section in the pop-up window', + arol => 'A role with no section will be added', + swbs => 'Sections will be switched to:', + rwba => 'Roles will be added for section(s):', + ); $r->print(< @@ -1931,12 +1934,47 @@ function verify_action (field) { } else { var message = document.studentform.bulkaction[document.studentform.bulkaction.selectedIndex].text; + var choice = document.studentform.bulkaction[document.studentform.bulkaction.selectedIndex].value; if (numchecked == 1) { message += singconf; } else { message += multconf; } + if (choice == 'chgdates' || choice == 'reenable' || choice == 'activate') { + var datemsg = ''; + if ((document.studentform.startdate_month.value == '') && + (document.studentform.startdate_day.value == '') && + (document.studentform.startdate_year.value == '')) { + datemsg = "\\n$lt{'acwi'},\\n$lt{'asyo'}.\\n"; + } + if ((document.studentform.enddate_month.value == '') && + (document.studentform.enddate_day.value == '') && + (document.studentform.enddate_year.value == '')) { + datemsg += "\\n$lt{'accw'},\\n$lt{'asyd'}.\\n"; + } + if (datemsg != '') { + message += "\\n"+datemsg; + } + } + if (choice == 'chgsec') { + var rolefilter = document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value; + var retained = document.studentform.retainsec.value; + var secshow = document.studentform.newsecs.value; + if (secshow == '') { + if (rolefilter == 'st' || retained == 0 || retained == "") { + message += "\\n\\n$lt{'sewi'},\\n$lt{'ayes'},\\n$lt{'oryo'}.\\n"; + } else { + message += "\\n\\n$lt{'arol'}\\n$lt{'ayes'},\\n$lt{'oryo'}.\\n"; + } + } else { + if (rolefilter == 'st' || retained == 0 || retained == "") { + message += "\\n\\n$lt{'swbs'} "+secshow+".\\n"; + } else { + message += "\\n\\n$lt{'rwba'} "+secshow+".\\n"; + } + } + } if (confirm(message)) { document.studentform.phase.value = 'bulkchange'; document.studentform.submit(); @@ -1987,6 +2025,7 @@ END 'clicker' => "clicker id", 'photo' => "photo", 'extent' => "extent", + 'go' => "go", 'pr' => "Proceed", 'ca' => "check all", 'ua' => "uncheck all", @@ -2069,10 +2108,10 @@ END $output .= &mt("Click on a username to view the user's personal page.").'
'; } if ($actionselect) { - $output .= <<"END"; -$lt{'ac'}: $actionselect

+ $output .= <<"END"; +$lt{'ac'}: $actionselect

  - +

END my @allroles; if ($env{'form.showrole'} eq 'Any') { @@ -2222,6 +2261,10 @@ END # Get groups, role, permanent e-mail so we can sort on them if # necessary. foreach my $user (keys(%{$userlist})) { + if ($user eq '' ) { + delete($userlist->{$user}); + next; + } if ($context eq 'domain' && $user eq $env{'request.role.domain'}.'-domainconfig:'.$env{'request.role.domain'}) { delete($userlist->{$user}); next; @@ -2267,6 +2310,13 @@ END } if ($mode ne 'autoenroll') { my $section = $userlist->{$user}->[$index{'section'}]; + if (($env{'request.course.sec'} ne '') && + ($section ne $env{'request.course.sec'})) { + if ($role eq 'st') { + delete($userlist->{$user}); + next; + } + } if ($secfilter eq 'none') { if ($section ne '') { delete($userlist->{$user}); @@ -2576,7 +2626,7 @@ sub select_actions { } } if ($options) { - $output = ''."\n". ''."\n".$options."\n".''; if ($choices{'dates'}) { @@ -2613,13 +2663,29 @@ sub date_section_javascript { } else { $title = &mt('Date selector'); } + my %nopopup = &Apache::lonlocal::texthash ( + revoke => "Check the boxes for any users for whom roles are to be revoked, and click 'Proceed'", + delete => "Check the boxes for any users for whom roles are to be deleted, and click 'Proceed'", + none => "Choose an action to take for selected users", + ); my $output = '