A UESPWiki – Sua fonte de The Elder Scrolls desde 1995

RestrictBlock is an extension that can do two things: prevent blocks longer than a specified amount of time, and prevent blocks that block the user from editing their talk page.

Source and installation

The following goes into extensions/RestrictBlock/RestrictBlock.php:


if ( !defined( 'MEDIAWIKI' ) ) {

//Give sysops the right to block editors from editing their talk page and for any length of time
$wgGroupPermissions['sysop']['blocktalk'] = true;
$wgGroupPermissions['sysop']['unrestrictedblock'] = true;
//Maximum block length, in seconds

$wgExtensionCredits['other'][] = array(
        'name' => 'RestrictBlock',
        'author' => '[http://www.mediawiki.org/wiki/User:Nx Nx]',
        'description' => 'Places restrictions on block length and options'

$wgRestrictBlockIP = dirname( __FILE__ );
$wgExtensionMessagesFiles['RestrictBlock'] = "$wgRestrictBlockIP/RestrictBlock.i18n.php";

$wgHooks['BlockIp'][] = 'RestrictBlockHook';

//Avoid unstubbing $wgParser on setHook() too early on modern (1.12+) MW versions, as per r35980
        $wgHooks['ParserFirstCallInit'][] = 'RestrictBlockInit';
} else { // Otherwise do things the old fashioned way
        $wgExtensionFunctions[] = 'RestrictBlockInit';

function RestrictBlockInit()
  //Load messages so that color-coding works.
  wfLoadExtensionMessages( 'RestrictBlock' );
  return true;

//intercept blocks
function RestrictBlockHook( &$ban, &$user )
  //check if the ban disables talk page editing
  global $wgBlockAllowsUTEdit;
  if ( $wgBlockAllowsUTEdit && !$ban->mAllowUsertalk && !$user->isAllowed('blocktalk') ) {
    return wfMsgWikiHtml('restrictblock-denied-utalk');
  //check for block length
  if ( !$user->isAllowed('unrestrictedblock') ) {
    global $wgRestrictBlockLength;
    //infinity is right out
    if ( $ban->mExpiry === 'infinity' ) {
      return wfMsgWikiHtml('restrictblock-denied', $wgRestrictBlockLength);
    $timediff = (wfTimestamp(TS_UNIX,$ban->mExpiry) - time());
    if ($timediff > $wgRestrictBlockLength) {
      return wfMsgWikiHtml('restrictblock-denied', $wgRestrictBlockLength);
  return true;

And this goes into extensions/RestrictBlock/RestrictBlock.i18n.php:

$messages = array();

$messages['en'] = array(
  'right-blocktalk'             => 'Block a user from editing their talk page',
  'right-unrestrictedblock'     => 'Block for any length of time',
  'restrictblock-denied-utalk'  => '<div class="error">You are not allowed to block a user from editing their talk page.</div>',
  'restrictblock-denied'        => '<div class="error">You are not allowed to block for more than $1 seconds.</div>',

Finally put

require_once( "$IP/extensions/RestrictBlock/RestrictBlock.php" );

into LocalSettings.php


The blocktalk right allows blocking a user from editing their talk page. The unrestrictedblock right allows blocking for any length of time. Both are given to sysops by the extension. The description of these (shown on Special:ListGroupRights) is at MediaWiki:right-blocktalk and MediaWiki:right-unrestrictedblock.

$wgRestrictBlockLength is the maximum length for a block that a user without the unrestrictedblock right can issue, in seconds. This defaults to 4 hours (14400 seconds).

There are two error messages: MediaWiki:restrictblock-denied-utalk for when the user is not allowed to block editing user talk pages, and MediaWiki:restrictblock-denied for when the user tries to block for longer than the allowed time.