--- loncom/auth/lonroles.pm 2012/02/09 01:11:52 1.256.2.6.2.3 +++ loncom/auth/lonroles.pm 2014/03/25 10:18:04 1.256.2.7 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.256.2.6.2.3 2012/02/09 01:11:52 raeburn Exp $ +# $Id: lonroles.pm,v 1.256.2.7 2014/03/25 10:18:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -57,7 +57,8 @@ course they should act on, etc. Both in handler determines via C's C<&allowed> function that a certain action is not allowed, C is used as error handler. This allows the user to select another role which may have permission to do -what they were trying to do. +what they were trying to do. C can also be accessed via the +B button in the Remote Control. =begin latex @@ -217,33 +218,12 @@ sub handler { my $now=time; my $then=$env{'user.login.time'}; my $refresh=$env{'user.refresh.time'}; - my $update=$env{'user.update.time'}; if (!$refresh) { $refresh = $then; } - if (!$update) { - $update = $then; - } - -# -------------------------------------------------------- Check for new roles - my $updateresult; - if ($env{'form.doupdate'}) { - my $show_course=&Apache::loncommon::show_course(); - my $checkingtxt; - if ($show_course) { - $checkingtxt = &mt('Checking for new courses ...'); - } else { - $checkingtxt = &mt('Checking for new roles ...'); - } - $updateresult = ''.$checkingtxt.''; - $updateresult .= &update_session_roles(); - &Apache::lonnet::appenv({'user.update.time' => $now}); - $update = $now; - } - my $envkey; my %dcroles = (); - my $numdc = &check_fordc(\%dcroles,$update,$then); + my $numdc = &check_fordc(\%dcroles,$then); &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); my $loncaparev = $Apache::lonnet::perlvar{'lonVersion'}; @@ -263,13 +243,13 @@ sub handler { if (defined($env{'user.role.'.$env{'form.switchrole'}})) { my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}}); if (!$end || $end > $now) { - if (!$start || $start < $update) { + if (!$start || $start < $refresh) { $switch_is_active = 1; } } } unless ($switch_is_active) { - &adhoc_course_role($refresh,$update,$then); + &adhoc_course_role($refresh,$then); } } my %temp=('logout_'.$env{'request.course.id'} => time); @@ -291,7 +271,7 @@ sub handler { ($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) { if ($dcroles{$domain}) { &Apache::lonnet::check_adhoc_privs($domain,$coursenum, - $update,$refresh,$now,$ccrole); + $then,$refresh,$now,$ccrole); } last; } @@ -331,7 +311,7 @@ sub handler { if ($dcroles{$domain}) { my ($server_status,$home) = &check_author_homeserver($user,$domain); if (($server_status eq 'ok') || ($server_status eq 'switchserver')) { - &Apache::lonnet::check_adhoc_privs($domain,$user,$update, + &Apache::lonnet::check_adhoc_privs($domain,$user,$then, $refresh,$now,'ca'); if ($server_status eq 'switchserver') { my $trolecode = 'ca./'.$domain.'/'.$user; @@ -353,7 +333,7 @@ sub handler { foreach $envkey (keys %env) { next if ($envkey!~/^user\.role\./); my ($where,$trolecode,$role,$tstatus,$tend,$tstart); - &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where, + &Apache::lonnet::role_status($envkey,$then,$refresh,$now,\$role,\$where, \$trolecode,\$tstatus,\$tstart,\$tend); if ($env{'form.'.$trolecode}) { if ($tstatus eq 'is') { @@ -514,11 +494,6 @@ ENDENTERKEY my $msg; my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum); - unless (($ferr) || ($env{'form.switchrole'})) { - &Apache::lonnet::put('nohist_crslastlogin', - {$env{'user.name'}.':'.$env{'user.domain'}. - ':'.$csec.':'.$role => $now},$cdom,$cnum); - } if (($env{'form.orgurl'}) && ($env{'form.orgurl'}!~/^\/adm\/flip/)) { my $dest=$env{'form.orgurl'}; @@ -700,13 +675,6 @@ function enterrole (thisform,rolecode,bu alert('$standby'); } } - -function setToUpdate(thisform) { - thisform.doupdate.value='1'; - thisform.selectrole.value=''; - thisform.submit(); -} - // ]]> ENDHEADER @@ -769,14 +737,13 @@ ENDHEADER } # -------------------------------------------------------- Choice or no choice? if ($nochoose) { - $r->print("

".&mt('Sorry ...')."

\n". - &mt('This action is currently not authorized.').''. - &Apache::loncommon::end_page()); - return OK; + $r->print("

".&mt('Sorry ...')."

\n". + &mt('This action is currently not authorized.').''. + &Apache::loncommon::end_page()); + return OK; } else { - $r->print($updateresult); if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) { - $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'}; + $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'}; } $r->print('
'); $r->print(''); @@ -786,45 +753,23 @@ ENDHEADER $r->rflush(); my (%roletext,%sortrole,%roleclass,%futureroles,%timezones); - my ($countactive,$countfuture,$inrole,$possiblerole) = - &gather_roles($update,$refresh,$now,$reinit,$nochoose,\%roletext,\%sortrole,\%roleclass, + my ($countactive,$countfuture,$inrole,$possiblerole) = + &gather_roles($then,$refresh,$now,$reinit,$nochoose,\%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 = ''. - ''; - } if ($env{'user.adv'}) { - my $showall = '