LimitWikiGroups
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.
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.
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 (|).
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
- Limit New Pages In Wiki Groups
- New Group Warning : how to display a warning when a user is creating a page in a non-existant wiki group, without blocking the page creation.
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?