Skip to content

Commit

Permalink
Item11208: perltidy
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@12925 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Oct 29, 2011
1 parent d3c3a46 commit 1d88457
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
60 changes: 35 additions & 25 deletions TopicUserMappingContrib/lib/Foswiki/Users/TopicUserMapping.pm
Expand Up @@ -380,7 +380,8 @@ sub addUser {
# Filter-in date format matching {DefaultDateFormat}
# The admin may have changed the format at some point of time
# so we test with a generic format that matches all 4 formats.
$odate = '' unless $odate =~ /^\d+[- .\/]+[A-Za-z0-9]+[- .\/]+\d+$/;
$odate = ''
unless $odate =~ /^\d+[- .\/]+[A-Za-z0-9]+[- .\/]+\d+$/;
$insidelist = 1;
}
elsif ( $line =~ /^\s+\*\s([A-Z]) - / ) {
Expand Down Expand Up @@ -664,7 +665,7 @@ sub eachGroupMember {
$members =
_expandUserList( $this,
$groupTopicObject->getPreference('GROUP') );
$this->{eachGroupMember}->{$group} = $members;
$this->{eachGroupMember}->{$group} = $members;
}

delete $expanding{$group};
Expand Down Expand Up @@ -760,7 +761,7 @@ sub groupAllowsView {
$this->{session}
->normalizeWebTopicName( $Foswiki::cfg{UsersWebName}, $Group );

# If a Group or User topic normalized somewhere else, doesn't make sense, so ignore the Webname
# If a Group or User topic normalized somewhere else, doesn't make sense, so ignore the Webname
$groupWeb = $Foswiki::cfg{UsersWebName};

$groupName = undef
Expand Down Expand Up @@ -794,7 +795,7 @@ sub groupAllowsChange {
$this->{session}
->normalizeWebTopicName( $Foswiki::cfg{UsersWebName}, $Group );

# If a Group or User topic normalized somewhere else, doesn't make sense, so ignore the Webname
# If a Group or User topic normalized somewhere else, doesn't make sense, so ignore the Webname
$groupWeb = $Foswiki::cfg{UsersWebName};

$groupName = undef
Expand Down Expand Up @@ -822,13 +823,11 @@ sub addUserToGroup {
$this->{session}
->normalizeWebTopicName( $Foswiki::cfg{UsersWebName}, $Group );

throw Error::Simple(
"Users cannot be added to $Group")
if ($Group eq 'NobodyGroup' || $Group eq 'BaseGroup');
throw Error::Simple("Users cannot be added to $Group")
if ( $Group eq 'NobodyGroup' || $Group eq 'BaseGroup' );

throw Error::Simple(
'Group names must end in Group')
unless ($Group =~ m/Group$/);
throw Error::Simple('Group names must end in Group')
unless ( $Group =~ m/Group$/ );

# the registration code will call this function using the rego agent
my $user = $this->{session}->{user};
Expand All @@ -853,19 +852,20 @@ sub addUserToGroup {

if ( !$groupTopicObject->haveAccess( 'CHANGE', $user ) ) {
return 0;

#throw Error::Simple(
# "CHANGE not permitted by $user");
}

$membersString = $groupTopicObject->getPreference('GROUP') || '';

my @l;
foreach my $ident ( split( /[\,\s]+/, $membersString ) ) {
$ident =~ s/^($Foswiki::cfg{UsersWebName}|%USERSWEB%|%MAINWEB%)\.//;
push( @l, $ident ) if $ident;
}
$membersString = join( ', ', @l );

if ( $create and !defined($cuid) ) {

#upgrade group topic.
Expand All @@ -879,8 +879,8 @@ sub addUserToGroup {
}
else {

# see if we have permission to add a topic, or to edit the existing topic, etc..
# see if we have permission to add a topic, or to edit the existing topic, etc..

#throw Error::Simple(
# 'Group does not exist and create not permitted')
return 0
Expand Down Expand Up @@ -1001,7 +1001,11 @@ sub _writeGroupTopic {

#TODO: should also consider securing the new topic?
my $user = $this->{session}->{user};
$groupTopicObject->saveAs( $groupWeb, $groupName, author => $user, forcenewrevision=>0 );
$groupTopicObject->saveAs(
$groupWeb, $groupName,
author => $user,
forcenewrevision => 0
);

}

Expand All @@ -1019,13 +1023,12 @@ sub removeUserFromGroup {
$this->{session}
->normalizeWebTopicName( $Foswiki::cfg{UsersWebName}, $groupName );

throw Error::Simple(
"Users cannot be removed from $groupName")
if ($groupName eq 'BaseGroup');
throw Error::Simple("Users cannot be removed from $groupName")
if ( $groupName eq 'BaseGroup' );

throw Error::Simple(
"AdminUser cannot be removed from $groupName")
if ($groupName eq "$Foswiki::cfg{SuperAdminGroup}" && $cuid eq 'BaseUserMapping_333');
throw Error::Simple("AdminUser cannot be removed from $groupName")
if ( $groupName eq "$Foswiki::cfg{SuperAdminGroup}"
&& $cuid eq 'BaseUserMapping_333' );

my $user = $this->{session}->{user};
my $usersObj = $this->{session}->{users};
Expand All @@ -1039,6 +1042,7 @@ sub removeUserFromGroup {
if ( !$usersObj->isInGroup( $cuid, $groupName, { expand => 0 } )
&& !$usersObj->isGroup($cuid) )
{

#throw Error::Simple(
# "User $cuid not in group, cannot be removed")
return 0;
Expand All @@ -1047,6 +1051,7 @@ sub removeUserFromGroup {
Foswiki::Meta->load( $this->{session}, $Foswiki::cfg{UsersWebName},
$groupName );
if ( !$groupTopicObject->haveAccess( 'CHANGE', $user ) ) {

#throw Error::Simple(
# "CHANGE by $user not permitted.")
return 0;
Expand Down Expand Up @@ -1419,7 +1424,7 @@ Returns 1 on success, undef on failure.
sub checkPassword {
my ( $this, $login, $pw ) = @_;

# If we don't have a PasswordManager and use TemplateLogin, always allow login
# If we don't have a PasswordManager and use TemplateLogin, always allow login
return 1
if ( $Foswiki::cfg{PasswordManager} eq 'none'
&& $Foswiki::cfg{LoginManager} eq
Expand Down Expand Up @@ -1519,6 +1524,7 @@ sub _getListOfGroups {

#create a MetaCache _before_ we do silly things with the session's users
$this->{session}->search->metacache();

# Temporarily set the user to admin, otherwise it cannot see groups
# where %USERSWEB% is protected from view
local $this->{session}->{user} = $Foswiki::cfg{SuperAdminGroup};
Expand Down Expand Up @@ -1622,23 +1628,27 @@ sub _expandUserList {
push( @l, $ident );
}
else {
my $it = $this->eachGroupMember( $ident, { expand => $expand } );
my $it =
$this->eachGroupMember( $ident, { expand => $expand } );
while ( $it->hasNext() ) {
push( @l, $it->next() );
}
}
}
else {

# Might be a wiki name (wiki names may map to several cUIDs)
my %namelist =
map { $_ => 1 }
@{ $this->{session}->{users}->findUserByWikiName($ident) };

# If we were not successful in finding by WikiName we assumed it
# may be a login name (login names map to a single cUID).
# If user is unknown we return whatever was listed so we can
# remove deleted or misspelled users
unless ( %namelist ) {
my $cUID = $this->{session}->{users}->getCanonicalUserID($ident) || $ident;
unless (%namelist) {
my $cUID = $this->{session}->{users}->getCanonicalUserID($ident)
|| $ident;
$namelist{$cUID} = 1 if $cUID;
}
push( @l, keys %namelist );
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/UI/Register.pm
Expand Up @@ -917,7 +917,7 @@ sub _complete {
}
}

$data->{AddToGroups} = join(',', @addedTo);
$data->{AddToGroups} = join( ',', @addedTo );
}
catch Error::Simple with {
my $e = shift;
Expand Down

0 comments on commit 1d88457

Please sign in to comment.