version 1.1277, 2017/03/21 23:13:17
|
version 1.1287, 2017/08/07 20:22:13
|
Line 71 use Apache::lonuserutils();
|
Line 71 use Apache::lonuserutils();
|
use Apache::lonuserstate(); |
use Apache::lonuserstate(); |
use Apache::courseclassifier(); |
use Apache::courseclassifier(); |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
use LONCAPA::LWPReq; |
use DateTime::TimeZone; |
use DateTime::TimeZone; |
use DateTime::Locale; |
use DateTime::Locale; |
use Encode(); |
use Encode(); |
Line 4991 sub blockcheck {
|
Line 4992 sub blockcheck {
|
# boards, chat or groups, check for blocking in current course only. |
# boards, chat or groups, check for blocking in current course only. |
|
|
if (($activity eq 'boards' || $activity eq 'chat' || |
if (($activity eq 'boards' || $activity eq 'chat' || |
$activity eq 'groups' || $activity eq 'printout') && |
$activity eq 'groups' || $activity eq 'printout' || |
|
$activity eq 'reinit' || $activity eq 'alert') && |
($env{'request.course.id'})) { |
($env{'request.course.id'})) { |
foreach my $key (keys(%live_courses)) { |
foreach my $key (keys(%live_courses)) { |
if ($key ne $env{'request.course.id'}) { |
if ($key ne $env{'request.course.id'}) { |
Line 5099 sub blockcheck {
|
Line 5101 sub blockcheck {
|
|
|
# Retrieve blocking times and identity of locker for course |
# Retrieve blocking times and identity of locker for course |
# of specified user, unless user has 'evb' privilege. |
# of specified user, unless user has 'evb' privilege. |
|
|
my ($start,$end,$trigger) = |
my ($start,$end,$trigger) = |
&get_blocks($setters,$activity,$cdom,$cnum,$url); |
&get_blocks($setters,$activity,$cdom,$cnum,$url); |
if (($start != 0) && |
if (($start != 0) && |
Line 5186 sub get_blocks {
|
Line 5188 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 5302 END_MYBLOCK
|
Line 5310 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 'alert') { |
|
$text = &mt('Checking Critical Messages Blocked'); |
|
} elsif ($activity eq 'reinit') { |
|
$text = &mt('Checking Course Update Blocked'); |
} |
} |
$output .= <<"END_BLOCK"; |
$output .= <<"END_BLOCK"; |
<div class='$class'> |
<div class='$class'> |
Line 6440 td.LC_menubuttons_text {
|
Line 6452 td.LC_menubuttons_text {
|
background: $tabbg; |
background: $tabbg; |
} |
} |
|
|
|
td.LC_zero_height { |
|
line-height: 0; |
|
cellpadding: 0; |
|
} |
|
|
table.LC_data_table { |
table.LC_data_table { |
border: 1px solid #000000; |
border: 1px solid #000000; |
border-collapse: separate; |
border-collapse: separate; |
Line 6761 td.LC_parm_overview_restrictions {
|
Line 6778 td.LC_parm_overview_restrictions {
|
border-collapse: collapse; |
border-collapse: collapse; |
} |
} |
|
|
|
span.LC_parm_recursive, |
|
td.LC_parm_recursive { |
|
font-weight: bold; |
|
font-size: smaller; |
|
} |
|
|
table.LC_parm_overview_restrictions td { |
table.LC_parm_overview_restrictions td { |
border-width: 1px 4px 1px 4px; |
border-width: 1px 4px 1px 4px; |
border-style: solid; |
border-style: solid; |
Line 7112 table.LC_data_table tr > td.LC_docs_entr
|
Line 7135 table.LC_data_table tr > td.LC_docs_entr
|
color: #990000; |
color: #990000; |
} |
} |
|
|
|
.LC_docs_alias { |
|
color: #440055; |
|
} |
|
|
|
.LC_domprefs_email, |
|
.LC_docs_alias_name, |
.LC_docs_reinit_warn, |
.LC_docs_reinit_warn, |
.LC_docs_ext_edit { |
.LC_docs_ext_edit { |
font-size: x-small; |
font-size: x-small; |
Line 8357 OFFLOAD
|
Line 8386 OFFLOAD
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> |
<meta name="apple-mobile-web-app-capable" content="yes" />'; |
<meta name="apple-mobile-web-app-capable" content="yes" />'; |
} |
} |
|
$result .= '<meta name="google" content="notranslate" />'."\n"; |
return $result.'</head>'; |
return $result.'</head>'; |
} |
} |
|
|
Line 10037 sub get_secgrprole_info {
|
Line 10067 sub get_secgrprole_info {
|
} |
} |
|
|
sub user_picker { |
sub user_picker { |
my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context,$fixeddom) = @_; |
my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context,$fixeddom,$noinstd) = @_; |
my $currdom = $dom; |
my $currdom = $dom; |
my @alldoms = &Apache::lonnet::all_domains(); |
my @alldoms = &Apache::lonnet::all_domains(); |
if (@alldoms == 1) { |
if (@alldoms == 1) { |
Line 10107 sub user_picker {
|
Line 10137 sub user_picker {
|
$allow_blank = 0; |
$allow_blank = 0; |
$domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1,undef,[$currdom]); |
$domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1,undef,[$currdom]); |
} else { |
} else { |
$domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1); |
my $defdom = $env{'request.role.domain'}; |
|
my ($trustedref,$untrustedref); |
|
if (($context eq 'requestcrs') || ($context eq 'course')) { |
|
($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('enroll',$defdom); |
|
} elsif ($context eq 'author') { |
|
($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('othcoau',$defdom); |
|
} elsif ($context eq 'domain') { |
|
($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('domroles',$defdom); |
|
} |
|
$domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1,undef,$trustedref,$untrustedref); |
} |
} |
my $srchinsel = ' <select name="srchin">'; |
my $srchinsel = ' <select name="srchin">'; |
|
|
Line 10120 sub user_picker {
|
Line 10159 sub user_picker {
|
next if ($option eq 'alc'); |
next if ($option eq 'alc'); |
next if (($option eq 'crs') && ($env{'form.form'} eq 'requestcrs')); |
next if (($option eq 'crs') && ($env{'form.form'} eq 'requestcrs')); |
next if ($option eq 'crs' && !$env{'request.course.id'}); |
next if ($option eq 'crs' && !$env{'request.course.id'}); |
|
next if (($option eq 'instd') && ($noinstd)); |
if ($curr_selected{'srchin'} eq $option) { |
if ($curr_selected{'srchin'} eq $option) { |
$srchinsel .= ' |
$srchinsel .= ' |
<option value="'.$option.'" selected="selected">'.$html_lt{$option}.'</option>'; |
<option value="'.$option.'" selected="selected">'.$html_lt{$option}.'</option>'; |
Line 16170 sub init_user_environment {
|
Line 16210 sub init_user_environment {
|
$reqauthor{'author'}{'timestamp'}; |
$reqauthor{'author'}{'timestamp'}; |
} |
} |
} |
} |
|
my ($types,$typename) = &course_types(); |
|
if (ref($types) eq 'ARRAY') { |
|
my @options = ('approval','validate','autolimit'); |
|
my $optregex = join('|',@options); |
|
my (%willtrust,%trustchecked); |
|
foreach my $type (@{$types}) { |
|
my $dom_str = $env{'environment.reqcrsotherdom.'.$type}; |
|
if ($dom_str ne '') { |
|
my $updatedstr = ''; |
|
my @possdomains = split(',',$dom_str); |
|
foreach my $entry (@possdomains) { |
|
my ($extdom,$extopt) = split(':',$entry); |
|
unless ($trustchecked{$extdom}) { |
|
$willtrust{$extdom} = &Apache::lonnet::will_trust('reqcrs',$domain,$extdom); |
|
$trustchecked{$extdom} = 1; |
|
} |
|
if ($willtrust{$extdom}) { |
|
$updatedstr .= $entry.','; |
|
} |
|
} |
|
$updatedstr =~ s/,$//; |
|
if ($updatedstr) { |
|
$userenv{'reqcrsotherdom.'.$type} = $updatedstr; |
|
} else { |
|
delete($userenv{'reqcrsotherdom.'.$type}); |
|
} |
|
} |
|
} |
|
} |
} |
} |
|
|
$env{'user.environment'} = "$lonids/$cookie.id"; |
$env{'user.environment'} = "$lonids/$cookie.id"; |
|
|
if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id", |
if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id", |
Line 16984 sub needs_coursereinit {
|
Line 17052 sub needs_coursereinit {
|
$interval = 600; |
$interval = 600; |
} |
} |
if (($now-$env{'request.course.timechecked'})>$interval) { |
if (($now-$env{'request.course.timechecked'})>$interval) { |
my $lastchange = &Apache::lonnet::get_coursechange($cdom,$cnum); |
|
&Apache::lonnet::appenv({'request.course.timechecked'=>$now}); |
&Apache::lonnet::appenv({'request.course.timechecked'=>$now}); |
|
my $blocked = &blocking_status('reinit',$cnum,$cdom,undef,1); |
|
if ($blocked) { |
|
return (); |
|
} |
|
my $lastchange = &Apache::lonnet::get_coursechange($cdom,$cnum); |
if ($lastchange > $env{'request.course.tied'}) { |
if ($lastchange > $env{'request.course.tied'}) { |
my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired'); |
my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired'); |
if ($curr_reqd_hash{'internal.releaserequired'} ne '') { |
if ($curr_reqd_hash{'internal.releaserequired'} ne '') { |
Line 17350 sub check_recaptcha {
|
Line 17422 sub check_recaptcha {
|
my ($privkey,$version) = @_; |
my ($privkey,$version) = @_; |
my $captcha_chk; |
my $captcha_chk; |
if ($version >= 2) { |
if ($version >= 2) { |
my $ua = LWP::UserAgent->new; |
|
$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 => $ENV{'REMOTE_ADDR'}, |
); |
); |
my $response = $ua->post('https://www.google.com/recaptcha/api/siteverify',\%info); |
my $request=new HTTP::Request('POST','https://www.google.com/recaptcha/api/siteverify'); |
|
$request->content(join('&',map { |
|
my $name = escape($_); |
|
"$name=" . ( ref($info{$_}) eq 'ARRAY' |
|
? join("&$name=", map {escape($_) } @{$info{$_}}) |
|
: &escape($info{$_}) ); |
|
} keys(%info))); |
|
my $response = &LONCAPA::LWPReq::makerequest('',$request,'','',10,1); |
if ($response->is_success) { |
if ($response->is_success) { |
my $data = JSON::DWIW->from_json($response->decoded_content); |
my $data = JSON::DWIW->from_json($response->decoded_content); |
if (ref($data) eq 'HASH') { |
if (ref($data) eq 'HASH') { |
Line 17420 sub cleanup_html {
|
Line 17497 sub cleanup_html {
|
|
|
# Checks for critical messages and returns a redirect url if one exists. |
# Checks for critical messages and returns a redirect url if one exists. |
# $interval indicates how often to check for messages. |
# $interval indicates how often to check for messages. |
|
# $context is the calling context -- roles, grades, contents, menu or flip. |
sub critical_redirect { |
sub critical_redirect { |
my ($interval) = @_; |
my ($interval,$context) = @_; |
if ((time-$env{'user.criticalcheck.time'})>$interval) { |
if ((time-$env{'user.criticalcheck.time'})>$interval) { |
|
if (($env{'request.course.id'}) && (($context eq 'flip') || ($context eq 'contents'))) { |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $blocked = &blocking_status('alert',$cnum,$cdom,undef,1); |
|
if ($blocked) { |
|
my $checkrole = "cm./$cdom/$cnum"; |
|
if ($env{'request.course.sec'} ne '') { |
|
$checkrole .= "/$env{'request.course.sec'}"; |
|
} |
|
unless ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) && |
|
($env{'request.role'} !~ m{^st\./$cdom/$cnum})) { |
|
return; |
|
} |
|
} |
|
} |
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}); |