version 1.353, 2021/11/03 01:04:02
|
version 1.360, 2022/02/24 13:08:59
|
Line 158 sub start_loading_course {
|
Line 158 sub start_loading_course {
|
my $brcrum = [{'href' => '', |
my $brcrum = [{'href' => '', |
'text' => $title},]; |
'text' => $title},]; |
my $start_page = &Apache::loncommon::start_page($title,undef, |
my $start_page = &Apache::loncommon::start_page($title,undef, |
{'bread_crumbs' => $brcrum,}); |
{'bread_crumbs' => $brcrum, |
|
'bread_crumbs_nomenu' => 1, |
|
'links_disabled' => 1}); |
$r->print(<<ENDREDIR); |
$r->print(<<ENDREDIR); |
$start_page |
$start_page |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
$swinfo |
$swinfo |
|
|
|
document.body.addEventListener('click', function (event) { |
|
// filter out clicks on any other elements |
|
if (event.target.nodeName == 'A' && event.target.getAttribute('aria-disabled') == 'true') { |
|
event.preventDefault(); |
|
} |
|
}); |
// ]]> |
// ]]> |
</script> |
</script> |
ENDREDIR |
ENDREDIR |
Line 172 ENDREDIR
|
Line 181 ENDREDIR
|
|
|
sub finish_loading_course { |
sub finish_loading_course { |
my ($r,$msg,$url) = @_; |
my ($r,$msg,$url) = @_; |
#FIXME add continue link, and add jquery to enable menu links when page is loaded |
my $link = '<div id="LC_course_loaded" style="display:none"><a href="'.$url.'">'.&mt('Continue').'</a></div>'; |
my $link; |
|
my $end_page = &Apache::loncommon::end_page(); |
my $end_page = &Apache::loncommon::end_page(); |
my $js_url = &js_escape($url); |
my $js_url = &js_escape($url); |
$r->print(<<END); |
$r->print(<<END); |
Line 181 $msg
|
Line 189 $msg
|
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
\$(document).ready(function() { |
\$(document).ready(function() { |
|
\$("#LC_course_loaded").css("display","block"); |
|
\$('.isDisabled > a').removeAttr("aria-disabled"); |
|
\$('.isDisabled').removeClass("isDisabled"); |
var url = "$js_url"; |
var url = "$js_url"; |
\$(location).attr('href',url); |
\$(location).attr('href',url); |
}); |
}); |
|
// ]]> |
</script> |
</script> |
$link |
$link |
$end_page |
$end_page |
Line 266 sub handler {
|
Line 278 sub handler {
|
$update = $then; |
$update = $then; |
} |
} |
|
|
my $norolelist; |
my ($norolelist,$blocked_by_ip,$blocked_type,$clientip); |
|
$clientip = &Apache::lonnet::get_requestor_ip($r); |
if (($env{'request.course.id'}) && ($env{'request.deeplink.login'})) { |
if (($env{'request.course.id'}) && ($env{'request.deeplink.login'})) { |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
Line 303 sub handler {
|
Line 316 sub handler {
|
} |
} |
} |
} |
|
|
|
if ($env{'form.selectrole'}) { |
|
my ($role,$cdom,$cnum,$rest); |
|
if ($env{'form.switchrole'} =~ m{^(co|cc|in|ta|ep|ad|st|cr).*?\./($match_domain)/($match_courseid)(/(\w+)|$)}) { |
|
($role,$cdom,$cnum,$rest) = ($1,$2,$3,$4); |
|
} elsif ($env{'form.newrole'} =~ m{^(co|cc|in|ta|ep|ad|st|cr).*?\./($match_domain)/($match_courseid)(/(\w+)|$)}) { |
|
($role,$cdom,$cnum,$rest) = ($1,$2,$3,$4); |
|
} |
|
if ($cdom ne '') { |
|
my ($has_evb,$check_ipaccess,$showrole); |
|
$showrole = 1; |
|
my $checkrole = "cm./$cdom/$cnum"; |
|
if ($rest ne '') { |
|
$checkrole .= "/$rest"; |
|
} |
|
if ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) && |
|
($role ne 'st')) { |
|
$has_evb = 1; |
|
} |
|
unless ($has_evb) { |
|
my @machinedoms = &Apache::lonnet::current_machine_domains(); |
|
my $udom = $env{'user.domain'}; |
|
if ($udom eq $cdom) { |
|
$check_ipaccess = 1; |
|
} elsif (($udom ne '') && (grep(/^\Q$udom\E$/,@machinedoms))) { |
|
$check_ipaccess = 1; |
|
} else { |
|
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
|
my $internet_names = &Apache::lonnet::get_internet_names($lonhost); |
|
my $cprim = &Apache::lonnet::domain($cdom,'primary'); |
|
my $cintdom = &Apache::lonnet::internet_dom($cprim); |
|
if (($cintdom ne '') && (ref($internet_names) eq 'ARRAY')) { |
|
if (grep(/^\Q$cintdom\E$/,@{$internet_names})) { |
|
$check_ipaccess = 1; |
|
} |
|
} |
|
} |
|
if ($check_ipaccess) { |
|
my ($ipaccessref,$cached)=&Apache::lonnet::is_cached_new('ipaccess',$cdom); |
|
unless (defined($cached)) { |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['ipaccess'],$cdom); |
|
$ipaccessref = &Apache::lonnet::do_cache_new('ipaccess',$cdom,$domconfig{'ipaccess'},1800); |
|
} |
|
if (ref($ipaccessref) eq 'HASH') { |
|
foreach my $id (keys(%{$ipaccessref})) { |
|
if (ref($ipaccessref->{$id}) eq 'HASH') { |
|
my $range = $ipaccessref->{$id}->{'ip'}; |
|
if ($range) { |
|
my $type = 'exclude'; |
|
if (&Apache::lonnet::ip_match($clientip,$range)) { |
|
$type = 'include'; |
|
} |
|
if (ref($ipaccessref->{$id}->{'courses'}) eq 'HASH') { |
|
if ($ipaccessref->{$id}->{'courses'}{$cdom.'_'.$cnum}) { |
|
if ($type eq 'include') { |
|
$showrole = 1; |
|
last; |
|
} else { |
|
$showrole = 0; |
|
} |
|
} else { |
|
if ($type eq 'include') { |
|
$showrole = 0; |
|
} else { |
|
$showrole = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
unless ($showrole) { |
|
$blocked_by_ip = 1; |
|
$blocked_type = &Apache::loncommon::course_type($cdom.'_'.$cnum); |
|
delete($env{'form.selectrole'}); |
|
delete($env{'form.newrole'}); |
|
} |
|
} |
|
} |
|
|
$registered_cleanup=0; |
$registered_cleanup=0; |
@{$rosterupdates}=(); |
@{$rosterupdates}=(); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
Line 685 ENDCLOSE
|
Line 781 ENDCLOSE
|
$r->rflush(); |
$r->rflush(); |
my ($msg,$blockcrit,$critmsg_check); |
my ($msg,$blockcrit,$critmsg_check); |
$critmsg_check = 1; |
$critmsg_check = 1; |
$blockcrit = &Apache::loncommon::blocking_status('alert',$cnum,$cdom,undef,1); |
$blockcrit = &Apache::loncommon::blocking_status('alert',$clientip,$cnum,$cdom,undef,1); |
if ($blockcrit) { |
if ($blockcrit) { |
my $checkrole = "cm./$cdom/$cnum"; |
my $checkrole = "cm./$cdom/$cnum"; |
if ($csec ne '') { |
if ($csec ne '') { |
Line 1057 ENDCLOSE
|
Line 1153 ENDCLOSE
|
$recent = &mt('Recent Courses'); |
$recent = &mt('Recent Courses'); |
$standby = &mt('Course selected. Please stand by.'); |
$standby = &mt('Course selected. Please stand by.'); |
} |
} |
|
if (($norolelist) && ((split(/:/,$env{'user.error.msg'}))[2])) { |
|
$crumbtext = 'Access Denied'; |
|
$pagetitle = 'Unauthorized'; |
|
} |
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; |
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; |
|
|
my %roles_in_env; |
my %roles_in_env; |
Line 1093 ENDCLOSE
|
Line 1193 ENDCLOSE
|
$start_page=&Apache::loncommon::start_page($pagetitle,undef, |
$start_page=&Apache::loncommon::start_page($pagetitle,undef, |
{bread_crumbs=>$brcrum,crstype=>'Placement'}); |
{bread_crumbs=>$brcrum,crstype=>'Placement'}); |
} else { |
} else { |
$funcs = &get_roles_functions($showcount,$cattype); |
|
my $crumbsright; |
my $crumbsright; |
if ($env{'browser.mobile'}) { |
unless (($norolelist) && ((split(/:/,$env{'user.error.msg'}))[2])) { |
$crumbsright = $funcs; |
$funcs = &get_roles_functions($showcount,$cattype); |
undef($funcs); |
if ($env{'browser.mobile'}) { |
|
$crumbsright = $funcs; |
|
undef($funcs); |
|
} |
} |
} |
$start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum, |
$start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum, |
bread_crumbs_component=>$crumbsright}); |
bread_crumbs_component=>$crumbsright}); |
Line 1205 ENDHEADER
|
Line 1307 ENDHEADER
|
} |
} |
if ($nochoose) { |
if ($nochoose) { |
$r->print("<h2>".&mt('Sorry ...')."</h2>\n<span class='LC_error'>". |
$r->print("<h2>".&mt('Sorry ...')."</h2>\n<span class='LC_error'>". |
&mt('This action is currently not authorized.').'</span>'. |
&mt('This action is currently not authorized.').'</span>'); |
&Apache::loncommon::end_page()); |
if ($error && $norolelist) { |
|
$r->print('<br /><br /><h4><span class="LC_error">'. |
|
&mt('As your session was launched from a web page external to LON-CAPA some course content may be unavailable, including the resource you were trying to access.'). |
|
'</span></h4>'. |
|
'<h4><span class="LC_error">'. |
|
&mt('You may need to login to LON-CAPA directly, or re-launch from a different external system.'). |
|
'</span></h4>'); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} else { |
} else { |
if ($updateresult || $reqauthor || $hotlist) { |
if ($updateresult || $reqauthor || $hotlist) { |
Line 1235 ENDHEADER
|
Line 1345 ENDHEADER
|
$r->print('<input type="hidden" name="newrole" value="" />'); |
$r->print('<input type="hidden" name="newrole" value="" />'); |
$r->print('<input type="hidden" name="display" value="'.$display.'" />'); |
$r->print('<input type="hidden" name="display" value="'.$display.'" />'); |
$r->print('<input type="hidden" name="state" value="" />'); |
$r->print('<input type="hidden" name="state" value="" />'); |
|
if ($blocked_by_ip) { |
|
my $blocked_role = 'student'; |
|
if ($blocked_type eq 'Community') { |
|
$blocked_role = 'member'; |
|
} |
|
$r->print('<h3><span class="LC_error">'. |
|
&mt('The [_1] you selected is not available for access with a [_2] role from your current IP address: [_3].', |
|
lc($blocked_type),$blocked_role,$clientip). |
|
'</span></h3>'); |
|
} |
} |
} |
$r->rflush(); |
$r->rflush(); |
|
|