version 1.1075.2.149, 2020/11/12 01:18:26
|
version 1.1075.2.164, 2022/01/23 00:53:02
|
Line 1378 sub help_open_menu {
|
Line 1378 sub help_open_menu {
|
} |
} |
|
|
sub top_nav_help { |
sub top_nav_help { |
my ($text) = @_; |
my ($text,$linkattr) = @_; |
$text = &mt($text); |
$text = &mt($text); |
my $stay_on_page; |
my $stay_on_page; |
unless ($env{'environment.remote'} eq 'on') { |
unless ($env{'environment.remote'} eq 'on') { |
Line 1394 sub top_nav_help {
|
Line 1394 sub top_nav_help {
|
if ($link) { |
if ($link) { |
return <<"END"; |
return <<"END"; |
$banner_link |
$banner_link |
<a href="$link" title="$title">$text</a> |
<a href="$link" title="$title" $linkattr>$text</a> |
END |
END |
} else { |
} else { |
return ' '.$text.' '; |
return ' '.$text.' '; |
Line 3127 sub authform_filesystem {
|
Line 3127 sub authform_filesystem {
|
$fsyscheck.' onchange="'.$jscall.'" onclick="'. |
$fsyscheck.' onchange="'.$jscall.'" onclick="'. |
$jscall.'"'.$disabled.' />'; |
$jscall.'"'.$disabled.' />'; |
} |
} |
$autharg = '<input type="text" size="10" name="fsysarg" value=""'. |
$autharg = '<input type="password" size="10" name="fsysarg" value=""'. |
' onchange="'.$jscall.'"'.$disabled.' />'; |
' onchange="'.$jscall.'"'.$disabled.' />'; |
$result = &mt |
$result = &mt |
('[_1] Filesystem Authenticated (with initial password [_2])', |
('[_1] Filesystem Authenticated (with initial password [_2])', |
'<label><input type="radio" name="login" value="fsys" '. |
'<label>'.$authtype,'</label>'.$autharg); |
$fsyscheck.'onchange="'.$jscall.'" onclick="'.$jscall.'"'.$disabled.' />', |
|
'</label><input type="password" size="10" name="fsysarg" value="" '. |
|
'onchange="'.$jscall.'"'.$disabled.' />'); |
|
return $result; |
return $result; |
} |
} |
|
|
Line 4731 sub findallcourses {
|
Line 4728 sub findallcourses {
|
############################################### |
############################################### |
|
|
sub blockcheck { |
sub blockcheck { |
my ($setters,$activity,$uname,$udom,$url,$is_course,$symb,$caller) = @_; |
my ($setters,$activity,$clientip,$uname,$udom,$url,$is_course,$symb,$caller) = @_; |
|
|
|
unless ($activity eq 'docs') { |
|
my ($has_evb,$check_ipaccess); |
|
my $dom = $env{'user.domain'}; |
|
if ($env{'request.course.id'}) { |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $checkrole = "cm./$cdom/$cnum"; |
|
my $sec = $env{'request.course.sec'}; |
|
if ($sec ne '') { |
|
$checkrole .= "/$sec"; |
|
} |
|
if ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) && |
|
($env{'request.role'} !~ /^st/)) { |
|
$has_evb = 1; |
|
} |
|
unless ($has_evb) { |
|
if (($activity eq 'printout') || ($activity eq 'grades') || ($activity eq 'search') || |
|
($activity eq 'boards') || ($activity eq 'groups') || ($activity eq 'chat')) { |
|
if ($udom eq $cdom) { |
|
$check_ipaccess = 1; |
|
} |
|
} |
|
} |
|
} elsif (($activity eq 'com') || ($activity eq 'port') || ($activity eq 'blogs') || |
|
($activity eq 'about') || ($activity eq 'wishlist') || ($activity eq 'passwd')) { |
|
my $checkrole; |
|
if ($env{'request.role.domain'} eq '') { |
|
$checkrole = "cm./$env{'user.domain'}/"; |
|
} else { |
|
$checkrole = "cm./$env{'request.role.domain'}/"; |
|
} |
|
if (($checkrole) && (&Apache::lonnet::allowed('evb',undef,undef,$checkrole))) { |
|
$has_evb = 1; |
|
} |
|
} |
|
unless ($has_evb || $check_ipaccess) { |
|
my @machinedoms = &Apache::lonnet::current_machine_domains(); |
|
if (($dom eq 'public') && ($activity eq 'port')) { |
|
$dom = $udom; |
|
} |
|
if (($dom ne '') && (grep(/^\Q$dom\E$/,@machinedoms))) { |
|
$check_ipaccess = 1; |
|
} else { |
|
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
|
my $internet_names = &Apache::lonnet::get_internet_names($lonhost); |
|
my $prim = &Apache::lonnet::domain($dom,'primary'); |
|
my $intdom = &Apache::lonnet::internet_dom($prim); |
|
if (($intdom ne '') && (ref($internet_names) eq 'ARRAY')) { |
|
if (grep(/^\Q$intdom\E$/,@{$internet_names})) { |
|
$check_ipaccess = 1; |
|
} |
|
} |
|
} |
|
} |
|
if ($check_ipaccess) { |
|
my ($ipaccessref,$cached)=&Apache::lonnet::is_cached_new('ipaccess',$dom); |
|
unless (defined($cached)) { |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['ipaccess'],$dom); |
|
$ipaccessref = &Apache::lonnet::do_cache_new('ipaccess',$dom,$domconfig{'ipaccess'},1800); |
|
} |
|
if ((ref($ipaccessref) eq 'HASH') && ($clientip)) { |
|
foreach my $id (keys(%{$ipaccessref})) { |
|
if (ref($ipaccessref->{$id}) eq 'HASH') { |
|
my $range = $ipaccessref->{$id}->{'ip'}; |
|
if ($range) { |
|
if (&Apache::lonnet::ip_match($clientip,$range)) { |
|
if (ref($ipaccessref->{$id}->{'commblocks'}) eq 'HASH') { |
|
if ($ipaccessref->{$id}->{'commblocks'}->{$activity} eq 'on') { |
|
return ('','','',$id,$dom); |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (($activity eq 'wishlist') || ($activity eq 'annotate')) { |
|
return (); |
|
} |
|
} |
if (defined($udom) && defined($uname)) { |
if (defined($udom) && defined($uname)) { |
# If uname and udom are for a course, check for blocks in the course. |
# If uname and udom are for a course, check for blocks in the course. |
if (($is_course) || (&Apache::lonnet::is_course($udom,$uname))) { |
if (($is_course) || (&Apache::lonnet::is_course($udom,$uname))) { |
Line 4748 sub blockcheck {
|
Line 4828 sub blockcheck {
|
my $startblock = 0; |
my $startblock = 0; |
my $endblock = 0; |
my $endblock = 0; |
my $triggerblock = ''; |
my $triggerblock = ''; |
my %live_courses = &findallcourses(undef,$uname,$udom); |
my %live_courses; |
|
unless (($activity eq 'wishlist') || ($activity eq 'annotate')) { |
|
%live_courses = &findallcourses(undef,$uname,$udom); |
|
} |
|
|
# If uname is for a user, and activity is course-specific, i.e., |
# If uname is for a user, and activity is course-specific, i.e., |
# boards, chat or groups, check for blocking in current course only. |
# boards, chat or groups, check for blocking in current course only. |
Line 4955 sub get_blocks {
|
Line 5038 sub get_blocks {
|
my $end = $start + $env{'course.'.$cdom.'_'.$cnum.'.timerinterval.'.$timersymb}; |
my $end = $start + $env{'course.'.$cdom.'_'.$cnum.'.timerinterval.'.$timersymb}; |
if ($start && $end) { |
if ($start && $end) { |
if (($start <= time) && ($end >= time)) { |
if (($start <= time) && ($end >= time)) { |
unless (grep(/^\Q$block\E$/,@blockers)) { |
if (ref($commblocks{$block}) eq 'HASH') { |
push(@blockers,$block); |
if (ref($commblocks{$block}{'blocks'}) eq 'HASH') { |
$triggered{$block} = { |
if ($commblocks{$block}{'blocks'}{$activity} eq 'on') { |
start => $start, |
unless(grep(/^\Q$block\E$/,@blockers)) { |
end => $end, |
push(@blockers,$block); |
type => $type, |
$triggered{$block} = { |
}; |
start => $start, |
|
end => $end, |
|
type => $type, |
|
}; |
|
} |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
Line 5025 sub parse_block_record {
|
Line 5114 sub parse_block_record {
|
} |
} |
|
|
sub blocking_status { |
sub blocking_status { |
my ($activity,$uname,$udom,$url,$is_course,$symb,$caller) = @_; |
my ($activity,$clientip,$uname,$udom,$url,$is_course,$symb,$caller) = @_; |
my %setters; |
my %setters; |
|
|
# check for active blocking |
# check for active blocking |
my ($startblock,$endblock,$triggerblock) = |
if ($clientip eq '') { |
&blockcheck(\%setters,$activity,$uname,$udom,$url,$is_course,$symb,$caller); |
$clientip = &Apache::lonnet::get_requestor_ip(); |
|
} |
|
my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) = |
|
&blockcheck(\%setters,$activity,$clientip,$uname,$udom,$url,$is_course,$symb,$caller); |
my $blocked = 0; |
my $blocked = 0; |
if ($startblock && $endblock) { |
if (($startblock && $endblock) || ($by_ip)) { |
$blocked = 1; |
$blocked = 1; |
} |
} |
|
|
Line 5041 sub blocking_status {
|
Line 5133 sub blocking_status {
|
|
|
# build a link to a popup window containing the details |
# build a link to a popup window containing the details |
my $querystring = "?activity=$activity"; |
my $querystring = "?activity=$activity"; |
# $uname and $udom decide whose portfolio the user is trying to look at |
# $uname and $udom decide whose portfolio (or information page) the user is trying to look at |
if (($activity eq 'port') || ($activity eq 'passwd')) { |
if (($activity eq 'port') || ($activity eq 'about') || ($activity eq 'passwd')) { |
$querystring .= "&udom=$udom" if ($udom =~ /^$match_domain$/); |
$querystring .= "&udom=$udom" if ($udom =~ /^$match_domain$/); |
$querystring .= "&uname=$uname" if ($uname =~ /^$match_username$/); |
$querystring .= "&uname=$uname" if ($uname =~ /^$match_username$/); |
} elsif ($activity eq 'docs') { |
} elsif ($activity eq 'docs') { |
Line 5076 END_MYBLOCK
|
Line 5168 END_MYBLOCK
|
$text = &mt('Printing Blocked'); |
$text = &mt('Printing Blocked'); |
} elsif ($activity eq 'passwd') { |
} elsif ($activity eq 'passwd') { |
$text = &mt('Password Changing Blocked'); |
$text = &mt('Password Changing Blocked'); |
|
} elsif ($activity eq 'grades') { |
|
$text = &mt('Gradebook Blocked'); |
|
} elsif ($activity eq 'search') { |
|
$text = &mt('Search Blocked'); |
|
} elsif ($activity eq 'about') { |
|
$text = &mt('Access to User Information Pages Blocked'); |
|
} elsif ($activity eq 'wishlist') { |
|
$text = &mt('Access to Stored Links Blocked'); |
|
} elsif ($activity eq 'annotate') { |
|
$text = &mt('Access to Annotations Blocked'); |
} |
} |
$output .= <<"END_BLOCK"; |
$output .= <<"END_BLOCK"; |
<div class='$class'> |
<div class='$class'> |
Line 5105 sub check_ip_acc {
|
Line 5207 sub check_ip_acc {
|
($ENV{'REMOTE_ADDR'} eq &Apache::lonnet::get_host_ip($Apache::lonnet::perlvar{'lonHostID'}))) { |
($ENV{'REMOTE_ADDR'} eq &Apache::lonnet::get_host_ip($Apache::lonnet::perlvar{'lonHostID'}))) { |
$ip = $env{'request.host'} || $ENV{'REMOTE_ADDR'} || $clientip; |
$ip = $env{'request.host'} || $ENV{'REMOTE_ADDR'} || $clientip; |
} else { |
} else { |
$ip = $ENV{'REMOTE_ADDR'} || $env{'request.host'} || $clientip; |
my $remote_ip = &Apache::lonnet::get_requestor_ip(); |
|
$ip = $remote_ip || $env{'request.host'} || $clientip; |
} |
} |
|
|
my $name; |
my $name; |
Line 5227 sub get_domainconf {
|
Line 5330 sub get_domainconf {
|
} |
} |
} |
} |
} |
} |
|
} elsif ($key eq 'saml') { |
|
if (ref($domconfig{'login'}{$key}) eq 'HASH') { |
|
foreach my $host (keys(%{$domconfig{'login'}{$key}})) { |
|
if (ref($domconfig{'login'}{$key}{$host}) eq 'HASH') { |
|
$designhash{$udom.'.login.'.$key.'_'.$host} = 1; |
|
foreach my $item ('text','img','alt','url','title','notsso') { |
|
$designhash{$udom.'.login.'.$key.'_'.$item.'_'.$host} = $domconfig{'login'}{$key}{$host}{$item}; |
|
} |
|
} |
|
} |
|
} |
} else { |
} else { |
foreach my $img (keys(%{$domconfig{'login'}{$key}})) { |
foreach my $img (keys(%{$domconfig{'login'}{$key}})) { |
$designhash{$udom.'.login.'.$key.'_'.$img} = |
$designhash{$udom.'.login.'.$key.'_'.$img} = |
Line 5331 sub domainlogo {
|
Line 5445 sub domainlogo {
|
&Apache::lonnet::repcopy($local_name); |
&Apache::lonnet::repcopy($local_name); |
} |
} |
$imgsrc = &lonhttpdurl($imgsrc); |
$imgsrc = &lonhttpdurl($imgsrc); |
} |
} |
return '<img src="'.$imgsrc.'" alt="'.$domain.'" />'; |
my $alttext = $domain; |
|
if ($designhash{$domain.'.login.alttext_domlogo'} ne '') { |
|
$alttext = $designhash{$domain.'.login.alttext_domlogo'}; |
|
} |
|
return '<img src="'.$imgsrc.'" alt="'.$alttext.'" id="lclogindomlogo" />'; |
} elsif (defined(&Apache::lonnet::domain($domain,'description'))) { |
} elsif (defined(&Apache::lonnet::domain($domain,'description'))) { |
return &Apache::lonnet::domain($domain,'description'); |
return &Apache::lonnet::domain($domain,'description'); |
} else { |
} else { |
Line 5596 sub bodytag {
|
Line 5714 sub bodytag {
|
if ($realm) { |
if ($realm) { |
$realm = '/'.$realm; |
$realm = '/'.$realm; |
} |
} |
if ($role eq 'ca') { |
if ($role eq 'ca') { |
my ($rdom,$rname) = ($realm =~ m{^/($match_domain)/($match_username)$}); |
my ($rdom,$rname) = ($realm =~ m{^/($match_domain)/($match_username)$}); |
$realm = &plainname($rname,$rdom); |
$realm = &plainname($rname,$rdom); |
} |
} |
# realm |
# realm |
|
my ($cid,$sec); |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
|
$cid = $env{'request.course.id'}; |
|
if ($env{'request.course.sec'}) { |
|
$sec = $env{'request.course.sec'}; |
|
} |
|
} elsif ($realm =~ m{^/($match_domain)/($match_courseid)(?:|/(\w+))$}) { |
|
if (&Apache::lonnet::is_course($1,$2)) { |
|
$cid = $1.'_'.$2; |
|
$sec = $3; |
|
} |
|
} |
|
if ($cid) { |
if ($env{'request.role'} !~ /^cr/) { |
if ($env{'request.role'} !~ /^cr/) { |
$role = &Apache::lonnet::plaintext($role,&course_type()); |
$role = &Apache::lonnet::plaintext($role,&course_type()); |
} elsif ($role =~ m{^cr/($match_domain)/\1-domainconfig/(\w+)$}) { |
} elsif ($role =~ m{^cr/($match_domain)/\1-domainconfig/(\w+)$}) { |
Line 5613 sub bodytag {
|
Line 5743 sub bodytag {
|
} else { |
} else { |
$role = (split(/\//,$role,4))[-1]; |
$role = (split(/\//,$role,4))[-1]; |
} |
} |
if ($env{'request.course.sec'}) { |
if ($sec) { |
$role .= (' 'x2).'- '.&mt('section:').' '.$env{'request.course.sec'}; |
$role .= (' 'x2).'- '.&mt('section:').' '.$sec; |
} |
} |
$realm = $env{'course.'.$env{'request.course.id'}.'.description'}; |
$realm = $env{'course.'.$cid.'.description'}; |
} else { |
} else { |
$role = &Apache::lonnet::plaintext($role); |
$role = &Apache::lonnet::plaintext($role); |
} |
} |
Line 5638 sub bodytag {
|
Line 5768 sub bodytag {
|
if ($public) { |
if ($public) { |
undef($role); |
undef($role); |
} |
} |
|
|
my $titleinfo = '<h1>'.$title.'</h1>'; |
my $titleinfo = '<h1>'.$title.'</h1>'; |
# |
# |
# Extra info if you are the DC |
# Extra info if you are the DC |
my $dc_info = ''; |
my $dc_info = ''; |
if ($env{'user.adv'} && exists($env{'user.role.dc./'. |
if (($env{'user.adv'}) && ($env{'request.course.id'}) && |
$env{'course.'.$env{'request.course.id'}. |
(exists($env{'user.role.dc./'.$env{'course.'.$cid.'.domain'}.'/'}))) { |
'.domain'}.'/'})) { |
|
my $cid = $env{'request.course.id'}; |
|
$dc_info = $cid.' '.$env{'course.'.$cid.'.internal.coursecode'}; |
$dc_info = $cid.' '.$env{'course.'.$cid.'.internal.coursecode'}; |
$dc_info =~ s/\s+$//; |
$dc_info =~ s/\s+$//; |
} |
} |
Line 5678 sub bodytag {
|
Line 5806 sub bodytag {
|
$bodytag .= Apache::lonhtmlcommon::scripttag( |
$bodytag .= Apache::lonhtmlcommon::scripttag( |
Apache::lonmenu::utilityfunctions($httphost), 'start'); |
Apache::lonmenu::utilityfunctions($httphost), 'start'); |
|
|
my ($left,$right) = Apache::lonmenu::primary_menu(); |
my ($left,$right) = Apache::lonmenu::primary_menu($args->{'links_disabled'}); |
|
|
if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { |
if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { |
if ($dc_info) { |
if ($dc_info) { |
$dc_info = qq|<span class="LC_cusr_subheading">$dc_info</span>|; |
$dc_info = qq|<span class="LC_cusr_subheading">$dc_info</span>|; |
} |
} |
$bodytag .= qq|<div id="LC_nav_bar">$left $role<br /> |
$bodytag .= qq|<div id="LC_nav_bar">$left $role<br /> |
<em>$realm</em> $dc_info</div>|; |
<em>$realm</em> $dc_info</div>|; |
Line 5706 sub bodytag {
|
Line 5834 sub bodytag {
|
} |
} |
#don't show menus for public users |
#don't show menus for public users |
if (!$public){ |
if (!$public){ |
$bodytag .= Apache::lonmenu::secondary_menu($httphost); |
$bodytag .= Apache::lonmenu::secondary_menu($httphost,$args->{'links_disabled'}); |
$bodytag .= Apache::lonmenu::serverform(); |
$bodytag .= Apache::lonmenu::serverform(); |
$bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); |
$bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); |
if ($env{'request.state'} eq 'construct') { |
if ($env{'request.state'} eq 'construct') { |
Line 5715 sub bodytag {
|
Line 5843 sub bodytag {
|
} elsif ($forcereg) { |
} elsif ($forcereg) { |
$bodytag .= &Apache::lonmenu::innerregister($forcereg,undef, |
$bodytag .= &Apache::lonmenu::innerregister($forcereg,undef, |
$args->{'group'}, |
$args->{'group'}, |
$args->{'hide_buttons', |
$args->{'hide_buttons'}, |
$hostname}); |
$hostname); |
} else { |
} else { |
my $forbodytag; |
my $forbodytag; |
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, |
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, |
Line 7824 ul.LC_funclist li {
|
Line 7952 ul.LC_funclist li {
|
cursor:pointer; |
cursor:pointer; |
} |
} |
|
|
|
.LCisDisabled { |
|
cursor: not-allowed; |
|
opacity: 0.5; |
|
} |
|
|
|
a[aria-disabled="true"] { |
|
color: currentColor; |
|
display: inline-block; /* For IE11/ MS Edge bug */ |
|
pointer-events: none; |
|
text-decoration: none; |
|
} |
|
|
pre.LC_wordwrap { |
pre.LC_wordwrap { |
white-space: pre-wrap; |
white-space: pre-wrap; |
white-space: -moz-pre-wrap; |
white-space: -moz-pre-wrap; |
Line 7992 ADDMETA
|
Line 8132 ADDMETA
|
unless (&Apache::lonnet::allowed('mau',$dom_in_use)) { |
unless (&Apache::lonnet::allowed('mau',$dom_in_use)) { |
my %domdefs = &Apache::lonnet::get_domain_defaults($dom_in_use); |
my %domdefs = &Apache::lonnet::get_domain_defaults($dom_in_use); |
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
my $offload; |
my ($offload,$offloadoth); |
if (ref($domdefs{'offloadnow'}) eq 'HASH') { |
if (ref($domdefs{'offloadnow'}) eq 'HASH') { |
if ($domdefs{'offloadnow'}{$lonhost}) { |
if ($domdefs{'offloadnow'}{$lonhost}) { |
$offload = 1; |
$offload = 1; |
|
if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne $dom_in_use) && |
|
(!(($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')))) { |
|
unless (&Apache::lonnet::shared_institution($env{'user.domain'})) { |
|
$offloadoth = 1; |
|
$dom_in_use = $env{'user.domain'}; |
|
} |
|
} |
} |
} |
} |
} |
unless ($offload) { |
unless ($offload) { |
Line 8005 ADDMETA
|
Line 8152 ADDMETA
|
(!(($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')))) { |
(!(($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')))) { |
unless (&Apache::lonnet::shared_institution($env{'user.domain'})) { |
unless (&Apache::lonnet::shared_institution($env{'user.domain'})) { |
$offload = 1; |
$offload = 1; |
|
$offloadoth = 1; |
$dom_in_use = $env{'user.domain'}; |
$dom_in_use = $env{'user.domain'}; |
} |
} |
} |
} |
Line 8012 ADDMETA
|
Line 8160 ADDMETA
|
} |
} |
} |
} |
if ($offload) { |
if ($offload) { |
my $newserver = &Apache::lonnet::spareserver(30000,undef,1,$dom_in_use); |
my $newserver = &Apache::lonnet::spareserver(undef,30000,undef,1,$dom_in_use); |
|
if (($newserver eq '') && ($offloadoth)) { |
|
my @domains = &Apache::lonnet::current_machine_domains(); |
|
if (($dom_in_use ne '') && (!grep(/^\Q$dom_in_use\E$/,@domains))) { |
|
($newserver) = &Apache::lonnet::choose_server($dom_in_use); |
|
} |
|
} |
if (($newserver) && ($newserver ne $lonhost)) { |
if (($newserver) && ($newserver ne $lonhost)) { |
my $numsec = 5; |
my $numsec = 5; |
my $timeout = $numsec * 1000; |
my $timeout = $numsec * 1000; |
Line 8026 ADDMETA
|
Line 8180 ADDMETA
|
} |
} |
if ($locknum) { |
if ($locknum) { |
my @lockinfo = sort(values(%locks)); |
my @lockinfo = sort(values(%locks)); |
$msg = &mt('Once the following tasks are complete: ')."\n". |
$msg = &mt('Once the following tasks are complete:')." \n". |
join(", ",sort(values(%locks)))."\n"; |
join(", ",sort(values(%locks)))."\n"; |
if (&show_course()) { |
if (&show_course()) { |
$msg .= &mt('your session will be transferred to a different server, after you click "Courses".'); |
$msg .= &mt('your session will be transferred to a different server, after you click "Courses".'); |
Line 8188 sub print_suppression {
|
Line 8342 sub print_suppression {
|
} |
} |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $blocked = &blocking_status('printout',$cnum,$cdom,undef,1); |
my $clientip = &Apache::lonnet::get_requestor_ip(); |
|
my $blocked = &blocking_status('printout',$clientip,$cnum,$cdom,undef,1); |
if ($blocked) { |
if ($blocked) { |
my $checkrole = "cm./$cdom/$cnum"; |
my $checkrole = "cm./$cdom/$cnum"; |
if ($env{'request.course.sec'} ne '') { |
if ($env{'request.course.sec'} ne '') { |
Line 8309 $args - additional optional args support
|
Line 8464 $args - additional optional args support
|
will contain https://<hostname> if server uses |
will contain https://<hostname> if server uses |
https (as per hosts.tab), but request is for http |
https (as per hosts.tab), but request is for http |
hostname -> hostname, originally from $r->hostname(), (optional). |
hostname -> hostname, originally from $r->hostname(), (optional). |
|
links_disabled -> Links in primary and secondary menus are disabled |
|
(Can enable them once page has loaded - see lonroles.pm |
|
for an example). |
|
|
=back |
=back |
|
|
Line 8515 ENDLINK
|
Line 8673 ENDLINK
|
} |
} |
|
|
sub modal_adhoc_script { |
sub modal_adhoc_script { |
my ($funcname,$width,$height,$content)=@_; |
my ($funcname,$width,$height,$content,$possmathjax)=@_; |
|
my $mathjax; |
|
if ($possmathjax) { |
|
$mathjax = <<'ENDJAX'; |
|
if (typeof MathJax == 'object') { |
|
MathJax.Hub.Queue(["Typeset",MathJax.Hub]); |
|
} |
|
ENDJAX |
|
} |
return (<<ENDADHOC); |
return (<<ENDADHOC); |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
Line 8526 sub modal_adhoc_script {
|
Line 8692 sub modal_adhoc_script {
|
modalWindow.height = $height; |
modalWindow.height = $height; |
modalWindow.content = '$content'; |
modalWindow.content = '$content'; |
modalWindow.open(); |
modalWindow.open(); |
|
$mathjax |
}; |
}; |
// ]]> |
// ]]> |
</script> |
</script> |
Line 8533 ENDADHOC
|
Line 8700 ENDADHOC
|
} |
} |
|
|
sub modal_adhoc_inner { |
sub modal_adhoc_inner { |
my ($funcname,$width,$height,$content)=@_; |
my ($funcname,$width,$height,$content,$possmathjax)=@_; |
my $innerwidth=$width-20; |
my $innerwidth=$width-20; |
$content=&js_ready( |
$content=&js_ready( |
&start_page('Dialog',undef,{'only_body'=>1,'bgcolor'=>'#FFFFFF'}). |
&start_page('Dialog',undef,{'only_body'=>1,'bgcolor'=>'#FFFFFF'}). |
Line 8542 sub modal_adhoc_inner {
|
Line 8709 sub modal_adhoc_inner {
|
&end_scrollbox(). |
&end_scrollbox(). |
&end_page() |
&end_page() |
); |
); |
return &modal_adhoc_script($funcname,$width,$height,$content); |
return &modal_adhoc_script($funcname,$width,$height,$content,$possmathjax); |
} |
} |
|
|
sub modal_adhoc_window { |
sub modal_adhoc_window { |
my ($funcname,$width,$height,$content,$linktext)=@_; |
my ($funcname,$width,$height,$content,$linktext,$possmathjax)=@_; |
return &modal_adhoc_inner($funcname,$width,$height,$content). |
return &modal_adhoc_inner($funcname,$width,$height,$content,$possmathjax). |
"<a href=\"javascript:$funcname();void(0);\">".$linktext."</a>"; |
"<a href=\"javascript:$funcname();void(0);\">".$linktext."</a>"; |
} |
} |
|
|
Line 10403 sub sorted_inst_types {
|
Line 10570 sub sorted_inst_types {
|
} |
} |
|
|
sub get_institutional_codes { |
sub get_institutional_codes { |
my ($settings,$allcourses,$LC_code) = @_; |
my ($cdom,$crs,$settings,$allcourses,$LC_code) = @_; |
# Get complete list of course sections to update |
# Get complete list of course sections to update |
my @currsections = (); |
my @currsections = (); |
my @currxlists = (); |
my @currxlists = (); |
|
my (%unclutteredsec,%unclutteredlcsec); |
my $coursecode = $$settings{'internal.coursecode'}; |
my $coursecode = $$settings{'internal.coursecode'}; |
|
my $crskey = $crs.':'.$coursecode; |
|
@{$unclutteredsec{$crskey}} = (); |
|
@{$unclutteredlcsec{$crskey}} = (); |
|
|
if ($$settings{'internal.sectionnums'} ne '') { |
if ($$settings{'internal.sectionnums'} ne '') { |
@currsections = split(/,/,$$settings{'internal.sectionnums'}); |
@currsections = split(/,/,$$settings{'internal.sectionnums'}); |
Line 10418 sub get_institutional_codes {
|
Line 10589 sub get_institutional_codes {
|
} |
} |
|
|
if (@currxlists > 0) { |
if (@currxlists > 0) { |
foreach (@currxlists) { |
foreach my $xl (@currxlists) { |
if (m/^([^:]+):(\w*)$/) { |
if ($xl =~ /^([^:]+):(\w*)$/) { |
unless (grep/^$1$/,@{$allcourses}) { |
unless (grep/^$1$/,@{$allcourses}) { |
push(@{$allcourses},$1); |
push(@{$allcourses},$1); |
$$LC_code{$1} = $2; |
$$LC_code{$1} = $2; |
Line 10427 sub get_institutional_codes {
|
Line 10598 sub get_institutional_codes {
|
} |
} |
} |
} |
} |
} |
|
|
if (@currsections > 0) { |
if (@currsections > 0) { |
foreach (@currsections) { |
foreach my $sec (@currsections) { |
if (m/^(\w+):(\w*)$/) { |
if ($sec =~ m/^(\w+):(\w*)$/ ) { |
my $sec = $coursecode.$1; |
my $instsec = $1; |
my $lc_sec = $2; |
my $lc_sec = $2; |
unless (grep/^$sec$/,@{$allcourses}) { |
unless (grep/^\Q$instsec\E$/,@{$unclutteredsec{$crskey}}) { |
|
push(@{$unclutteredsec{$crskey}},$instsec); |
|
push(@{$unclutteredlcsec{$crskey}},$lc_sec); |
|
} |
|
} |
|
} |
|
} |
|
|
|
if (@{$unclutteredsec{$crskey}} > 0) { |
|
my %formattedsec = &Apache::lonnet::auto_instsec_reformat($cdom,'clutter',\%unclutteredsec); |
|
if ((ref($formattedsec{$crskey}) eq 'ARRAY') && (ref($unclutteredlcsec{$crskey}) eq 'ARRAY')) { |
|
for (my $i=0; $i<@{$formattedsec{$crskey}}; $i++) { |
|
my $sec = $coursecode.$formattedsec{$crskey}[$i]; |
|
unless (grep/^\Q$sec\E$/,@{$allcourses}) { |
push(@{$allcourses},$sec); |
push(@{$allcourses},$sec); |
$$LC_code{$sec} = $lc_sec; |
$$LC_code{$sec} = $unclutteredlcsec{$crskey}[$i]; |
} |
} |
} |
} |
} |
} |
Line 14727 sub recurse_categories {
|
Line 14911 sub recurse_categories {
|
for (my $k=0; $k<@{$cats->[$depth]{$category}}; $k++) { |
for (my $k=0; $k<@{$cats->[$depth]{$category}}; $k++) { |
my $name = $cats->[$depth]{$category}[$k]; |
my $name = $cats->[$depth]{$category}[$k]; |
my $item = &escape($category).':'.&escape($parents->[-1]).':'.$shallower; |
my $item = &escape($category).':'.&escape($parents->[-1]).':'.$shallower; |
my $trailstr = join(' -> ',(@{$parents},$category)); |
my $trailstr = join(' » ',(@{$parents},$category)); |
if ($allitems->{$item} eq '') { |
if ($allitems->{$item} eq '') { |
push(@{$trails},$trailstr); |
push(@{$trails},$trailstr); |
$allitems->{$item} = scalar(@{$trails})-1; |
$allitems->{$item} = scalar(@{$trails})-1; |
Line 15332 sub construct_course {
|
Line 15516 sub construct_course {
|
'plc.users.denied', |
'plc.users.denied', |
'hidefromcat', |
'hidefromcat', |
'checkforpriv', |
'checkforpriv', |
'categories', |
'categories'], |
'internal.uniquecode'], |
|
$$crsudom,$$crsunum); |
$$crsudom,$$crsunum); |
if ($args->{'textbook'}) { |
if ($args->{'textbook'}) { |
$cenv{'internal.textbook'} = $args->{'textbook'}; |
$cenv{'internal.textbook'} = $args->{'textbook'}; |
Line 15783 sub compare_arrays {
|
Line 15966 sub compare_arrays {
|
return @difference; |
return @difference; |
} |
} |
|
|
|
sub lon_status_items { |
|
my %defaults = ( |
|
E => 100, |
|
W => 4, |
|
N => 1, |
|
U => 5, |
|
threshold => 200, |
|
sysmail => 2500, |
|
); |
|
my %names = ( |
|
E => 'Errors', |
|
W => 'Warnings', |
|
N => 'Notices', |
|
U => 'Unsent', |
|
); |
|
return (\%defaults,\%names); |
|
} |
|
|
# -------------------------------------------------------- Initialize user login |
# -------------------------------------------------------- Initialize user login |
sub init_user_environment { |
sub init_user_environment { |
my ($r, $username, $domain, $authhost, $form, $args) = @_; |
my ($r, $username, $domain, $authhost, $form, $args) = @_; |
Line 15885 sub init_user_environment {
|
Line 16086 sub init_user_environment {
|
# --------------------------------------------------------- Write first profile |
# --------------------------------------------------------- Write first profile |
|
|
{ |
{ |
|
my $ip = &Apache::lonnet::get_requestor_ip(); |
my %initial_env = |
my %initial_env = |
("user.name" => $username, |
("user.name" => $username, |
"user.domain" => $domain, |
"user.domain" => $domain, |
Line 15903 sub init_user_environment {
|
Line 16105 sub init_user_environment {
|
"request.course.sec" => '', |
"request.course.sec" => '', |
"request.role" => 'cm', |
"request.role" => 'cm', |
"request.role.adv" => $env{'user.adv'}, |
"request.role.adv" => $env{'user.adv'}, |
"request.host" => $ENV{'REMOTE_ADDR'},); |
"request.host" => $ip,); |
|
|
if ($form->{'localpath'}) { |
if ($form->{'localpath'}) { |
$initial_env{"browser.localpath"} = $form->{'localpath'}; |
$initial_env{"browser.localpath"} = $form->{'localpath'}; |
Line 17086 sub create_captcha {
|
Line 17288 sub create_captcha {
|
|
|
if (-e $Apache::lonnet::perlvar{'lonCaptchaDir'}.'/'.$md5sum.'.png') { |
if (-e $Apache::lonnet::perlvar{'lonCaptchaDir'}.'/'.$md5sum.'.png') { |
$output = '<input type="hidden" name="crypt" value="'.$md5sum.'" />'."\n". |
$output = '<input type="hidden" name="crypt" value="'.$md5sum.'" />'."\n". |
|
'<span class="LC_nobreak">'. |
&mt('Type in the letters/numbers shown below').' '. |
&mt('Type in the letters/numbers shown below').' '. |
'<input type="text" size="5" name="code" value="" autocomplete="off" />'. |
'<input type="text" size="5" name="code" value="" autocomplete="off" />'. |
'<br />'. |
'</span><br />'. |
'<img src="'.$captcha_params{'www_output_dir'}.'/'.$md5sum.'.png" alt="captcha" />'; |
'<img src="'.$captcha_params{'www_output_dir'}.'/'.$md5sum.'.png" alt="captcha" />'; |
last; |
last; |
} |
} |
} |
} |
|
if ($output eq '') { |
|
&Apache::lonnet::logthis("Failed to create Captcha code after $tries attempts."); |
|
} |
return $output; |
return $output; |
} |
} |
|
|
Line 17131 sub check_captcha {
|
Line 17337 sub check_captcha {
|
sub create_recaptcha { |
sub create_recaptcha { |
my ($pubkey,$version) = @_; |
my ($pubkey,$version) = @_; |
if ($version >= 2) { |
if ($version >= 2) { |
return '<div class="g-recaptcha" data-sitekey="'.$pubkey.'"></div>'; |
return '<div class="g-recaptcha" data-sitekey="'.$pubkey.'"></div>'. |
|
'<div style="padding:0;clear:both;margin:0;border:0"></div>'; |
} else { |
} else { |
my $use_ssl; |
my $use_ssl; |
if ($ENV{'SERVER_PORT'} == 443) { |
if ($ENV{'SERVER_PORT'} == 443) { |
Line 17149 sub create_recaptcha {
|
Line 17356 sub create_recaptcha {
|
sub check_recaptcha { |
sub check_recaptcha { |
my ($privkey,$version) = @_; |
my ($privkey,$version) = @_; |
my $captcha_chk; |
my $captcha_chk; |
|
my $ip = &Apache::lonnet::get_requestor_ip(); |
if ($version >= 2) { |
if ($version >= 2) { |
my $ua = LWP::UserAgent->new; |
my $ua = LWP::UserAgent->new; |
$ua->timeout(10); |
$ua->timeout(10); |
my %info = ( |
my %info = ( |
secret => $privkey, |
secret => $privkey, |
response => $env{'form.g-recaptcha-response'}, |
response => $env{'form.g-recaptcha-response'}, |
remoteip => $ENV{'REMOTE_ADDR'}, |
remoteip => $ip, |
); |
); |
my $response = $ua->post('https://www.google.com/recaptcha/api/siteverify',\%info); |
my $response = $ua->post('https://www.google.com/recaptcha/api/siteverify',\%info); |
if ($response->is_success) { |
if ($response->is_success) { |
Line 17171 sub check_recaptcha {
|
Line 17379 sub check_recaptcha {
|
my $captcha_result = |
my $captcha_result = |
$captcha->check_answer( |
$captcha->check_answer( |
$privkey, |
$privkey, |
$ENV{'REMOTE_ADDR'}, |
$ip, |
$env{'form.recaptcha_challenge_field'}, |
$env{'form.recaptcha_challenge_field'}, |
$env{'form.recaptcha_response_field'}, |
$env{'form.recaptcha_response_field'}, |
); |
); |
Line 17222 sub cleanup_html {
|
Line 17430 sub cleanup_html {
|
# $interval indicates how often to check for messages. |
# $interval indicates how often to check for messages. |
sub critical_redirect { |
sub critical_redirect { |
my ($interval) = @_; |
my ($interval) = @_; |
|
unless (($env{'user.domain'} ne '') && ($env{'user.name'} ne '')) { |
|
return (); |
|
} |
if ((time-$env{'user.criticalcheck.time'})>$interval) { |
if ((time-$env{'user.criticalcheck.time'})>$interval) { |
my @what=&Apache::lonnet::dump('critical', $env{'user.domain'}, |
my @what=&Apache::lonnet::dump('critical', $env{'user.domain'}, |
$env{'user.name'}); |
$env{'user.name'}); |
&Apache::lonnet::appenv({'user.criticalcheck.time'=>time}); |
&Apache::lonnet::appenv({'user.criticalcheck.time'=>time}); |
my $redirecturl; |
my $redirecturl; |
if ($what[0]) { |
if ($what[0]) { |
if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) { |
if (($what[0] ne 'con_lost') && ($what[0] ne 'no_such_host') && ($what[0]!~/^error\:/)) { |
$redirecturl='/adm/email?critical=display'; |
$redirecturl='/adm/email?critical=display'; |
my $url=&Apache::lonnet::absolute_url().$redirecturl; |
my $url=&Apache::lonnet::absolute_url().$redirecturl; |
return (1, $url); |
return (1, $url); |