Skip to content
Permalink
Browse files

Item10939: perltidy

git-svn-id: http://svn.foswiki.org/trunk@12131 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information...
SvenDowideit SvenDowideit
SvenDowideit authored and SvenDowideit committed Jul 5, 2011
1 parent efc33a2 commit 952e225c88758d187612e63ad54fd3b79232bc1b
@@ -16,15 +16,14 @@ sub new {
return $self;
}


sub loadExtraConfig {
my $this = shift; # the Test::Unit::TestCase object
my $context = shift;

$this->SUPER::loadExtraConfig( $context, @_ );

#can't change to AdminOnlyAccessControl here, as we need to be able to create topics.
#$Foswiki::cfg{AccessControl} = 'Foswiki::Access::AdminOnlyAccess'
#can't change to AdminOnlyAccessControl here, as we need to be able to create topics.
#$Foswiki::cfg{AccessControl} = 'Foswiki::Access::AdminOnlyAccess'
}

my $MrWhite;
@@ -412,6 +411,7 @@ THIS
, undef
);
$topicObject->save();

# renew Foswiki, so WebPreferences gets re-read
$this->{session}->finish();
$Foswiki::cfg{AccessControl} = 'Foswiki::Access::AdminOnlyAccess';
@@ -465,6 +465,7 @@ THIS
Foswiki::Meta->new( $this->{session}, $this->{test_web},
$this->{test_topic}, $text );
$topicObject->save();

# renew Foswiki, so WebPreferences gets re-read
$this->{session}->finish();
$Foswiki::cfg{AccessControl} = 'Foswiki::Access::AdminOnlyAccess';
@@ -491,6 +492,7 @@ sub test_setInMETA {
};
$topicObject->putKeyed( 'PREFERENCE', $args );
$topicObject->save();

# renew Foswiki, so WebPreferences gets re-read
$this->{session}->finish();
$Foswiki::cfg{AccessControl} = 'Foswiki::Access::AdminOnlyAccess';
@@ -521,6 +523,7 @@ THIS
};
$topicObject->putKeyed( 'PREFERENCE', $args );
$topicObject->save();

# renew Foswiki, so WebPreferences gets re-read
$this->{session}->finish();
$Foswiki::cfg{AccessControl} = 'Foswiki::Access::AdminOnlyAccess';
@@ -565,7 +568,7 @@ THIS
$Foswiki::cfg{AccessControl} = 'Foswiki::Access::AdminOnlyAccess';
$this->{session} = new Foswiki();
$this->DENIED( "VIEW", $MrOrange, $subweb );
$this->DENIED( "VIEW", $MrGreen, $subweb );
$this->DENIED( "VIEW", $MrGreen, $subweb );
$this->DENIED( "VIEW", $MrGreen );
$this->DENIED( "VIEW", $MrOrange );
$this->PERMITTED( "VIEW", 'BaseUserMapping_333' );
@@ -599,7 +602,7 @@ THIS
$this->{session}->finish();
$Foswiki::cfg{AccessControl} = 'Foswiki::Access::AdminOnlyAccess';
$this->{session} = new Foswiki();
$this->DENIED( "VIEW", $MrGreen, $subweb );
$this->DENIED( "VIEW", $MrGreen, $subweb );
$this->DENIED( "VIEW", $MrOrange, $subweb );
$this->DENIED( "VIEW", $MrGreen );
$this->DENIED( "VIEW", $MrOrange );
@@ -636,7 +639,7 @@ THIS
$Foswiki::cfg{AccessControl} = 'Foswiki::Access::AdminOnlyAccess';
$this->{session} = new Foswiki();
$this->DENIED( "VIEW", $MrOrange, $subweb );
$this->DENIED( "VIEW", $MrGreen, $subweb );
$this->DENIED( "VIEW", $MrGreen, $subweb );
$this->DENIED( "VIEW", $MrGreen );
$this->DENIED( "VIEW", $MrOrange );
$this->PERMITTED( "VIEW", 'BaseUserMapping_333' );
@@ -13,7 +13,6 @@ package Foswiki::Access;
use strict;
use Assert;

# Enable this for debug. Done as a sub to allow perl to optimise it out.
use constant MONITOR => 0;

=begin TML
@@ -25,17 +24,17 @@ Constructor.
=cut

sub new {
my ( $class, $session ) = @_;
ASSERT($session->isa( 'Foswiki')) if DEBUG;
my $imp= $Foswiki::cfg{AccessControl} || 'Foswiki::Access::TopicACLAccess';
my ( $class, $session ) = @_;
ASSERT( $session->isa('Foswiki') ) if DEBUG;
my $imp = $Foswiki::cfg{AccessControl} || 'Foswiki::Access::TopicACLAccess';

print STDERR "using $imp Access Control\n" if MONITOR;
eval ("use $imp");

eval("use $imp");
my $this = $imp->new($session);
return $this;
}

return $this;
}

=begin TML
@@ -84,8 +83,8 @@ sub haveAccess {
die 'base class';
}


1;

# Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2008-2011 Foswiki Contributors. Foswiki Contributors
@@ -1,6 +1,5 @@
# See bottom of file for license and copyright information


=pod
---+ package Foswiki::Access::AdminOnlyAccess
@@ -20,8 +19,8 @@ use Assert;

sub new {
my ( $class, $session ) = @_;
ASSERT($session->isa( 'Foswiki')) if DEBUG;
my $this = bless( {session=>$session}, $class );
ASSERT( $session->isa('Foswiki') ) if DEBUG;
my $this = bless( { session => $session }, $class );

return $this;
}
@@ -57,7 +56,6 @@ sub haveAccess {
return 0;
}


1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
@@ -1,6 +1,5 @@
# See bottom of file for license and copyright information


=pod
---+ package Foswiki::Access::TopicACLAccess
@@ -14,22 +13,20 @@ package Foswiki::Access::TopicACLAccess;
use Foswiki::Access;
@ISA = qw(Foswiki::Access);

# Enable this for debug. Done as a sub to allow perl to optimise it out.
use constant MONITOR => 0;


use strict;
use Assert;

use Foswiki ();
use Foswiki ();
use Foswiki::Address ();
use Foswiki::Meta ();
use Foswiki::Users ();
use Foswiki::Meta ();
use Foswiki::Users ();

sub new {
my ( $class, $session ) = @_;
ASSERT($session->isa( 'Foswiki')) if DEBUG;
my $this = bless( {session=>$session}, $class );
ASSERT( $session->isa('Foswiki') ) if DEBUG;
my $this = bless( { session => $session }, $class );

return $this;
}
@@ -54,20 +51,24 @@ sub haveAccess {

my $session = $this->{session};
undef $this->{failure};

my $meta;

if (ref($param1) eq '') {

if ( ref($param1) eq '' ) {

#scalar - treat as web, topic
$meta = Foswiki::Meta->load($session, $param1, $param2);
} else {
if (ref($param1) eq 'Foswiki::Address') {
$meta = Foswiki::Meta->load($session, $param1->web(), $param2->topic());
} else {
$meta = Foswiki::Meta->load( $session, $param1, $param2 );
}
else {
if ( ref($param1) eq 'Foswiki::Address' ) {
$meta =
Foswiki::Meta->load( $session, $param1->web(), $param2->topic() );
}
else {
$meta = $param1;
}
}
ASSERT($meta->isa( 'Foswiki::Meta')) if DEBUG;
ASSERT( $meta->isa('Foswiki::Meta') ) if DEBUG;

print STDERR "Check $mode access $cUID to " . $meta->getPath() . "\n"
if MONITOR;
@@ -83,16 +84,16 @@ sub haveAccess {
my ( $allow, $deny );
if ( $meta->{_topic} ) {

my $allow = $this->_getACL($meta, 'ALLOWTOPIC' . $mode );
my $deny = $this->_getACL($meta, 'DENYTOPIC' . $mode );
my $allow = $this->_getACL( $meta, 'ALLOWTOPIC' . $mode );
my $deny = $this->_getACL( $meta, 'DENYTOPIC' . $mode );

# Check DENYTOPIC
if ( defined($deny) ) {
if ( scalar(@$deny) != 0 ) {
if ( $session->{users}->isInUserList( $cUID, $deny ) ) {
$this->{failure} =
$session->i18n->maketext('access denied on topic');
print STDERR 'a '.$this->{failure}, "\n" if MONITOR;
print STDERR 'a ' . $this->{failure}, "\n" if MONITOR;
return 0;
}
}
@@ -110,8 +111,9 @@ sub haveAccess {
print STDERR "in ALLOWTOPIC\n" if MONITOR;
return 1;
}
$this->{failure} = $session->i18n->maketext('access not allowed on topic');
print STDERR 'b '.$this->{failure}, "\n" if MONITOR;
$this->{failure} =
$session->i18n->maketext('access not allowed on topic');
print STDERR 'b ' . $this->{failure}, "\n" if MONITOR;
return 0;
}
$meta = $meta->getContainer(); # Web
@@ -122,24 +124,26 @@ sub haveAccess {
# Check DENYWEB, but only if DENYTOPIC is not set (even if it
# is empty - empty means "don't deny anybody")
unless ( defined($deny) ) {
$deny = $this->_getACL($meta, 'DENYWEB' . $mode );
$deny = $this->_getACL( $meta, 'DENYWEB' . $mode );
if ( defined($deny)
&& $session->{users}->isInUserList( $cUID, $deny ) )
{
$this->{failure} = $session->i18n->maketext('access denied on web');
print STDERR 'c '.$this->{failure}, "\n" if MONITOR;
$this->{failure} =
$session->i18n->maketext('access denied on web');
print STDERR 'c ' . $this->{failure}, "\n" if MONITOR;
return 0;
}
}

# Check ALLOWWEB. If this is defined and not overridden by
# ALLOWTOPIC, the user _must_ be in it.
$allow = $this->_getACL($meta, 'ALLOWWEB' . $mode );
$allow = $this->_getACL( $meta, 'ALLOWWEB' . $mode );

if ( defined($allow) && scalar(@$allow) != 0 ) {
unless ( $session->{users}->isInUserList( $cUID, $allow ) ) {
$this->{failure} = $session->i18n->maketext('access not allowed on web');
print STDERR 'd '.$this->{failure}, "\n" if MONITOR;
$this->{failure} =
$session->i18n->maketext('access not allowed on web');
print STDERR 'd ' . $this->{failure}, "\n" if MONITOR;
return 0;
}
}
@@ -148,23 +152,24 @@ sub haveAccess {
else {

# No web, we are checking at the root. Check DENYROOT and ALLOWROOT.
$deny = $this->_getACL($meta, 'DENYROOT' . $mode );
$deny = $this->_getACL( $meta, 'DENYROOT' . $mode );

if ( defined($deny)
&& $session->{users}->isInUserList( $cUID, $deny ) )
{
$this->{failure} = $session->i18n->maketext('access denied on root');
print STDERR 'e '.$this->{failure}, "\n" if MONITOR;
$this->{failure} =
$session->i18n->maketext('access denied on root');
print STDERR 'e ' . $this->{failure}, "\n" if MONITOR;
return 0;
}

$allow = $this->_getACL($meta, 'ALLOWROOT' . $mode );
$allow = $this->_getACL( $meta, 'ALLOWROOT' . $mode );

if ( defined($allow) && scalar(@$allow) != 0 ) {
unless ( $session->{users}->isInUserList( $cUID, $allow ) ) {
$this->{failure} =
$session->i18n->maketext('access not allowed on root');
print STDERR 'f '.$this->{failure}, "\n" if MONITOR;
print STDERR 'f ' . $this->{failure}, "\n" if MONITOR;
return 0;
}
}
@@ -203,9 +208,9 @@ sub _getACL {
s/^($Foswiki::cfg{UsersWebName}|%USERSWEB%|%MAINWEB%)\.//;
$_
} split( /[,\s]+/, $text );
#print STDERR "getACL($mode): ".join(', ', @list)."\n";

#print STDERR "getACL($mode): ".join(', ', @list)."\n";

return \@list;
}

0 comments on commit 952e225

Please sign in to comment.
You can’t perform that action at this time.