--- loncom/auth/lonroles.pm 2016/08/08 13:39:26 1.269.2.25 +++ loncom/auth/lonroles.pm 2015/03/01 22:21:00 1.310 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.269.2.25 2016/08/08 13:39:26 raeburn Exp $ +# $Id: lonroles.pm,v 1.310 2015/03/01 22:21:00 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -143,7 +143,7 @@ use Apache::lonrss; use GDBM_File; use LONCAPA qw(:DEFAULT :match); use HTML::Entities; - + sub redirect_user { my ($r,$title,$url,$msg) = @_; @@ -151,7 +151,6 @@ sub redirect_user { &Apache::loncommon::content_type($r,'text/html'); &Apache::loncommon::no_cache($r); $r->send_http_header; - my $swinfo=&Apache::lonmenu::rawconfig(); # Breadcrumbs my $brcrum = [{'href' => $url, @@ -166,11 +165,6 @@ sub redirect_user { $url=~s/ /\%20/g; $r->print(< -// -

$msg

$end_page ENDREDIR @@ -229,7 +223,7 @@ sub handler { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); -# -------------------------------------------------- Check if setting hot list +# -------------------------------------------------- Check if setting hot list my $hotlist; if ($env{'form.action'} eq 'verify_and_change_rolespref') { $hotlist = &Apache::lonpreferences::verify_and_change_rolespref($r); @@ -518,10 +512,10 @@ ENDENTERKEY if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) { my $msg; - my ($furl,$ferr)= - &Apache::lonuserstate::readmap($cdom.'/'.$cnum); + my ($furl,$ferr)= + &Apache::lonuserstate::readmap($cdom.'/'.$cnum); unless ($ferr) { - unless (($env{'form.switchrole'}) || + unless (($env{'form.switchrole'}) || ($env{"environment.internal.$cdom.$cnum.$role.adhoc"})) { &Apache::lonnet::put('nohist_crslastlogin', {$env{'user.name'}.':'.$env{'user.domain'}. @@ -544,7 +538,7 @@ ENDENTERKEY } if (($env{'form.orgurl'}) && ($env{'form.orgurl'}!~/^\/adm\/flip/) && - ($env{'form.orgurl'} ne '/adm/roles')) { + ($env{'form.orgurl'} ne '/adm/roles')) { my $dest=$env{'form.orgurl'}; if ($env{'form.symb'}) { if ($dest =~ /\?/) { @@ -610,7 +604,7 @@ ENDENTERKEY if ($env{'request.role.adv'}) { $dest = &Apache::lonenc::unencrypted($dest); if ($destsymb eq '') { - ($destsymb) = ($dest =~ /(?:\?|\&)symb=([^\&]*)/); + ($destsymb) = ($dest =~ /(?:\?|\&)symb=([^\&]*)/); $destsymb = &unescape($destsymb); } } @@ -635,7 +629,7 @@ ENDENTERKEY } } } - unless (($dest =~ m{^/enc/}) || ($dest =~ /(\?|\&)symb=.+___\d+___.+/)) { + unless (($dest =~ m{^/enc/}) || ($dest =~ /(\?|\&)symb=.+___\d+___.+/)) { if (($destsymb ne '') && ($destsymb !~ m{^/enc/})) { my $esc_symb = &escape($destsymb); $dest .= '?symb='.$esc_symb; @@ -663,7 +657,6 @@ ENDENTERKEY } } # Are we allowed to look at the first resource? - my $access; if ($furl =~ m{^(/adm/wrapper|)/ext/}) { # If it's an external resource, # strip off the symb argument and possible query @@ -671,16 +664,14 @@ ENDENTERKEY # Unencode $symb $symb = &unescape($symb); # Then check for permission - $access = &Apache::lonnet::allowed('bre',$exturl,$symb); + if (!&Apache::lonnet::allowed('bre',$exturl,$symb)) { + $furl = &Apache::lonpageflip::first_accessible_resource(); + } # For other resources just check for permission - } else { - $access = &Apache::lonnet::allowed('bre',$furl); - } - if (!$access) { + } elsif (!&Apache::lonnet::allowed('bre',$furl)) { $furl = &Apache::lonpageflip::first_accessible_resource(); - } elsif ($access eq 'B') { - $furl = '/adm/navmaps?showOnlyHomework=1'; } + $msg = &mt('Entering [_1] ...', $env{'course.'.$cdom.'_'.$cnum.'.description'}); &redirect_user($r, &mt('Entering [_1]', @@ -738,7 +729,7 @@ ENDENTERKEY $crumbtext = 'Courses'; $pagetitle = 'My Courses'; $recent = &mt('Recent Courses'); - $standby = &mt('Course selected. Please stand by.'); + $standby = &mt('Course selected. Please stand by.'); } my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; @@ -753,7 +744,7 @@ ENDENTERKEY $cattype = $domdefs{'catauth'}; } my $funcs = &get_roles_functions($showcount,$cattype); - &js_escape(\$standby); + $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.').'

'; $r->print(<print($showresult); } elsif ($env{'form.state'} eq 'queued') { @@ -1766,11 +1757,10 @@ sub courselink { } sub coursepick_jscript { - my %js_lt = &Apache::lonlocal::texthash( + my %lt = &Apache::lonlocal::texthash( plsu => "Please use the 'Select Course/Community' link to open a separate pick course window where you may select the course or community you wish to enter.", youc => 'You can only use this screen to select courses and communities in the current domain.', ); - &js_escape(\%js_lt); my $verify_script = <<"END";