version 1.95, 2001/01/11 10:43:09
|
version 1.103, 2001/02/27 20:44:18
|
Line 13
|
Line 13
|
# 1: user needs to choose course |
# 1: user needs to choose course |
# 2: browse allowed |
# 2: browse allowed |
# definerole(rolename,sys,dom,cou) : define a custom role rolename |
# definerole(rolename,sys,dom,cou) : define a custom role rolename |
# set priviledges in format of lonTabs/roles.tab for |
# set privileges in format of lonTabs/roles.tab for |
# system, domain and course level, |
# system, domain and course level, |
# assignrole(udom,uname,url,role,end,start) : give a role to a user for the |
# assignrole(udom,uname,url,role,end,start) : give a role to a user for the |
# level given by url. Optional start and end dates |
# level given by url. Optional start and end dates |
Line 86
|
Line 86
|
# 05/01,06/01,09/01 Gerd Kortemeyer |
# 05/01,06/01,09/01 Gerd Kortemeyer |
# 09/01 Guy Albertelli |
# 09/01 Guy Albertelli |
# 09/01,10/01,11/01 Gerd Kortemeyer |
# 09/01,10/01,11/01 Gerd Kortemeyer |
|
# 02/27/01 Scott Harrison |
|
|
package Apache::lonnet; |
package Apache::lonnet; |
|
|
Line 248 sub appenv {
|
Line 249 sub appenv {
|
|
|
my $lockfh; |
my $lockfh; |
unless ($lockfh=Apache::File->new("$ENV{'user.environment'}")) { |
unless ($lockfh=Apache::File->new("$ENV{'user.environment'}")) { |
return 'error'; |
return 'error: '.$!; |
} |
} |
unless (flock($lockfh,LOCK_EX)) { |
unless (flock($lockfh,LOCK_EX)) { |
&logthis("<font color=blue>WARNING: ". |
&logthis("<font color=blue>WARNING: ". |
Line 261 sub appenv {
|
Line 262 sub appenv {
|
{ |
{ |
my $fh; |
my $fh; |
unless ($fh=Apache::File->new("$ENV{'user.environment'}")) { |
unless ($fh=Apache::File->new("$ENV{'user.environment'}")) { |
return 'error'; |
return 'error: '.$!; |
} |
} |
@oldenv=<$fh>; |
@oldenv=<$fh>; |
$fh->close(); |
$fh->close(); |
Line 693 sub coursedescription {
|
Line 694 sub coursedescription {
|
if ($chome ne 'no_host') { |
if ($chome ne 'no_host') { |
my $rep=reply("dump:$cdomain:$cnum:environment",$chome); |
my $rep=reply("dump:$cdomain:$cnum:environment",$chome); |
if ($rep ne 'con_lost') { |
if ($rep ne 'con_lost') { |
my $normalid=$courseid; |
my $normalid=$cdomain.'_'.$cnum; |
$normalid=~s/\//\_/g; |
|
my %envhash=(); |
my %envhash=(); |
my %returnhash=('home' => $chome, |
my %returnhash=('home' => $chome, |
'domain' => $cdomain, |
'domain' => $cdomain, |
Line 720 sub coursedescription {
|
Line 720 sub coursedescription {
|
return (); |
return (); |
} |
} |
|
|
# -------------------------------------------------------- Get user priviledges |
# -------------------------------------------------------- Get user privileges |
|
|
sub rolesinit { |
sub rolesinit { |
my ($domain,$username,$authhost)=@_; |
my ($domain,$username,$authhost)=@_; |
Line 794 sub rolesinit {
|
Line 794 sub rolesinit {
|
%thesepriv=(); |
%thesepriv=(); |
map { |
map { |
if ($_ ne '') { |
if ($_ ne '') { |
my ($priviledge,$restrictions)=split(/&/,$_); |
my ($privilege,$restrictions)=split(/&/,$_); |
if ($restrictions eq '') { |
if ($restrictions eq '') { |
$thesepriv{$priviledge}='F'; |
$thesepriv{$privilege}='F'; |
} else { |
} else { |
if ($thesepriv{$priviledge} ne 'F') { |
if ($thesepriv{$privilege} ne 'F') { |
$thesepriv{$priviledge}.=$restrictions; |
$thesepriv{$privilege}.=$restrictions; |
} |
} |
} |
} |
} |
} |
Line 909 sub eget {
|
Line 909 sub eget {
|
return %returnhash; |
return %returnhash; |
} |
} |
|
|
# ------------------------------------------------- Check for a user priviledge |
# ------------------------------------------------- Check for a user privilege |
|
|
sub allowed { |
sub allowed { |
my ($priv,$uri)=@_; |
my ($priv,$uri)=@_; |
Line 960 sub allowed {
|
Line 960 sub allowed {
|
return $thisallowed; |
return $thisallowed; |
} |
} |
# |
# |
# Gathered so far: system, domain and course wide priviledges |
# Gathered so far: system, domain and course wide privileges |
# |
# |
# Course: See if uri or referer is an individual resource that is part of |
# Course: See if uri or referer is an individual resource that is part of |
# the course |
# the course |
Line 1011 sub allowed {
|
Line 1011 sub allowed {
|
} |
} |
|
|
# |
# |
# Gathered now: all priviledges that could apply, and condition number |
# Gathered now: all privileges that could apply, and condition number |
# |
# |
# |
# |
# Full or no access? |
# Full or no access? |
Line 1595 sub EXT {
|
Line 1595 sub EXT {
|
if ($ENV{'request.course.id'}) { |
if ($ENV{'request.course.id'}) { |
# ----------------------------------------------------- Cascading lookup scheme |
# ----------------------------------------------------- Cascading lookup scheme |
my $symbp=&symbread(); |
my $symbp=&symbread(); |
unless ($symbp) { |
|
&logthis('No symb for '.$ENV{'request.filename'}); |
|
} |
|
my $mapp=(split(/\_\_\_/,$symbp))[0]; |
my $mapp=(split(/\_\_\_/,$symbp))[0]; |
|
|
my $symbparm=$symbp.'.'.$spacequalifierrest; |
my $symbparm=$symbp.'.'.$spacequalifierrest; |
Line 1642 sub EXT {
|
Line 1639 sub EXT {
|
} |
} |
|
|
# -------------------------------------------------------- second, check course |
# -------------------------------------------------------- second, check course |
my $section=''; |
|
if ($ENV{'request.course.sec'}) { |
|
$section='_'.$ENV{'request.course.sec'}; |
|
} |
|
my $reply=&reply('get:'. |
my $reply=&reply('get:'. |
$ENV{'course.'.$ENV{'request.course.id'}.$section.'.domain'}.':'. |
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.':'. |
$ENV{'course.'.$ENV{'request.course.id'}.$section.'.num'}. |
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}. |
':resourcedata:'. |
':resourcedata:'. |
&escape($seclevelr).'&'.&escape($seclevelm).'&'.&escape($seclevel).'&'. |
&escape($seclevelr).'&'.&escape($seclevelm).'&'.&escape($seclevel).'&'. |
&escape($courselevelr).'&'.&escape($courselevelm).'&'.&escape($courselevel), |
&escape($courselevelr).'&'.&escape($courselevelm).'&'.&escape($courselevel), |
$ENV{'course.'.$ENV{'request.course.id'}.$section.'.home'}); |
$ENV{'course.'.$ENV{'request.course.id'}.'.home'}); |
if ($reply!~/^error\:/) { |
if ($reply!~/^error\:/) { |
map { |
map { |
if ($_) { return &unescape($_); } |
if ($_) { return &unescape($_); } |
Line 1661 sub EXT {
|
Line 1655 sub EXT {
|
if (($reply=~/^con_lost/) || ($reply=~/^error\:/)) { |
if (($reply=~/^con_lost/) || ($reply=~/^error\:/)) { |
&logthis("<font color=blue>WARNING:". |
&logthis("<font color=blue>WARNING:". |
" Getting ".$reply." asking for ".$varname." for ". |
" Getting ".$reply." asking for ".$varname." for ". |
$ENV{'course.'.$ENV{'request.course.id'}.$section.'.num'}. |
$ENV{'course.'.$ENV{'request.course.id'}.'.num'}. |
' at '. |
' at '. |
$ENV{'course.'.$ENV{'request.course.id'}.$section.'.domain'}. |
$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}. |
' from '. |
' from '. |
$ENV{'course.'.$ENV{'request.course.id'}.$section.'.home'}. |
$ENV{'course.'.$ENV{'request.course.id'}.'.home'}. |
"</font>"); |
"</font>"); |
} |
} |
# ------------------------------------------------------ third, check map parms |
# ------------------------------------------------------ third, check map parms |
Line 1850 sub numval {
|
Line 1844 sub numval {
|
sub rndseed { |
sub rndseed { |
my $symb; |
my $symb; |
unless ($symb=&symbread()) { return time; } |
unless ($symb=&symbread()) { return time; } |
my $symbchck=unpack("%32C*",$symb); |
{ |
my $symbseed=numval($symb)%$symbchck; |
use integer; |
my $namechck=unpack("%32C*",$ENV{'user.name'}); |
my $symbchck=unpack("%32C*",$symb) << 27; |
my $nameseed=numval($ENV{'user.name'})%$namechck; |
my $symbseed=numval($symb) << 22; |
return int( $symbseed |
my $namechck=unpack("%32C*",$ENV{'user.name'}) << 17; |
.$nameseed |
my $nameseed=numval($ENV{'user.name'}) << 12; |
.unpack("%32C*",$ENV{'user.domain'}) |
my $domainseed=unpack("%32C*",$ENV{'user.domain'}) << 7; |
.unpack("%32C*",$ENV{'request.course.id'}) |
my $courseseed=unpack("%32C*",$ENV{'request.course.id'}); |
.$namechck |
my $num=$symbseed+$nameseed+$domainseed+$courseseed+$namechck+$symbchck; |
.$symbchck); |
#uncommenting these lines can break things! |
|
#&Apache::lonxml::debug("$symbseed:$nameseed;$domainseed|$courseseed;$namechck:$symbchck"); |
|
#&Apache::lonxml::debug("rndseed :$num:$symb"); |
|
return $num; |
|
} |
} |
} |
|
|
sub ireceipt { |
sub ireceipt { |