Extension:LimitUserCount
From MediaWiki.org
|
LimitUserCount Release status: stable |
|||
|---|---|---|---|
| Implementation | User activity | ||
| Description | Provides the ability to limit the creation of new users based on user count | ||
| Author(s) | witerate | ||
| Last version | 1.0 | ||
| MediaWiki | 1.17-1.19 | ||
| License | No license specified | ||
| Download | see below | ||
|
|||
|
|||
|
Check usage (experimental) |
|||
LimitUserCount is a MediaWiki extension which provides the ability to limit the creation of new users based on user count.
It checks the current number of users in your Media Wiki and prevents on creating a new user if that number surpasses $wgLimitUserCount.
Contents |
[edit] Motivation
When you start managing a wiki farm with tens or even hundred of wikis, and you want to control the number of registered users on each wiki without actually opening yourself each account, this extension can help you a lot.
[edit] Installation and usage
- Copy LimitUserCount.php to your Media Wiki extensions folder.
- Add the following lines at the end of LocalSettings.php:
require_once( "$IP/extensions/LimitUserCount.php" );
$wgLimitUserCount = 10;
(In the above example, only 10 users will be allowed in the Wiki)
[edit] Source of LimitUserCount.php
- LimitUserCount.php
<?php /** * LimitUserCount - MediaWiki extension * * provides the ability to limit the creation of new users based on user count * */ $wgHooks['AbortNewAccount'][] = 'LimitUserCount'; $wgExtensionMessagesFiles['LimitUserCount'] = dirname( __FILE__ ) . '/LimitUserCount.i18n.php'; function LimitUserCount( $user, $message ) { global $wgLimitUserCount; if( !is_int( $wgLimitUserCount ) ) { return true; # no or invalid limit } $dbr = wfGetDB( DB_SLAVE ); $numUsers = $dbr->selectField( 'user', 'COUNT(*) AS numusers', array(), __METHOD__ ); $message = wfMsg( 'limitusercount-message', $wgLimitUserCount ); return $numUsers < $wgLimitUserCount; } /** * Add extension information to Special:Version */ $wgExtensionCredits['other'][] = array( 'name' => 'LimitUserCount', 'version' => '1.0', 'author' => array( 'Gregory Rashkevitch, Witerate.com Software Solutions', 'SPQRobin' ), 'descriptionmsg' => 'limitusercount-desc', 'url' => 'https://www.mediawiki.org/wiki/Extension:LimitUserCount', ); $wgLimitUserCount = false;
- LimitUserCount.i18n.php
<?php /** * Internationalisation file for extension NewUserMessage. * * @file * @ingroup Extensions */ $messages = array(); $messages['en'] = array( 'limitusercount-message' => 'Cannot create user, the maximum number of users allowed on this wiki has been exceeded!', 'limitusercount-desc' => 'Enable limitation on user creation based on users count', ); $messages['fr'] = array( 'limitusercount-message' => 'Ne peut pas créer l´utilisateur, le nombre maximum d´utilisateurs permises sur ce wiki est dépassé!', 'limitusercount-desc' => 'Permet de limiter les créations des utilisateurs basé sur le nombre d´utilisateurs', ); $messages['nl'] = array( 'limitusercount-message' => 'Kan de gebruiker niet aanmaken, want het maximum aantal gebruikers op deze wiki is bereikt!', 'limitusercount-desc' => 'Laat beperking van nieuwe gebruikers toe volgens het aantal bestaande gebruikers', );
[edit] Configuration
- $wgLimitUserCount - Defines the maximum user count allowed in the Wiki.
- The 'limitusercount-message' message which you can alter. You can find it here - [[MediaWiki:Limitusercount-message]]
[edit] To do
- Consider extra parameters in the users count - bots, admins, blocked users
