Skip to content
Permalink
Browse files

Item2378: GROUPINFO needs a format operator

git-svn-id: http://svn.foswiki.org/trunk@5581 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit SvenDowideit
SvenDowideit authored and SvenDowideit committed Nov 19, 2009
1 parent ba3c9a1 commit 1a832142526a2396050c3f1d52e7dd348deb6b12
@@ -665,6 +665,33 @@ sub eachMembership {
};
return $it;
}
=begin TML
---++ ObjectMethod groupAllowsChange($group) -> boolean
returns 1 if the group is able to be modified by the current logged in user
=cut

sub groupAllowsChange {
my $this = shift;
my $Group = shift;

my $user = $this->{session}->{user};


$Group = Foswiki::Sandbox::untaint( $Group,
\&Foswiki::Sandbox::validateTopicName );
my ( $groupWeb, $groupName ) =
$this->{session}
->normalizeWebTopicName( $Foswiki::cfg{UsersWebName}, $Group );

$groupName = undef
if (not $this->{session}->topicExists( $groupWeb, $groupName ));

return Foswiki::Func::checkAccessPermission(
'CHANGE', $user, undef, $groupName, $groupWeb);
}

=begin TML
@@ -708,7 +735,7 @@ sub addUserToGroup {
if (
$usersObj->isGroup($groupName)
and ( $this->{session}
->topicExists( $Foswiki::cfg{UsersWebName}, $groupName ) )
->topicExists( $groupWeb, $groupName ) )
)
{
if ( $usersObj->isInGroup( $cuid, $groupName ) ) {
@@ -717,7 +744,7 @@ sub addUserToGroup {
return 1; #user already in group, nothing to do
}
my $groupTopicObject =
Foswiki::Meta->load( $this->{session}, $Foswiki::cfg{UsersWebName},
Foswiki::Meta->load( $this->{session}, $groupWeb,
$groupName );

return 0
@@ -739,12 +766,12 @@ sub addUserToGroup {
return 0
unless (
Foswiki::Func::checkAccessPermission(
'CHANGE', $cuid, '', $groupName, $Foswiki::cfg{UsersWebName}
'CHANGE', $user, '', $groupName, $groupWeb
)
);

my $groupTopicObject =
Foswiki::Meta->load( $this->{session}, $Foswiki::cfg{UsersWebName},
Foswiki::Meta->load( $this->{session}, $groupWeb,
'GroupTemplate' );
$groupTopicObject->putKeyed(
'PREFERENCE',
@@ -755,7 +782,7 @@ sub addUserToGroup {
}
);
#TODO: should also consider securing the new topic?
$groupTopicObject->saveAs( $Foswiki::cfg{UsersWebName},
$groupTopicObject->saveAs( $groupWeb,
$groupName, -author => $user );
return 1;
}
@@ -51,12 +51,13 @@ This is a list of all known groups that can be used to define [[%SYSTEMWEB%.Acce
<th>%MAKETEXT{"Members"}%**</th>
</tr>$n"
format="<tr>
<td> $percntIF{\"not istopic '$name'\" then=\"<nop>\"}$percnt$name </td>
<td> $percntIF{\"not istopic '$name'\" then=\"<nop>\"}$percnt$name</td>
<td>
$percntINCLUDE{\"%WEB%.%TOPIC%\"
section=\"rendergroup\"
groupname=\"$name\"
username=\"$wikiname\"
allowschange=\"$allowschange\"
}$percnt
</td>
</tr>"
@@ -67,19 +68,13 @@ This is a list of all known groups that can be used to define [[%SYSTEMWEB%.Acce

<verbatim style="display:none">
<!--
parameters: username, groupname
parameters: username, groupname, allowschange
-->
%STARTSECTION{"rendergroup"}%<!-- rendergroup -->
<div class='foswikiRight'>
%TWISTYBUTTON{
id="%groupname%_add"
link="<img src='%PLUSICONURL%' />"
}%
%TWISTYBUTTON{
id="%groupname%_remove"
link="<img src='%MINUSICONURL%' />"
%INCLUDE{"%WEB%.%TOPIC%"
section="%IF{"%allowschange%" then="changegroup" else="nochange"}%"
groupname="%groupname%"
}%
</div>
%GROUPINFO{"%groupname%"
format="$percntIF{\"not istopic '%username%'\" then=\"<nop>\"}$percnt%username%"
separator=", "
@@ -127,6 +122,33 @@ This is a list of all known groups that can be used to define [[%SYSTEMWEB%.Acce
<!-- //rendergroup -->%ENDSECTION{"rendergroup"}%
</verbatim>

<verbatim style="display:none">
<!--
parameters: username, groupname
-->
%STARTSECTION{"nochange"}%<!-- nochange // -->%ENDSECTION{"nochange"}%
</verbatim>

<verbatim style="display:none">
<!--
parameters: groupname
-->
%STARTSECTION{"changegroup"}%<!-- changegroup -->
<div class='foswikiRight'>
%TWISTYBUTTON{
id="%groupname%_add"
link="<img src='%PLUSICONURL%' />"
}%
%TWISTYBUTTON{
id="%groupname%_remove"
link="<img src='%MINUSICONURL%' />"
}%
</div>
<!-- //changegroup -->%ENDSECTION{"changegroup"}%
</verbatim>



<!--
* Set PLUSICONURL = %IF{"istopic '%SYSTEMWEB%.FamFamFamSilkIcons'"
then="%PUBURLPATH%/%SYSTEMWEB%/FamFamFamSilkIcons/add.png"
@@ -7,7 +7,11 @@
* Syntax: =%<nop>GROUPINFO{"groupname"}%=
* Expands to: comma-separated list of users in that group
* Parameters:
| =format= | Format of a single user or group in the list. =$name= expands to the group name, and (for users list only) =$wikiname=, =$username= and =$wikiusername= to the relevant strings. The standard FormatTokens are also supported. | =$name= for groups list, =$wikiusername= for users list |
| =format= | Format of a single user or group in the list. \
=$name= expands to the group name, and (for users list only) \
=$wikiname=, =$username= and =$wikiusername= to the relevant strings. \
=$allowschange= returns 0 (false) or 1 (true) if that group can be modified by the current user \
The standard FormatTokens are also supported. | =$name= for groups list, =$wikiusername= for users list |
| =separator= | separator between items in the list | =,= |
| =header= | Header for the list | '' |
| =footer= | Footer for the list | '' |
@@ -4501,13 +4501,19 @@ sub GROUPINFO {
my $wname = $this->{users}->getWikiName( $cUID );
my $uname = $this->{users}->getLoginName( $cUID );
my $wuname = $this->{users}->webDotWikiName( $cUID );
$row =~ s/\$wikiname/$wname/g;
$row =~ s/\$username/$uname/g;
$row =~ s/\$wikiusername/$wuname/g;
my $change = $this->{users}->groupAllowsChange( $group );

$row =~ s/\$wikiname/$wname/ge;
$row =~ s/\$username/$uname/ge;
$row =~ s/\$wikiusername/$wuname/ge;
$row =~ s/\$name/$group/g;
$row =~ s/\$allowschange/$change/ge;
} else {
# all groups
my $change = $this->{users}->groupAllowsChange( $cUID );

$row =~ s/\$name/$cUID/g;
$row =~ s/\$allowschange/$change/ge;
}
push(@rows, $row);
last if (--$limit == 0);
@@ -308,6 +308,18 @@ sub eachMembership {

=begin TML
---++ ObjectMethod groupAllowsChange($group) -> boolean
returns 1 if the group is able to be modified by the current logged in user
=cut

sub groupAllowsChange {
return 0;
}

=begin TML
---++ ObjectMethod addToGroup( $cuid, $group, $create ) -> $boolean
adds the user specified by the cuid to the group.
If the group does not exist, it will return false and do nothing, unless the create flag is set.
@@ -896,6 +896,21 @@ sub eachMembership {

=begin TML
---++ ObjectMethod groupAllowsChange($group) -> boolean
returns 1 if the group is able to be modified by the current logged in user
=cut

sub groupAllowsChange {
my $this = shift;
my $group = shift;
my $mapping = $this->{mapping};
return $mapping->groupAllowsChange( $group );
}

=begin TML
---++ ObjectMethod addToGroup( $cuid, $group, $create ) -> $boolean
adds the user specified by the cuid to the group.
If the group does not exist, it will return false and do nothing, unless the create flag is set.

0 comments on commit 1a83214

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