LimitWikiGroups

Summary: How to limit the names or number of groups in your wiki
Status:
Version:
Prerequisites: pmwiki-2.0
Maintainer:
Categories: Administration
Votes:

Questions this recipe answers

  • Can I limit, constrain, restrict, or control the groups or group names on my wiki?
  • Can I prevent users from creating new WikiGroups?

The answer to both questions is "yes". There are at least four ways to do this. Each has advantages and disadvantages.

Method 1:

First, block all edits with a site-wide edit password in local/config.php:

$DefaultPasswords['edit'] = crypt('yersecretpass');

Then set the edit password to "nopass" in the GroupAttributes page for each group where editing and page creation should be allowed.

Advantages: Only groups with the correct attribute can be edited. No one can create a new group unless they know "yersecretpass". To add a new group, just use "yersecretpass" when asked for a password. You do not need to change the config file for each new group.
Disadvantages: You need to explicitly allow editing and page creation in each group, which can be a pain for wikis with a lot of groups. In particular, you need to add edit permissions to each new group you create.

Method 2:

Add the following to local/config.php.

$rc = FmtPageName('$Group.RecentChanges', $pagename);
if (!PageExists($rc)) 
  $DefaultPasswords['edit'] = $DefaultPasswords['admin']; 

This prevents new pages from being created unless the group already contains a RecentChanges page or you use the administrator password. An attempt to create a page in a new group will fail, because there is no RecentChanges page until the group is created.

Advantages: You can add new groups if you know the admin password. You do not have to do anything special for new groups. You do not need to change the config file for each new group. This is the best "set and forget" method.
Disadvantages: Any wikigroup you want to edit must have a RecentChanges pages. Under normal circumstances all groups will have such a page, but there may be wikis where some groups do not.
Tip: You could instead use Group.HomePage which is likely to be the first page created in a group.

Method 3:

Set PmWiki's $GroupPattern variable to only accept the group names you want to define. For example, to limit pages to the "Site", "SiteAdmin", "PmWiki", "Main", "Profiles", and "Example" groups, add the following to local/config.php:

$GroupPattern = '(?:Site|SiteAdmin|PmWiki|Main|Profiles|Example)'; # (case insensitive)
$GroupPattern = '(?-i:Site|SiteAdmin|PmWiki|Main|Profiles|Example)'; # (case sensitive)

With this setting only the listed groups will be considered valid WikiGroups. You can add more groups to the list by placing additional group names separated by pipes (|).

Advantages: Gives you complete control over group names. You can "pre-authorize" group names by including them in the list before they are created. You do not have to do anything special "inside" the group (such as setting attributes).
Disadvantages: You have to explicitly name all of the groups allowed. Requires access to the config file for each group addition (unless you pre-authorize a bunch). This not only limits the groups that can be created, but also the groups that can be read.

Note that in PmWiki version 2.2.0-beta58 (2007-07-17) and newer, the group SiteAdmin is used by PmWiki for some settings. If you used a custom $GroupPattern with an older version, when you upgrade you need to change it to include the SiteAdmin group.

Method 4

Add the following to local/config.php.

$pagename = ResolvePageName($pagename);

$rc = FmtPageName('$Group.$DefaultName', $pagename);
if (!PageExists($rc))
   $DefaultPasswords['edit'] = crypt('group_creation_password');

This prevents new pages from being created unless the group already contains a wiki group home page, or you use the administrator password. An attempt to create a page in a new group will fail, because there is no default home page until the group is created.

See also

Contributors

  • Pm, 21-Mar-2005
  • Old Al copied this from the pmwiki mailing list, 2005.03.22
  • Radu rearranged all and added the second solution from Pm's message of 2005.05.06
  • NeilHerber March 11, 2006, at 10:35 PM rewriting

Comments

See discussion at LimitWikiGroups-Talk?