Tags:
twiki_func1Add my vote for this tag create new tag
, view all tags

Merge FuncUsersContrib with Func

FuncUsersContrib has a bunch of functionality that was originall intended to be merged for 4.1. On revisiting this functionality, i found that the get/set ACLs stuff, and the all-users and all-groups methods, are useless on a large site (they can generate multi-thousand user lists). Iterators are required instead.

So it really isn't right for Func as written, so I cherry-picked the best functions and added them (with more efficient APIs). The existing FuncUsersContrib APIs are still available from the contrib, but the methods in the core are far more efficient.

This is checked in to MAIN, but can of course be reverted if it is rejected. All code is supported by unit tests. I named the new functions to avoid conflicts in existing FUC applications.

Note that the changes run all the way down to the user mapping code, so alternate user mapping implementations - such as LdapContrib - will almost certainly need to be recoded. However they will benefit from the change.

=pod

emailToWikiNames( $email, $dontAddWeb ) -> @wikiNames

  • $email - email address to look up
  • $dontAddWeb - Do not add web prefix if "1"
Find the wikinames of all users who have the given email address as their registered address. Since several users could register with the same email address, this returns a list of wikinames rather than a single wikiname.

Since: TWiki::Plugins::VERSION 1.12

=cut

=pod

wikiNameToEmails( $wikiname ) -> @emails

  • $wikiname - wikiname of user to look up
Returns the registered email addresses of the named user. If $wikiname is undef, returns the registered email addresses for the logged-in user.

Since: TWiki::Plugins::VERSION 1.12

=cut

=pod

isAnAdmin( $user ) -> $boolean

Find out if the user is an admin or not. If the user is not given, the currently logged-in user is assumed.

Since: TWiki::Plugins::VERSION 1.12

=cut

=pod

isGroupMember( $group, $user ) -> $boolean

Find out if the $user is in the named group. e.g.

if( TWiki::Func::isInGroup( "HesperionXXGroup", "JordiSavall" )) {
    ...
}
If $user is undef, it defaults to the currently logged-in user.

Since: TWiki::Plugins::VERSION 1.12

=cut

=pod

eachUser() -> $iterator

Get an iterator over the list of all the registered users not including groups. The iterator will return each wikiname in turn (e.g. FredBloggs).

Use it as follows:

    my $iterator = TWiki::Func::getAllUsers();
    while ($iterator->hasNext()) {
        my $user = $iterator->next();
        # $user is a wikiname
    }

WARNING on large sites, this could be a long list!

Since: TWiki::Plugins::VERSION 1.12

=cut

=pod

eachGroup() -> $iterator

Get an iterator over all groups.

Use it as follows:

    my $iterator = TWiki::Func::getAllGroups();
    while ($iterator->hasNext()) {
         my $group = $it->next();
        # $group is a group name e.g. TWikiAdminGroup
    }

WARNING on large sites, this could be a long list!

Since: TWiki::Plugins::VERSION 1.12

=cut

=pod

isGroup( $group ) -> $boolean

Checks if $group is the name of a group known to TWiki.

=cut

=pod

eachGroupMember( $group ) -> $iterator

Returns an iterator over the names of all users (and groups) in a group. Use it as follows:

    my $iterator = TWiki::Func::eachGroupMember($group);
    while ($iterator->hasNext()) {
        my $user = $it->next();
        # $user is a wikiname
    }

WARNING on large sites, this could be a long list!

=cut

=pod

eachMembership($user) -> @iterator

Get an iterator over of the names of all groups that the user is a member of. If $user is undef, defaults to the currently logged-in user.

Since: TWiki::Plugins::VERSION 1.12

=cut

-- Contributors: CrawfordCurrie - 08 Feb 2007

Discussion

I'd rename getAllUsers() to getUserItereator() and getAllGroups() to getGroupIterator() as this better reflects what's going on.

-- MichaelDaum - 08 Feb 2007

How about eachUser and eachGroup? It is more perlish.

Must also change the names of isAdmin and isInGroup to avoid conflicts with sites that have FuncUsersContrib installed. isAnAdmin and isGroupMember are intention revealing.

Done above.

-- CrawfordCurrie - 08 Feb 2007

As I wrote in the bug item. This change is to large for a Patch release. We will be injecting new bugs with this. So this is for 4.2

-- KennethLavrsen - 09 Feb 2007

This was accepted by the 14-day rule. No real concerns was raised. The spec discussion was settled between Michael and Crawford.

-- KennethLavrsen - 09 Apr 2007

Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r10 - 2007-05-08 - 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-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.