Feature Proposal: New %ISINGROUP{}% variable
Motivation
There's often a need to include stuff depending on a person's "role", which roughly corresponds to groups.
Description
Add an
%ISINGROUP{"groupname" wikiuser="FooBar"}% variable. A context would also be way useful, for use with
%IF{}%
Impact and Available Solutions
Documentation
Examples
Implementation
--
Contributors: MeredithLesly
Discussion
This functionality is certainly useful. As an idea, it could be added to the existing
%USERINFO{}% instead, e.g.
$isingroup(TWikiAdminGroup)
--
PeterThoeny - 10 Feb 2006
while implementing this tag, can we add a sub to Func?
TWiki::Func::isUserInGroup($user,$group)?
--
RafaelAlvarez - 10 Feb 2006
The Func enhancement is useful too.
Make sure to define the syntax for the three different types of user: username (e.g.
jsmith), wikiname (e.g.
JohnSmith), wikiusername (e.g.
Main.JohnSmith)
--
PeterThoeny - 10 Feb 2006
please remember that with the current implementation, any time that you ask for groups information, you are slowing your render loop. to get this information, TWiki needs to parse every Group topic, and then do lookups (and partially parse any users it find in those groups.
this
$groups format is exactly what was the slowdown in 4.0.1, and I did not remove this slowdown, I simply made it optional on the use of
$group.
As I am working in the User code right now (and I've extracted the User to group mapping into an over-rideable
UserMapping module, I will have a play, but the fact remains, TWiki's one topic per Group&User method sucks performance like crazy.
--
SvenDowideit - 10 Feb 2006
To some extent, what's really needed is a user=>role(s) functionality, which isinGroup provides. For example, there may be developers, editor, and ordinary people. Perhaps instead of using what is apparently an expensive solution, a simple table of tuples (user, role) would be more efficient and serve many if not most of the needs of this more expensive solution.
--
MeredithLesly - 12 Feb 2006
As I understand it, you want to be able to present different information depending on whether someone is in a group or not. So
%IF{"ingroup TWikiAdminGroup" then="You can" else="You can't"}%
is a fairly natural approach, and trivial to implement.
Suggest you add an Item to Bugs web to cover this.
CC
Was this ever implemented? Nothing listed on
http://twiki.org/cgi-bin/view/TWiki/TWikiVariables#USERINFO_retrieve_details_about
Thanks, M.
--
MartinCleaver - 12 Oct 2007
ConditionalBasedOnGroupMembership has an answer.
--
MartinCleaver - 12 Oct 2007
Simple small very self contained change
yoinc:
Bugs:Item4809
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"}%
--
SvenDowideit - 13 Oct 2007