from
TWiki:Support.ConditionalBasedOnGroupMembership
Here's a little hack to add "group" functionality to %IF... Insert the following code into lib/TWiki/If.pm, somewhere around line 86:
$defOps{group} =
{ name => 'group',
prec => 5,
type => 0, # unary
exec => sub {
my( $twiki, $a, $b ) = @_;
my $s=$b->evaluate($twiki);
for my $group ($twiki->{user}->getGroups) {
return 1 if( $s eq $group->wikiName );
}
return 0;
}
};
Then you can use the following syntax:
%IF{ "group TWikiAdminGroup" then="*yes*" else="no"}%
Hope this helps.
--
SteveMokris - 28 Sep 2007
--
TWiki:Main/SvenDowideit - 13 Oct 2007
Simple small very self contained change
I've made the if a little more generic for 4.2, and written a set of unit tests for it:
%IF{ "SvenDowideit ingroup TWikiAdminGroup" then="*yes*" else="no"}%
--
TWiki:Main.SvenDowideit - 13 Oct 2007