version 1.625, 2005/04/18 21:10:41
|
version 1.669, 2005/10/27 19:47:39
|
Line 37 use HTTP::Date;
|
Line 37 use HTTP::Date;
|
use vars |
use vars |
qw(%perlvar %hostname %badServerCache %iphost %spareid %hostdom |
qw(%perlvar %hostname %badServerCache %iphost %spareid %hostdom |
%libserv %pr %prp $memcache %packagetab |
%libserv %pr %prp $memcache %packagetab |
%courselogs %accesshash %userrolehash $processmarker $dumpcount |
%courselogs %accesshash %userrolehash %domainrolehash $processmarker $dumpcount |
%coursedombuf %coursenumbuf %coursehombuf %coursedescrbuf %courseinstcodebuf %courseownerbuf |
%coursedombuf %coursenumbuf %coursehombuf %coursedescrbuf %courseinstcodebuf %courseownerbuf |
%domaindescription %domain_auth_def %domain_auth_arg_def |
%domaindescription %domain_auth_def %domain_auth_arg_def |
%domain_lang_def %domain_city %domain_longi %domain_lati $tmpdir $_64bit |
%domain_lang_def %domain_city %domain_longi %domain_lati $tmpdir $_64bit |
Line 47 use IO::Socket;
|
Line 47 use IO::Socket;
|
use GDBM_File; |
use GDBM_File; |
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
use HTML::LCParser; |
use HTML::LCParser; |
|
use HTML::Parser; |
use Fcntl qw(:flock); |
use Fcntl qw(:flock); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Storable qw(lock_store lock_nstore lock_retrieve freeze thaw nfreeze); |
use Storable qw(lock_store lock_nstore lock_retrieve freeze thaw nfreeze); |
Line 766 sub validate_access_key {
|
Line 767 sub validate_access_key {
|
} |
} |
|
|
# ------------------------------------- Find the section of student in a course |
# ------------------------------------- Find the section of student in a course |
|
sub devalidate_getsection_cache { |
|
my ($udom,$unam,$courseid)=@_; |
|
$courseid=~s/\_/\//g; |
|
$courseid=~s/^(\w)/\/$1/; |
|
my $hashid="$udom:$unam:$courseid"; |
|
&devalidate_cache_new('getsection',$hashid); |
|
} |
|
|
sub getsection { |
sub getsection { |
my ($udom,$unam,$courseid)=@_; |
my ($udom,$unam,$courseid)=@_; |
Line 827 sub getsection {
|
Line 835 sub getsection {
|
} |
} |
|
|
sub save_cache { |
sub save_cache { |
|
my ($r)=@_; |
|
if (! $r->is_initial_req()) { return DECLINED; } |
&purge_remembered(); |
&purge_remembered(); |
undef(%env); |
undef(%env); |
|
return OK; |
} |
} |
|
|
my $to_remember=-1; |
my $to_remember=-1; |
Line 1128 sub allowuploaded {
|
Line 1139 sub allowuploaded {
|
} |
} |
|
|
# --------- File operations in /home/httpd/html/userfiles/$domain/1/2/3/$course |
# --------- File operations in /home/httpd/html/userfiles/$domain/1/2/3/$course |
# input: action, courseID, current domain, home server for course, intended |
# input: action, courseID, current domain, intended |
# path to file, source of file. |
# path to file, source of file, instruction to parse file for objects, |
|
# ref to hash for embedded objects, |
|
# ref to hash for codebase of java objects. |
|
# |
# output: url to file (if action was uploaddoc), |
# output: url to file (if action was uploaddoc), |
# ok if successful, or diagnostic message otherwise (if action was propagate or copy) |
# ok if successful, or diagnostic message otherwise (if action was propagate or copy) |
# |
# |
Line 1152 sub allowuploaded {
|
Line 1166 sub allowuploaded {
|
# /home/httpd/html/userfiles/$domain/1/2/3/$course/$file |
# /home/httpd/html/userfiles/$domain/1/2/3/$course/$file |
# and will then be copied to /home/httpd/lonUsers/1/2/3/$course/userfiles/$file |
# and will then be copied to /home/httpd/lonUsers/1/2/3/$course/userfiles/$file |
# in course's home server. |
# in course's home server. |
|
# |
|
|
sub process_coursefile { |
sub process_coursefile { |
my ($action,$docuname,$docudom,$docuhome,$file,$source)=@_; |
my ($action,$docuname,$docudom,$file,$source,$parser,$allfiles,$codebase)=@_; |
my $fetchresult; |
my $fetchresult; |
|
my $home=&homeserver($docuname,$docudom); |
if ($action eq 'propagate') { |
if ($action eq 'propagate') { |
$fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file |
$fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file, |
,$docuhome); |
$home); |
} else { |
} else { |
my $fetchresult = ''; |
|
my $fpath = ''; |
my $fpath = ''; |
my $fname = $file; |
my $fname = $file; |
($fpath,$fname) = ($file =~ m|^(.*)/([^/]+)$|); |
($fpath,$fname) = ($file =~ m|^(.*)/([^/]+)$|); |
$fpath=$docudom.'/'.$docuname.'/'.$fpath; |
$fpath=$docudom.'/'.$docuname.'/'.$fpath; |
my $filepath=$perlvar{'lonDocRoot'}.'/userfiles'; |
my $filepath = &build_filepath($fpath); |
unless ($fpath eq '') { |
|
my @parts=split('/',$fpath); |
|
foreach my $part (@parts) { |
|
$filepath.= '/'.$part; |
|
if ((-e $filepath)!=1) { |
|
mkdir($filepath,0777); |
|
} |
|
} |
|
} |
|
if ($action eq 'copy') { |
if ($action eq 'copy') { |
if ($source eq '') { |
if ($source eq '') { |
$fetchresult = 'no source file'; |
$fetchresult = 'no source file'; |
Line 1184 sub process_coursefile {
|
Line 1189 sub process_coursefile {
|
my $destination = $filepath.'/'.$fname; |
my $destination = $filepath.'/'.$fname; |
rename($source,$destination); |
rename($source,$destination); |
$fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file, |
$fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file, |
$docuhome); |
$home); |
} |
} |
} elsif ($action eq 'uploaddoc') { |
} elsif ($action eq 'uploaddoc') { |
open(my $fh,'>'.$filepath.'/'.$fname); |
open(my $fh,'>'.$filepath.'/'.$fname); |
print $fh $env{'form.'.$source}; |
print $fh $env{'form.'.$source}; |
close($fh); |
close($fh); |
|
if ($parser eq 'parse') { |
|
my $parse_result = &extract_embedded_items($filepath,$fname,$allfiles,$codebase); |
|
unless ($parse_result eq 'ok') { |
|
&logthis('Failed to parse '.$filepath.'/'.$fname.' for embedded media: '.$parse_result); |
|
} |
|
} |
$fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file, |
$fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file, |
$docuhome); |
$home); |
if ($fetchresult eq 'ok') { |
if ($fetchresult eq 'ok') { |
return '/uploaded/'.$fpath.'/'.$fname; |
return '/uploaded/'.$fpath.'/'.$fname; |
} else { |
} else { |
&logthis('Failed to transfer '.$docudom.'/'.$docuname.'/'.$file. |
&logthis('Failed to transfer '.$docudom.'/'.$docuname.'/'.$file. |
' to host '.$docuhome.': '.$fetchresult); |
' to host '.$home.': '.$fetchresult); |
return '/adm/notfound.html'; |
return '/adm/notfound.html'; |
} |
} |
} |
} |
} |
} |
unless ( $fetchresult eq 'ok') { |
unless ( $fetchresult eq 'ok') { |
&logthis('Failed to transfer '.$docudom.'/'.$docuname.'/'.$file. |
&logthis('Failed to transfer '.$docudom.'/'.$docuname.'/'.$file. |
' to host '.$docuhome.': '.$fetchresult); |
' to host '.$home.': '.$fetchresult); |
} |
} |
return $fetchresult; |
return $fetchresult; |
} |
} |
|
|
|
sub build_filepath { |
|
my ($fpath) = @_; |
|
my $filepath=$perlvar{'lonDocRoot'}.'/userfiles'; |
|
unless ($fpath eq '') { |
|
my @parts=split('/',$fpath); |
|
foreach my $part (@parts) { |
|
$filepath.= '/'.$part; |
|
if ((-e $filepath)!=1) { |
|
mkdir($filepath,0777); |
|
} |
|
} |
|
} |
|
return $filepath; |
|
} |
|
|
|
sub store_edited_file { |
|
my ($primary_url,$content,$docudom,$docuname,$fetchresult) = @_; |
|
my $file = $primary_url; |
|
$file =~ s#^/uploaded/$docudom/$docuname/##; |
|
my $fpath = ''; |
|
my $fname = $file; |
|
($fpath,$fname) = ($file =~ m|^(.*)/([^/]+)$|); |
|
$fpath=$docudom.'/'.$docuname.'/'.$fpath; |
|
my $filepath = &build_filepath($fpath); |
|
open(my $fh,'>'.$filepath.'/'.$fname); |
|
print $fh $content; |
|
close($fh); |
|
my $home=&homeserver($docuname,$docudom); |
|
$$fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$file, |
|
$home); |
|
if ($$fetchresult eq 'ok') { |
|
return '/uploaded/'.$fpath.'/'.$fname; |
|
} else { |
|
&logthis('Failed to transfer '.$docudom.'/'.$docuname.'/'.$file. |
|
' to host '.$home.': '.$$fetchresult); |
|
return '/adm/notfound.html'; |
|
} |
|
} |
|
|
sub clean_filename { |
sub clean_filename { |
my ($fname)=@_; |
my ($fname)=@_; |
# Replace Windows backslashes by forward slashes |
# Replace Windows backslashes by forward slashes |
Line 1230 sub clean_filename {
|
Line 1280 sub clean_filename {
|
|
|
|
|
sub userfileupload { |
sub userfileupload { |
my ($formname,$coursedoc,$subdir)=@_; |
my ($formname,$coursedoc,$subdir,$parser,$allfiles,$codebase)=@_; |
if (!defined($subdir)) { $subdir='unknown'; } |
if (!defined($subdir)) { $subdir='unknown'; } |
my $fname=$env{'form.'.$formname.'.filename'}; |
my $fname=$env{'form.'.$formname.'.filename'}; |
$fname=&clean_filename($fname); |
$fname=&clean_filename($fname); |
Line 1254 sub userfileupload {
|
Line 1304 sub userfileupload {
|
return $fullpath.'/'.$fname; |
return $fullpath.'/'.$fname; |
} |
} |
# Create the directory if not present |
# Create the directory if not present |
my $docuname=''; |
|
my $docudom=''; |
|
my $docuhome=''; |
|
$fname="$subdir/$fname"; |
$fname="$subdir/$fname"; |
if ($coursedoc) { |
if ($coursedoc) { |
$docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
$docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
$docuhome=$env{'course.'.$env{'request.course.id'}.'.home'}; |
if ($env{'form.folder'} =~ m/^(default|supplemental)/) { |
if ($env{'form.folder'} =~ m/^default/) { |
return &finishuserfileupload($docuname,$docudom, |
return &finishuserfileupload($docuname,$docudom,$docuhome,$formname,$fname); |
$formname,$fname,$parser,$allfiles, |
|
$codebase); |
} else { |
} else { |
$fname=$env{'form.folder'}.'/'.$fname; |
$fname=$env{'form.folder'}.'/'.$fname; |
return &process_coursefile('uploaddoc',$docuname,$docudom,$docuhome,$fname,$formname); |
return &process_coursefile('uploaddoc',$docuname,$docudom, |
|
$fname,$formname,$parser, |
|
$allfiles,$codebase); |
} |
} |
} else { |
} else { |
$docuname=$env{'user.name'}; |
my $docuname=$env{'user.name'}; |
$docudom=$env{'user.domain'}; |
my $docudom=$env{'user.domain'}; |
$docuhome=$env{'user.home'}; |
return &finishuserfileupload($docuname,$docudom,$formname, |
return &finishuserfileupload($docuname,$docudom,$docuhome,$formname,$fname); |
$fname,$parser,$allfiles,$codebase); |
} |
} |
} |
} |
|
|
sub finishuserfileupload { |
sub finishuserfileupload { |
my ($docuname,$docudom,$docuhome,$formname,$fname)=@_; |
my ($docuname,$docudom,$formname,$fname,$parser,$allfiles,$codebase) = @_; |
my $path=$docudom.'/'.$docuname.'/'; |
my $path=$docudom.'/'.$docuname.'/'; |
my $filepath=$perlvar{'lonDocRoot'}; |
my $filepath=$perlvar{'lonDocRoot'}; |
my ($fnamepath,$file); |
my ($fnamepath,$file); |
Line 1300 sub finishuserfileupload {
|
Line 1350 sub finishuserfileupload {
|
print FH $env{'form.'.$formname}; |
print FH $env{'form.'.$formname}; |
close(FH); |
close(FH); |
} |
} |
|
if ($parser eq 'parse') { |
|
my $parse_result = &extract_embedded_items($filepath,$file,$allfiles, |
|
$codebase); |
|
unless ($parse_result eq 'ok') { |
|
&logthis('Failed to parse '.$filepath.$file. |
|
' for embedded media: '.$parse_result); |
|
} |
|
} |
# Notify homeserver to grep it |
# Notify homeserver to grep it |
# |
# |
|
my $docuhome=&homeserver($docuname,$docudom); |
my $fetchresult= &reply('fetchuserfile:'.$path.$file,$docuhome); |
my $fetchresult= &reply('fetchuserfile:'.$path.$file,$docuhome); |
if ($fetchresult eq 'ok') { |
if ($fetchresult eq 'ok') { |
# |
# |
Line 1314 sub finishuserfileupload {
|
Line 1373 sub finishuserfileupload {
|
} |
} |
} |
} |
|
|
|
sub extract_embedded_items { |
|
my ($filepath,$file,$allfiles,$codebase,$content) = @_; |
|
my @state = (); |
|
my %javafiles = ( |
|
codebase => '', |
|
code => '', |
|
archive => '' |
|
); |
|
my %mediafiles = ( |
|
src => '', |
|
movie => '', |
|
); |
|
my $p; |
|
if ($content) { |
|
$p = HTML::LCParser->new($content); |
|
} else { |
|
$p = HTML::LCParser->new($filepath.'/'.$file); |
|
} |
|
while (my $t=$p->get_token()) { |
|
if ($t->[0] eq 'S') { |
|
my ($tagname, $attr) = ($t->[1],$t->[2]); |
|
push (@state, $tagname); |
|
if (lc($tagname) eq 'allow') { |
|
&add_filetype($allfiles,$attr->{'src'},'src'); |
|
} |
|
if (lc($tagname) eq 'img') { |
|
&add_filetype($allfiles,$attr->{'src'},'src'); |
|
} |
|
if (lc($tagname) eq 'script') { |
|
if ($attr->{'archive'} =~ /\.jar$/i) { |
|
&add_filetype($allfiles,$attr->{'archive'},'archive'); |
|
} else { |
|
&add_filetype($allfiles,$attr->{'src'},'src'); |
|
} |
|
} |
|
if (lc($tagname) eq 'link') { |
|
if (lc($attr->{'rel'}) eq 'stylesheet') { |
|
&add_filetype($allfiles,$attr->{'href'},'href'); |
|
} |
|
} |
|
if (lc($tagname) eq 'object' || |
|
(lc($tagname) eq 'embed' && lc($state[-2]) ne 'object')) { |
|
foreach my $item (keys(%javafiles)) { |
|
$javafiles{$item} = ''; |
|
} |
|
} |
|
if (lc($state[-2]) eq 'object' && lc($tagname) eq 'param') { |
|
my $name = lc($attr->{'name'}); |
|
foreach my $item (keys(%javafiles)) { |
|
if ($name eq $item) { |
|
$javafiles{$item} = $attr->{'value'}; |
|
last; |
|
} |
|
} |
|
foreach my $item (keys(%mediafiles)) { |
|
if ($name eq $item) { |
|
&add_filetype($allfiles, $attr->{'value'}, 'value'); |
|
last; |
|
} |
|
} |
|
} |
|
if (lc($tagname) eq 'embed' || lc($tagname) eq 'applet') { |
|
foreach my $item (keys(%javafiles)) { |
|
if ($attr->{$item}) { |
|
$javafiles{$item} = $attr->{$item}; |
|
last; |
|
} |
|
} |
|
foreach my $item (keys(%mediafiles)) { |
|
if ($attr->{$item}) { |
|
&add_filetype($allfiles,$attr->{$item},$item); |
|
last; |
|
} |
|
} |
|
} |
|
} elsif ($t->[0] eq 'E') { |
|
my ($tagname) = ($t->[1]); |
|
if ($javafiles{'codebase'} ne '') { |
|
$javafiles{'codebase'} .= '/'; |
|
} |
|
if (lc($tagname) eq 'applet' || |
|
lc($tagname) eq 'object' || |
|
(lc($tagname) eq 'embed' && lc($state[-2]) ne 'object') |
|
) { |
|
foreach my $item (keys(%javafiles)) { |
|
if ($item ne 'codebase' && $javafiles{$item} ne '') { |
|
my $file=$javafiles{'codebase'}.$javafiles{$item}; |
|
&add_filetype($allfiles,$file,$item); |
|
} |
|
} |
|
} |
|
pop @state; |
|
} |
|
} |
|
return 'ok'; |
|
} |
|
|
|
sub add_filetype { |
|
my ($allfiles,$file,$type)=@_; |
|
if (exists($allfiles->{$file})) { |
|
unless (grep/^\Q$type\E$/, @{$allfiles->{$file}}) { |
|
push(@{$allfiles->{$file}}, &escape($type)); |
|
} |
|
} else { |
|
@{$allfiles->{$file}} = (&escape($type)); |
|
} |
|
} |
|
|
sub removeuploadedurl { |
sub removeuploadedurl { |
my ($url)=@_; |
my ($url)=@_; |
my (undef,undef,$udom,$uname,$fname)=split('/',$url,5); |
my (undef,undef,$udom,$uname,$fname)=split('/',$url,5); |
Line 1442 sub flushcourselogs {
|
Line 1609 sub flushcourselogs {
|
delete $userrolehash{$entry}; |
delete $userrolehash{$entry}; |
} |
} |
} |
} |
|
# |
|
# Reverse lookup of domain roles (dc, ad, li, sc, au) |
|
# |
|
my %domrolebuffer = (); |
|
foreach my $entry (keys %domainrolehash) { |
|
my ($role,$uname,$udom,$runame,$rudom,$rsec)=split/:/,$entry; |
|
if ($domrolebuffer{$rudom}) { |
|
$domrolebuffer{$rudom}.='&'.&escape($entry). |
|
'='.&escape($domainrolehash{$entry}); |
|
} else { |
|
$domrolebuffer{$rudom}.=&escape($entry). |
|
'='.&escape($domainrolehash{$entry}); |
|
} |
|
delete $domainrolehash{$entry}; |
|
} |
|
foreach my $dom (keys(%domrolebuffer)) { |
|
foreach my $tryserver (keys %libserv) { |
|
if ($hostdom{$tryserver} eq $dom) { |
|
unless (&reply('domroleput:'.$dom.':'. |
|
$domrolebuffer{$dom},$tryserver) eq 'ok') { |
|
&logthis('Put of domain roles failed for '.$dom.' and '.$tryserver); |
|
} |
|
} |
|
} |
|
} |
$dumpcount++; |
$dumpcount++; |
} |
} |
|
|
Line 1475 sub courseacclog {
|
Line 1667 sub courseacclog {
|
my $fnsymb=shift; |
my $fnsymb=shift; |
unless ($env{'request.course.id'}) { return ''; } |
unless ($env{'request.course.id'}) { return ''; } |
my $what=$fnsymb.':'.$env{'user.name'}.':'.$env{'user.domain'}; |
my $what=$fnsymb.':'.$env{'user.name'}.':'.$env{'user.domain'}; |
if ($fnsymb=~/(problem|exam|quiz|assess|survey|form|page)$/) { |
if ($fnsymb=~/(problem|exam|quiz|assess|survey|form|task|page)$/) { |
$what.=':POST'; |
$what.=':POST'; |
# FIXME: Probably ought to escape things.... |
# FIXME: Probably ought to escape things.... |
foreach (keys %env) { |
foreach (keys %env) { |
Line 1517 sub linklog {
|
Line 1709 sub linklog {
|
|
|
sub userrolelog { |
sub userrolelog { |
my ($trole,$username,$domain,$area,$tstart,$tend)=@_; |
my ($trole,$username,$domain,$area,$tstart,$tend)=@_; |
if (($trole=~/^ca/) || ($trole=~/^in/) || |
if (($trole=~/^ca/) || ($trole=~/^aa/) || |
($trole=~/^cc/) || ($trole=~/^ep/) || |
($trole=~/^in/) || ($trole=~/^cc/) || |
($trole=~/^cr/) || ($trole=~/^ta/)) { |
($trole=~/^ep/) || ($trole=~/^cr/) || |
|
($trole=~/^ta/)) { |
my (undef,$rudom,$runame,$rsec)=split(/\//,$area); |
my (undef,$rudom,$runame,$rsec)=split(/\//,$area); |
$userrolehash |
$userrolehash |
{$trole.':'.$username.':'.$domain.':'.$runame.':'.$rudom.':'.$rsec} |
{$trole.':'.$username.':'.$domain.':'.$runame.':'.$rudom.':'.$rsec} |
=$tend.':'.$tstart; |
=$tend.':'.$tstart; |
} |
} |
|
if (($trole=~/^dc/) || ($trole=~/^ad/) || |
|
($trole=~/^li/) || ($trole=~/^li/) || |
|
($trole=~/^au/) || ($trole=~/^dg/) || |
|
($trole=~/^sc/)) { |
|
my (undef,$rudom,$runame,$rsec)=split(/\//,$area); |
|
$domainrolehash |
|
{$trole.':'.$username.':'.$domain.':'.$runame.':'.$rudom.':'.$rsec} |
|
= $tend.':'.$tstart; |
|
} |
} |
} |
|
|
sub get_course_adv_roles { |
sub get_course_adv_roles { |
Line 1548 sub get_course_adv_roles {
|
Line 1750 sub get_course_adv_roles {
|
if ($username eq '' || $domain eq '') { next; } |
if ($username eq '' || $domain eq '') { next; } |
if ((&privileged($username,$domain)) && |
if ((&privileged($username,$domain)) && |
(!$nothide{$username.':'.$domain})) { next; } |
(!$nothide{$username.':'.$domain})) { next; } |
|
if ($role eq 'cr') { next; } |
my $key=&plaintext($role); |
my $key=&plaintext($role); |
|
if ($role =~ /^cr/) { |
|
$key=(split('/',$role))[3]; |
|
} |
if ($section) { $key.=' (Sec/Grp '.$section.')'; } |
if ($section) { $key.=' (Sec/Grp '.$section.')'; } |
if ($returnhash{$key}) { |
if ($returnhash{$key}) { |
$returnhash{$key}.=','.$username.':'.$domain; |
$returnhash{$key}.=','.$username.':'.$domain; |
Line 1639 sub courseiddump {
|
Line 1845 sub courseiddump {
|
return %returnhash; |
return %returnhash; |
} |
} |
|
|
# |
# ---------------------------------------------------------- DC e-mail |
|
|
|
sub dcmailput { |
|
my ($domain,$msgid,$contents,$server)=@_; |
|
my $status = &Apache::lonnet::critical( |
|
'dcmailput:'.$domain.':'.&Apache::lonnet::escape($msgid).'='. |
|
&Apache::lonnet::escape($$contents{$server}),$server); |
|
return $status; |
|
} |
|
|
|
sub dcmaildump { |
|
my ($dom,$startdate,$enddate,$senders) = @_; |
|
my %returnhash=(); |
|
foreach my $tryserver (keys(%libserv)) { |
|
if ($hostdom{$tryserver} eq $dom) { |
|
%{$returnhash{$tryserver}}=(); |
|
my $cmd='dcmaildump:'.$dom.':'. |
|
&escape($startdate).':'.&escape($enddate).':'; |
|
my @esc_senders=map { &escape($_)} @$senders; |
|
$cmd.=&escape(join('&',@esc_senders)); |
|
foreach (split(/\&/,&reply($cmd,$tryserver))) { |
|
my ($key,$value) = split(/\=/,$_); |
|
if (($key) && ($value)) { |
|
$returnhash{$tryserver}{&unescape($key)} = &unescape($value); |
|
} |
|
} |
|
} |
|
} |
|
return %returnhash; |
|
} |
|
# ---------------------------------------------------------- Domain roles |
|
|
|
sub get_domain_roles { |
|
my ($dom,$roles,$startdate,$enddate)=@_; |
|
if (undef($startdate) || $startdate eq '') { |
|
$startdate = '.'; |
|
} |
|
if (undef($enddate) || $enddate eq '') { |
|
$enddate = '.'; |
|
} |
|
my $rolelist = join(':',@{$roles}); |
|
my %personnel = (); |
|
foreach my $tryserver (keys(%libserv)) { |
|
if ($hostdom{$tryserver} eq $dom) { |
|
%{$personnel{$tryserver}}=(); |
|
foreach ( |
|
split(/\&/,&reply('domrolesdump:'.$dom.':'. |
|
&escape($startdate).':'.&escape($enddate).':'. |
|
&escape($rolelist), $tryserver))) { |
|
my($key,$value) = split(/\=/,$_); |
|
if (($key) && ($value)) { |
|
$personnel{$tryserver}{&unescape($key)} = &unescape($value); |
|
} |
|
} |
|
} |
|
} |
|
return %personnel; |
|
} |
|
|
# ----------------------------------------------------------- Check out an item |
# ----------------------------------------------------------- Check out an item |
|
|
sub get_first_access { |
sub get_first_access { |
Line 2314 sub rolesinit {
|
Line 2578 sub rolesinit {
|
if ($_!~/^rolesdef_/) { |
if ($_!~/^rolesdef_/) { |
my ($area,$role)=split(/=/,$_); |
my ($area,$role)=split(/=/,$_); |
$area=~s/\_\w\w$//; |
$area=~s/\_\w\w$//; |
|
|
my ($trole,$tend,$tstart); |
my ($trole,$tend,$tstart); |
if ($role=~/^cr/) { |
if ($role=~/^cr/) { |
($trole,my $trest)=($role=~m|^(cr/\w+/\w+/[a-zA-Z0-9]+)_(.*)$|); |
if ($role=~m|^(cr/\w+/\w+/[a-zA-Z0-9]+)_(.*)$|) { |
($tend,$tstart)=split('_',$trest); |
($trole,my $trest)=($role=~m|^(cr/\w+/\w+/[a-zA-Z0-9]+)_(.*)$|); |
|
($tend,$tstart)=split('_',$trest); |
|
} else { |
|
$trole=$role; |
|
} |
} else { |
} else { |
($trole,$tend,$tstart)=split(/_/,$role); |
($trole,$tend,$tstart)=split(/_/,$role); |
} |
} |
Line 2334 sub rolesinit {
|
Line 2601 sub rolesinit {
|
&standard_roleprivs(\%allroles,$trole,$tdomain,$spec,$trest,$area); |
&standard_roleprivs(\%allroles,$trole,$tdomain,$spec,$trest,$area); |
} |
} |
} |
} |
} |
} |
} |
} |
my ($author,$adv) = &set_userprivs(\$userroles,\%allroles); |
my ($author,$adv) = &set_userprivs(\$userroles,\%allroles); |
$userroles.='user.adv='.$adv."\n". |
$userroles.='user.adv='.$adv."\n". |
Line 2561 sub convert_dump_to_currentdump{
|
Line 2828 sub convert_dump_to_currentdump{
|
return \%returnhash; |
return \%returnhash; |
} |
} |
|
|
|
# ------------------------------------------------------ critical inc interface |
|
|
|
sub cinc { |
|
return &inc(@_,'critical'); |
|
} |
|
|
# --------------------------------------------------------------- inc interface |
# --------------------------------------------------------------- inc interface |
|
|
sub inc { |
sub inc { |
my ($namespace,$store,$udomain,$uname) = @_; |
my ($namespace,$store,$udomain,$uname,$critical) = @_; |
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 2582 sub inc {
|
Line 2855 sub inc {
|
} |
} |
} |
} |
$items=~s/\&$//; |
$items=~s/\&$//; |
return &reply("inc:$udomain:$uname:$namespace:$items",$uhome); |
if ($critical) { |
|
return &critical("inc:$udomain:$uname:$namespace:$items",$uhome); |
|
} else { |
|
return &reply("inc:$udomain:$uname:$namespace:$items",$uhome); |
|
} |
} |
} |
|
|
# --------------------------------------------------------------- put interface |
# --------------------------------------------------------------- put interface |
Line 2600 sub put {
|
Line 2877 sub put {
|
return &reply("put:$udomain:$uname:$namespace:$items",$uhome); |
return &reply("put:$udomain:$uname:$namespace:$items",$uhome); |
} |
} |
|
|
# ---------------------------------------------------------- putstore interface |
# ------------------------------------------------------------ newput interface |
|
|
|
sub newput { |
|
my ($namespace,$storehash,$udomain,$uname)=@_; |
|
if (!$udomain) { $udomain=$env{'user.domain'}; } |
|
if (!$uname) { $uname=$env{'user.name'}; } |
|
my $uhome=&homeserver($uname,$udomain); |
|
my $items=''; |
|
foreach my $key (keys(%$storehash)) { |
|
$items.=&escape($key).'='.&freeze_escape($$storehash{$key}).'&'; |
|
} |
|
$items=~s/\&$//; |
|
return &reply("newput:$udomain:$uname:$namespace:$items",$uhome); |
|
} |
|
|
|
# --------------------------------------------------------- putstore interface |
|
|
sub putstore { |
sub putstore { |
my ($namespace,$storehash,$udomain,$uname)=@_; |
my ($namespace,$storehash,$udomain,$uname)=@_; |
if (!$udomain) { $udomain=$env{'user.domain'}; } |
if (!$udomain) { $udomain=$env{'user.domain'}; } |
Line 2639 sub cput {
|
Line 2931 sub cput {
|
return &critical("put:$udomain:$uname:$namespace:$items",$uhome); |
return &critical("put:$udomain:$uname:$namespace:$items",$uhome); |
} |
} |
|
|
# ------------------------------------------------------ critical inc interface |
|
|
|
sub cinc { |
|
my ($namespace,$storehash,$udomain,$uname)=@_; |
|
if (!$udomain) { $udomain=$env{'user.domain'}; } |
|
if (!$uname) { $uname=$env{'user.name'}; } |
|
my $uhome=&homeserver($uname,$udomain); |
|
my $items=''; |
|
foreach (keys %$storehash) { |
|
$items.=escape($_).'='.&freeze_escape($$storehash{$_}).'&'; |
|
} |
|
$items=~s/\&$//; |
|
return &critical("inc:$udomain:$uname:$namespace:$items",$uhome); |
|
} |
|
|
|
# -------------------------------------------------------------- eget interface |
# -------------------------------------------------------------- eget interface |
|
|
sub eget { |
sub eget { |
Line 2677 sub eget {
|
Line 2954 sub eget {
|
return %returnhash; |
return %returnhash; |
} |
} |
|
|
|
# ------------------------------------------------------------ tmpput interface |
|
sub tmpput { |
|
my ($storehash,$server)=@_; |
|
my $items=''; |
|
foreach (keys(%$storehash)) { |
|
$items.=&escape($_).'='.&freeze_escape($$storehash{$_}).'&'; |
|
} |
|
$items=~s/\&$//; |
|
return &reply("tmpput:$items",$server); |
|
} |
|
|
|
# ------------------------------------------------------------ tmpget interface |
|
sub tmpget { |
|
my ($token)=@_; |
|
my $rep=&reply("tmpget:$token",$perlvar{'lonHostID'}); |
|
my %returnhash; |
|
foreach my $item (split(/\&/,$rep)) { |
|
my ($key,$value)=split(/=/,$item); |
|
$returnhash{&unescape($key)}=&thaw_unescape($value); |
|
} |
|
return %returnhash; |
|
} |
|
|
# ---------------------------------------------- Custom access rule evaluation |
# ---------------------------------------------- Custom access rule evaluation |
|
|
sub customaccess { |
sub customaccess { |
Line 2730 sub allowed {
|
Line 3030 sub allowed {
|
|
|
# Free bre access to user's own portfolio contents |
# Free bre access to user's own portfolio contents |
my ($space,$domain,$name,$dir)=split('/',$uri); |
my ($space,$domain,$name,$dir)=split('/',$uri); |
if (($space=~/^(uploaded|ediupload)$/) && ($env{'user.name'} eq $name) && |
if (($space=~/^(uploaded|editupload)$/) && ($env{'user.name'} eq $name) && |
($env{'user.domain'} eq $domain) && ('portfolio' eq $dir)) { |
($env{'user.domain'} eq $domain) && ('portfolio' eq $dir)) { |
return 'F'; |
return 'F'; |
} |
} |
Line 2798 sub allowed {
|
Line 3098 sub allowed {
|
$thisallowed.=$1; |
$thisallowed.=$1; |
} |
} |
|
|
# URI is an uploaded document for this course |
# URI is an uploaded document for this course, default permissions don't matter |
# not allowing 'edit' access (editupload) to uploaded course docs |
# not allowing 'edit' access (editupload) to uploaded course docs |
if (($priv eq 'bre') && ($uri=~m|^uploaded/|)) { |
if (($priv eq 'bre') && ($uri=~m|^uploaded/|)) { |
|
$thisallowed=''; |
my $refuri=$env{'httpref.'.$orguri}; |
my $refuri=$env{'httpref.'.$orguri}; |
if ($refuri) { |
if ($refuri) { |
if ($refuri =~ m|^/adm/|) { |
if ($refuri =~ m|^/adm/|) { |
$thisallowed='F'; |
$thisallowed='F'; |
|
} else { |
|
$refuri=&declutter($refuri); |
|
my ($match) = &is_on_map($refuri); |
|
if ($match) { |
|
$thisallowed='F'; |
|
} |
} |
} |
} |
} |
} |
} |
Line 2817 sub allowed {
|
Line 3124 sub allowed {
|
|
|
# If this is generating or modifying users, exit with special codes |
# If this is generating or modifying users, exit with special codes |
|
|
if (':csu:cdc:ccc:cin:cta:cep:ccr:cst:cad:cli:cau:cdg:cca:'=~/\:\Q$priv\E\:/) { |
if (':csu:cdc:ccc:cin:cta:cep:ccr:cst:cad:cli:cau:cdg:cca:caa:'=~/\:\Q$priv\E\:/) { |
|
if (($priv eq 'cca') || ($priv eq 'caa')) { |
|
my ($audom,$auname)=split('/',$uri); |
|
# no author name given, so this just checks on the general right to make a co-author in this domain |
|
unless ($auname) { return $thisallowed; } |
|
# an author name is given, so we are about to actually make a co-author for a certain account |
|
if (($auname ne $env{'user.name'} && $env{'request.role'} !~ /^dc\./) || |
|
(($audom ne $env{'user.domain'} && $env{'request.role'} !~ /^dc\./) && |
|
($audom ne $env{'request.role.domain'}))) { return ''; } |
|
} |
return $thisallowed; |
return $thisallowed; |
} |
} |
# |
# |
Line 3013 sub allowed {
|
Line 3329 sub allowed {
|
# --------------------------------------------------- Is a resource on the map? |
# --------------------------------------------------- Is a resource on the map? |
|
|
sub is_on_map { |
sub is_on_map { |
my $uri=&declutter(shift); |
my $uri=&deversion(&declutter(shift)); |
$uri=~s/\.\d+\.(\w+)$/\.$1/; |
|
my @uriparts=split(/\//,$uri); |
my @uriparts=split(/\//,$uri); |
my $filename=$uriparts[$#uriparts]; |
my $filename=$uriparts[$#uriparts]; |
my $pathname=$uri; |
my $pathname=$uri; |
Line 3384 sub assignrole {
|
Line 3699 sub assignrole {
|
my $answer=&reply($command,&homeserver($uname,$udom)); |
my $answer=&reply($command,&homeserver($uname,$udom)); |
# log new user role if status is ok |
# log new user role if status is ok |
if ($answer eq 'ok') { |
if ($answer eq 'ok') { |
&userrolelog($mrole,$uname,$udom,$url,$start,$end); |
&userrolelog($role,$uname,$udom,$url,$start,$end); |
} |
} |
return $answer; |
return $answer; |
} |
} |
Line 3587 sub modify_student_enrollment {
|
Line 3902 sub modify_student_enrollment {
|
$cdom,$cnum); |
$cdom,$cnum); |
unless (($reply eq 'ok') || ($reply eq 'delayed')) { |
unless (($reply eq 'ok') || ($reply eq 'delayed')) { |
return 'error: '.$reply; |
return 'error: '.$reply; |
|
} else { |
|
&devalidate_getsection_cache($udom,$uname,$cid); |
} |
} |
# Add student role to user |
# Add student role to user |
my $uurl='/'.$cid; |
my $uurl='/'.$cid; |
Line 3691 sub createcourse {
|
Line 4008 sub createcourse {
|
</map> |
</map> |
ENDINITMAP |
ENDINITMAP |
$topurl=&declutter( |
$topurl=&declutter( |
&finishuserfileupload($uname,$udom,$uhome,'initmap','default.sequence') |
&finishuserfileupload($uname,$udom,'initmap','default.sequence') |
); |
); |
} |
} |
# ----------------------------------------------------------- Write preferences |
# ----------------------------------------------------------- Write preferences |
Line 3758 sub mark_as_readonly {
|
Line 4075 sub mark_as_readonly {
|
my %current_permissions = &dump('file_permissions',$domain,$user); |
my %current_permissions = &dump('file_permissions',$domain,$user); |
my ($tmp)=keys(%current_permissions); |
my ($tmp)=keys(%current_permissions); |
if ($tmp=~/^error:/) { undef(%current_permissions); } |
if ($tmp=~/^error:/) { undef(%current_permissions); } |
|
|
foreach my $file (@{$files}) { |
foreach my $file (@{$files}) { |
push(@{$current_permissions{$file}},$what); |
push(@{$current_permissions{$file}},$what); |
} |
} |
Line 3837 sub files_not_in_path {
|
Line 4153 sub files_not_in_path {
|
|
|
#--------------------------------------------------------------Get Marked as Read Only |
#--------------------------------------------------------------Get Marked as Read Only |
|
|
|
|
sub get_marked_as_readonly { |
sub get_marked_as_readonly { |
my ($domain,$user,$what) = @_; |
my ($domain,$user,$what) = @_; |
my %current_permissions = &dump('file_permissions',$domain,$user); |
my %current_permissions = &dump('file_permissions',$domain,$user); |
my ($tmp)=keys(%current_permissions); |
my ($tmp)=keys(%current_permissions); |
if ($tmp=~/^error:/) { undef(%current_permissions); } |
if ($tmp=~/^error:/) { undef(%current_permissions); } |
|
|
my @readonly_files; |
my @readonly_files; |
|
my $cmp1=$what; |
|
if (ref($what)) { $cmp1=join('',@{$what}) }; |
while (my ($file_name,$value) = each(%current_permissions)) { |
while (my ($file_name,$value) = each(%current_permissions)) { |
if (ref($value) eq "ARRAY"){ |
if (ref($value) eq "ARRAY"){ |
foreach my $stored_what (@{$value}) { |
foreach my $stored_what (@{$value}) { |
if ($stored_what eq $what) { |
my $cmp2=$stored_what; |
|
if (ref($stored_what)) { $cmp2=join('',@{$stored_what}) }; |
|
if ($cmp1 eq $cmp2) { |
push(@readonly_files, $file_name); |
push(@readonly_files, $file_name); |
} elsif (!defined($what)) { |
} elsif (!defined($what)) { |
push(@readonly_files, $file_name); |
push(@readonly_files, $file_name); |
Line 3882 sub get_marked_as_readonly_hash {
|
Line 4202 sub get_marked_as_readonly_hash {
|
# ------------------------------------------------------------ Unmark as Read Only |
# ------------------------------------------------------------ Unmark as Read Only |
|
|
sub unmark_as_readonly { |
sub unmark_as_readonly { |
# unmarks all files locked by $what |
# unmarks $file_name (if $file_name is defined), or all files locked by $what |
# for portfolio submissions, $what contains $crsid and $symb |
# for portfolio submissions, $what contains [$symb,$crsid] |
my ($domain,$user,$what) = @_; |
my ($domain,$user,$what,$file_name) = @_; |
|
my $symb_crs = $what; |
|
if (ref($what)) { $symb_crs=join('',@$what); } |
my %current_permissions = &dump('file_permissions',$domain,$user); |
my %current_permissions = &dump('file_permissions',$domain,$user); |
my ($tmp)=keys(%current_permissions); |
my ($tmp)=keys(%current_permissions); |
if ($tmp=~/^error:/) { undef(%current_permissions); } |
if ($tmp=~/^error:/) { undef(%current_permissions); } |
|
|
my @readonly_files = &get_marked_as_readonly($domain,$user,$what); |
my @readonly_files = &get_marked_as_readonly($domain,$user,$what); |
foreach my $file(@readonly_files){ |
foreach my $file (@readonly_files) { |
my $current_locks = $current_permissions{$file}; |
if (defined($file_name) && ($file_name ne $file)) { next; } |
|
my $current_locks = $current_permissions{$file}; |
my @new_locks; |
my @new_locks; |
my @del_keys; |
my @del_keys; |
if (ref($current_locks) eq "ARRAY"){ |
if (ref($current_locks) eq "ARRAY"){ |
foreach my $locker (@{$current_locks}) { |
foreach my $locker (@{$current_locks}) { |
unless ($locker eq $what) { |
my $compare=$locker; |
push(@new_locks, $what); |
if (ref($locker)) { $compare=join('',@{$locker}) }; |
|
if ($compare ne $symb_crs) { |
|
push(@new_locks, $locker); |
} |
} |
} |
} |
if (@new_locks > 0) { |
if (scalar(@new_locks) > 0) { |
$current_permissions{$file} = \@new_locks; |
$current_permissions{$file} = \@new_locks; |
} else { |
} else { |
push(@del_keys, $file); |
push(@del_keys, $file); |
&del('file_permissions',\@del_keys, $domain, $user); |
&del('file_permissions',\@del_keys, $domain, $user); |
delete $current_permissions{$file}; |
delete($current_permissions{$file}); |
} |
} |
} |
} |
} |
} |
Line 4122 sub get_courseresdata {
|
Line 4446 sub get_courseresdata {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub devalidateuserresdata { |
|
my ($uname,$udom)=@_; |
|
my $hashid="$udom:$uname"; |
|
&devalidate_cache_new('userres',$hashid); |
|
} |
|
|
sub get_userresdata { |
sub get_userresdata { |
my ($uname,$udom)=@_; |
my ($uname,$udom)=@_; |
#most student don\'t have any data set, check if there is some data |
#most student don\'t have any data set, check if there is some data |
Line 4145 sub get_userresdata {
|
Line 4475 sub get_userresdata {
|
$uname." at ".$udom.": ". |
$uname." at ".$udom.": ". |
$tmp."</font>"); |
$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); |
|
undef($tmp); # not really an error so don't send it back |
} |
} |
return $tmp; |
return $tmp; |
} |
} |
Line 4189 sub EXT_cache_status {
|
Line 4521 sub EXT_cache_status {
|
sub EXT_cache_set { |
sub EXT_cache_set { |
my ($target_domain,$target_user) = @_; |
my ($target_domain,$target_user) = @_; |
my $cachename = 'cache.EXT.'.$target_user.'.'.$target_domain; |
my $cachename = 'cache.EXT.'.$target_user.'.'.$target_domain; |
&appenv($cachename => time); |
#&appenv($cachename => time); |
} |
} |
|
|
# --------------------------------------------------------- Value of a Variable |
# --------------------------------------------------------- Value of a Variable |
Line 4225 sub EXT {
|
Line 4557 sub EXT {
|
if ($realm eq 'user') { |
if ($realm eq 'user') { |
# --------------------------------------------------------------- user.resource |
# --------------------------------------------------------------- user.resource |
if ($space eq 'resource') { |
if ($space eq 'resource') { |
if (defined($Apache::lonhomework::parsing_a_problem) || |
if ( (defined($Apache::lonhomework::parsing_a_problem) |
defined($Apache::lonhomework::parsing_a_task)) { |
|| defined($Apache::lonhomework::parsing_a_task)) |
|
&& |
|
($symbparm eq &symbread()) ) { |
return $Apache::lonhomework::history{$qualifierrest}; |
return $Apache::lonhomework::history{$qualifierrest}; |
} else { |
} else { |
my %restored; |
my %restored; |
Line 4620 sub metadata {
|
Line 4954 sub metadata {
|
} |
} |
my ($extension) = ($uri =~ /\.(\w+)$/); |
my ($extension) = ($uri =~ /\.(\w+)$/); |
foreach my $key (sort(keys(%packagetab))) { |
foreach my $key (sort(keys(%packagetab))) { |
#&logthis("extsion1 $extension $key !!"); |
|
#no specific packages #how's our extension |
#no specific packages #how's our extension |
if ($key!~/^extension_\Q$extension\E&/) { next; } |
if ($key!~/^extension_\Q$extension\E&/) { next; } |
&metadata_create_package_def($uri,$key,'extension_'.$extension, |
&metadata_create_package_def($uri,$key,'extension_'.$extension, |
Line 4708 sub metadata_generate_part0 {
|
Line 5041 sub metadata_generate_part0 {
|
'.type'}; |
'.type'}; |
my $olddis=$$metacache{':parameter_'.$allnames{$name}.'_'.$name. |
my $olddis=$$metacache{':parameter_'.$allnames{$name}.'_'.$name. |
'.display'}; |
'.display'}; |
my $expr='\\[Part: '.$allnames{$name}.'\\]'; |
my $expr='[Part: '.$allnames{$name}.']'; |
$olddis=~s/\Q$expr\E/\[Part: 0\]/; |
$olddis=~s/\Q$expr\E/\[Part: 0\]/; |
$$metacache{"$key.display"}=$olddis; |
$$metacache{"$key.display"}=$olddis; |
} |
} |
Line 4813 sub symbverify {
|
Line 5146 sub symbverify {
|
if ($ids) { |
if ($ids) { |
# ------------------------------------------------------------------- Has ID(s) |
# ------------------------------------------------------------------- Has ID(s) |
foreach (split(/\,/,$ids)) { |
foreach (split(/\,/,$ids)) { |
my ($mapid,$resid)=split(/\./,$_); |
my ($mapid,$resid)=split(/\./,$_); |
if ( |
if ( |
&symbclean(&declutter($bighash{'map_id_'.$mapid}).'___'.$resid.'___'.$thisfn) |
&symbclean(&declutter($bighash{'map_id_'.$mapid}).'___'.$resid.'___'.$thisfn) |
eq $symb) { |
eq $symb) { |
Line 4952 sub symbread {
|
Line 5285 sub symbread {
|
if ($#possibilities==0) { |
if ($#possibilities==0) { |
# ----------------------------------------------- There is only one possibility |
# ----------------------------------------------- There is only one possibility |
my ($mapid,$resid)=split(/\./,$ids); |
my ($mapid,$resid)=split(/\./,$ids); |
$syval=declutter($bighash{'map_id_'.$mapid}).'___'.$resid; |
$syval=&encode_symb($bighash{'map_id_'.$mapid}, |
|
$resid,$thisfn); |
} elsif (!$donotrecurse) { |
} elsif (!$donotrecurse) { |
# ------------------------------------------ There is more than one possibility |
# ------------------------------------------ There is more than one possibility |
my $realpossible=0; |
my $realpossible=0; |
Line 4962 sub symbread {
|
Line 5296 sub symbread {
|
my ($mapid,$resid)=split(/\./,$_); |
my ($mapid,$resid)=split(/\./,$_); |
if ($bighash{'map_type_'.$mapid} ne 'page') { |
if ($bighash{'map_type_'.$mapid} ne 'page') { |
$realpossible++; |
$realpossible++; |
$syval=declutter($bighash{'map_id_'.$mapid}). |
$syval=&encode_symb($bighash{'map_id_'.$mapid}, |
'___'.$resid; |
$resid,$thisfn); |
} |
} |
} |
} |
} |
} |
Line 4977 sub symbread {
|
Line 5311 sub symbread {
|
} |
} |
if ($syval) { |
if ($syval) { |
return $env{$cache_str}=$syval; |
return $env{$cache_str}=$syval; |
#return $env{$cache_str}=&symbclean($syval.'___'.$thisfn); |
|
} |
} |
} |
} |
&appenv('request.ambiguous' => $thisfn); |
&appenv('request.ambiguous' => $thisfn); |
Line 5447 sub filelocation {
|
Line 5780 sub filelocation {
|
if ($file=~m:^/~:) { # is a contruction space reference |
if ($file=~m:^/~:) { # is a contruction space reference |
$location = $file; |
$location = $file; |
$location =~ s:/~(.*?)/(.*):/home/$1/public_html/$2:; |
$location =~ s:/~(.*?)/(.*):/home/$1/public_html/$2:; |
|
} elsif ($file=~m:^/home/[^/]*/public_html/:) { |
|
# is a correct contruction space reference |
|
$location = $file; |
} elsif ($file=~/^\/*(uploaded|editupload)/) { # is an uploaded file |
} elsif ($file=~/^\/*(uploaded|editupload)/) { # is an uploaded file |
my ($udom,$uname,$filename)= |
my ($udom,$uname,$filename)= |
($file=~m -^/+(?:uploaded|editupload)/+([^/]+)/+([^/]+)/+(.*)$-); |
($file=~m -^/+(?:uploaded|editupload)/+([^/]+)/+([^/]+)/+(.*)$-); |
Line 5479 sub filelocation {
|
Line 5815 sub filelocation {
|
sub hreflocation { |
sub hreflocation { |
my ($dir,$file)=@_; |
my ($dir,$file)=@_; |
unless (($file=~m-^http://-i) || ($file=~m-^/-)) { |
unless (($file=~m-^http://-i) || ($file=~m-^/-)) { |
my $finalpath=filelocation($dir,$file); |
$file=filelocation($dir,$file); |
$finalpath=~s-^/home/httpd/html--; |
} |
$finalpath=~s-^/home/(\w+)/public_html/-/~$1/-; |
if ($file=~m-^\Q$perlvar{'lonDocRoot'}\E-) { |
return $finalpath; |
$file=~s-^\Q$perlvar{'lonDocRoot'}\E--; |
} elsif ($file=~m-^/home-) { |
} elsif ($file=~m-/home/(\w+)/public_html/-) { |
$file=~s-^/home/httpd/html--; |
|
$file=~s-^/home/(\w+)/public_html/-/~$1/-; |
$file=~s-^/home/(\w+)/public_html/-/~$1/-; |
return $file; |
} elsif ($file=~m-^\Q$perlvar{'lonUsersDir'}\E-) { |
|
$file=~s-^/home/httpd/lonUsers/([^/]*)/./././([^/]*)/userfiles/ |
|
-/uploaded/$1/$2/-x; |
} |
} |
return $file; |
return $file; |
} |
} |
Line 5688 BEGIN {
|
Line 6025 BEGIN {
|
|
|
sub get_iphost { |
sub get_iphost { |
if (%iphost) { return %iphost; } |
if (%iphost) { return %iphost; } |
|
my %name_to_ip; |
foreach my $id (keys(%hostname)) { |
foreach my $id (keys(%hostname)) { |
my $name=$hostname{$id}; |
my $name=$hostname{$id}; |
my $ip = gethostbyname($name); |
my $ip; |
if (!$ip || length($ip) ne 4) { |
if (!exists($name_to_ip{$name})) { |
&logthis("Skipping host $id name $name no IP found\n"); |
$ip = gethostbyname($name); |
next; |
if (!$ip || length($ip) ne 4) { |
|
&logthis("Skipping host $id name $name no IP found\n"); |
|
next; |
|
} |
|
$ip=inet_ntoa($ip); |
|
$name_to_ip{$name} = $ip; |
|
} else { |
|
$ip = $name_to_ip{$name}; |
} |
} |
$ip=inet_ntoa($ip); |
|
push(@{$iphost{$ip}},$id); |
push(@{$iphost{$ip}},$id); |
} |
} |
return %iphost; |
return %iphost; |
Line 6172 revokecustomrole($udom,$uname,$url,$role
|
Line 6516 revokecustomrole($udom,$uname,$url,$role
|
|
|
=item * |
=item * |
|
|
coursedescription($courseid) : course description |
coursedescription($courseid) : returns a hash of information about the |
|
specified course id, including all environment settings for the |
|
course, the description of the course will be in the hash under the |
|
key 'description' |
|
|
=item * |
=item * |
|
|
Line 6594 userspace, probably shouldn't be called
|
Line 6941 userspace, probably shouldn't be called
|
|
|
docuname: username or courseid of destination for the file |
docuname: username or courseid of destination for the file |
docudom: domain of user/course of destination for the file |
docudom: domain of user/course of destination for the file |
docuhome: loncapa id of the library server that is getting the file |
|
formname: same as for userfileupload() |
formname: same as for userfileupload() |
fname: filename (inculding subdirectories) for the file |
fname: filename (inculding subdirectories) for the file |
|
|