[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm /xml londefdef.pm
www
lon-capa-cvs@mail.lon-capa.org
Tue, 18 Mar 2003 07:26:49 -0000
www Tue Mar 18 02:26:49 2003 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
/loncom/xml londefdef.pm
Log:
Continued work on custom access rights, and rewrite of a truly amazing bit
of ancient code for custom role access ...
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.340 loncom/lonnet/perl/lonnet.pm:1.341
--- loncom/lonnet/perl/lonnet.pm:1.340 Fri Mar 14 14:35:54 2003
+++ loncom/lonnet/perl/lonnet.pm Tue Mar 18 02:26:49 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.340 2003/03/14 19:35:54 albertel Exp $
+# $Id: lonnet.pm,v 1.341 2003/03/18 07:26:49 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1870,6 +1870,18 @@
return %returnhash;
}
+# ---------------------------------------------- Custom access rule evaluation
+
+sub customaccess {
+ my ($priv,$uri)=@_;
+ my $access=0;
+ foreach (split(/\s*\,\s*/,&metadata($uri,'rule_rights'))) {
+ my ($effect,$realm,$content)=split(/\:/,$_);
+ &logthis('testing '.$effect.' '.$realm.' '.$content);
+ }
+ return $access;
+}
+
# ------------------------------------------------- Check for a user privilege
sub allowed {
@@ -1908,6 +1920,9 @@
# Library role, so allow browsing of resources in this domain.
return 'F';
}
+ if ($copyright eq 'custom') {
+ unless (&customaccess($priv,$uri)) { return ''; }
+ }
}
# Domain coordinator is trying to create a course
if (($priv eq 'ccc') && ($ENV{'request.role'} =~ /^dc\./)) {
@@ -2125,20 +2140,10 @@
if ($thisallowed=~/R/) {
my $rolecode=(split(/\./,$ENV{'request.role'}))[0];
- my $filename=$perlvar{'lonDocRoot'}.'/res/'.$uri.'.meta';
- if (-e $filename) {
- my @content;
- {
- my $fh=Apache::File->new($filename);
- @content=<$fh>;
- }
- if (join('',@content)=~
- /\<roledeny[^\>]*\>[^\<]*$rolecode[^\<]*\<\/roledeny\>/) {
- &log($ENV{'user.domain'},$ENV{'user.name'},$ENV{'user.host'},
+ if (&metadata($uri,'roledeny')=~/$rolecode/) {
+ &log($ENV{'user.domain'},$ENV{'user.name'},$ENV{'user.host'},
'Denied by role: '.$priv.' for '.$uri.' as '.$rolecode);
- return '';
-
- }
+ return '';
}
}
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.120 loncom/xml/londefdef.pm:1.121
--- loncom/xml/londefdef.pm:1.120 Fri Feb 28 16:06:42 2003
+++ loncom/xml/londefdef.pm Tue Mar 18 02:26:49 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.120 2003/02/28 21:06:42 albertel Exp $
+# $Id: londefdef.pm,v 1.121 2003/03/18 07:26:49 www Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -54,7 +54,7 @@
BEGIN {
- &Apache::lonxml::register('Apache::londefdef',('a','abbr','acronym','address','allow','applet','area','b','base','basefont','bgo','bgsound','big','blink','blockquote','blankspace','body','br','button','caption','center','cite','code','col','colgroup','dd','del','dfn','dir','div','dl','dt','em','embed','externallink','fieldset','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','i','iframe','img','input','ins','insert','isindex','kbd','keygen','label','layer','legend','li','link','m','map','marquee','menu','meta','multicol','nobr','noembed','noframes','nolayer','noscript','object','ol','optgroup','option','output','p','param','pre','q','s','samp','select','server','small','spacer','span','strike','strong','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','tthoption','u','ul','var','wbr'));
+ &Apache::lonxml::register('Apache::londefdef',('a','abbr','acronym','accessrule','address','allow','applet','area','b','base','basefont','bgo','bgsound','big','blink','blockquote','blankspace','body','br','button','caption','center','cite','code','col','colgroup','dd','del','dfn','dir','div','dl','dt','em','embed','externallink','fieldset','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','i','iframe','img','input','ins','insert','isindex','kbd','keygen','label','layer','legend','li','link','m','map','marquee','menu','meta','multicol','nobr','noembed','noframes','nolayer','noscript','object','ol','optgroup','option','output','p','param','pre','q','s','samp','select','server','small','spacer','span','strike','strong','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','tthoption','u','ul','var','wbr'));
}
@@ -354,6 +354,46 @@
return $currentstring;
}
sub end_meta {
+ my ($target,$token,$tagstack,$parstack,$parser) = @_;
+ my $currentstring = '';
+ if ($target eq 'web') {
+ my $args='';
+ if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
+ if ($args ne '') {
+ $currentstring = $token->[4];
+ }
+ }
+ return $currentstring;
+ }
+# accessrule
+ sub start_accessrule {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
+ my $currentstring = '';
+ my $eff=&Apache::lonxml::get_param
+ ('effect',$parstack,$safeeval,undef,1);
+ my $realm=&Apache::lonxml::get_param
+ ('realm',$parstack,$safeeval,undef,1);
+ my $cont=&Apache::lonxml::get_param
+ ('content',$parstack,$safeeval,undef,1);
+ $cont=~s/\s+//g;
+ $cont=~s/\W/\;/g;
+ if ($target eq 'web') {
+ my $args='';
+ if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
+ if ($args eq '') {
+ &Apache::lonxml::get_all_text("/accessrule",$parser);
+ } else {
+ $currentstring = $token->[4];
+ }
+ }
+ if ($target eq 'meta') {
+ $currentstring='<rule>'.
+ $eff.':'.$realm.':'.$cont.
+ '</rule>';
+ }
+ return $currentstring;
+ }
+ sub end_accessrule {
my ($target,$token,$tagstack,$parstack,$parser) = @_;
my $currentstring = '';
if ($target eq 'web') {