version 1.101, 2001/01/30 01:31:05
|
version 1.115, 2001/03/22 16:13:22
|
Line 3
|
Line 3
|
# |
# |
# Functions for use by content handlers: |
# Functions for use by content handlers: |
# |
# |
|
# metadata_query(sql-query-string,custom-metadata-regex) : |
|
# returns file handle of where sql and |
|
# regex results will be stored for query |
# plaintext(short) : plain text explanation of short term |
# plaintext(short) : plain text explanation of short term |
# fileembstyle(ext) : embed style in page for file extension |
# fileembstyle(ext) : embed style in page for file extension |
# filedescription(ext) : descriptor text for file extension |
# filedescription(ext) : descriptor text for file extension |
Line 13
|
Line 16
|
# 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 85
|
Line 88
|
# 05/01/01 Guy Albertelli |
# 05/01/01 Guy Albertelli |
# 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,29/01 Gerd Kortemeyer |
# 09/01,10/01,11/01 Gerd Kortemeyer |
|
# 02/27/01 Scott Harrison |
|
# 3/2 Gerd Kortemeyer |
|
# 3/15 Scott Harrison |
|
# 3/19,3/20 Gerd Kortemeyer |
|
# 3/22 Scott Harrison |
|
|
package Apache::lonnet; |
package Apache::lonnet; |
|
|
Line 622 sub log {
|
Line 630 sub log {
|
return critical("log:$dom:$nam:$what",$hom); |
return critical("log:$dom:$nam:$what",$hom); |
} |
} |
|
|
|
# --------------------------------------------- Set Expire Date for Spreadsheet |
|
|
|
sub expirespread { |
|
my ($uname,$udom,$stype,$usymb)=@_; |
|
my $cid=$ENV{'request.course.id'}; |
|
if ($cid) { |
|
my $now=time; |
|
my $key=$uname.':'.$udom.':'.$stype.':'.$usymb; |
|
return &reply('put:'.$ENV{'course.'.$cid.'.domain'}.':'. |
|
$ENV{'course.'.$cid.'.num'}. |
|
':nohist_expirationdates:'. |
|
&escape($key).'='.$now, |
|
$ENV{'course.'.$cid.'.home'}) |
|
} |
|
return 'ok'; |
|
} |
|
|
|
# ----------------------------------------------------- Devalidate Spreadsheets |
|
|
|
sub devalidate { |
|
my $symb=shift; |
|
my $cid=$ENV{'request.course.id'}; |
|
if ($cid) { |
|
my $key=$ENV{'user.name'}.':'.$ENV{'user.domain'}.':'; |
|
my $status= |
|
&reply('del:'.$ENV{'course.'.$cid.'.domain'}.':'. |
|
$ENV{'course.'.$cid.'.num'}. |
|
':nohist_calculatedsheets:'. |
|
&escape($key.'studentcalc:'), |
|
$ENV{'course.'.$cid.'.home'}) |
|
.' '. |
|
&reply('del:'.$ENV{'user.domain'}.':'. |
|
$ENV{'user.name'}. |
|
':nohist_calculatedsheets_'.$cid.':'. |
|
&escape($key.'assesscalc:'.$symb), |
|
$ENV{'user.home'}); |
|
unless ($status eq 'ok ok') { |
|
&logthis('Could not devalidate spreadsheet '. |
|
$ENV{'user.name'}.' at '.$ENV{'user.domain'}.' for '. |
|
$symb.': '.$status); |
|
} |
|
} |
|
} |
|
|
# ----------------------------------------------------------------------- Store |
# ----------------------------------------------------------------------- Store |
|
|
sub store { |
sub store { |
my %storehash=@_; |
my %storehash=@_; |
my $symb; |
my $symb; |
unless ($symb=escape(&symbread())) { return ''; } |
unless ($symb=&symbread()) { return ''; } |
|
|
|
&devalidate($symb); |
|
|
|
$symb=escape($symb); |
my $namespace; |
my $namespace; |
unless ($namespace=$ENV{'request.course.id'}) { return ''; } |
unless ($namespace=$ENV{'request.course.id'}) { return ''; } |
my $namevalue=''; |
my $namevalue=''; |
Line 645 sub store {
|
Line 701 sub store {
|
sub cstore { |
sub cstore { |
my %storehash=@_; |
my %storehash=@_; |
my $symb; |
my $symb; |
unless ($symb=escape(&symbread())) { return ''; } |
unless ($symb=&symbread()) { return ''; } |
|
|
|
&devalidate($symb); |
|
|
|
$symb=escape($symb); |
my $namespace; |
my $namespace; |
unless ($namespace=$ENV{'request.course.id'}) { return ''; } |
unless ($namespace=$ENV{'request.course.id'}) { return ''; } |
my $namevalue=''; |
my $namevalue=''; |
Line 719 sub coursedescription {
|
Line 779 sub coursedescription {
|
return (); |
return (); |
} |
} |
|
|
# -------------------------------------------------------- Get user priviledges |
# -------------------------------------------------------- Get user privileges |
|
|
sub rolesinit { |
sub rolesinit { |
my ($domain,$username,$authhost)=@_; |
my ($domain,$username,$authhost)=@_; |
Line 793 sub rolesinit {
|
Line 853 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 908 sub eget {
|
Line 968 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 959 sub allowed {
|
Line 1019 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 1010 sub allowed {
|
Line 1070 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 1180 sub definerole {
|
Line 1240 sub definerole {
|
} |
} |
} |
} |
|
|
|
# ---------------- Make a metadata query against the network of library servers |
|
|
|
sub metadata_query { |
|
my ($query,$custom)=@_; |
|
# need to put in a loop here and return list |
|
unless ($custom) { |
|
my $reply=&reply("querysend:".&escape($query),'msul3'); |
|
return $reply; |
|
} |
|
else { |
|
my $reply=&reply("querysend:".&escape($query).':'. |
|
&escape($custom),'msul3'); |
|
return $reply; |
|
} |
|
my ($query)=@_; |
|
my $reply=&reply("querysend:".&escape($query),'msul3'); |
|
} |
|
|
# ------------------------------------------------------------------ Plain Text |
# ------------------------------------------------------------------ Plain Text |
|
|
sub plaintext { |
sub plaintext { |
Line 1207 sub assignrole {
|
Line 1285 sub assignrole {
|
my ($udom,$uname,$url,$role,$end,$start)=@_; |
my ($udom,$uname,$url,$role,$end,$start)=@_; |
my $mrole; |
my $mrole; |
if ($role =~ /^cr\//) { |
if ($role =~ /^cr\//) { |
unless (&allowed('ccr',$url)) { return 'refused'; } |
unless (&allowed('ccr',$url)) { |
|
&logthis('Refused custom assignrole: '. |
|
$udom.' '.$uname.' '.$url.' '.$role.' '.$end.' '.$start.' by '. |
|
$ENV{'user.name'}.' at '.$ENV{'user.domain'}); |
|
return 'refused'; |
|
} |
$mrole='cr'; |
$mrole='cr'; |
} else { |
} else { |
my $cwosec=$url; |
my $cwosec=$url; |
$cwosec=~s/^\/(\w+)\/(\w+)\/.*/$1\/$2/; |
$cwosec=~s/^\/(\w+)\/(\w+)\/.*/$1\/$2/; |
unless (&allowed('c'.$role,$cwosec)) { return 'refused'; } |
unless (&allowed('c'.$role,$cwosec)) { |
|
&logthis('Refused assignrole: '. |
|
$udom.' '.$uname.' '.$url.' '.$role.' '.$end.' '.$start.' by '. |
|
$ENV{'user.name'}.' at '.$ENV{'user.domain'}); |
|
return 'refused'; |
|
} |
$mrole=$role; |
$mrole=$role; |
} |
} |
my $command="encrypt:rolesput:$ENV{'user.domain'}:$ENV{'user.name'}:". |
my $command="encrypt:rolesput:$ENV{'user.domain'}:$ENV{'user.name'}:". |
Line 1527 sub condval {
|
Line 1615 sub condval {
|
# --------------------------------------------------------- Value of a Variable |
# --------------------------------------------------------- Value of a Variable |
|
|
sub EXT { |
sub EXT { |
my ($varname,$psymb)=@_; |
my $varname=shift; |
unless ($varname) { return ''; } |
unless ($varname) { return ''; } |
my ($realm,$space,$qualifier,@therest)=split(/\./,$varname); |
my ($realm,$space,$qualifier,@therest)=split(/\./,$varname); |
my $rest; |
my $rest; |
Line 1593 sub EXT {
|
Line 1681 sub EXT {
|
} elsif ($realm eq 'resource') { |
} elsif ($realm eq 'resource') { |
if ($ENV{'request.course.id'}) { |
if ($ENV{'request.course.id'}) { |
# ----------------------------------------------------- Cascading lookup scheme |
# ----------------------------------------------------- Cascading lookup scheme |
my $symbp; |
my $symbp=&symbread(); |
if ($psymb) { |
|
$symbp=$psymb; |
|
} else { |
|
$symbp=&symbread(); |
|
} |
|
my $mapp=(split(/\_\_\_/,$symbp))[0]; |
my $mapp=(split(/\_\_\_/,$symbp))[0]; |
|
|
my $symbparm=$symbp.'.'.$spacequalifierrest; |
my $symbparm=$symbp.'.'.$spacequalifierrest; |