Tags:
create new tag
, view all tags

Feature Proposal: Add USERSLIST TWiki variable

Motivation

Now we have proper user mappers, the old search mechanisms are no longer good enough to get a list of users.

See also: GetRidOfTWikiUsersPage, ReplaceAllUsersPage

Description and Documentation

USERSLIST{"format"} -- list of all users

  • List of all users on this TWiki. The "format" defines the format of one user item. It may include variables: The $wikiname variable gets expanded to the users wikiname, $marker to marker parameter where topic matches selection, (also username, wikiusername etc - like USERINFO) or any of the standard FormatTokens.
  • Syntax: %USERSLIST{"format" ...}%
  • Supported parameters:
    Parameter: Description: Default:
    "format" Format of one line, may include $wikiname, $marker (which expands to marker for the item matching selection only) "$wikiname"
    format="format" (Alternative to above) "$topic"
    separator=", " line separator "$n" (new line)
    marker="selected" Text for $marker if the item matches selection "selected"
    selection="UserA, UserB" Current value to be selected in list (none)

Also GROUPSLIST

Examples

<select size="7" name="users" multiple="multiple">
%USERSLIST{format="<option $marker>$name</option>" selection="%URLPARAM{"users" multiple="on" separator=", "}%"}%
</select>

Impact

WhatDoesItAffect: API, Usability, Vars

Implementation

sub USERSLIST {
    my( $this, $params ) = @_;
    my $format = $params->{_DEFAULT} || $params->{'format'} || '$wikiname';
    my $separator = $params->{separator} || "\n";
    $separator =~ s/\$n/\n/;
    my $selection = $params->{selection} || '';
    $selection =~ s/\,/ /g;
    $selection = " $selection ";
    my $marker = $params->{marker} || 'selected="selected"';

    my @items;
    my $it = TWiki::Func::eachUser();
    while ($it->hasNext()) {
        my $item = $it->next();
        my $line = $format;
        $line =~ s/\$wikiname\b/$item/g;
        my $mark = ( $selection =~ / \Q$item\E / ) ? $marker : '';
        $line =~ s/\$marker/$mark/g;
        if (defined(&TWiki::Func::decodeFormatTokens)) {
            $line = TWiki::Func::decodeFormatTokens( $line );
        } else {
            $line =~ s/\$n\(\)/\n/gs;
            $line =~ s/\$n([^$TWiki::regex{mixedAlpha}]|$)/\n$1/gs;
            $line =~ s/\$nop(\(\))?//gs;
            $line =~ s/\$quot(\(\))?/\"/gs;
            $line =~ s/\$percnt(\(\))?/\%/gs;
            $line =~ s/\$dollar(\(\))?/\$/gs;
        }
        push( @items, $line );
    }
    return join( $separator, @items);
}
GROUPSLIST would be done similarly.

-- Contributors: CrawfordCurrie - 04 Dec 2007

Discussion

-   my $separator = $params->{separator} || "\n";
+  my $separator = $params->{separator};
+  $separator = "\n" unless defined $separator;
Same for marker and format. I can't set them to the empty string otherwise.

-- MichaelDaum - 04 Dec 2007

Remember - Georgetown - ie after release of 4.2.0

-- KennethLavrsen - 05 Dec 2007

Where does the login to wikiname mapping get stored if we discontinue the TWikiUsers topic?

-- PeterThoeny - 05 Dec 2007

Depends on the user mapper. The TWikiUserMapping shipped with the standard TWiki still uses the TWikiUsers topic, but other user mappers (e.g. LDAP & various other SSO solutions) do not.

-- CrawfordCurrie - 06 Dec 2007

The TWikiUsers topic is now only used to map if {AllowLoginNames} is set to true. Like on TWiki.org, its faster to just use the password system, if no mapping is needed. So.. I'd like to extend this proposal to be used on the TWikiUsers topic in the {AllowLoginNames} = off case too.

BUT. we should re-write it not to get all the users, then iterate over the list. Rather to use the iterator to do partial evaluations, and to provide paging. Which leads to the bigger refactoring proposal: ExtractAndCentralizeFormattingRefactor

-- SvenDowideit - 15 Dec 2007

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