/**
* Constructor for Special:Blockip page
*
- * @addtogroup SpecialPage
+ * @file
+ * @ingroup SpecialPage
*/
/**
/**
* Form object for the Special:Blockip page.
*
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
*/
class IPBlockForm {
var $BlockAddress, $BlockExpiry, $BlockReason;
$this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', $byDefault );
$this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', $byDefault );
$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;
}
if ( "" != $err ) {
$wgOut->setSubtitle( wfMsgHtml( 'formerror' ) );
- $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $err ) );
+ $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $err ) );
}
$scBlockExpiryOptions = wfMsgForContent( 'ipboptions' );
}
$reasonDropDown = Xml::listDropDown( 'wpBlockReasonList',
- wfMsgForContent( 'ipbreason-dropdown' ),
+ wfMsgForContent( 'ipbreason-dropdown' ),
wfMsgForContent( 'ipbreasonotherlist' ), '', 'wpBlockDropDown', 4 );
global $wgStylePath, $wgStyleVersion;
{$mIpbexpiry}
</td>
<td class='mw-input'>" .
- Xml::tags( 'select',
+ Xml::tags( 'select',
array(
'id' => 'wpBlockExpiry',
'name' => 'wpBlockExpiry',
</tr>"
);
}
+
+ # Watchlist their user page?
+ $wgOut->addHTML("
+ <tr id='wpEnableWatchUser'>
+ <td> </td>
+ <td class='mw-input'>" .
+ Xml::checkLabel( wfMsg( 'ipbwatchuser' ),
+ 'wpWatchUser', 'wpWatchUser', $this->BlockWatchUser,
+ array( 'tabindex' => '11' ) ) . "
+ </td>
+ </tr>"
+ );
$wgOut->addHTML("
<tr>
<td style='padding-top: 1em'> </td>
<td class='mw-submit' style='padding-top: 1em'>" .
Xml::submitButton( wfMsg( 'ipbsubmit' ),
- array( 'name' => 'wpBlock', 'tabindex' => '11' ) ) . "
+ array( 'name' => 'wpBlock', 'tabindex' => '12' ) ) . "
</td>
</tr>" .
Xml::closeElement( 'table' ) .
$rxIP4 = '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
$rxIP6 = '\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}:\w{1,4}';
$rxIP = "($rxIP4|$rxIP6)";
-
+
# Check for invalid specifications
if ( !preg_match( "/^$rxIP$/", $this->BlockAddress ) ) {
$matches = array();
# Username block
if ( $wgSysopUserBans ) {
$user = User::newFromName( $this->BlockAddress );
- if( !is_null( $user ) && $user->getID() ) {
+ if( !is_null( $user ) && $user->getId() ) {
# Use canonical name
- $userId = $user->getID();
+ $userId = $user->getId();
$this->BlockAddress = $user->getName();
} else {
return array('nosuchusershort', htmlspecialchars( $user ? $user->getName() : $this->BlockAddress ) );
if (strlen($expirestr) == 0) {
return array('ipb_expiry_invalid');
}
-
- if ( $expirestr == 'infinite' || $expirestr == 'indefinite' ) {
- $expiry = Block::infinity();
- } else {
- # Convert GNU-style date, on error returns -1 for PHP <5.1 and false for PHP >=5.1
- $expiry = strtotime( $expirestr );
-
- if ( $expiry < 0 || $expiry === false ) {
- return array('ipb_expiry_invalid');
- }
-
- $expiry = wfTimestamp( TS_MW, $expiry );
+
+ if ( false === ($expiry = Block::parseExpiryInput( $expirestr )) ) {
+ // Bad expiry.
+ return array('ipb_expiry_invalid');
}
# Create block
# Note: for a user block, ipb_address is only for display purposes
- $block = new Block( $this->BlockAddress, $userId, $wgUser->getID(),
+ $block = new Block( $this->BlockAddress, $userId, $wgUser->getId(),
$reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly,
$this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName,
$this->BlockEmail);
+ if ( $this->BlockWatchUser ) {
+ $wgUser->addWatch ( Title::makeTitle( NS_USER, $this->BlockAddress ) );
+ }
+
if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) {
if ( !$block->insert() ) {
}
}
}
-