*/
class IPBlockForm {
var $BlockAddress, $BlockExpiry, $BlockReason;
+ // The maximum number of edits a user can have and still be hidden
+ const HIDEUSER_CONTRIBLIMIT = 1000;
public function __construct( $par ) {
global $wgRequest, $wgUser, $wgBlockAllowsUTEdit;
$this->BlockAnonOnly = $wgRequest->getBool( 'wpAnonOnly', $byDefault );
$this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', $byDefault );
$this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', $byDefault );
- $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false );
+ $this->BlockEmail = false;
+ if( self::canBlockEmail( $wgUser ) ) {
+ $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false );
+ }
$this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false );
# Re-check user's rights to hide names, very serious, defaults to 0
$this->BlockHideName = ( $wgRequest->getBool( 'wpHideName', 0 ) && $wgUser->isAllowed( 'hideuser' ) ) ? 1 : 0;
{$mIpaddress}
</td>
<td class='mw-input'>" .
- Xml::input( 'wpBlockAddress', 45, $this->BlockAddress,
- array(
- 'tabindex' => '1',
- 'id' => 'mw-bi-target',
- 'onchange' => 'updateBlockOptions()' ) ). "
+ Html::input( 'wpBlockAddress', $this->BlockAddress, 'text', array(
+ 'tabindex' => '1',
+ 'id' => 'mw-bi-target',
+ 'onchange' => 'updateBlockOptions()',
+ 'size' => '45',
+ 'required' => ''
+ ) + ( $this->BlockAddress ? array() : array( 'autofocus' ) ) ). "
</td>
</tr>
<tr>"
{$mIpbreason}
</td>
<td class='mw-input'>" .
- Xml::input( 'wpBlockReason', 45, $this->BlockReason,
- array( 'tabindex' => '5', 'id' => 'mw-bi-reason', 'maxlength'=> '200' ) ) . "
+ Html::input( 'wpBlockReason', $this->BlockReason, 'text', array(
+ 'tabindex' => '5',
+ 'id' => 'mw-bi-reason',
+ 'maxlength' => '200',
+ 'size' => '45'
+ ) + ( $this->BlockAddress ? array( 'autofocus' ) : array() ) ) . "
</td>
</tr>
<tr id='wpAnonOnlyRow'>
</tr>"
);
- global $wgSysopEmailBans, $wgBlockAllowsUTEdit;
- if( $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) {
+ if( self::canBlockEmail( $wgUser ) ) {
$wgOut->addHTML("
<tr id='wpEnableEmailBan'>
<td> </td>
</td>
</tr>"
);
+
+ # Can we explicitly disallow the use of user_talk?
+ global $wgBlockAllowsUTEdit;
if( $wgBlockAllowsUTEdit ){
$wgOut->addHTML("
<tr id='wpAllowUsertalkRow'>
$this->showLogFragment( $wgOut, Title::makeTitle( NS_USER, $this->BlockAddress ) );
}
}
+
+ /**
+ * Can we do an email block?
+ * @param User $user The sysop wanting to make a block
+ * @return boolean
+ */
+ public static function canBlockEmail( $user ) {
+ global $wgEnableUserEmail, $wgSysopEmailBans;
+ return ($wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' ));
+ }
/**
* Backend block code.
} else if( $expiry !== 'infinity' ) {
// Bad expiry.
return array('ipb_expiry_temp');
- } else if( User::edits($userId) > 3000 ) {
+ } else if( User::edits($userId) > self::HIDEUSER_CONTRIBLIMIT ) {
// Typically, the user should have a handful of edits.
// Disallow hiding users with many edits for performance.
return array('ipb_hide_invalid');
# Set *_deleted fields if requested
if( $this->BlockHideName ) {
- self::suppressUserName( $this->BlockAddress, $userId, $reasonstr );
+ self::suppressUserName( $this->BlockAddress, $userId );
}
# Only show watch link when this is no range block
}
}
- public static function suppressUserName( $name, $userId, $reason = '' ) {
- $user = User::newFromName( $name, false );
- # Delete the user pages that exists
- $title = $user->getUserPage();
- if( ($id = $title->getArticleID(GAID_FOR_UPDATE)) ) {
- $article = new Article( $title );
- $article->doDeleteArticle( $reason, true /*suppress*/, $id );
- }
- # Delete the user talk pages that exists
- $title = $user->getTalkPage();
- if( $id = $title->getArticleID(GAID_FOR_UPDATE) ) {
- $article = new Article( $title );
- $article->doDeleteArticle( $reason, true /*suppress*/, $id );
- }
+ public static function suppressUserName( $name, $userId ) {
$op = '|'; // bitwise OR
return self::setUsernameBitfields( $name, $userId, $op );
}
$delAction = LogPage::DELETED_ACTION | Revision::DELETED_RESTRICTED;
# Normalize user name
$userTitle = Title::makeTitleSafe( NS_USER, $name );
- $userDbKey = $userTitle->getDBKey();
+ $userDbKey = $userTitle->getDBkey();
# To suppress, we OR the current bitfields with Revision::DELETED_USER
# to put a 1 in the username *_deleted bit. To unsuppress we AND the
# current bitfields with the inverse of Revision::DELETED_USER. The
private function showLogFragment( $out, $title ) {
global $wgUser;
- $out->addHTML( Xml::element( 'h2', NULL, LogPage::logName( 'block' ) ) );
- $count = LogEventsList::showLogExtract( $out, 'block', $title->getPrefixedText(), '', 10 );
- if( $count > 10 ) {
- $out->addHTML( $wgUser->getSkin()->link(
- SpecialPage::getTitleFor( 'Log' ),
- wfMsgHtml( 'blocklog-fulllog' ),
- array(),
- array(
- 'type' => 'block',
- 'page' => $title->getPrefixedText() ) ) );
- }
+
+ // Used to support GENDER in 'blocklog-showlog' and 'blocklog-showsuppresslog'
+ $userBlocked = $title->getText();
+
+ LogEventsList::showLogExtract(
+ $out,
+ 'block',
+ $title->getPrefixedText(),
+ '',
+ array(
+ 'lim' => 10,
+ 'msgKey' => array(
+ 'blocklog-showlog',
+ $userBlocked
+ ),
+ 'showIfEmpty' => false
+ )
+ );
+
// Add suppression block entries if allowed
- if( $wgUser->isAllowed('hideuser') ) {
- $out->addHTML( Xml::element( 'h2', NULL, LogPage::logName( 'suppress' ) ) );
+ if( $wgUser->isAllowed( 'hideuser' ) ) {
LogEventsList::showLogExtract( $out, 'suppress', $title->getPrefixedText(), '',
- 10, array('log_action' => array('block','reblock','unblock')) );
+ array(
+ 'lim' => 10,
+ 'conds' => array(
+ 'log_action' => array(
+ 'block',
+ 'reblock',
+ 'unblock'
+ )
+ ),
+ 'msgKey' => array(
+ 'blocklog-showsuppresslog',
+ $userBlocked
+ ),
+ 'showIfEmpty' => false
+ )
+ );
}
}
$links[] = $this->getContribsLink( $skin );
$links[] = $this->getUnblockLink( $skin );
$links[] = $this->getBlockListLink( $skin );
- $links[] = $skin->makeLink ( 'MediaWiki:Ipbreason-dropdown', wfMsgHtml( 'ipb-edit-dropdown' ) );
+ $title = Title::makeTitle( NS_MEDIAWIKI, 'Ipbreason-dropdown' );
+ $links[] = $skin->link(
+ $title,
+ wfMsgHtml( 'ipb-edit-dropdown' ),
+ array(),
+ array( 'action' => 'edit' )
+ );
return '<p class="mw-ipb-conveniencelinks">' . $wgLang->pipeList( $links ) . '</p>';
}
*/
private function getContribsLink( $skin ) {
$contribsPage = SpecialPage::getTitleFor( 'Contributions', $this->BlockAddress );
- return $skin->link( $contribsPage, wfMsgHtml( 'ipb-blocklist-contribs', $this->BlockAddress ) );
+ return $skin->link( $contribsPage, wfMsgExt( 'ipb-blocklist-contribs', 'escape', $this->BlockAddress ) );
}
/**
*/
private function getUnblockLink( $skin ) {
$list = SpecialPage::getTitleFor( 'Ipblocklist' );
+ $query = array( 'action' => 'unblock' );
+
if( $this->BlockAddress ) {
- $addr = htmlspecialchars( strtr( $this->BlockAddress, '_', ' ' ) );
- return $skin->makeKnownLinkObj( $list, wfMsgHtml( 'ipb-unblock-addr', $addr ),
- 'action=unblock&ip=' . urlencode( $this->BlockAddress ) );
+ $addr = strtr( $this->BlockAddress, '_', ' ' );
+ $message = wfMsg( 'ipb-unblock-addr', $addr );
+ $query['ip'] = $this->BlockAddress;
} else {
- return $skin->makeKnownLinkObj( $list, wfMsgHtml( 'ipb-unblock' ), 'action=unblock' );
+ $message = wfMsg( 'ipb-unblock' );
}
+ return $skin->linkKnown(
+ $list,
+ htmlspecialchars($message),
+ array(),
+ $query
+ );
}
/**
*/
private function getBlockListLink( $skin ) {
$list = SpecialPage::getTitleFor( 'Ipblocklist' );
+ $query = array();
+
if( $this->BlockAddress ) {
- $addr = htmlspecialchars( strtr( $this->BlockAddress, '_', ' ' ) );
- return $skin->makeKnownLinkObj( $list, wfMsgHtml( 'ipb-blocklist-addr', $addr ),
- 'ip=' . urlencode( $this->BlockAddress ) );
+ $addr = strtr( $this->BlockAddress, '_', ' ' );
+ $message = wfMsg( 'ipb-blocklist-addr', $addr );
+ $query['ip'] = $this->BlockAddress;
} else {
- return $skin->makeKnownLinkObj( $list, wfMsgHtml( 'ipb-blocklist' ) );
+ $message = wfMsg( 'ipb-blocklist' );
}
+
+ return $skin->linkKnown(
+ $list,
+ htmlspecialchars($message),
+ array(),
+ $query
+ );
}
/**