--- loncom/auth/lonroles.pm 2012/08/16 17:02:46 1.274 +++ loncom/auth/lonroles.pm 2012/09/04 20:47:46 1.276 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.274 2012/08/16 17:02:46 raeburn Exp $ +# $Id: lonroles.pm,v 1.276 2012/09/04 20:47:46 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -141,7 +141,7 @@ use Apache::loncoursequeueadmin; use GDBM_File; use LONCAPA qw(:DEFAULT :match); use HTML::Entities; - + sub redirect_user { my ($r,$title,$url,$msg) = @_; @@ -291,8 +291,10 @@ sub handler { if (my ($ccrole,$domain,$coursenum) = ($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) { if ($dcroles{$domain}) { - &Apache::lonnet::check_adhoc_privs($domain,$coursenum, - $update,$refresh,$now,$ccrole); + if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum, + $update,$refresh,$now,$ccrole)) { + &Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.$ccrole.adhoc" => time}); + } } last; } @@ -515,6 +517,12 @@ ENDENTERKEY my $msg; my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum); + unless (($ferr) || ($env{'form.switchrole'}) || + ($env{"environment.internal.$cdom.$cnum.$role.adhoc"})) { + &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'}; @@ -571,11 +579,52 @@ ENDENTERKEY $furl = "/adm/helper/course.initialization.helper"; # Send the user to the course they selected } elsif ($env{'request.course.id'}) { - if ($env{'form.destinationurl'}) { - my $dest = $env{'form.destinationurl'}; - if ($env{'form.destsymb'} ne '') { - my $esc_symb = &HTML::Entities::encode($env{'form.destsymb'},'"<>&'); - $dest .= '?symb='.$esc_symb; + my ($dest,$destsymb,$checkenc); + $dest = $env{'form.destinationurl'}; + $destsymb = $env{'form.destsymb'}; + if ($dest ne '') { + if ($env{'form.switchrole'}) { + if ($destsymb ne '') { + if ($destsymb !~ m{^/enc/}) { + unless ($env{'request.role.adv'}) { + $checkenc = 1; + } + } + } + if ($dest =~ m{^/enc/}) { + if ($env{'request.role.adv'}) { + $dest = &Apache::lonenc::unencrypted($dest); + if ($destsymb eq '') { + ($destsymb) = ($dest =~ /\?symb=([^\&]*)/); + $destsymb = &unescape($destsymb); + } + } + } else { + if ($destsymb eq '') { + ($destsymb) = ($dest =~ /\?symb=([^\&]+)/); + $destsymb = &unescape($destsymb); + } + unless ($env{'request.role.adv'}) { + $checkenc = 1; + } + } + if (($checkenc) && ($destsymb ne '')) { + my ($encstate,$unencsymb,$res); + my $unencsymb = &Apache::lonnet::symbclean($destsymb); + (undef,undef,$res) = &Apache::lonnet::decode_symb($unencsymb); + &Apache::lonnet::symbverify($unencsymb,$res,\$encstate); + if ($encstate) { + if (($dest ne '') && ($dest !~ m{^/enc/})) { + $dest=&Apache::lonenc::encrypted($dest); + } + } + } + } + unless (($dest =~ m{^/enc/}) || ($dest =~ /\?symb=.+___\d+___.+/)) { + if (($destsymb ne '') && ($destsymb !~ m{^/enc/})) { + my $esc_symb = &escape($destsymb); + $dest .= '?symb='.$esc_symb; + } } &redirect_user($r, &mt('Entering [_1]', $env{'course.'.$courseid.'.description'}),