--- loncom/auth/lonroles.pm 2012/08/15 16:56:52 1.273 +++ loncom/auth/lonroles.pm 2012/08/16 17:02:46 1.274 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.273 2012/08/15 16:56:52 raeburn Exp $ +# $Id: lonroles.pm,v 1.274 2012/08/16 17:02:46 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -211,9 +211,17 @@ sub handler { $update = $then; } + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); + +# -------------------------------------------------- Check if setting hot list + my $hotlist; + if ($env{'form.action'} eq 'verify_and_change_rolespref') { + $hotlist = &Apache::lonpreferences::verify_and_change_rolespref($r); + } + # -------------------------------------------------------- Check for new roles my $updateresult; - if ($env{'form.doupdate'}) { + if ($env{'form.state'} eq 'doupdate') { my $show_course=&Apache::loncommon::show_course(); my $checkingtxt; if ($show_course) { @@ -221,7 +229,7 @@ sub handler { } else { $checkingtxt = &mt('Checking for new roles ...'); } - $updateresult = ''.$checkingtxt.''; + $updateresult = $checkingtxt; $updateresult .= &update_session_roles(); &Apache::lonnet::appenv({'user.update.time' => $now}); $update = $now; @@ -230,14 +238,13 @@ sub handler { # -------------------------------------------------- Check for author requests my $reqauthor; - if ($env{'form.requestauthor'}) { + if ($env{'form.state'} eq 'requestauthor') { $reqauthor = &Apache::loncoursequeueadmin::process_reqauthor(\$update); } my $envkey; my %dcroles = (); my $numdc = &check_fordc(\%dcroles,$update,$then); - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); my $loncaparev = $Apache::lonnet::perlvar{'lonVersion'}; # ================================================================== Roles Init @@ -654,15 +661,20 @@ ENDENTERKEY $recent = &mt('Recent Courses'); } my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; + + my %roles_in_env; + my $showcount = &roles_from_env(\%roles_in_env,$update); + my $swinfo=&Apache::lonmenu::rawconfig(); my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum}); + my $funcs = &get_roles_functions($showcount); my $standby=&mt('Role selected. Please stand by.'); $standby=~s/\n/\\n/g; - my $noscript=''.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'
'.&mt('As this is not the case, most functionality in the system will be unavailable.').'

'; + my $noscript='
'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'
'.&mt('As this is not the case, most functionality in the system will be unavailable.').'

'; $r->print(< +$funcs @@ -685,16 +697,17 @@ function enterrole (thisform,rolecode,bu } } -function setToUpdate(thisform) { - thisform.doupdate.value='1'; - thisform.selectrole.value=''; - thisform.submit(); -} - -function setToRequestAuthor(thisform) { - thisform.requestauthor.value='1'; - thisform.selectrole.value=''; - thisform.submit(); +function rolesView (caller) { + if ((caller == 'showall') || (caller == 'noshowall')) { + document.rolechoice.display.value = caller; + } else { + if ((caller == 'doupdate') || (caller == 'requestauthor') || + (caller == 'queued')) { + document.rolechoice.state.value = caller; + } + } + document.rolechoice.selectrole.value=''; + document.rolechoice.submit(); } // ]]> @@ -763,115 +776,43 @@ ENDHEADER &Apache::loncommon::end_page()); return OK; } else { - if ($updateresult || $reqauthor) { - $r->print('
'. - $updateresult. - $reqauthor. - '
'); + if ($updateresult || $reqauthor || $hotlist) { + my $showresult = '
'; + if ($updateresult) { + $showresult .= &Apache::lonhtmlcommon::confirm_success($updateresult); + } + if ($reqauthor) { + $showresult .= &Apache::lonhtmlcommon::confirm_success($reqauthor); + } + if ($hotlist) { + $showresult .= $hotlist; + } + $showresult .= '
'; + $r->print($showresult); + } elsif ($env{'form.state'} eq 'queued') { + $r->print(&get_queued()); } if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) { $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'}; } + my $display = ($env{'form.display'} =~ /^(showall)$/); $r->print('
'); $r->print(''); $r->print(''); $r->print(''); + $r->print(''); + $r->print(''); } $r->rflush(); my (%roletext,%sortrole,%roleclass,%futureroles,%timezones); my ($countactive,$countfuture,$inrole,$possiblerole) = - &gather_roles($update,$refresh,$now,$reinit,$nochoose,\%roletext,\%sortrole,\%roleclass, - \%futureroles,\%timezones,$loncaparev); + &gather_roles($update,$refresh,$now,$reinit,$nochoose,\%roles_in_env,\%roletext, + \%sortrole,\%roleclass,\%futureroles,\%timezones,$loncaparev); $refresh = $now; &Apache::lonnet::appenv({'user.refresh.time' => $refresh}); - my $updatebutton = &mt('Check for role changes'); - my $show_course=&Apache::loncommon::show_course(); - if ($show_course) { - $updatebutton = &mt('Check for new courses'); - } - my $do_update; - unless (($env{'form.source'} eq 'login') || ($env{'form.doupdate'})) { - $do_update = ''. - ''; - } - my ($requestauthor,$requestcrs); - unless ($reqauthor) { - if ($env{'environment.canrequest.author'}) { - unless (&Apache::loncoursequeueadmin::is_active_author()) { - my ($status,$timestamp) = split(/:/,$env{'environment.requestauthorqueued'}); - if ($status eq 'approval') { - $requestauthor = &mt('A request for authoring space submitted on [_1] is awaiting approval',&Apache::lonlocal::locallocaltime($timestamp)); - } elsif (($status eq 'approved') && ($do_update)) { - my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', - ['active'],['au'],[$env{'user.domain'}]); - if (keys(%roleshash)) { - $requestauthor = &mt('Your request for an author role has been approved.').'
'; - if ($show_course) { - $requestauthor .= &mt('Use the "Check for new courses" button to update your list of roles.'); - } else { - $requestauthor .= &mt('Use the "Check for new roles" button to update your list of roles.'); - } - $requestauthor = ''.$requestauthor.''; - } - } - unless ($requestauthor) { - $requestauthor = - ''. - ''; - } - } - } - } - my $do_update; - unless (($env{'form.source'} eq 'login') || ($env{'form.doupdate'})) { - $do_update = ''. - ''; - } - if ($env{'user.adv'}) { - my $showall = '