Tags:
create new tag
view all tags

SID-01405: List the users and Groups using search

Status: Answered Answered TWiki version: 5.1.0 Perl version:
Category: CategorySearch Server OS: Linux Last update: 13 years ago

I need a search to list all the users and groups of a web in single column separated by commas something like TWikiGroups, this will be used in a Form Field pulldown.

For example:
user1,
user2,
group1,
group2

-- RonMascarenhas - 2012-02-17

Discussion and Answer

First build two searches that return all users and all groups as a comma-space separated list. Then you convert that list into option tags of a select tag:

All users:

%SEARCH{
 "META:FORM.*[U]serForm;%URLPARAM{"search" encode="quote"}%"
 type="regex"
 web="%USERSWEB%"
 nonoise="on"
 topic="RonM*"
 excludetopic="UserList, *Template"
 format="$topic"
 separator=", "
}%
returns: (here restricted to all RonM* topics because of so many users on twiki.org)
RonMaayan, RonMargalit, RonMascarenhas, RonMatuschek, RonMcCaffertyJr, RonMiner

All groups:

%SEARCH{
 "Set GROUP"
 web="%USERSWEB%"
 topic="*Group"
 casesensitive="on"
 nonoise="on"
 format="$topic"
 separator=", "
}%
returns:
AstroHepBrGroup, DevelopBranchGroup, Jack2021Group, NameGroup, SecurityTeamSupportGroup, StanStateGroup, TWikiAdminGroup, TWikiCommunityGroup

Now let's put this together with SET, GET and CALC to produce the html select:

View the raw content to see how this works.

Details in VarSEARCH, FormattedSearch, VarSET, VarGET, VarCALC, SpreadSheetPlugin

-- PeterThoeny - 2012-02-18

This does not work on Twiki 5.0.1, is the syntax different on that release. All I get there is

$SET( "users" value="RonMascarenhas" ) $SET( "groups" value="NobodyGroup, TWikiAdminGroup" ) and $item in the pulldown

-- RonMascarenhas - 2012-02-24

You need to install the SetGetPlugin. Alternatively, use the $SET() and $GET() functions of the SpreadSheetPlugin.

-- PeterThoeny - 2012-02-24

I am trying to use this search in a form and template, I defined a Form and a topic from which to get the values from a search. The values are shown in the pulldown in the topic but I get a blank box when I attach the form to a template. Is there a way to defer the search till the template is invoked.

Form definition:

Name Type Size Values Tooltip Values Attributes
DocUser Select+multi 1   H

DocUser Topic:

Name
%SET{ "users" value="%SEARCH{ "META:FORM.*[U]serForm;%URLPARAM{"search" encode="quote"}%" type="regex" web="%USERSWEB%" nonoise="on" topic="*" excludetopic="UserList, *Template" format="$topic" separator=", " }%" }% %SET{ "groups" value="%SEARCH{ "Set GROUP" web="Main" topic="*Group" casesensitive="on" nonoise="on" format="$topic" separator=", " }%" }% <select> %CALC{$LISTJOIN($sp, $LISTMAP(|<option>$item</option>,%GET{users}%, -----, %GET{groups}%)|)}% </select>

-- RonMascarenhas - 2012-03-05

Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the TWiki consultants if you need timely help. We invite you to get involved with the community, it is more likely you get community support if you support the open source project!

-- PeterThoeny - 2012-07-01

      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.
SupportForm
Status Answered
Title List the users and Groups using search
SupportCategory CategorySearch
TWiki version 5.1.0
Server OS Linux
Web server Apache 2
Perl version

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2012-07-01 - PeterThoeny
 
  • 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-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.