create new tag
, view all tags

SID-02278: Display Members of a Group

Status: Answered Answered TWiki version: 6.0.1 Perl version:
Category: CategoryAccessControl Server OS: Last update: 1 year ago

Is there a way to display the usernames of all members of a group if the parent group contains nested groups?

%SEARCH{ "Set GROUP =" web="Main" topic="TWikiAdminGroup" nosearch="on" nototal="on" multiple="on" format="$percntCALC{$SET(list, $pattern(.*\= *([^\n]*).*)) $GET(list) }$percnt" }%

The above works if the group contains ONLY individual users however if the group contains other groups the output returns the group name.

If this doesn't exist would a good strategy be to modify the GROUPS variable be modified to allow for an individual group name to be entered as a parameter?

-- Jani Hamalainen - 2016-11-24

Discussion and Answer

I agree with the enhancement to GROUPS to limit output to a single group.

By the way: There is (there always seems to be) a way to leverage the GROUPS variable to do what you want:

  1. Use GROUPS to populate a SpreadSheetPlugin-hash mapping group names to group members
  2. Use $GETHASH to retrieve a single group.

%GROUPS{header="" format="$percntCALC{$SETHASH(groups,$group,$members)}$percnt"}%
Members of !TopLevelGroup: %CALC{$GETHASH(groups,TopLevelGroup)}%
Other formats of the user list can be achieved by mangling the GETHASH result through the amazing functions of the SpreadSheetPlugin. Get a sorted bullet list like this (note there are exactly three spaces before CALC to get the first entry right):
   %CALC{$LISTJOIN($n$sp$sp$sp,$LISTEACH($index $item,$LISTSORT($GETHASH(groups,TopLevelGroup))))}%

-- Harald Jörg - 2016-11-24

Brilliant! Thank you Harald!

I've submitted this as a Feature Proposal as well - GroupsAdditionalFunctionality.

-- Jani Hamalainen - 2016-11-24

For anyone else coming across this support request I've added the info below if you want to use the results of the hash as Main.Harald posted above as values in a form.

I believe that the $SETHASH must be provided for each formfield value.

For example, a topic defining a form:

---+ %TOPIC%

| *Name* | *Type* | *Size* | *Values* | *Tooltip message* | *Attributes* |
| PaintReviewers | checkbox | 5 | %CALCULATE{%GROUPS{header="none" format="$SETHASH(groups,$group,$members)" memberformat="$wikiname" separator=""}%$GETHASH(groups, PaintReviewerGroup)}%| | |
| PaintApprovers | checkbox | 5 | %CALCULATE{%GROUPS{header="none" format="$SETHASH(groups,$group,$members)" memberformat="$wikiname" separator=""}%$GETHASH(groups, PaintApproverGroup)}% | | |

If the hash is defined outside of the Values column of the form table the HASH itself is not defined and the result is no options in your form.

%EDITFORMFIELD{"PaintReviewer" topic="%TOPIC%"}%

An alternative is defining the hash ($SETHASH) in each topic that the form is used however I believe this is a better way.

-- Jani Hamalainen - 2016-11-30

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
Status Answered
Title Display Members of a Group
SupportCategory CategoryAccessControl
TWiki version 6.0.1
Server OS

Web server

Perl version

Browser & version

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2016-11-30 - JaniHamalainen
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.