version 1.1172.2.40, 2014/02/24 03:09:05
|
version 1.1172.2.80, 2016/09/17 19:23:42
|
Line 89 use GDBM_File;
|
Line 89 use GDBM_File;
|
use HTML::LCParser; |
use HTML::LCParser; |
use Fcntl qw(:flock); |
use Fcntl qw(:flock); |
use Storable qw(thaw nfreeze); |
use Storable qw(thaw nfreeze); |
use Time::HiRes qw( gettimeofday tv_interval ); |
use Time::HiRes qw( sleep gettimeofday tv_interval ); |
use Cache::Memcached; |
use Cache::Memcached; |
use Digest::MD5; |
use Digest::MD5; |
use Math::Random; |
use Math::Random; |
Line 102 use LONCAPA::Lond;
|
Line 102 use LONCAPA::Lond;
|
use File::Copy; |
use File::Copy; |
|
|
my $readit; |
my $readit; |
my $max_connection_retries = 10; # Or some such value. |
my $max_connection_retries = 20; # Or some such value. |
|
|
require Exporter; |
require Exporter; |
|
|
Line 370 sub subreply {
|
Line 370 sub subreply {
|
|
|
my $lockfile=$peerfile.".lock"; |
my $lockfile=$peerfile.".lock"; |
while (-e $lockfile) { # Need to wait for the lockfile to disappear. |
while (-e $lockfile) { # Need to wait for the lockfile to disappear. |
sleep(1); |
sleep(0.1); |
} |
} |
# At this point, either a loncnew parent is listening or an old lonc |
# At this point, either a loncnew parent is listening or an old lonc |
# or loncnew child is listening so we can connect or everything's dead. |
# or loncnew child is listening so we can connect or everything's dead. |
Line 388 sub subreply {
|
Line 388 sub subreply {
|
} else { |
} else { |
&create_connection(&hostname($server),$server); |
&create_connection(&hostname($server),$server); |
} |
} |
sleep(1); # Try again later if failed connection. |
sleep(0.1); # Try again later if failed connection. |
} |
} |
my $answer; |
my $answer; |
if ($client) { |
if ($client) { |
Line 417 sub reply {
|
Line 417 sub reply {
|
|
|
sub reconlonc { |
sub reconlonc { |
my ($lonid) = @_; |
my ($lonid) = @_; |
my $hostname = &hostname($lonid); |
|
if ($lonid) { |
if ($lonid) { |
|
my $hostname = &hostname($lonid); |
my $peerfile="$perlvar{'lonSockDir'}/$hostname"; |
my $peerfile="$perlvar{'lonSockDir'}/$hostname"; |
if ($hostname && -e $peerfile) { |
if ($hostname && -e $peerfile) { |
&logthis("Trying to reconnect lonc for $lonid ($hostname)"); |
&logthis("Trying to reconnect lonc for $lonid ($hostname)"); |
Line 464 sub critical {
|
Line 464 sub critical {
|
} |
} |
my $answer=reply($cmd,$server); |
my $answer=reply($cmd,$server); |
if ($answer eq 'con_lost') { |
if ($answer eq 'con_lost') { |
&reconlonc("$perlvar{'lonSockDir'}/$server"); |
&reconlonc($server); |
my $answer=reply($cmd,$server); |
my $answer=reply($cmd,$server); |
if ($answer eq 'con_lost') { |
if ($answer eq 'con_lost') { |
my $now=time; |
my $now=time; |
Line 481 sub critical {
|
Line 481 sub critical {
|
close($dfh); |
close($dfh); |
} |
} |
} |
} |
sleep 2; |
sleep 1; |
my $wcmd=''; |
my $wcmd=''; |
{ |
{ |
my $dfh; |
my $dfh; |
Line 844 sub spareserver {
|
Line 844 sub spareserver {
|
if (ref($spareshash) eq 'HASH') { |
if (ref($spareshash) eq 'HASH') { |
if (ref($spareshash->{'primary'}) eq 'ARRAY') { |
if (ref($spareshash->{'primary'}) eq 'ARRAY') { |
foreach my $try_server (@{ $spareshash->{'primary'} }) { |
foreach my $try_server (@{ $spareshash->{'primary'} }) { |
if ($uint_dom) { |
next unless (&spare_can_host($udom,$uint_dom,$remotesessions, |
next unless (&spare_can_host($udom,$uint_dom,$remotesessions, |
$try_server)); |
$try_server)); |
|
} |
|
($spare_server, $lowest_load) = |
($spare_server, $lowest_load) = |
&compare_server_load($try_server, $spare_server, $lowest_load); |
&compare_server_load($try_server, $spare_server, $lowest_load); |
} |
} |
Line 858 sub spareserver {
|
Line 856 sub spareserver {
|
if (!$found_server) { |
if (!$found_server) { |
if (ref($spareshash->{'default'}) eq 'ARRAY') { |
if (ref($spareshash->{'default'}) eq 'ARRAY') { |
foreach my $try_server (@{ $spareshash->{'default'} }) { |
foreach my $try_server (@{ $spareshash->{'default'} }) { |
if ($uint_dom) { |
next unless (&spare_can_host($udom,$uint_dom, |
next unless (&spare_can_host($udom,$uint_dom, |
$remotesessions,$try_server)); |
$remotesessions,$try_server)); |
|
} |
|
($spare_server, $lowest_load) = |
($spare_server, $lowest_load) = |
&compare_server_load($try_server, $spare_server, $lowest_load); |
&compare_server_load($try_server, $spare_server, $lowest_load); |
} |
} |
Line 885 sub spareserver {
|
Line 881 sub spareserver {
|
} |
} |
|
|
sub compare_server_load { |
sub compare_server_load { |
my ($try_server, $spare_server, $lowest_load) = @_; |
my ($try_server, $spare_server, $lowest_load, $required) = @_; |
|
|
|
if ($required) { |
|
my ($reqdmajor,$reqdminor) = ($required =~ /^(\d+)\.(\d+)$/); |
|
my $remoterev = &get_server_loncaparev(undef,$try_server); |
|
my ($major,$minor) = ($remoterev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/); |
|
if (($major eq '' && $minor eq '') || |
|
(($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) { |
|
return ($spare_server,$lowest_load); |
|
} |
|
} |
|
|
my $loadans = &reply('load', $try_server); |
my $loadans = &reply('load', $try_server); |
my $userloadans = &reply('userload',$try_server); |
my $userloadans = &reply('userload',$try_server); |
Line 946 sub has_user_session {
|
Line 952 sub has_user_session {
|
# --------- determine least loaded server in a user's domain which allows login |
# --------- determine least loaded server in a user's domain which allows login |
|
|
sub choose_server { |
sub choose_server { |
my ($udom,$checkloginvia) = @_; |
my ($udom,$checkloginvia,$required,$skiploadbal) = @_; |
my %domconfhash = &Apache::loncommon::get_domainconf($udom); |
my %domconfhash = &Apache::loncommon::get_domainconf($udom); |
my %servers = &get_servers($udom); |
my %servers = &get_servers($udom); |
my $lowest_load = 30000; |
my $lowest_load = 30000; |
my ($login_host,$hostname,$portal_path,$isredirect); |
my ($login_host,$hostname,$portal_path,$isredirect,$balancers); |
|
if ($skiploadbal) { |
|
($balancers,my $cached)=&is_cached_new('loadbalancing',$udom); |
|
unless (defined($cached)) { |
|
my $cachetime = 60*60*24; |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['loadbalancing'],$udom); |
|
if (ref($domconfig{'loadbalancing'}) eq 'HASH') { |
|
$balancers = &do_cache_new('loadbalancing',$udom,$domconfig{'loadbalancing'}, |
|
$cachetime); |
|
} |
|
} |
|
} |
foreach my $lonhost (keys(%servers)) { |
foreach my $lonhost (keys(%servers)) { |
my $loginvia; |
my $loginvia; |
|
if ($skiploadbal) { |
|
if (ref($balancers) eq 'HASH') { |
|
next if (exists($balancers->{$lonhost})); |
|
} |
|
} |
if ($checkloginvia) { |
if ($checkloginvia) { |
$loginvia = $domconfhash{$udom.'.login.loginvia_'.$lonhost}; |
$loginvia = $domconfhash{$udom.'.login.loginvia_'.$lonhost}; |
if ($loginvia) { |
if ($loginvia) { |
my ($server,$path) = split(/:/,$loginvia); |
my ($server,$path) = split(/:/,$loginvia); |
($login_host, $lowest_load) = |
($login_host, $lowest_load) = |
&compare_server_load($server, $login_host, $lowest_load); |
&compare_server_load($server, $login_host, $lowest_load, $required); |
if ($login_host eq $server) { |
if ($login_host eq $server) { |
$portal_path = $path; |
$portal_path = $path; |
$isredirect = 1; |
$isredirect = 1; |
} |
} |
} else { |
} else { |
($login_host, $lowest_load) = |
($login_host, $lowest_load) = |
&compare_server_load($lonhost, $login_host, $lowest_load); |
&compare_server_load($lonhost, $login_host, $lowest_load, $required); |
if ($login_host eq $lonhost) { |
if ($login_host eq $lonhost) { |
$portal_path = ''; |
$portal_path = ''; |
$isredirect = ''; |
$isredirect = ''; |
Line 973 sub choose_server {
|
Line 996 sub choose_server {
|
} |
} |
} else { |
} else { |
($login_host, $lowest_load) = |
($login_host, $lowest_load) = |
&compare_server_load($lonhost, $login_host, $lowest_load); |
&compare_server_load($lonhost, $login_host, $lowest_load, $required); |
} |
} |
} |
} |
if ($login_host ne '') { |
if ($login_host ne '') { |
Line 1146 sub can_host_session {
|
Line 1169 sub can_host_session {
|
sub spare_can_host { |
sub spare_can_host { |
my ($udom,$uint_dom,$remotesessions,$try_server)=@_; |
my ($udom,$uint_dom,$remotesessions,$try_server)=@_; |
my $canhost=1; |
my $canhost=1; |
my @intdoms; |
my $try_server_hostname = &hostname($try_server); |
my $internet_names = &Apache::lonnet::get_internet_names($try_server); |
my $serverhomeID = &get_server_homeID($try_server_hostname); |
if (ref($internet_names) eq 'ARRAY') { |
my $serverhomedom = &host_domain($serverhomeID); |
@intdoms = @{$internet_names}; |
my %defdomdefaults = &get_domain_defaults($serverhomedom); |
} |
if (ref($defdomdefaults{'offloadnow'}) eq 'HASH') { |
unless (grep(/^\Q$uint_dom\E$/,@intdoms)) { |
if ($defdomdefaults{'offloadnow'}{$try_server}) { |
my $serverhomeID = &Apache::lonnet::get_server_homeID($try_server); |
$canhost = 0; |
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
} |
my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom); |
} |
my $remoterev = &Apache::lonnet::get_server_loncaparev(undef,$try_server); |
if (($canhost) && ($uint_dom)) { |
$canhost = &can_host_session($udom,$try_server,$remoterev, |
my @intdoms; |
$remotesessions, |
my $internet_names = &get_internet_names($try_server); |
$defdomdefaults{'hostedsessions'}); |
if (ref($internet_names) eq 'ARRAY') { |
|
@intdoms = @{$internet_names}; |
|
} |
|
unless (grep(/^\Q$uint_dom\E$/,@intdoms)) { |
|
my $remoterev = &get_server_loncaparev(undef,$try_server); |
|
$canhost = &can_host_session($udom,$try_server,$remoterev, |
|
$remotesessions, |
|
$defdomdefaults{'hostedsessions'}); |
|
} |
} |
} |
return $canhost; |
return $canhost; |
} |
} |
Line 1252 sub check_loadbalancing {
|
Line 1283 sub check_loadbalancing {
|
my $uintdom = &Apache::lonnet::internet_dom($uprimary_id); |
my $uintdom = &Apache::lonnet::internet_dom($uprimary_id); |
my $intdom = &Apache::lonnet::internet_dom($lonhost); |
my $intdom = &Apache::lonnet::internet_dom($lonhost); |
my $serverhomedom = &host_domain($lonhost); |
my $serverhomedom = &host_domain($lonhost); |
|
my $domneedscache; |
my $cachetime = 60*60*24; |
my $cachetime = 60*60*24; |
|
|
if (($uintdom ne '') && ($uintdom eq $intdom)) { |
if (($uintdom ne '') && ($uintdom eq $intdom)) { |
Line 1267 sub check_loadbalancing {
|
Line 1298 sub check_loadbalancing {
|
&Apache::lonnet::get_dom('configuration',['loadbalancing'],$dom_in_use); |
&Apache::lonnet::get_dom('configuration',['loadbalancing'],$dom_in_use); |
if (ref($domconfig{'loadbalancing'}) eq 'HASH') { |
if (ref($domconfig{'loadbalancing'}) eq 'HASH') { |
$result = &do_cache_new('loadbalancing',$dom_in_use,$domconfig{'loadbalancing'},$cachetime); |
$result = &do_cache_new('loadbalancing',$dom_in_use,$domconfig{'loadbalancing'},$cachetime); |
|
} else { |
|
$domneedscache = $dom_in_use; |
} |
} |
} |
} |
if (ref($result) eq 'HASH') { |
if (ref($result) eq 'HASH') { |
Line 1325 sub check_loadbalancing {
|
Line 1358 sub check_loadbalancing {
|
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['loadbalancing'],$serverhomedom); |
&Apache::lonnet::get_dom('configuration',['loadbalancing'],$serverhomedom); |
if (ref($domconfig{'loadbalancing'}) eq 'HASH') { |
if (ref($domconfig{'loadbalancing'}) eq 'HASH') { |
$result = &do_cache_new('loadbalancing',$dom_in_use,$domconfig{'loadbalancing'},$cachetime); |
$result = &do_cache_new('loadbalancing',$serverhomedom,$domconfig{'loadbalancing'},$cachetime); |
|
} else { |
|
$domneedscache = $serverhomedom; |
} |
} |
} |
} |
if (ref($result) eq 'HASH') { |
if (ref($result) eq 'HASH') { |
Line 1345 sub check_loadbalancing {
|
Line 1380 sub check_loadbalancing {
|
$is_balancer = 1; |
$is_balancer = 1; |
$offloadto = &this_host_spares($dom_in_use); |
$offloadto = &this_host_spares($dom_in_use); |
} |
} |
|
unless (defined($cached)) { |
|
$domneedscache = $serverhomedom; |
|
} |
} |
} |
} else { |
} else { |
if ($perlvar{'lonBalancer'} eq 'yes') { |
if ($perlvar{'lonBalancer'} eq 'yes') { |
$is_balancer = 1; |
$is_balancer = 1; |
$offloadto = &this_host_spares($dom_in_use); |
$offloadto = &this_host_spares($dom_in_use); |
} |
} |
|
unless (defined($cached)) { |
|
$domneedscache = $serverhomedom; |
|
} |
|
} |
|
if ($domneedscache) { |
|
&do_cache_new('loadbalancing',$domneedscache,$is_balancer,$cachetime); |
} |
} |
if ($is_balancer) { |
if ($is_balancer) { |
my $lowest_load = 30000; |
my $lowest_load = 30000; |
Line 1523 sub idget {
|
Line 1567 sub idget {
|
|
|
my %servers = &get_servers($udom,'library'); |
my %servers = &get_servers($udom,'library'); |
foreach my $tryserver (keys(%servers)) { |
foreach my $tryserver (keys(%servers)) { |
my $idlist=join('&',@ids); |
my $idlist=join('&', map { &escape($_); } @ids); |
$idlist=~tr/A-Z/a-z/; |
$idlist=~tr/A-Z/a-z/; |
my $reply=&reply("idget:$udom:".$idlist,$tryserver); |
my $reply=&reply("idget:$udom:".$idlist,$tryserver); |
my @answer=(); |
my @answer=(); |
Line 1533 sub idget {
|
Line 1577 sub idget {
|
my $i; |
my $i; |
for ($i=0;$i<=$#ids;$i++) { |
for ($i=0;$i<=$#ids;$i++) { |
if ($answer[$i]) { |
if ($answer[$i]) { |
$returnhash{$ids[$i]}=$answer[$i]; |
$returnhash{$ids[$i]}=&unescape($answer[$i]); |
} |
} |
} |
} |
} |
} |
Line 1620 sub dump_dom {
|
Line 1664 sub dump_dom {
|
|
|
sub get_dom { |
sub get_dom { |
my ($namespace,$storearr,$udom,$uhome)=@_; |
my ($namespace,$storearr,$udom,$uhome)=@_; |
|
return if ($udom eq 'public'); |
my $items=''; |
my $items=''; |
foreach my $item (@$storearr) { |
foreach my $item (@$storearr) { |
$items.=&escape($item).'&'; |
$items.=&escape($item).'&'; |
Line 1627 sub get_dom {
|
Line 1672 sub get_dom {
|
$items=~s/\&$//; |
$items=~s/\&$//; |
if (!$udom) { |
if (!$udom) { |
$udom=$env{'user.domain'}; |
$udom=$env{'user.domain'}; |
|
return if ($udom eq 'public'); |
if (defined(&domain($udom,'primary'))) { |
if (defined(&domain($udom,'primary'))) { |
$uhome=&domain($udom,'primary'); |
$uhome=&domain($udom,'primary'); |
} else { |
} else { |
Line 1730 sub retrieve_inst_usertypes {
|
Line 1776 sub retrieve_inst_usertypes {
|
my %domdefs = &Apache::lonnet::get_domain_defaults($udom); |
my %domdefs = &Apache::lonnet::get_domain_defaults($udom); |
if ((ref($domdefs{'inststatustypes'}) eq 'HASH') && |
if ((ref($domdefs{'inststatustypes'}) eq 'HASH') && |
(ref($domdefs{'inststatusorder'}) eq 'ARRAY')) { |
(ref($domdefs{'inststatusorder'}) eq 'ARRAY')) { |
%returnhash = %{$domdefs{'inststatustypes'}}; |
return ($domdefs{'inststatustypes'},$domdefs{'inststatusorder'}); |
@order = @{$domdefs{'inststatusorder'}}; |
|
} else { |
} else { |
if (defined(&domain($udom,'primary'))) { |
if (defined(&domain($udom,'primary'))) { |
my $uhome=&domain($udom,'primary'); |
my $uhome=&domain($udom,'primary'); |
my $rep=&reply("inst_usertypes:$udom",$uhome); |
my $rep=&reply("inst_usertypes:$udom",$uhome); |
if ($rep =~ /^(con_lost|error|no_such_host|refused)/) { |
if ($rep =~ /^(con_lost|error|no_such_host|refused)/) { |
&logthis("get_dom failed - $rep returned from $uhome in domain: $udom"); |
&logthis("retrieve_inst_usertypes failed - $rep returned from $uhome in domain: $udom"); |
return (\%returnhash,\@order); |
return (\%returnhash,\@order); |
} |
} |
my ($hashitems,$orderitems) = split(/:/,$rep); |
my ($hashitems,$orderitems) = split(/:/,$rep); |
Line 1753 sub retrieve_inst_usertypes {
|
Line 1798 sub retrieve_inst_usertypes {
|
push(@order,&unescape($item)); |
push(@order,&unescape($item)); |
} |
} |
} else { |
} else { |
&logthis("get_dom failed - no primary domain server for $udom"); |
&logthis("retrieve_inst_usertypes failed - no primary domain server for $udom"); |
} |
} |
|
return (\%returnhash,\@order); |
} |
} |
return (\%returnhash,\@order); |
|
} |
} |
|
|
sub is_domainimage { |
sub is_domainimage { |
my ($url) = @_; |
my ($url) = @_; |
if ($url=~m-^/+res/+($match_domain)/+\1\-domainconfig/+(img|logo|domlogo)/+-) { |
if ($url=~m-^/+res/+($match_domain)/+\1\-domainconfig/+(img|logo|domlogo)/+[^/]-) { |
if (&domain($1) ne '') { |
if (&domain($1) ne '') { |
return '1'; |
return '1'; |
} |
} |
Line 1902 sub get_instuser {
|
Line 1947 sub get_instuser {
|
return ($outcome,%userinfo); |
return ($outcome,%userinfo); |
} |
} |
|
|
|
sub get_multiple_instusers { |
|
my ($udom,$users,$caller) = @_; |
|
my ($outcome,$results); |
|
if (ref($users) eq 'HASH') { |
|
my $count = keys(%{$users}); |
|
my $requested = &freeze_escape($users); |
|
my $homeserver = &domain($udom,'primary'); |
|
if ($homeserver ne '') { |
|
my $queryid=&reply('querysend:getmultinstusers:::'.$caller.'='.$requested,$homeserver); |
|
my $host=&hostname($homeserver); |
|
if ($queryid !~/^\Q$host\E\_/) { |
|
&logthis('get_multiple_instusers invalid queryid: '.$queryid. |
|
' for host: '.$homeserver.'in domain '.$udom); |
|
return ($outcome,$results); |
|
} |
|
my $response = &get_query_reply($queryid); |
|
my $maxtries = 5; |
|
if ($count > 100) { |
|
$maxtries = 1+int($count/20); |
|
} |
|
my $tries = 1; |
|
while (($response=~/^timeout/) && ($tries <= $maxtries)) { |
|
$response = &get_query_reply($queryid); |
|
$tries ++; |
|
} |
|
if ($response eq '') { |
|
$results = {}; |
|
foreach my $key (keys(%{$users})) { |
|
my ($uname,$id); |
|
if ($caller eq 'id') { |
|
$id = $key; |
|
} else { |
|
$uname = $key; |
|
} |
|
my ($resp,%info) = &get_instuser($udom,$uname,$id); |
|
$outcome = $resp; |
|
if ($resp eq 'ok') { |
|
%{$results} = (%{$results}, %info); |
|
} else { |
|
last; |
|
} |
|
} |
|
} elsif(!&error($response) && ($response ne 'refused')) { |
|
if (($response eq 'unavailable') || ($response eq 'invalid') || ($response eq 'timeout')) { |
|
$outcome = $response; |
|
} else { |
|
($outcome,my $userdata) = split(/=/,$response,2); |
|
if ($outcome eq 'ok') { |
|
$results = &thaw_unescape($userdata); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return ($outcome,$results); |
|
} |
|
|
sub inst_rulecheck { |
sub inst_rulecheck { |
my ($udom,$uname,$id,$item,$rules) = @_; |
my ($udom,$uname,$id,$item,$rules) = @_; |
my %returnhash; |
my %returnhash; |
Line 1997 sub get_domain_defaults {
|
Line 2099 sub get_domain_defaults {
|
&Apache::lonnet::get_dom('configuration',['defaults','quotas', |
&Apache::lonnet::get_dom('configuration',['defaults','quotas', |
'requestcourses','inststatus', |
'requestcourses','inststatus', |
'coursedefaults','usersessions', |
'coursedefaults','usersessions', |
'requestauthor'],$domain); |
'requestauthor','selfenrollment', |
|
'coursecategories','autoenroll'],$domain); |
|
my @coursetypes = ('official','unofficial','community','textbook'); |
if (ref($domconfig{'defaults'}) eq 'HASH') { |
if (ref($domconfig{'defaults'}) eq 'HASH') { |
$domdefaults{'lang_def'} = $domconfig{'defaults'}{'lang_def'}; |
$domdefaults{'lang_def'} = $domconfig{'defaults'}{'lang_def'}; |
$domdefaults{'auth_def'} = $domconfig{'defaults'}{'auth_def'}; |
$domdefaults{'auth_def'} = $domconfig{'defaults'}{'auth_def'}; |
Line 2035 sub get_domain_defaults {
|
Line 2139 sub get_domain_defaults {
|
$domdefaults{'requestauthor'} = $domconfig{'requestauthor'}; |
$domdefaults{'requestauthor'} = $domconfig{'requestauthor'}; |
} |
} |
if (ref($domconfig{'inststatus'}) eq 'HASH') { |
if (ref($domconfig{'inststatus'}) eq 'HASH') { |
foreach my $item ('inststatustypes','inststatusorder') { |
foreach my $item ('inststatustypes','inststatusorder','inststatusguest') { |
$domdefaults{$item} = $domconfig{'inststatus'}{$item}; |
$domdefaults{$item} = $domconfig{'inststatus'}{$item}; |
} |
} |
} |
} |
if (ref($domconfig{'coursedefaults'}) eq 'HASH') { |
if (ref($domconfig{'coursedefaults'}) eq 'HASH') { |
if (ref($domconfig{'coursedefaults'}{'coursecredits'}) eq 'HASH') { |
$domdefaults{'usejsme'} = $domconfig{'coursedefaults'}{'usejsme'}; |
$domdefaults{'officialcredits'} = $domconfig{'coursedefaults'}{'coursecredits'}{'official'}; |
$domdefaults{'uselcmath'} = $domconfig{'coursedefaults'}{'uselcmath'}; |
$domdefaults{'unofficialcredits'} = $domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'}; |
if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') { |
$domdefaults{'textbookcredits'} = $domconfig{'coursedefaults'}{'coursecredits'}{'textbook'}; |
$domdefaults{'postsubmit'} = $domconfig{'coursedefaults'}{'postsubmit'}{'client'}; |
} |
} |
if (ref($domconfig{'coursedefaults'}{'uploadquota'}) eq 'HASH') { |
foreach my $type (@coursetypes) { |
$domdefaults{'officialquota'} = $domconfig{'coursedefaults'}{'uploadquota'}{'official'}; |
if (ref($domconfig{'coursedefaults'}{'coursecredits'}) eq 'HASH') { |
$domdefaults{'unofficialquota'} = $domconfig{'coursedefaults'}{'uploadquota'}{'unofficial'}; |
unless ($type eq 'community') { |
$domdefaults{'communityquota'} = $domconfig{'coursedefaults'}{'uploadquota'}{'community'}; |
$domdefaults{$type.'credits'} = $domconfig{'coursedefaults'}{'coursecredits'}{$type}; |
$domdefaults{'textbookquota'} = $domconfig{'coursedefaults'}{'uploadquota'}{'textbook'}; |
} |
|
} |
|
if (ref($domconfig{'coursedefaults'}{'uploadquota'}) eq 'HASH') { |
|
$domdefaults{$type.'quota'} = $domconfig{'coursedefaults'}{'uploadquota'}{$type}; |
|
} |
|
if ($domdefaults{'postsubmit'} eq 'on') { |
|
if (ref($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') { |
|
$domdefaults{$type.'postsubtimeout'} = |
|
$domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$type}; |
|
} |
|
} |
|
} |
|
if (ref($domconfig{'coursedefaults'}{'canclone'}) eq 'HASH') { |
|
if (ref($domconfig{'coursedefaults'}{'canclone'}{'instcode'}) eq 'ARRAY') { |
|
my @clonecodes = @{$domconfig{'coursedefaults'}{'canclone'}{'instcode'}}; |
|
if (@clonecodes) { |
|
$domdefaults{'canclone'} = join('+',@clonecodes); |
|
} |
|
} |
|
} elsif ($domconfig{'coursedefaults'}{'canclone'}) { |
|
$domdefaults{'canclone'}=$domconfig{'coursedefaults'}{'canclone'}; |
} |
} |
} |
} |
if (ref($domconfig{'usersessions'}) eq 'HASH') { |
if (ref($domconfig{'usersessions'}) eq 'HASH') { |
Line 2059 sub get_domain_defaults {
|
Line 2183 sub get_domain_defaults {
|
if (ref($domconfig{'usersessions'}{'hosted'}) eq 'HASH') { |
if (ref($domconfig{'usersessions'}{'hosted'}) eq 'HASH') { |
$domdefaults{'hostedsessions'} = $domconfig{'usersessions'}{'hosted'}; |
$domdefaults{'hostedsessions'} = $domconfig{'usersessions'}{'hosted'}; |
} |
} |
|
if (ref($domconfig{'usersessions'}{'offloadnow'}) eq 'HASH') { |
|
$domdefaults{'offloadnow'} = $domconfig{'usersessions'}{'offloadnow'}; |
|
} |
|
} |
|
if (ref($domconfig{'selfenrollment'}) eq 'HASH') { |
|
if (ref($domconfig{'selfenrollment'}{'admin'}) eq 'HASH') { |
|
my @settings = ('types','registered','enroll_dates','access_dates','section', |
|
'approval','limit'); |
|
foreach my $type (@coursetypes) { |
|
if (ref($domconfig{'selfenrollment'}{'admin'}{$type}) eq 'HASH') { |
|
my @mgrdc = (); |
|
foreach my $item (@settings) { |
|
if ($domconfig{'selfenrollment'}{'admin'}{$type}{$item} eq '0') { |
|
push(@mgrdc,$item); |
|
} |
|
} |
|
if (@mgrdc) { |
|
$domdefaults{$type.'selfenrolladmdc'} = join(',',@mgrdc); |
|
} |
|
} |
|
} |
|
} |
|
if (ref($domconfig{'selfenrollment'}{'default'}) eq 'HASH') { |
|
foreach my $type (@coursetypes) { |
|
if (ref($domconfig{'selfenrollment'}{'default'}{$type}) eq 'HASH') { |
|
foreach my $item (keys(%{$domconfig{'selfenrollment'}{'default'}{$type}})) { |
|
$domdefaults{$type.'selfenroll'.$item} = $domconfig{'selfenrollment'}{'default'}{$type}{$item}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (ref($domconfig{'coursecategories'}) eq 'HASH') { |
|
$domdefaults{'catauth'} = 'std'; |
|
$domdefaults{'catunauth'} = 'std'; |
|
if ($domconfig{'coursecategories'}{'auth'}) { |
|
$domdefaults{'catauth'} = $domconfig{'coursecategories'}{'auth'}; |
|
} |
|
if ($domconfig{'coursecategories'}{'unauth'}) { |
|
$domdefaults{'catunauth'} = $domconfig{'coursecategories'}{'unauth'}; |
|
} |
|
} |
|
if (ref($domconfig{'autoenroll'}) eq 'HASH') { |
|
$domdefaults{'autofailsafe'} = $domconfig{'autoenroll'}{'autofailsafe'}; |
} |
} |
&do_cache_new('domdefaults',$domain,\%domdefaults,$cachetime); |
&do_cache_new('domdefaults',$domain,\%domdefaults,$cachetime); |
return %domdefaults; |
return %domdefaults; |
Line 2650 sub ssi {
|
Line 2818 sub ssi {
|
&Apache::lonenc::check_encrypt(\$fn); |
&Apache::lonenc::check_encrypt(\$fn); |
if (%form) { |
if (%form) { |
$request=new HTTP::Request('POST',&absolute_url().$fn); |
$request=new HTTP::Request('POST',&absolute_url().$fn); |
$request->content(join('&',map { &escape($_).'='.&escape($form{$_}) } keys(%form))); |
$request->content(join('&',map { |
|
my $name = escape($_); |
|
"$name=" . ( ref($form{$_}) eq 'ARRAY' |
|
? join("&$name=", map {escape($_) } @{$form{$_}}) |
|
: &escape($form{$_}) ); |
|
} keys(%form))); |
} else { |
} else { |
$request=new HTTP::Request('GET',&absolute_url().$fn); |
$request=new HTTP::Request('GET',&absolute_url().$fn); |
} |
} |
Line 4171 sub courseiddump {
|
Line 4344 sub courseiddump {
|
$coursefilter,$hostidflag,$hostidref,$typefilter,$regexp_ok, |
$coursefilter,$hostidflag,$hostidref,$typefilter,$regexp_ok, |
$selfenrollonly,$catfilter,$showhidden,$caller,$cloner,$cc_clone, |
$selfenrollonly,$catfilter,$showhidden,$caller,$cloner,$cc_clone, |
$cloneonly,$createdbefore,$createdafter,$creationcontext,$domcloner, |
$cloneonly,$createdbefore,$createdafter,$creationcontext,$domcloner, |
$hasuniquecode)=@_; |
$hasuniquecode,$reqcrsdom,$reqinstcode)=@_; |
my $as_hash = 1; |
my $as_hash = 1; |
my %returnhash; |
my %returnhash; |
if (!$domfilter) { $domfilter=''; } |
if (!$domfilter) { $domfilter=''; } |
Line 4194 sub courseiddump {
|
Line 4367 sub courseiddump {
|
&escape($catfilter), $showhidden, $caller, |
&escape($catfilter), $showhidden, $caller, |
&escape($cloner), &escape($cc_clone), $cloneonly, |
&escape($cloner), &escape($cc_clone), $cloneonly, |
&escape($createdbefore), &escape($createdafter), |
&escape($createdbefore), &escape($createdafter), |
&escape($creationcontext), $domcloner, $hasuniquecode))); |
&escape($creationcontext),$domcloner,$hasuniquecode, |
|
$reqcrsdom,&escape($reqinstcode)))); |
} else { |
} else { |
$rep = &reply('courseiddump:'.&host_domain($tryserver).':'. |
$rep = &reply('courseiddump:'.&host_domain($tryserver).':'. |
$sincefilter.':'.&escape($descfilter).':'. |
$sincefilter.':'.&escape($descfilter).':'. |
Line 4205 sub courseiddump {
|
Line 4379 sub courseiddump {
|
$showhidden.':'.$caller.':'.&escape($cloner).':'. |
$showhidden.':'.$caller.':'.&escape($cloner).':'. |
&escape($cc_clone).':'.$cloneonly.':'. |
&escape($cc_clone).':'.$cloneonly.':'. |
&escape($createdbefore).':'.&escape($createdafter).':'. |
&escape($createdbefore).':'.&escape($createdafter).':'. |
&escape($creationcontext).':'.$domcloner.':'.$hasuniquecode, |
&escape($creationcontext).':'.$domcloner.':'.$hasuniquecode. |
$tryserver); |
':'.$reqcrsdom.':'.&escape($reqinstcode),$tryserver); |
} |
} |
|
|
my @pairs=split(/\&/,$rep); |
my @pairs=split(/\&/,$rep); |
Line 4345 my $cachedkey='';
|
Line 4519 my $cachedkey='';
|
# The cached times for this user |
# The cached times for this user |
my %cachedtimes=(); |
my %cachedtimes=(); |
# When this was last done |
# When this was last done |
my $cachedtime=(); |
my $cachedtime=''; |
|
|
sub load_all_first_access { |
sub load_all_first_access { |
my ($uname,$udom)=@_; |
my ($uname,$udom)=@_; |
Line 4863 sub tmprestore {
|
Line 5037 sub tmprestore {
|
# ----------------------------------------------------------------------- Store |
# ----------------------------------------------------------------------- Store |
|
|
sub store { |
sub store { |
my ($storehash,$symb,$namespace,$domain,$stuname) = @_; |
my ($storehash,$symb,$namespace,$domain,$stuname,$laststore) = @_; |
my $home=''; |
my $home=''; |
|
|
if ($stuname) { $home=&homeserver($stuname,$domain); } |
if ($stuname) { $home=&homeserver($stuname,$domain); } |
Line 4893 sub store {
|
Line 5067 sub store {
|
} |
} |
$namevalue=~s/\&$//; |
$namevalue=~s/\&$//; |
&courselog($symb.':'.$stuname.':'.$domain.':STORE:'.$namevalue); |
&courselog($symb.':'.$stuname.':'.$domain.':STORE:'.$namevalue); |
return reply("store:$domain:$stuname:$namespace:$symb:$namevalue","$home"); |
return reply("store:$domain:$stuname:$namespace:$symb:$namevalue:$laststore","$home"); |
} |
} |
|
|
# -------------------------------------------------------------- Critical Store |
# -------------------------------------------------------------- Critical Store |
|
|
sub cstore { |
sub cstore { |
my ($storehash,$symb,$namespace,$domain,$stuname) = @_; |
my ($storehash,$symb,$namespace,$domain,$stuname,$laststore) = @_; |
my $home=''; |
my $home=''; |
|
|
if ($stuname) { $home=&homeserver($stuname,$domain); } |
if ($stuname) { $home=&homeserver($stuname,$domain); } |
Line 4930 sub cstore {
|
Line 5104 sub cstore {
|
$namevalue=~s/\&$//; |
$namevalue=~s/\&$//; |
&courselog($symb.':'.$stuname.':'.$domain.':CSTORE:'.$namevalue); |
&courselog($symb.':'.$stuname.':'.$domain.':CSTORE:'.$namevalue); |
return critical |
return critical |
("store:$domain:$stuname:$namespace:$symb:$namevalue","$home"); |
("store:$domain:$stuname:$namespace:$symb:$namevalue:$laststore","$home"); |
} |
} |
|
|
# --------------------------------------------------------------------- Restore |
# --------------------------------------------------------------------- Restore |
Line 5110 sub privileged {
|
Line 5284 sub privileged {
|
my %rolesdump = &dump("roles", $domain, $username) or return 0; |
my %rolesdump = &dump("roles", $domain, $username) or return 0; |
my $now = time; |
my $now = time; |
|
|
for my $role (@rolesdump{grep { ! /^rolesdef_/ } keys %rolesdump}) { |
for my $role (@rolesdump{grep { ! /^rolesdef_/ } keys(%rolesdump)}) { |
my ($trole, $tend, $tstart) = split(/_/, $role); |
my ($trole, $tend, $tstart) = split(/_/, $role); |
if (grep(/^\Q$trole\E$/,@{$roles})) { |
if (grep(/^\Q$trole\E$/,@{$roles})) { |
return 1 unless ($tend && $tend < $now) |
return 1 unless ($tend && $tend < $now) |
Line 5199 sub rolesinit {
|
Line 5373 sub rolesinit {
|
my %allroles=(); |
my %allroles=(); |
my %allgroups=(); |
my %allgroups=(); |
|
|
for my $area (grep { ! /^rolesdef_/ } keys %rolesdump) { |
for my $area (grep { ! /^rolesdef_/ } keys(%rolesdump)) { |
my $role = $rolesdump{$area}; |
my $role = $rolesdump{$area}; |
$area =~ s/\_\w\w$//; |
$area =~ s/\_\w\w$//; |
|
|
Line 5639 sub dump {
|
Line 5813 sub dump {
|
if (!$uname) { $uname=$env{'user.name'}; } |
if (!$uname) { $uname=$env{'user.name'}; } |
my $uhome=&homeserver($uname,$udomain); |
my $uhome=&homeserver($uname,$udomain); |
|
|
my $reply; |
if ($regexp) { |
|
$regexp=&escape($regexp); |
|
} else { |
|
$regexp='.'; |
|
} |
if (grep { $_ eq $uhome } ¤t_machine_ids()) { |
if (grep { $_ eq $uhome } ¤t_machine_ids()) { |
# user is hosted on this machine |
# user is hosted on this machine |
$reply = LONCAPA::Lond::dump_with_regexp(join(':', ($udomain, |
my $reply = LONCAPA::Lond::dump_with_regexp(join(':', ($udomain, |
$uname, $namespace, $regexp, $range)), $perlvar{'lonVersion'}); |
$uname, $namespace, $regexp, $range)), $perlvar{'lonVersion'}); |
return %{&unserialize($reply, $escapedkeys)}; |
return %{&unserialize($reply, $escapedkeys)}; |
} |
} |
if ($regexp) { |
|
$regexp=&escape($regexp); |
|
} else { |
|
$regexp='.'; |
|
} |
|
my $rep=&reply("dump:$udomain:$uname:$namespace:$regexp:$range",$uhome); |
my $rep=&reply("dump:$udomain:$uname:$namespace:$regexp:$range",$uhome); |
my @pairs=split(/\&/,$rep); |
my @pairs=split(/\&/,$rep); |
my %returnhash=(); |
my %returnhash=(); |
Line 5698 sub currentdump {
|
Line 5871 sub currentdump {
|
$sdom = $env{'user.domain'} if (! defined($sdom)); |
$sdom = $env{'user.domain'} if (! defined($sdom)); |
$sname = $env{'user.name'} if (! defined($sname)); |
$sname = $env{'user.name'} if (! defined($sname)); |
my $uhome = &homeserver($sname,$sdom); |
my $uhome = &homeserver($sname,$sdom); |
my $rep=reply('currentdump:'.$sdom.':'.$sname.':'.$courseid,$uhome); |
my $rep; |
|
|
|
if (grep { $_ eq $uhome } current_machine_ids()) { |
|
$rep = LONCAPA::Lond::dump_profile_database(join(":", ($sdom, $sname, |
|
$courseid))); |
|
} else { |
|
$rep = reply('currentdump:'.$sdom.':'.$sname.':'.$courseid,$uhome); |
|
} |
|
|
return if ($rep =~ /^(error:|no_such_host)/); |
return if ($rep =~ /^(error:|no_such_host)/); |
# |
# |
my %returnhash=(); |
my %returnhash=(); |
Line 5819 sub newput {
|
Line 6000 sub newput {
|
# --------------------------------------------------------- putstore interface |
# --------------------------------------------------------- putstore interface |
|
|
sub putstore { |
sub putstore { |
my ($namespace,$symb,$version,$storehash,$udomain,$uname)=@_; |
my ($namespace,$symb,$version,$storehash,$udomain,$uname,$tolog)=@_; |
if (!$udomain) { $udomain=$env{'user.domain'}; } |
if (!$udomain) { $udomain=$env{'user.domain'}; } |
if (!$uname) { $uname=$env{'user.name'}; } |
if (!$uname) { $uname=$env{'user.name'}; } |
my $uhome=&homeserver($uname,$udomain); |
my $uhome=&homeserver($uname,$udomain); |
Line 5833 sub putstore {
|
Line 6014 sub putstore {
|
my $reply = |
my $reply = |
&reply("putstore:$udomain:$uname:$namespace:$esc_symb:$esc_v:$items", |
&reply("putstore:$udomain:$uname:$namespace:$esc_symb:$esc_v:$items", |
$uhome); |
$uhome); |
|
if (($tolog) && ($reply eq 'ok')) { |
|
my $namevalue=''; |
|
foreach my $key (keys(%{$storehash})) { |
|
$namevalue.=&escape($key).'='.&freeze_escape($storehash->{$key}).'&'; |
|
} |
|
$namevalue .= 'ip='.&escape($ENV{'REMOTE_ADDR'}). |
|
'&host='.&escape($perlvar{'lonHostID'}). |
|
'&version='.$esc_v. |
|
'&by='.&escape($env{'user.name'}.':'.$env{'user.domain'}); |
|
&Apache::lonnet::courselog($symb.':'.$uname.':'.$udomain.':PUTSTORE:'.$namevalue); |
|
} |
if ($reply eq 'unknown_cmd') { |
if ($reply eq 'unknown_cmd') { |
# gfall back to way things use to be done |
# gfall back to way things use to be done |
return &old_putstore($namespace,$symb,$version,$storehash,$udomain, |
return &old_putstore($namespace,$symb,$version,$storehash,$udomain, |
Line 5991 sub get_timebased_id {
|
Line 6183 sub get_timebased_id {
|
my %inuse = &Apache::lonnet::dump('nohist_'.$namespace,$cdom,$cnum,$prefix); |
my %inuse = &Apache::lonnet::dump('nohist_'.$namespace,$cdom,$cnum,$prefix); |
my $id = time; |
my $id = time; |
$newid = $id; |
$newid = $id; |
|
if ($idtype eq 'addcode') { |
|
$newid .= &sixnum_code(); |
|
} |
my $idtries = 0; |
my $idtries = 0; |
while (exists($inuse{$prefix."\0".$newid}) && $idtries < $maxtries) { |
while (exists($inuse{$prefix."\0".$newid}) && $idtries < $maxtries) { |
if ($idtype eq 'concat') { |
if ($idtype eq 'concat') { |
$newid = $id.$idtries; |
$newid = $id.$idtries; |
|
} elsif ($idtype eq 'addcode') { |
|
$newid = $newid.&sixnum_code(); |
} else { |
} else { |
$newid ++; |
$newid ++; |
} |
} |
Line 6011 sub get_timebased_id {
|
Line 6208 sub get_timebased_id {
|
$error = 'error saving new item: '.$putresult; |
$error = 'error saving new item: '.$putresult; |
} |
} |
} else { |
} else { |
|
undef($newid); |
$error = ('error: no unique suffix available for the new item '); |
$error = ('error: no unique suffix available for the new item '); |
} |
} |
# remove lock |
# remove lock |
Line 6019 sub get_timebased_id {
|
Line 6217 sub get_timebased_id {
|
} else { |
} else { |
$error = "error: could not obtain lockfile\n"; |
$error = "error: could not obtain lockfile\n"; |
$dellock = 'ok'; |
$dellock = 'ok'; |
|
if (($prefix eq 'paste') && ($namespace eq 'courseeditor') && ($keyid eq 'num')) { |
|
$dellock = 'nolock'; |
|
} |
} |
} |
return ($newid,$dellock,$error); |
return ($newid,$dellock,$error); |
} |
} |
|
|
|
sub sixnum_code { |
|
my $code; |
|
for (0..6) { |
|
$code .= int( rand(9) ); |
|
} |
|
return $code; |
|
} |
|
|
# -------------------------------------------------- portfolio access checking |
# -------------------------------------------------- portfolio access checking |
|
|
sub portfolio_access { |
sub portfolio_access { |
my ($requrl) = @_; |
my ($requrl,$clientip) = @_; |
my (undef,$udom,$unum,$file_name,$group) = &parse_portfolio_url($requrl); |
my (undef,$udom,$unum,$file_name,$group) = &parse_portfolio_url($requrl); |
my $result = &get_portfolio_access($udom,$unum,$file_name,$group); |
my $result = &get_portfolio_access($udom,$unum,$file_name,$group,$clientip); |
if ($result) { |
if ($result) { |
my %setters; |
my %setters; |
if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { |
if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { |
Line 6054 sub portfolio_access {
|
Line 6263 sub portfolio_access {
|
} |
} |
|
|
sub get_portfolio_access { |
sub get_portfolio_access { |
my ($udom,$unum,$file_name,$group,$access_hash) = @_; |
my ($udom,$unum,$file_name,$group,$clientip,$access_hash) = @_; |
|
|
if (!ref($access_hash)) { |
if (!ref($access_hash)) { |
my $current_perms = &get_portfile_permissions($udom,$unum); |
my $current_perms = &get_portfile_permissions($udom,$unum); |
Line 6063 sub get_portfolio_access {
|
Line 6272 sub get_portfolio_access {
|
$access_hash = $access_controls{$file_name}; |
$access_hash = $access_controls{$file_name}; |
} |
} |
|
|
my ($public,$guest,@domains,@users,@courses,@groups); |
my ($public,$guest,@domains,@users,@courses,@groups,@ips); |
my $now = time; |
my $now = time; |
if (ref($access_hash) eq 'HASH') { |
if (ref($access_hash) eq 'HASH') { |
foreach my $key (keys(%{$access_hash})) { |
foreach my $key (keys(%{$access_hash})) { |
Line 6087 sub get_portfolio_access {
|
Line 6296 sub get_portfolio_access {
|
push(@courses,$key); |
push(@courses,$key); |
} elsif ($scope eq 'group') { |
} elsif ($scope eq 'group') { |
push(@groups,$key); |
push(@groups,$key); |
|
} elsif ($scope eq 'ip') { |
|
push(@ips,$key); |
} |
} |
} |
} |
if ($public) { |
if ($public) { |
return 'ok'; |
return 'ok'; |
|
} elsif (@ips > 0) { |
|
my $allowed; |
|
foreach my $ipkey (@ips) { |
|
if (ref($access_hash->{$ipkey}{'ip'}) eq 'ARRAY') { |
|
if (&Apache::loncommon::check_ip_acc(join(',',@{$access_hash->{$ipkey}{'ip'}}),$clientip)) { |
|
$allowed = 1; |
|
last; |
|
} |
|
} |
|
} |
|
if ($allowed) { |
|
return 'ok'; |
|
} |
} |
} |
if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { |
if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { |
if ($guest) { |
if ($guest) { |
Line 6574 sub customaccess {
|
Line 6798 sub customaccess {
|
# ------------------------------------------------- Check for a user privilege |
# ------------------------------------------------- Check for a user privilege |
|
|
sub allowed { |
sub allowed { |
my ($priv,$uri,$symb,$role)=@_; |
my ($priv,$uri,$symb,$role,$clientip,$noblockcheck)=@_; |
my $ver_orguri=$uri; |
my $ver_orguri=$uri; |
$uri=&deversion($uri); |
$uri=&deversion($uri); |
my $orguri=$uri; |
my $orguri=$uri; |
Line 6769 sub allowed {
|
Line 6993 sub allowed {
|
if ($match) { |
if ($match) { |
if ($env{'user.priv.'.$env{'request.role'}.'./'} |
if ($env{'user.priv.'.$env{'request.role'}.'./'} |
=~/\Q$priv\E\&([^\:]*)/) { |
=~/\Q$priv\E\&([^\:]*)/) { |
my @blockers = &has_comm_blocking($priv,$symb,$uri); |
my $value = $1; |
if (@blockers > 0) { |
if ($noblockcheck) { |
$thisallowed = 'B'; |
$thisallowed.=$value; |
} else { |
} else { |
$thisallowed.=$1; |
my @blockers = &has_comm_blocking($priv,$symb,$uri); |
|
if (@blockers > 0) { |
|
$thisallowed = 'B'; |
|
} else { |
|
$thisallowed.=$value; |
|
} |
} |
} |
} |
} |
} else { |
} else { |
Line 6785 sub allowed {
|
Line 7014 sub allowed {
|
$refuri=&declutter($refuri); |
$refuri=&declutter($refuri); |
my ($match) = &is_on_map($refuri); |
my ($match) = &is_on_map($refuri); |
if ($match) { |
if ($match) { |
my @blockers = &has_comm_blocking($priv,$symb,$refuri); |
if ($noblockcheck) { |
if (@blockers > 0) { |
|
$thisallowed = 'B'; |
|
} else { |
|
$thisallowed='F'; |
$thisallowed='F'; |
|
} else { |
|
my @blockers = &has_comm_blocking($priv,$symb,$refuri); |
|
if (@blockers > 0) { |
|
$thisallowed = 'B'; |
|
} else { |
|
$thisallowed='F'; |
|
} |
} |
} |
} |
} |
} |
} |
Line 6801 sub allowed {
|
Line 7034 sub allowed {
|
&& $thisallowed ne 'F' |
&& $thisallowed ne 'F' |
&& $thisallowed ne '2' |
&& $thisallowed ne '2' |
&& &is_portfolio_url($uri)) { |
&& &is_portfolio_url($uri)) { |
$thisallowed = &portfolio_access($uri); |
$thisallowed = &portfolio_access($uri,$clientip); |
} |
} |
|
|
# Full access at system, domain or course-wide level? Exit. |
# Full access at system, domain or course-wide level? Exit. |
Line 6844 sub allowed {
|
Line 7077 sub allowed {
|
=~/\Q$priv\E\&([^\:]*)/) { |
=~/\Q$priv\E\&([^\:]*)/) { |
my $value = $1; |
my $value = $1; |
if ($priv eq 'bre') { |
if ($priv eq 'bre') { |
my @blockers = &has_comm_blocking($priv,$symb,$uri); |
if ($noblockcheck) { |
if (@blockers > 0) { |
|
$thisallowed = 'B'; |
|
} else { |
|
$thisallowed.=$value; |
$thisallowed.=$value; |
|
} else { |
|
my @blockers = &has_comm_blocking($priv,$symb,$uri); |
|
if (@blockers > 0) { |
|
$thisallowed = 'B'; |
|
} else { |
|
$thisallowed.=$value; |
|
} |
} |
} |
} else { |
} else { |
$thisallowed.=$value; |
$thisallowed.=$value; |
Line 6882 sub allowed {
|
Line 7119 sub allowed {
|
=~/\Q$priv\E\&([^\:]*)/) { |
=~/\Q$priv\E\&([^\:]*)/) { |
my $value = $1; |
my $value = $1; |
if ($priv eq 'bre') { |
if ($priv eq 'bre') { |
my @blockers = &has_comm_blocking($priv,$symb,$refuri); |
if ($noblockcheck) { |
if (@blockers > 0) { |
|
$thisallowed = 'B'; |
|
} else { |
|
$thisallowed.=$value; |
$thisallowed.=$value; |
|
} else { |
|
my @blockers = &has_comm_blocking($priv,$symb,$refuri); |
|
if (@blockers > 0) { |
|
$thisallowed = 'B'; |
|
} else { |
|
$thisallowed.=$value; |
|
} |
} |
} |
} else { |
} else { |
$thisallowed.=$value; |
$thisallowed.=$value; |
Line 7117 sub constructaccess {
|
Line 7358 sub constructaccess {
|
return ''; |
return ''; |
} |
} |
|
|
|
# ----------------------------------------------------------- Content Blocking |
|
|
|
{ |
|
# Caches for faster Course Contents display where content blocking |
|
# is in operation (i.e., interval param set) for timed quiz. |
|
# |
|
# User for whom data are being temporarily cached. |
|
my $cacheduser=''; |
|
# Cached blockers for this user (a hash of blocking items). |
|
my %cachedblockers=(); |
|
# When the data were last cached. |
|
my $cachedlast=''; |
|
|
|
sub load_all_blockers { |
|
my ($uname,$udom,$blocks)=@_; |
|
if (($uname ne '') && ($udom ne '')) { |
|
if (($cacheduser eq $uname.':'.$udom) && |
|
(abs($cachedlast-time)<5)) { |
|
return; |
|
} |
|
} |
|
$cachedlast=time; |
|
$cacheduser=$uname.':'.$udom; |
|
%cachedblockers = &get_commblock_resources($blocks); |
|
} |
|
|
sub get_comm_blocks { |
sub get_comm_blocks { |
my ($cdom,$cnum) = @_; |
my ($cdom,$cnum) = @_; |
if ($cdom eq '' || $cnum eq '') { |
if ($cdom eq '' || $cnum eq '') { |
Line 7137 sub get_comm_blocks {
|
Line 7404 sub get_comm_blocks {
|
return %commblocks; |
return %commblocks; |
} |
} |
|
|
sub has_comm_blocking { |
sub get_commblock_resources { |
my ($priv,$symb,$uri,$blocks) = @_; |
my ($blocks) = @_; |
return unless ($env{'request.course.id'}); |
my %blockers = (); |
return unless ($priv eq 'bre'); |
return %blockers unless ($env{'request.course.id'}); |
return if ($env{'user.priv.'.$env{'request.role'}} =~/evb\&([^\:]*)/); |
return %blockers if ($env{'user.priv.'.$env{'request.role'}} =~/evb\&([^\:]*)/); |
my %commblocks; |
my %commblocks; |
if (ref($blocks) eq 'HASH') { |
if (ref($blocks) eq 'HASH') { |
%commblocks = %{$blocks}; |
%commblocks = %{$blocks}; |
} else { |
} else { |
%commblocks = &get_comm_blocks(); |
%commblocks = &get_comm_blocks(); |
} |
} |
return unless (keys(%commblocks) > 0); |
return %blockers unless (keys(%commblocks) > 0); |
if (!$symb) { $symb=&symbread($uri,1); } |
|
my ($map,$resid,undef)=&decode_symb($symb); |
|
my %tocheck = ( |
|
maps => $map, |
|
resources => $symb, |
|
); |
|
my @blockers; |
|
my $now = time; |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
return %blockers unless (ref($navmap)); |
|
my $now = time; |
foreach my $block (keys(%commblocks)) { |
foreach my $block (keys(%commblocks)) { |
if ($block =~ /^(\d+)____(\d+)$/) { |
if ($block =~ /^(\d+)____(\d+)$/) { |
my ($start,$end) = ($1,$2); |
my ($start,$end) = ($1,$2); |
Line 7165 sub has_comm_blocking {
|
Line 7426 sub has_comm_blocking {
|
if (ref($commblocks{$block}{'blocks'}) eq 'HASH') { |
if (ref($commblocks{$block}{'blocks'}) eq 'HASH') { |
if (ref($commblocks{$block}{'blocks'}{'docs'}) eq 'HASH') { |
if (ref($commblocks{$block}{'blocks'}{'docs'}) eq 'HASH') { |
if (ref($commblocks{$block}{'blocks'}{'docs'}{'maps'}) eq 'HASH') { |
if (ref($commblocks{$block}{'blocks'}{'docs'}{'maps'}) eq 'HASH') { |
if ($commblocks{$block}{'blocks'}{'docs'}{'maps'}{$map}) { |
if (keys(%{$commblocks{$block}{'blocks'}{'docs'}{'maps'}})) { |
unless (grep(/^\Q$block\E$/,@blockers)) { |
$blockers{$block}{maps} = $commblocks{$block}{'blocks'}{'docs'}{'maps'}; |
push(@blockers,$block); |
|
} |
|
} |
} |
} |
} |
if (ref($commblocks{$block}{'blocks'}{'docs'}{'resources'}) eq 'HASH') { |
if (ref($commblocks{$block}{'blocks'}{'docs'}{'resources'}) eq 'HASH') { |
if ($commblocks{$block}{'blocks'}{'docs'}{'resources'}{$symb}) { |
if (keys(%{$commblocks{$block}{'blocks'}{'docs'}{'resources'}})) { |
unless (grep(/^\Q$block\E$/,@blockers)) { |
$blockers{$block}{'resources'} = $commblocks{$block}{'blocks'}{'docs'}{'resources'}; |
push(@blockers,$block); |
|
} |
|
} |
} |
} |
} |
} |
} |
Line 7186 sub has_comm_blocking {
|
Line 7443 sub has_comm_blocking {
|
my @to_test; |
my @to_test; |
if (ref($commblocks{$block}{'blocks'}) eq 'HASH') { |
if (ref($commblocks{$block}{'blocks'}) eq 'HASH') { |
if (ref($commblocks{$block}{'blocks'}{'docs'}) eq 'HASH') { |
if (ref($commblocks{$block}{'blocks'}{'docs'}) eq 'HASH') { |
my $check_interval; |
my @interval; |
if (&check_docs_block($commblocks{$block}{'blocks'}{'docs'},\%tocheck)) { |
my $type = 'map'; |
my @interval; |
if ($item eq 'course') { |
my $type = 'map'; |
$type = 'course'; |
if ($item eq 'course') { |
@interval=&EXT("resource.0.interval"); |
$type = 'course'; |
} else { |
@interval=&EXT("resource.0.interval"); |
if ($item =~ /___\d+___/) { |
|
$type = 'resource'; |
|
@interval=&EXT("resource.0.interval",$item); |
|
if (ref($navmap)) { |
|
my $res = $navmap->getBySymb($item); |
|
push(@to_test,$res); |
|
} |
} else { |
} else { |
if ($item =~ /___\d+___/) { |
my $mapsymb = &symbread($item,1); |
$type = 'resource'; |
if ($mapsymb) { |
@interval=&EXT("resource.0.interval",$item); |
if (ref($navmap)) { |
if (ref($navmap)) { |
my $mapres = $navmap->getBySymb($mapsymb); |
my $res = $navmap->getBySymb($item); |
@to_test = $mapres->retrieveResources($mapres,undef,0,0,0,1); |
push(@to_test,$res); |
foreach my $res (@to_test) { |
} |
my $symb = $res->symb(); |
} else { |
next if ($symb eq $mapsymb); |
my $mapsymb = &symbread($item,1); |
if ($symb ne '') { |
if ($mapsymb) { |
@interval=&EXT("resource.0.interval",$symb); |
if (ref($navmap)) { |
if ($interval[1] eq 'map') { |
my $mapres = $navmap->getBySymb($mapsymb); |
|
@to_test = $mapres->retrieveResources($mapres,undef,0,1); |
|
foreach my $res (@to_test) { |
|
my $symb = $res->symb(); |
|
next if ($symb eq $mapsymb); |
|
if ($symb ne '') { |
|
@interval=&EXT("resource.0.interval",$symb); |
|
last; |
last; |
} |
} |
} |
} |
Line 7219 sub has_comm_blocking {
|
Line 7475 sub has_comm_blocking {
|
} |
} |
} |
} |
} |
} |
if ($interval[0] =~ /\d+/) { |
} |
my $first_access; |
if ($interval[0] =~ /^\d+$/) { |
if ($type eq 'resource') { |
my $first_access; |
$first_access=&get_first_access($interval[1],$item); |
if ($type eq 'resource') { |
} elsif ($type eq 'map') { |
$first_access=&get_first_access($interval[1],$item); |
$first_access=&get_first_access($interval[1],undef,$item); |
} elsif ($type eq 'map') { |
} else { |
$first_access=&get_first_access($interval[1],undef,$item); |
$first_access=&get_first_access($interval[1]); |
} else { |
} |
$first_access=&get_first_access($interval[1]); |
if ($first_access) { |
} |
my $timesup = $first_access+$interval[0]; |
if ($first_access) { |
if ($timesup > $now) { |
my $timesup = $first_access+$interval[0]; |
foreach my $res (@to_test) { |
if ($timesup > $now) { |
if ($res->is_problem()) { |
my $activeblock; |
if ($res->completable()) { |
foreach my $res (@to_test) { |
unless (grep(/^\Q$block\E$/,@blockers)) { |
if ($res->answerable()) { |
push(@blockers,$block); |
$activeblock = 1; |
} |
last; |
last; |
} |
} |
} |
|
if ($activeblock) { |
|
if (ref($commblocks{$block}{'blocks'}{'docs'}{'maps'}) eq 'HASH') { |
|
if (keys(%{$commblocks{$block}{'blocks'}{'docs'}{'maps'}})) { |
|
$blockers{$block}{'maps'} = $commblocks{$block}{'blocks'}{'docs'}{'maps'}; |
|
} |
|
} |
|
if (ref($commblocks{$block}{'blocks'}{'docs'}{'resources'}) eq 'HASH') { |
|
if (keys(%{$commblocks{$block}{'blocks'}{'docs'}{'resources'}})) { |
|
$blockers{$block}{'resources'} = $commblocks{$block}{'blocks'}{'docs'}{'resources'}; |
} |
} |
} |
} |
} |
} |
Line 7249 sub has_comm_blocking {
|
Line 7514 sub has_comm_blocking {
|
} |
} |
} |
} |
} |
} |
return @blockers; |
return %blockers; |
} |
} |
|
|
sub check_docs_block { |
sub has_comm_blocking { |
my ($docsblock,$tocheck) =@_; |
my ($priv,$symb,$uri,$blocks) = @_; |
if ((ref($docsblock) ne 'HASH') || (ref($tocheck) ne 'HASH')) { |
my @blockers; |
return; |
return unless ($env{'request.course.id'}); |
|
return unless ($priv eq 'bre'); |
|
return if ($env{'user.priv.'.$env{'request.role'}} =~/evb\&([^\:]*)/); |
|
return if ($env{'request.state'} eq 'construct'); |
|
&load_all_blockers($env{'user.name'},$env{'user.domain'},$blocks); |
|
return unless (keys(%cachedblockers) > 0); |
|
my (%possibles,@symbs); |
|
if (!$symb) { |
|
$symb = &symbread($uri,1,1,1,\%possibles); |
} |
} |
if (ref($docsblock->{'maps'}) eq 'HASH') { |
if ($symb) { |
if ($tocheck->{'maps'}) { |
@symbs = ($symb); |
if ($docsblock->{'maps'}{$tocheck->{'maps'}}) { |
} elsif (keys(%possibles)) { |
return 1; |
@symbs = keys(%possibles); |
|
} |
|
my $noblock; |
|
foreach my $symb (@symbs) { |
|
last if ($noblock); |
|
my ($map,$resid,$resurl)=&decode_symb($symb); |
|
foreach my $block (keys(%cachedblockers)) { |
|
if ($block =~ /^firstaccess____(.+)$/) { |
|
my $item = $1; |
|
if (($item eq $map) || ($item eq $symb)) { |
|
$noblock = 1; |
|
last; |
|
} |
} |
} |
} |
if (ref($cachedblockers{$block}) eq 'HASH') { |
} |
if (ref($cachedblockers{$block}{'resources'}) eq 'HASH') { |
if (ref($docsblock->{'resources'}) eq 'HASH') { |
if ($cachedblockers{$block}{'resources'}{$symb}) { |
if ($tocheck->{'resources'}) { |
unless (grep(/^\Q$block\E$/,@blockers)) { |
if ($docsblock->{'resources'}{$tocheck->{'resources'}}) { |
push(@blockers,$block); |
return 1; |
} |
|
} |
|
} |
|
} |
|
if (ref($cachedblockers{$block}{'maps'}) eq 'HASH') { |
|
if ($cachedblockers{$block}{'maps'}{$map}) { |
|
unless (grep(/^\Q$block\E$/,@blockers)) { |
|
push(@blockers,$block); |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
return; |
return if ($noblock); |
|
return @blockers; |
} |
} |
|
} |
|
|
|
# -------------------------------- Deversion and split uri into path an filename |
|
|
# |
# |
# Removes the versino from a URI and |
# Removes the version from a URI and |
# splits it in to its filename and path to the filename. |
# splits it in to its filename and path to the filename. |
# Seems like File::Basename could have done this more clearly. |
# Seems like File::Basename could have done this more clearly. |
# Parameters: |
# Parameters: |
Line 7457 sub update_allusers_table {
|
Line 7755 sub update_allusers_table {
|
|
|
sub fetch_enrollment_query { |
sub fetch_enrollment_query { |
my ($context,$affiliatesref,$replyref,$dom,$cnum) = @_; |
my ($context,$affiliatesref,$replyref,$dom,$cnum) = @_; |
my $homeserver; |
my ($homeserver,$sleep,$loopmax); |
my $maxtries = 1; |
my $maxtries = 1; |
if ($context eq 'automated') { |
if ($context eq 'automated') { |
$homeserver = $perlvar{'lonHostID'}; |
$homeserver = $perlvar{'lonHostID'}; |
|
$sleep = 2; |
|
$loopmax = 100; |
$maxtries = 10; # will wait for up to 2000s for retrieval of classlist data before timeout |
$maxtries = 10; # will wait for up to 2000s for retrieval of classlist data before timeout |
} else { |
} else { |
$homeserver = &homeserver($cnum,$dom); |
$homeserver = &homeserver($cnum,$dom); |
Line 7478 sub fetch_enrollment_query {
|
Line 7778 sub fetch_enrollment_query {
|
&logthis('fetch_enrollment_query: invalid queryid: '.$queryid.' for host: '.$host.' and homeserver: '.$homeserver.' context: '.$context.' '.$cnum); |
&logthis('fetch_enrollment_query: invalid queryid: '.$queryid.' for host: '.$host.' and homeserver: '.$homeserver.' context: '.$context.' '.$cnum); |
return 'error: '.$queryid; |
return 'error: '.$queryid; |
} |
} |
my $reply = &get_query_reply($queryid); |
my $reply = &get_query_reply($queryid,$sleep.$loopmax); |
my $tries = 1; |
my $tries = 1; |
while (($reply=~/^timeout/) && ($tries < $maxtries)) { |
while (($reply=~/^timeout/) && ($tries < $maxtries)) { |
$reply = &get_query_reply($queryid); |
$reply = &get_query_reply($queryid,$sleep,$loopmax); |
$tries ++; |
$tries ++; |
} |
} |
if ( ($reply =~/^timeout/) || ($reply =~/^error/) ) { |
if ( ($reply =~/^timeout/) || ($reply =~/^error/) ) { |
Line 7523 sub fetch_enrollment_query {
|
Line 7823 sub fetch_enrollment_query {
|
} |
} |
|
|
sub get_query_reply { |
sub get_query_reply { |
my $queryid=shift; |
my ($queryid,$sleep,$loopmax) = @_; |
|
if (($sleep eq '') || ($sleep !~ /^\d+\.?\d*$/)) { |
|
$sleep = 0.2; |
|
} |
|
if (($loopmax eq '') || ($loopmax =~ /\D/)) { |
|
$loopmax = 100; |
|
} |
my $replyfile=LONCAPA::tempdir().$queryid; |
my $replyfile=LONCAPA::tempdir().$queryid; |
my $reply=''; |
my $reply=''; |
for (1..100) { |
for (1..$loopmax) { |
sleep 2; |
sleep($sleep); |
if (-e $replyfile.'.end') { |
if (-e $replyfile.'.end') { |
if (open(my $fh,$replyfile)) { |
if (open(my $fh,$replyfile)) { |
$reply = join('',<$fh>); |
$reply = join('',<$fh>); |
Line 7889 sub auto_courserequest_checks {
|
Line 8195 sub auto_courserequest_checks {
|
} |
} |
|
|
sub auto_courserequest_validation { |
sub auto_courserequest_validation { |
my ($dom,$owner,$crstype,$inststatuslist,$instcode,$instseclist) = @_; |
my ($dom,$owner,$crstype,$inststatuslist,$instcode,$instseclist,$custominfo) = @_; |
my ($homeserver,$response); |
my ($homeserver,$response); |
if ($dom =~ /^$match_domain$/) { |
if ($dom =~ /^$match_domain$/) { |
$homeserver = &domain($dom,'primary'); |
$homeserver = &domain($dom,'primary'); |
} |
} |
unless ($homeserver eq 'no_host') { |
unless ($homeserver eq 'no_host') { |
|
my $customdata; |
|
if (ref($custominfo) eq 'HASH') { |
|
$customdata = &freeze_escape($custominfo); |
|
} |
$response=&unescape(&reply('autocrsreqvalidation:'.$dom.':'.&escape($owner). |
$response=&unescape(&reply('autocrsreqvalidation:'.$dom.':'.&escape($owner). |
':'.&escape($crstype).':'.&escape($inststatuslist). |
':'.&escape($crstype).':'.&escape($inststatuslist). |
':'.&escape($instcode).':'.&escape($instseclist), |
':'.&escape($instcode).':'.&escape($instseclist).':'. |
$homeserver)); |
$customdata,$homeserver)); |
} |
} |
return $response; |
return $response; |
} |
} |
Line 7920 sub auto_validate_class_sec {
|
Line 8229 sub auto_validate_class_sec {
|
|
|
sub auto_crsreq_update { |
sub auto_crsreq_update { |
my ($cdom,$cnum,$crstype,$action,$ownername,$ownerdomain,$fullname,$title, |
my ($cdom,$cnum,$crstype,$action,$ownername,$ownerdomain,$fullname,$title, |
$code,$inbound) = @_; |
$code,$accessstart,$accessend,$inbound) = @_; |
my ($homeserver,%crsreqresponse); |
my ($homeserver,%crsreqresponse); |
if ($cdom =~ /^$match_domain$/) { |
if ($cdom =~ /^$match_domain$/) { |
$homeserver = &domain($cdom,'primary'); |
$homeserver = &domain($cdom,'primary'); |
Line 7933 sub auto_crsreq_update {
|
Line 8242 sub auto_crsreq_update {
|
my $response=&reply('autocrsrequpdate:'.$cdom.':'.$cnum.':'.&escape($crstype). |
my $response=&reply('autocrsrequpdate:'.$cdom.':'.$cnum.':'.&escape($crstype). |
':'.&escape($action).':'.&escape($ownername).':'. |
':'.&escape($action).':'.&escape($ownername).':'. |
&escape($ownerdomain).':'.&escape($fullname).':'. |
&escape($ownerdomain).':'.&escape($fullname).':'. |
&escape($title).':'.&escape($code).':'.$info,$homeserver); |
&escape($title).':'.&escape($code).':'. |
|
&escape($accessstart).':'.&escape($accessend).':'.$info,$homeserver); |
unless ($response =~ /(con_lost|error|no_such_host|refused)/) { |
unless ($response =~ /(con_lost|error|no_such_host|refused)/) { |
my @items = split(/&/,$response); |
my @items = split(/&/,$response); |
foreach my $item (@items) { |
foreach my $item (@items) { |
Line 7945 sub auto_crsreq_update {
|
Line 8255 sub auto_crsreq_update {
|
return \%crsreqresponse; |
return \%crsreqresponse; |
} |
} |
|
|
|
sub auto_export_grades { |
|
my ($cdom,$cnum,$inforef,$gradesref) = @_; |
|
my ($homeserver,%exportresponse); |
|
if ($cdom =~ /^$match_domain$/) { |
|
$homeserver = &domain($cdom,'primary'); |
|
} |
|
unless (($homeserver eq 'no_host') || ($homeserver eq '')) { |
|
my $info; |
|
if (ref($inforef) eq 'HASH') { |
|
$info = &freeze_escape($inforef); |
|
} |
|
if (ref($gradesref) eq 'HASH') { |
|
my $grades = &freeze_escape($gradesref); |
|
my $response=&reply('encrypt:autoexportgrades:'.$cdom.':'.$cnum.':'. |
|
$info.':'.$grades,$homeserver); |
|
unless ($response =~ /(con_lost|error|no_such_host|refused|unknown_command)/) { |
|
my @items = split(/&/,$response); |
|
foreach my $item (@items) { |
|
my ($key,$value) = split('=',$item); |
|
$exportresponse{&unescape($key)} = &thaw_unescape($value); |
|
} |
|
} |
|
} |
|
} |
|
return \%exportresponse; |
|
} |
|
|
|
sub check_instcode_cloning { |
|
my ($codedefaults,$code_order,$cloner,$clonefromcode,$clonetocode) = @_; |
|
unless ((ref($codedefaults) eq 'HASH') && (ref($code_order) eq 'ARRAY')) { |
|
return; |
|
} |
|
my $canclone; |
|
if (@{$code_order} > 0) { |
|
my $instcoderegexp ='^'; |
|
my @clonecodes = split(/\&/,$cloner); |
|
foreach my $item (@{$code_order}) { |
|
if (grep(/^\Q$item\E=/,@clonecodes)) { |
|
foreach my $pair (@clonecodes) { |
|
my ($key,$val) = split(/\=/,$pair,2); |
|
$val = &unescape($val); |
|
if ($key eq $item) { |
|
$instcoderegexp .= '('.$val.')'; |
|
last; |
|
} |
|
} |
|
} else { |
|
$instcoderegexp .= $codedefaults->{$item}; |
|
} |
|
} |
|
$instcoderegexp .= '$'; |
|
my (@from,@to); |
|
eval { |
|
(@from) = ($clonefromcode =~ /$instcoderegexp/); |
|
(@to) = ($clonetocode =~ /$instcoderegexp/); |
|
}; |
|
if ((@from > 0) && (@to > 0)) { |
|
my @diffs = &Apache::loncommon::compare_arrays(\@from,\@to); |
|
if (!@diffs) { |
|
$canclone = 1; |
|
} |
|
} |
|
} |
|
return $canclone; |
|
} |
|
|
|
sub default_instcode_cloning { |
|
my ($clonedom,$domdefclone,$clonefromcode,$clonetocode,$codedefaultsref,$codeorderref) = @_; |
|
my (%codedefaults,@code_order,$canclone); |
|
if ((ref($codedefaultsref) eq 'HASH') && (ref($codeorderref) eq 'ARRAY')) { |
|
%codedefaults = %{$codedefaultsref}; |
|
@code_order = @{$codeorderref}; |
|
} elsif ($clonedom) { |
|
&auto_instcode_defaults($clonedom,\%codedefaults,\@code_order); |
|
} |
|
if (($domdefclone) && (@code_order)) { |
|
my @clonecodes = split(/\+/,$domdefclone); |
|
my $instcoderegexp ='^'; |
|
foreach my $item (@code_order) { |
|
if (grep(/^\Q$item\E$/,@clonecodes)) { |
|
$instcoderegexp .= '('.$codedefaults{$item}.')'; |
|
} else { |
|
$instcoderegexp .= $codedefaults{$item}; |
|
} |
|
} |
|
$instcoderegexp .= '$'; |
|
my (@from,@to); |
|
eval { |
|
(@from) = ($clonefromcode =~ /$instcoderegexp/); |
|
(@to) = ($clonetocode =~ /$instcoderegexp/); |
|
}; |
|
if ((@from > 0) && (@to > 0)) { |
|
my @diffs = &Apache::loncommon::compare_arrays(\@from,\@to); |
|
if (!@diffs) { |
|
$canclone = 1; |
|
} |
|
} |
|
} |
|
return $canclone; |
|
} |
|
|
# ------------------------------------------------------- Course Group routines |
# ------------------------------------------------------- Course Group routines |
|
|
sub get_coursegroups { |
sub get_coursegroups { |
Line 8614 sub modifyuser {
|
Line 9025 sub modifyuser {
|
sub modifystudent { |
sub modifystudent { |
my ($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,$usec, |
my ($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene,$usec, |
$end,$start,$forceid,$desiredhome,$email,$type,$locktype,$cid, |
$end,$start,$forceid,$desiredhome,$email,$type,$locktype,$cid, |
$selfenroll,$context,$inststatus,$credits)=@_; |
$selfenroll,$context,$inststatus,$credits,$instsec)=@_; |
if (!$cid) { |
if (!$cid) { |
unless ($cid=$env{'request.course.id'}) { |
unless ($cid=$env{'request.course.id'}) { |
return 'not_in_class'; |
return 'not_in_class'; |
Line 8630 sub modifystudent {
|
Line 9041 sub modifystudent {
|
$uid = undef if (!$forceid); |
$uid = undef if (!$forceid); |
$reply = &modify_student_enrollment($udom,$uname,$uid,$first,$middle,$last, |
$reply = &modify_student_enrollment($udom,$uname,$uid,$first,$middle,$last, |
$gene,$usec,$end,$start,$type,$locktype, |
$gene,$usec,$end,$start,$type,$locktype, |
$cid,$selfenroll,$context,$credits); |
$cid,$selfenroll,$context,$credits,$instsec); |
return $reply; |
return $reply; |
} |
} |
|
|
sub modify_student_enrollment { |
sub modify_student_enrollment { |
my ($udom,$uname,$uid,$first,$middle,$last,$gene,$usec,$end,$start,$type, |
my ($udom,$uname,$uid,$first,$middle,$last,$gene,$usec,$end,$start,$type, |
$locktype,$cid,$selfenroll,$context,$credits) = @_; |
$locktype,$cid,$selfenroll,$context,$credits,$instsec) = @_; |
my ($cdom,$cnum,$chome); |
my ($cdom,$cnum,$chome); |
if (!$cid) { |
if (!$cid) { |
unless ($cid=$env{'request.course.id'}) { |
unless ($cid=$env{'request.course.id'}) { |
Line 8683 sub modify_student_enrollment {
|
Line 9094 sub modify_student_enrollment {
|
my %old_entry = &Apache::lonnet::get('classlist',[$user],$cdom,$cnum); |
my %old_entry = &Apache::lonnet::get('classlist',[$user],$cdom,$cnum); |
my $reply=cput('classlist', |
my $reply=cput('classlist', |
{$user => |
{$user => |
join(':',$end,$start,$uid,$usec,$fullname,$type,$locktype,$credits) }, |
join(':',$end,$start,$uid,$usec,$fullname,$type,$locktype,$credits,$instsec) }, |
$cdom,$cnum); |
$cdom,$cnum); |
if (($reply eq 'ok') || ($reply eq 'delayed')) { |
if (($reply eq 'ok') || ($reply eq 'delayed')) { |
&devalidate_getsection_cache($udom,$uname,$cid); |
&devalidate_getsection_cache($udom,$uname,$cid); |
Line 9207 sub modify_access_controls {
|
Line 9618 sub modify_access_controls {
|
my $tries = 0; |
my $tries = 0; |
my $gotlock = &newput('file_permissions',$lockhash,$domain,$user); |
my $gotlock = &newput('file_permissions',$lockhash,$domain,$user); |
|
|
while (($gotlock ne 'ok') && $tries <3) { |
while (($gotlock ne 'ok') && $tries < 10) { |
$tries ++; |
$tries ++; |
sleep 1; |
sleep(0.1); |
$gotlock = &newput('file_permissions',$lockhash,$domain,$user); |
$gotlock = &newput('file_permissions',$lockhash,$domain,$user); |
} |
} |
if ($gotlock eq 'ok') { |
if ($gotlock eq 'ok') { |
Line 9502 sub dirlist {
|
Line 9913 sub dirlist {
|
foreach my $user (sort(keys(%allusers))) { |
foreach my $user (sort(keys(%allusers))) { |
push(@alluserslist,$user.'&user'); |
push(@alluserslist,$user.'&user'); |
} |
} |
return (\@alluserslist); |
if (!%listerror) { |
|
# no errors |
|
return (\@alluserslist); |
|
} elsif (scalar(keys(%servers)) == 1) { |
|
# one library server, one error |
|
my ($key) = keys(%listerror); |
|
return (\@alluserslist, $listerror{$key}); |
|
} elsif ( grep { $_ eq 'con_lost' } values(%listerror) ) { |
|
# con_lost indicates that we might miss data from at least one |
|
# library server |
|
return (\@alluserslist, 'con_lost'); |
|
} else { |
|
# multiple library servers and no con_lost -> data should be |
|
# complete. |
|
return (\@alluserslist); |
|
} |
|
|
} else { |
} else { |
return ([],'missing username'); |
return ([],'missing username'); |
} |
} |
Line 9719 sub get_userresdata {
|
Line 10146 sub get_userresdata {
|
} |
} |
#error 2 occurs when the .db doesn't exist |
#error 2 occurs when the .db doesn't exist |
if ($tmp!~/error: 2 /) { |
if ($tmp!~/error: 2 /) { |
&logthis("<font color=\"blue\">WARNING:". |
if ((!defined($cached)) || ($tmp ne 'con_lost')) { |
" Trying to get resource data for ". |
&logthis("<font color=\"blue\">WARNING:". |
$uname." at ".$udom.": ". |
" Trying to get resource data for ". |
$tmp."</font>"); |
$uname." at ".$udom.": ". |
|
$tmp."</font>"); |
|
} |
} elsif ($tmp=~/error: 2 /) { |
} elsif ($tmp=~/error: 2 /) { |
#&EXT_cache_set($udom,$uname); |
#&EXT_cache_set($udom,$uname); |
&do_cache_new('userres',$hashid,undef,600); |
&do_cache_new('userres',$hashid,undef,600); |
Line 10220 sub metadata {
|
Line 10649 sub metadata {
|
($uri =~ m|/$|) || ($uri =~ m|/.meta$|) || ($uri =~ m{^/*uploaded/.+\.sequence$})) { |
($uri =~ m|/$|) || ($uri =~ m|/.meta$|) || ($uri =~ m{^/*uploaded/.+\.sequence$})) { |
return undef; |
return undef; |
} |
} |
if (($uri =~ /^priv/ || $uri=~/home\/httpd\/html\/priv/) |
if (($uri =~ /^priv/ || $uri=~m{^home/httpd/html/priv}) |
&& &Apache::lonxml::get_state('target') =~ /^(|meta)$/) { |
&& &Apache::lonxml::get_state('target') =~ /^(|meta)$/) { |
return undef; |
return undef; |
} |
} |
Line 10481 sub metadata {
|
Line 10910 sub metadata {
|
|
|
$metaentry{':keys'} = join(',',keys(%metathesekeys)); |
$metaentry{':keys'} = join(',',keys(%metathesekeys)); |
&metadata_generate_part0(\%metathesekeys,\%metaentry,$uri); |
&metadata_generate_part0(\%metathesekeys,\%metaentry,$uri); |
$metaentry{':allpossiblekeys'}=join(',',keys %metathesekeys); |
$metaentry{':allpossiblekeys'}=join(',',keys(%metathesekeys)); |
&do_cache_new('meta',$uri,\%metaentry,$cachetime); |
&do_cache_new('meta',$uri,\%metaentry,$cachetime); |
# this is the end of "was not already recently cached |
# this is the end of "was not already recently cached |
} |
} |
Line 10852 sub deversion {
|
Line 11281 sub deversion {
|
# ------------------------------------------------------ Return symb list entry |
# ------------------------------------------------------ Return symb list entry |
|
|
sub symbread { |
sub symbread { |
my ($thisfn,$donotrecurse)=@_; |
my ($thisfn,$donotrecurse,$ignorecachednull,$checkforblock,$possibles)=@_; |
my $cache_str; |
my $cache_str='request.symbread.cached.'.$thisfn; |
if ($thisfn ne '') { |
if (defined($env{$cache_str})) { |
$cache_str='request.symbread.cached.'.$thisfn; |
if ($ignorecachednull) { |
if ($env{$cache_str} ne '') { |
return $env{$cache_str} unless ($env{$cache_str} eq ''); |
|
} else { |
return $env{$cache_str}; |
return $env{$cache_str}; |
} |
} |
} else { |
} |
# no filename provided? try from environment |
# no filename provided? try from environment |
|
unless ($thisfn) { |
if ($env{'request.symb'}) { |
if ($env{'request.symb'}) { |
return $env{$cache_str}=&symbclean($env{'request.symb'}); |
return $env{$cache_str}=&symbclean($env{'request.symb'}); |
} |
} |
Line 10920 sub symbread {
|
Line 11351 sub symbread {
|
my ($mapid,$resid)=split(/\./,$ids); |
my ($mapid,$resid)=split(/\./,$ids); |
$syval=&encode_symb($bighash{'map_id_'.$mapid}, |
$syval=&encode_symb($bighash{'map_id_'.$mapid}, |
$resid,$thisfn); |
$resid,$thisfn); |
} elsif (!$donotrecurse) { |
if (ref($possibles) eq 'HASH') { |
|
$possibles->{$syval} = 1; |
|
} |
|
if ($checkforblock) { |
|
my @blockers = &has_comm_blocking('bre',$syval,$bighash{'src_'.$ids}); |
|
if (@blockers) { |
|
$syval = ''; |
|
return; |
|
} |
|
} |
|
} elsif ((!$donotrecurse) || ($checkforblock) || (ref($possibles) eq 'HASH')) { |
# ------------------------------------------ There is more than one possibility |
# ------------------------------------------ There is more than one possibility |
my $realpossible=0; |
my $realpossible=0; |
foreach my $id (@possibilities) { |
foreach my $id (@possibilities) { |
my $file=$bighash{'src_'.$id}; |
my $file=$bighash{'src_'.$id}; |
if (&allowed('bre',$file)) { |
my $canaccess; |
my ($mapid,$resid)=split(/\./,$id); |
if (($donotrecurse) || ($checkforblock) || (ref($possibles) eq 'HASH')) { |
if ($bighash{'map_type_'.$mapid} ne 'page') { |
$canaccess = 1; |
$realpossible++; |
} else { |
$syval=&encode_symb($bighash{'map_id_'.$mapid}, |
$canaccess = &allowed('bre',$file); |
$resid,$thisfn); |
} |
} |
if ($canaccess) { |
|
my ($mapid,$resid)=split(/\./,$id); |
|
if ($bighash{'map_type_'.$mapid} ne 'page') { |
|
my $poss_syval=&encode_symb($bighash{'map_id_'.$mapid}, |
|
$resid,$thisfn); |
|
if (ref($possibles) eq 'HASH') { |
|
$possibles->{$syval} = 1; |
|
} |
|
if ($checkforblock) { |
|
my @blockers = &has_comm_blocking('bre',$poss_syval,$file); |
|
unless (@blockers > 0) { |
|
$syval = $poss_syval; |
|
$realpossible++; |
|
} |
|
} else { |
|
$syval = $poss_syval; |
|
$realpossible++; |
|
} |
|
} |
} |
} |
} |
} |
if ($realpossible!=1) { $syval=''; } |
if ($realpossible!=1) { $syval=''; } |
Line 10939 sub symbread {
|
Line 11398 sub symbread {
|
$syval=''; |
$syval=''; |
} |
} |
} |
} |
untie(%bighash) |
untie(%bighash); |
} |
} |
} |
} |
if ($syval) { |
if ($syval) { |
Line 11277 sub rndseed_CODE_64bit5 {
|
Line 11736 sub rndseed_CODE_64bit5 {
|
sub setup_random_from_rndseed { |
sub setup_random_from_rndseed { |
my ($rndseed)=@_; |
my ($rndseed)=@_; |
if ($rndseed =~/([,:])/) { |
if ($rndseed =~/([,:])/) { |
my ($num1,$num2)=split(/[,:]/,$rndseed); |
my ($num1,$num2) = map { abs($_); } (split(/[,:]/,$rndseed)); |
&Math::Random::random_set_seed(abs($num1),abs($num2)); |
if ((!$num1) || (!$num2) || ($num1 > 2147483562) || ($num2 > 2147483398)) { |
|
&Math::Random::random_set_seed_from_phrase($rndseed); |
|
} else { |
|
&Math::Random::random_set_seed($num1,$num2); |
|
} |
} else { |
} else { |
&Math::Random::random_set_seed_from_phrase($rndseed); |
&Math::Random::random_set_seed_from_phrase($rndseed); |
} |
} |
Line 11669 sub default_login_domain {
|
Line 12132 sub default_login_domain {
|
sub declutter { |
sub declutter { |
my $thisfn=shift; |
my $thisfn=shift; |
if ($thisfn=~m|^/enc/|) { $thisfn=&Apache::lonenc::unencrypted($thisfn); } |
if ($thisfn=~m|^/enc/|) { $thisfn=&Apache::lonenc::unencrypted($thisfn); } |
$thisfn=~s/^\Q$perlvar{'lonDocRoot'}\E//; |
unless ($thisfn=~m{^/home/httpd/html/priv/}) { |
|
$thisfn=~s{^/home/httpd/html}{}; |
|
} |
$thisfn=~s/^\///; |
$thisfn=~s/^\///; |
$thisfn=~s|^adm/wrapper/||; |
$thisfn=~s|^adm/wrapper/||; |
$thisfn=~s|^adm/coursedocs/showdoc/||; |
$thisfn=~s|^adm/coursedocs/showdoc/||; |
Line 11796 sub get_dns {
|
Line 12261 sub get_dns {
|
$alldns{$host} = $protocol; |
$alldns{$host} = $protocol; |
} |
} |
while (%alldns) { |
while (%alldns) { |
my ($dns) = keys(%alldns); |
my ($dns) = sort { $b cmp $a } keys(%alldns); |
my $ua=new LWP::UserAgent; |
my $ua=new LWP::UserAgent; |
$ua->timeout(30); |
$ua->timeout(30); |
my $request=new HTTP::Request('GET',"$alldns{$dns}://$dns$url"); |
my $request=new HTTP::Request('GET',"$alldns{$dns}://$dns$url"); |
Line 11822 sub get_dns {
|
Line 12287 sub get_dns {
|
# ------------------------------------------------------Get DNS checksums file |
# ------------------------------------------------------Get DNS checksums file |
sub parse_dns_checksums_tab { |
sub parse_dns_checksums_tab { |
my ($lines,$hashref) = @_; |
my ($lines,$hashref) = @_; |
my $machine_dom = &Apache::lonnet::host_domain($perlvar{'lonHostID'}); |
my $lonhost = $perlvar{'lonHostID'}; |
|
my $machine_dom = &Apache::lonnet::host_domain($lonhost); |
my $loncaparev = &get_server_loncaparev($machine_dom); |
my $loncaparev = &get_server_loncaparev($machine_dom); |
|
my $distro = (split(/\:/,&get_server_distarch($lonhost)))[0]; |
|
my $webconfdir = '/etc/httpd/conf'; |
|
if ($distro =~ /^(ubuntu|debian)(\d+)$/) { |
|
$webconfdir = '/etc/apache2'; |
|
} elsif ($distro =~ /^sles(\d+)$/) { |
|
if ($1 >= 10) { |
|
$webconfdir = '/etc/apache2'; |
|
} |
|
} elsif ($distro =~ /^suse(\d+\.\d+)$/) { |
|
if ($1 >= 10.0) { |
|
$webconfdir = '/etc/apache2'; |
|
} |
|
} |
my ($release,$timestamp) = split(/\-/,$loncaparev); |
my ($release,$timestamp) = split(/\-/,$loncaparev); |
my (%chksum,%revnum); |
my (%chksum,%revnum); |
if (ref($lines) eq 'ARRAY') { |
if (ref($lines) eq 'ARRAY') { |
Line 11832 sub parse_dns_checksums_tab {
|
Line 12311 sub parse_dns_checksums_tab {
|
if ($version eq $release) { |
if ($version eq $release) { |
foreach my $line (@{$lines}) { |
foreach my $line (@{$lines}) { |
my ($file,$version,$shasum) = split(/,/,$line); |
my ($file,$version,$shasum) = split(/,/,$line); |
|
if ($file =~ m{^/etc/httpd/conf}) { |
|
if ($webconfdir eq '/etc/apache2') { |
|
$file =~ s{^\Q/etc/httpd/conf/\E}{$webconfdir/}; |
|
} |
|
} |
$chksum{$file} = $shasum; |
$chksum{$file} = $shasum; |
$revnum{$file} = $version; |
$revnum{$file} = $version; |
} |
} |
Line 11849 sub parse_dns_checksums_tab {
|
Line 12333 sub parse_dns_checksums_tab {
|
sub fetch_dns_checksums { |
sub fetch_dns_checksums { |
my %checksums; |
my %checksums; |
my $machine_dom = &Apache::lonnet::host_domain($perlvar{'lonHostID'}); |
my $machine_dom = &Apache::lonnet::host_domain($perlvar{'lonHostID'}); |
my $loncaparev = &get_server_loncaparev($machine_dom); |
my $loncaparev = &get_server_loncaparev($machine_dom,$perlvar{'lonHostID'}); |
my ($release,$timestamp) = split(/\-/,$loncaparev); |
my ($release,$timestamp) = split(/\-/,$loncaparev); |
&get_dns("/adm/dns/checksums/$release",\&parse_dns_checksums_tab,1,1, |
&get_dns("/adm/dns/checksums/$release",\&parse_dns_checksums_tab,1,1, |
\%checksums); |
\%checksums); |
Line 11884 sub fetch_dns_checksums {
|
Line 12368 sub fetch_dns_checksums {
|
} |
} |
|
|
sub load_domain_tab { |
sub load_domain_tab { |
my ($ignore_cache) = @_; |
my ($ignore_cache,$nocache) = @_; |
&get_dns('/adm/dns/domain',\&parse_domain_tab,$ignore_cache); |
&get_dns('/adm/dns/domain',\&parse_domain_tab,$ignore_cache,$nocache); |
my $fh; |
my $fh; |
if (open($fh,"<".$perlvar{'lonTabDir'}.'/domain.tab')) { |
if (open($fh,"<".$perlvar{'lonTabDir'}.'/domain.tab')) { |
my @lines = <$fh>; |
my @lines = <$fh>; |
Line 11971 sub fetch_dns_checksums {
|
Line 12455 sub fetch_dns_checksums {
|
} |
} |
|
|
sub load_hosts_tab { |
sub load_hosts_tab { |
my ($ignore_cache) = @_; |
my ($ignore_cache,$nocache) = @_; |
&get_dns('/adm/dns/hosts',\&parse_hosts_tab,$ignore_cache); |
&get_dns('/adm/dns/hosts',\&parse_hosts_tab,$ignore_cache,$nocache); |
open(my $config,"<$perlvar{'lonTabDir'}/hosts.tab"); |
open(my $config,"<$perlvar{'lonTabDir'}/hosts.tab"); |
my @config = <$config>; |
my @config = <$config>; |
&parse_hosts_tab(\@config); |
&parse_hosts_tab(\@config); |
Line 11994 sub fetch_dns_checksums {
|
Line 12478 sub fetch_dns_checksums {
|
} |
} |
|
|
sub all_names { |
sub all_names { |
&load_hosts_tab() if (!$loaded); |
my ($ignore_cache,$nocache) = @_; |
|
&load_hosts_tab($ignore_cache,$nocache) if (!$loaded); |
|
|
return %name_to_host; |
return %name_to_host; |
} |
} |
Line 12116 sub fetch_dns_checksums {
|
Line 12601 sub fetch_dns_checksums {
|
} |
} |
|
|
sub get_iphost { |
sub get_iphost { |
my ($ignore_cache) = @_; |
my ($ignore_cache,$nocache) = @_; |
|
|
if (!$ignore_cache) { |
if (!$ignore_cache) { |
if (%iphost) { |
if (%iphost) { |
Line 12140 sub fetch_dns_checksums {
|
Line 12625 sub fetch_dns_checksums {
|
%old_name_to_ip = %{$ip_info->[1]}; |
%old_name_to_ip = %{$ip_info->[1]}; |
} |
} |
|
|
my %name_to_host = &all_names(); |
my %name_to_host = &all_names($ignore_cache,$nocache); |
foreach my $name (keys(%name_to_host)) { |
foreach my $name (keys(%name_to_host)) { |
my $ip; |
my $ip; |
if (!exists($name_to_ip{$name})) { |
if (!exists($name_to_ip{$name})) { |
Line 12165 sub fetch_dns_checksums {
|
Line 12650 sub fetch_dns_checksums {
|
} |
} |
push(@{$iphost{$ip}},@{$name_to_host{$name}}); |
push(@{$iphost{$ip}},@{$name_to_host{$name}}); |
} |
} |
&do_cache_new('iphost','iphost', |
unless ($nocache) { |
[\%iphost,\%name_to_ip,\%lonid_to_ip], |
&do_cache_new('iphost','iphost', |
48*60*60); |
[\%iphost,\%name_to_ip,\%lonid_to_ip], |
|
48*60*60); |
|
} |
|
|
return %iphost; |
return %iphost; |
} |
} |
Line 12548 were new keys. I.E. 1:foo will become 1:
|
Line 13035 were new keys. I.E. 1:foo will become 1:
|
Calling convention: |
Calling convention: |
|
|
my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$uname); |
my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$uname); |
&Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$uname); |
&Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$uname,$laststore); |
|
|
For more detailed information, see lonnet specific documentation. |
For more detailed information, see lonnet specific documentation. |
|
|
Line 12684 escaped strings of the action recorded i
|
Line 13171 escaped strings of the action recorded i
|
|
|
=item * |
=item * |
|
|
allowed($priv,$uri,$symb,$role) : check for a user privilege; returns codes for allowed actions |
allowed($priv,$uri,$symb,$role,$clientip,$noblockcheck) : check for a user privilege; |
|
returns codes for allowed actions. |
|
|
|
The first argument is required, all others are optional. |
|
|
|
$priv is the privilege being checked. |
|
$uri contains additional information about what is being checked for access (e.g., |
|
URL, course ID etc.). |
|
$symb is the unique resource instance identifier in a course; if needed, |
|
but not provided, it will be retrieved via a call to &symbread(). |
|
$role is the role for which a priv is being checked (only used if priv is evb). |
|
$clientip is the user's IP address (only used when checking for access to portfolio |
|
files). |
|
$noblockcheck, if true, skips calls to &has_comm_blocking() for the bre priv. This |
|
prevents recursive calls to &allowed. |
|
|
F: full access |
F: full access |
U,I,K: authentication modes (cxx only) |
U,I,K: authentication modes (cxx only) |
'': forbidden |
'': forbidden |
1: user needs to choose course |
1: user needs to choose course |
2: browse allowed |
2: browse allowed |
A: passphrase authentication needed |
A: passphrase authentication needed |
|
B: access temporarily blocked because of a blocking event in a course. |
|
|
=item * |
=item * |
|
|
Line 12915 Inputs:
|
Line 13418 Inputs:
|
|
|
=item $credits, number of credits student will earn from this class |
=item $credits, number of credits student will earn from this class |
|
|
|
=item $instsec, institutional course section code for student |
|
|
=back |
=back |
|
|
|
|
Line 13084 will be stored for query
|
Line 13589 will be stored for query
|
|
|
=item * |
=item * |
|
|
symbread($filename) : return symbolic list entry (filename argument optional); |
symbread($filename,$donotrecurse,$ignorecachednull,$checkforblock,$possibles) : |
|
return symbolic list entry (all arguments optional). |
|
|
|
Args: filename is the filename (including path) for the file for which a symb |
|
is required; donotrecurse, if true will prevent calls to allowed() being made |
|
to check access status if more than one resource was found in the bighash |
|
(see rev. 1.249) to avoid an infinite loop if an ambiguous resource is part of |
|
a randompick); ignorecachednull, if true will prevent a symb of '' being |
|
returned if $env{$cache_str} is defined as ''; checkforblock if true will |
|
cause possible symbs to be checked to determine if they are subject to content |
|
blocking, if so they will not be included as possible symbs; possibles is a |
|
ref to a hash, which, as a side effect, will be populated with all possible |
|
symbs (content blocking not tested). |
|
|
returns the data handle |
returns the data handle |
|
|
=item * |
=item * |
Line 13185 homeserver.
|
Line 13703 homeserver.
|
|
|
=item * |
=item * |
|
|
store($storehash,$symb,$namespace,$udom,$uname) : stores hash permanently |
store($storehash,$symb,$namespace,$udom,$uname,$laststore) : stores hash |
for this url; hashref needs to be given and should be a \%hashname; the |
permanently for this url; hashref needs to be given and should be a \%hashname; |
remaining args aren't required and if they aren't passed or are '' they will |
the remaining args aren't required and if they aren't passed or are '' they will |
be derived from the env |
be derived from the env (with the exception of $laststore, which is an |
|
optional arg used when a user's submission is stored in grading). |
|
$laststore is $version=$timestamp, where $version is the most recent version |
|
number retrieved for the corresponding $symb in the $namespace db file, and |
|
$timestamp is the timestamp for that transaction (UNIX time). |
|
$laststore is currently only passed when cstore() is called by |
|
structuretags::finalize_storage(). |
|
|
=item * |
=item * |
|
|
cstore($storehash,$symb,$namespace,$udom,$uname) : same as store but |
cstore($storehash,$symb,$namespace,$udom,$uname,$laststore) : same as store |
uses critical subroutine |
but uses critical subroutine |
|
|
=item * |
=item * |
|
|
Line 13216 $range should be either an integer '100'
|
Line 13740 $range should be either an integer '100'
|
|
|
=item * |
=item * |
|
|
putstore($namespace,$symb,$version,$storehash,$udomain,$uname) : |
putstore($namespace,$symb,$version,$storehash,$udomain,$uname,$tolog) : |
replaces a &store() version of data with a replacement set of data |
replaces a &store() version of data with a replacement set of data |
for a particular resource in a namespace passed in the $storehash hash |
for a particular resource in a namespace passed in the $storehash hash |
reference |
reference. If $tolog is true, the transaction is logged in the courselog |
|
with an action=PUTSTORE. |
|
|
=item * |
=item * |
|
|
Line 13373 inststatus: types of institutional affil
|
Line 13898 inststatus: types of institutional affil
|
=over |
=over |
|
|
=item |
=item |
inststatustypes, inststatusorder |
inststatustypes, inststatusorder, inststatusguest |
|
|
=back |
=back |
|
|
Line 13384 for course's uploaded content.
|
Line 13909 for course's uploaded content.
|
=over |
=over |
|
|
=item |
=item |
canuse_pdfforms, officialcredits, unofficialcredits, textbookcredits, officialquota, unofficialquota, communityquota, textbookquota |
canuse_pdfforms, officialcredits, unofficialcredits, textbookcredits, officialquota, unofficialquota, |
|
communityquota, textbookquota |
|
|
=back |
=back |
|
|
Line 13637 filelocation except for hrefs
|
Line 14163 filelocation except for hrefs
|
|
|
=item * |
=item * |
|
|
declutter() : declutters URLs (remove docroot, beginning slashes, 'res' etc) |
declutter() : declutters URLs -- remove beginning slashes, 'res' etc. |
|
also removes beginning /home/httpd/html unless /priv/ follows it. |
|
|
=back |
=back |
|
|