version 1.811, 2006/12/01 21:52:30
|
version 1.816.2.1, 2007/01/03 04:15:59
|
Line 53 use Time::HiRes qw( gettimeofday tv_inte
|
Line 53 use Time::HiRes qw( gettimeofday tv_inte
|
use Cache::Memcached; |
use Cache::Memcached; |
use Digest::MD5; |
use Digest::MD5; |
use Math::Random; |
use Math::Random; |
use lib '/home/httpd/lib/perl'; |
|
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA::Configuration; |
use LONCAPA::Configuration; |
|
|
Line 878 sub devalidate_getsection_cache {
|
Line 877 sub devalidate_getsection_cache {
|
&devalidate_cache_new('getsection',$hashid); |
&devalidate_cache_new('getsection',$hashid); |
} |
} |
|
|
|
sub courseid_to_courseurl { |
|
my ($courseid) = @_; |
|
#already url style courseid |
|
return $courseid if ($courseid =~ m{^/}); |
|
|
|
if (exists($env{'course.'.$courseid.'.num'})) { |
|
my $cnum = $env{'course.'.$courseid.'.num'}; |
|
my $cdom = $env{'course.'.$courseid.'.domain'}; |
|
return "/$cdom/$cnum"; |
|
} |
|
|
|
my %courseinfo=&Apache::lonnet::coursedescription($courseid); |
|
if (exists($courseinfo{'num'})) { |
|
return "/$courseinfo{'domain'}/$courseinfo{'num'}"; |
|
} |
|
|
|
return undef; |
|
} |
|
|
sub getsection { |
sub getsection { |
my ($udom,$unam,$courseid)=@_; |
my ($udom,$unam,$courseid)=@_; |
my $cachetime=1800; |
my $cachetime=1800; |
Line 901 sub getsection {
|
Line 919 sub getsection {
|
# If there is more than one expired role, choose the one which ended last. |
# If there is more than one expired role, choose the one which ended last. |
# If there is a role which has expired, return it. |
# If there is a role which has expired, return it. |
# |
# |
|
$courseid = &courseid_to_courseurl($courseid); |
foreach my $line (split(/\&/,&reply('dump:'.$udom.':'.$unam.':roles', |
foreach my $line (split(/\&/,&reply('dump:'.$udom.':'.$unam.':roles', |
&homeserver($unam,$udom)))) { |
&homeserver($unam,$udom)))) { |
my ($key,$value)=split(/\=/,$line,2); |
my ($key,$value)=split(/\=/,$line,2); |
Line 3044 sub getkeys {
|
Line 3063 sub getkeys {
|
my $rep=reply("keys:$udomain:$uname:$namespace",$uhome); |
my $rep=reply("keys:$udomain:$uname:$namespace",$uhome); |
my @keyarray=(); |
my @keyarray=(); |
foreach my $key (split(/\&/,$rep)) { |
foreach my $key (split(/\&/,$rep)) { |
|
next if ($key =~ /^error: 2 /); |
push(@keyarray,&unescape($key)); |
push(@keyarray,&unescape($key)); |
} |
} |
return @keyarray; |
return @keyarray; |
Line 3302 sub portfolio_access {
|
Line 3322 sub portfolio_access {
|
my ($requrl) = @_; |
my ($requrl) = @_; |
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); |
|
if ($result) { |
|
my %setters; |
|
if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { |
|
my ($startblock,$endblock) = |
|
&Apache::loncommon::blockcheck(\%setters,'port',$unum,$udom); |
|
if ($startblock && $endblock) { |
|
return 'B'; |
|
} |
|
} else { |
|
my ($startblock,$endblock) = |
|
&Apache::loncommon::blockcheck(\%setters,'port'); |
|
if ($startblock && $endblock) { |
|
return 'B'; |
|
} |
|
} |
|
} |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
return 'F'; |
return 'F'; |
} elsif ($result =~ /^[^:]+:guest_/) { |
} elsif ($result =~ /^[^:]+:guest_/) { |
Line 3522 sub is_portfolio_file {
|
Line 3558 sub is_portfolio_file {
|
sub customaccess { |
sub customaccess { |
my ($priv,$uri)=@_; |
my ($priv,$uri)=@_; |
my ($urole,$urealm)=split(/\./,$env{'request.role'},2); |
my ($urole,$urealm)=split(/\./,$env{'request.role'},2); |
my ($udom,$ucrs,$usec)=split(/\//,$urealm); |
my (undef,$udom,$ucrs,$usec)=split(/\//,$urealm); |
$udom = &LONCAPA::clean_domain($udom); |
$udom = &LONCAPA::clean_domain($udom); |
$ucrs = &LONCAPA::clean_username($ucrs); |
$ucrs = &LONCAPA::clean_username($ucrs); |
my $access=0; |
my $access=0; |
Line 3582 sub allowed {
|
Line 3618 sub allowed {
|
my ($space,$domain,$name,@dir)=split('/',$uri); |
my ($space,$domain,$name,@dir)=split('/',$uri); |
if (($space=~/^(uploaded|editupload)$/) && ($env{'user.name'} eq $name) && |
if (($space=~/^(uploaded|editupload)$/) && ($env{'user.name'} eq $name) && |
($env{'user.domain'} eq $domain) && ('portfolio' eq $dir[0])) { |
($env{'user.domain'} eq $domain) && ('portfolio' eq $dir[0])) { |
return 'F'; |
my %setters; |
|
my ($startblock,$endblock) = |
|
&Apache::loncommon::blockcheck(\%setters,'port'); |
|
if ($startblock && $endblock) { |
|
return 'B'; |
|
} else { |
|
return 'F'; |
|
} |
} |
} |
|
|
# bre access to group portfolio for rgf priv in group, or mdg or vcg in course. |
# bre access to group portfolio for rgf priv in group, or mdg or vcg in course. |
Line 3858 sub allowed {
|
Line 3901 sub allowed {
|
unless ($env{'request.course.id'}) { |
unless ($env{'request.course.id'}) { |
if ($thisallowed eq 'A') { |
if ($thisallowed eq 'A') { |
return 'A'; |
return 'A'; |
|
} elsif ($thisallowed eq 'B') { |
|
return 'B'; |
} else { |
} else { |
return '1'; |
return '1'; |
} |
} |
Line 3925 sub allowed {
|
Line 3970 sub allowed {
|
|
|
if ($thisallowed eq 'A') { |
if ($thisallowed eq 'A') { |
return 'A'; |
return 'A'; |
|
} elsif ($thisallowed eq 'B') { |
|
return 'B'; |
} |
} |
return 'F'; |
return 'F'; |
} |
} |
Line 4466 sub get_users_groups {
|
Line 4513 sub get_users_groups {
|
@usersgroups = split(/:/,$grouplist); |
@usersgroups = split(/:/,$grouplist); |
} else { |
} else { |
$grouplist = ''; |
$grouplist = ''; |
my %roleshash = &dump('roles',$udom,$uname,$courseid); |
my $courseurl = &courseid_to_courseurl($courseid); |
|
my %roleshash = &dump('roles',$udom,$uname,$courseurl); |
my ($tmp) = keys(%roleshash); |
my ($tmp) = keys(%roleshash); |
if ($tmp=~/^error:/) { |
if ($tmp=~/^error:/) { |
&logthis('Error retrieving roles: '.$tmp.' for '.$uname.':'.$udom); |
&logthis('Error retrieving roles: '.$tmp.' for '.$uname.':'.$udom); |
Line 4475 sub get_users_groups {
|
Line 4523 sub get_users_groups {
|
'.default_enrollment_end_date'}; |
'.default_enrollment_end_date'}; |
my $now = time; |
my $now = time; |
foreach my $key (keys(%roleshash)) { |
foreach my $key (keys(%roleshash)) { |
if ($key =~ /^\Q$courseid\E\/(\w+)\_gr$/) { |
if ($key =~ /^\Q$courseurl\E\/(\w+)\_gr$/) { |
my $group = $1; |
my $group = $1; |
if ($roleshash{$key} =~ /_(\d+)_(\d+)$/) { |
if ($roleshash{$key} =~ /_(\d+)_(\d+)$/) { |
my $start = $2; |
my $start = $2; |
Line 4930 ENDINITMAP
|
Line 4978 ENDINITMAP
|
return '/'.$udom.'/'.$uname; |
return '/'.$udom.'/'.$uname; |
} |
} |
|
|
|
sub is_course { |
|
my ($cdom,$cnum) = @_; |
|
my %courses = &courseiddump($cdom,'.',1,'.','.',$cnum,undef, |
|
undef,'.'); |
|
if (exists($courses{$cdom.'_'.$cnum})) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
# ---------------------------------------------------------- Assign Custom Role |
# ---------------------------------------------------------- Assign Custom Role |
|
|
sub assigncustomrole { |
sub assigncustomrole { |