--- loncom/auth/lonroles.pm 2018/05/28 23:26:12 1.338 +++ loncom/auth/lonroles.pm 2021/04/19 20:09:07 1.346 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.338 2018/05/28 23:26:12 raeburn Exp $ +# $Id: lonroles.pm,v 1.346 2021/04/19 20:09:07 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -272,6 +272,12 @@ sub handler { # ================================================================== Roles Init if ($env{'form.selectrole'}) { + if (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq '')) { + if ($env{'form.ltitarget'} eq 'iframe') { + &Apache::lonnet::appenv({'request.lti.target' => 'iframe'}); + delete($env{'form.ltitarget'}); + } + } my $locknum=&Apache::lonnet::get_locks(); if ($locknum) { return 409; } @@ -499,6 +505,7 @@ sub handler { my $end_page=&Apache::loncommon::end_page(); my $buttontext=&mt('Enter Course'); my $message=&mt('Successfully registered key'); + my $ip = &Apache::lonnet::get_requestor_ip(); my $assignresult= &Apache::lonnet::assign_access_key( $env{'form.newkey'}, @@ -507,7 +514,7 @@ sub handler { $env{'user.domain'}, $env{'user.name'}, &mt('Assigned from [_1] at [_2] for [_3]' - ,$ENV{'REMOTE_ADDR'} + ,$ip ,&Apache::lonlocal::locallocaltime() ,$trolecode) ); @@ -584,9 +591,21 @@ ENDENTERKEY } } } - my $msg; + my ($msg,$blockcrit,$critmsg_check); + $critmsg_check = 1; + $blockcrit = &Apache::loncommon::blocking_status('alert',$cnum,$cdom,undef,1); + if ($blockcrit) { + my $checkrole = "cm./$cdom/$cnum"; + if ($csec ne '') { + $checkrole .= "/$csec"; + } + unless ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) && + ($trolecode !~ m{^st\./$cdom/$cnum})) { + $critmsg_check = 0; + } + } my ($furl,$ferr)= - &Apache::lonuserstate::readmap($cdom.'/'.$cnum); + &Apache::lonuserstate::readmap($cdom.'/'.$cnum,$critmsg_check); unless ($ferr) { &Apache::lonnet::appenv({'request.course.timechecked'=>$now}); unless (($env{'form.switchrole'}) || @@ -646,6 +665,13 @@ ENDENTERKEY if (($ferr) && ($tadv)) { &error_page($r,$ferr,$dest); } else { + if ($env{'request.course.id'} eq $cdom.'_'.$cnum) { + if (($env{'form.orgurl'} ne '') && ($env{'form.symb'} ne '')) { + unless (&Apache::lonnet::symbverify($env{'form.symb'},$env{'form.orgurl'}) { + $dest=$env{'form.orgurl'}; + } + } + } if ($dest =~ m{^/adm/coursedocs\?folderpath}) { if ($env{'request.course.id'} eq $cdom.'_'.$cnum) { my $chome = &Apache::lonnet::homeserver($cnum,$cdom); @@ -715,9 +741,11 @@ ENDENTERKEY if (($dest =~ m{^\Q/public/$cdom/$cnum/syllabus\E.*(\?|\&)usehttp=1}) || ($dest =~ m{^\Q/adm/wrapper/ext/\E(?!https:)})) { if ($ENV{'SERVER_PORT'} == 443) { - my $hostname = $r->hostname(); - if ($hostname ne '') { - $dest = 'http://'.$hostname.$dest; + unless (&Apache::lonnet::uses_sts()) { + my $hostname = $r->hostname(); + if ($hostname ne '') { + $dest = 'http://'.$hostname.$dest; + } } } } @@ -1100,7 +1128,11 @@ ENDHEADER # No active roles if ($countactive==0) { - &requestcourse_advice($r,$cattype,$inrole); + my $elapsed = 0; + if ($now && $update) { + $elapsed = $now - $update; + } + &requestcourse_advice($r,$cattype,$inrole,$elapsed); $r->print(''); if ($countfuture) { $r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture)); @@ -1360,8 +1392,8 @@ sub gather_roles { if (!$allowed) { $button=0; unless ($trustchecked{$tdom}) { - if ((&Apache::lonnet::will_trust('othcoau',$tdom,$env{'user.domain'})) && - (&Apache::lonnet::will_trust('coremau',$env{'user.domain'},$tdom))) { + if ((&Apache::lonnet::will_trust('othcoau',$env{'user.domain'},$tdom)) && + (&Apache::lonnet::will_trust('coaurem',$tdom,$env{'user.domain'}))) { $willtrust{$tdom} = 1; $trustchecked{$tdom} = 1; } @@ -1650,21 +1682,26 @@ sub print_rolerows { } sub findcourse_advice { - my ($r,$cattype) = @_; + my ($r,$cattype,$elapsed) = @_; my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) { - $r->print(&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).' + $r->print('

'.&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).'

'); +
  • '.&mt('Automated enrollment added you to the course in the time since you last logged-in.').' '.&mt('If that is the case you can use the "Check for changes" link in the gray Functions bar to update the list of your available course roles.').'
  • +

    '); } else { - $r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'
    '); + $r->print('

    '.&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'

    '); + if ($elapsed > 600) { + $r->print('

    '.&mt('You may also have been assigned to a course in the time since you last logged-in, or checked for changes'). + '
    '. + &mt('If that is the case you can use the "Check for changes" link in the gray Functions bar to update the list of your available course roles.').'

    '); + } } if (($cattype eq 'std') || ($cattype eq 'domonly')) { $r->print('

    '.&mt('Self-Enrollment').'

    '. @@ -1676,7 +1713,7 @@ sub findcourse_advice { } sub requestcourse_advice { - my ($r,$cattype,$inrole) = @_; + my ($r,$cattype,$inrole,$elapsed) = @_; my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); my (%can_request,%request_doms,$output); @@ -1737,7 +1774,7 @@ sub requestcourse_advice { } else { $r->print('

    '.&mt('Currently no active roles, courses or communities').'

    '); } - &findcourse_advice($r,$cattype); + &findcourse_advice($r,$cattype,$elapsed); } return; }