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');
+ }
+
+ if( $this->BlockHideName && $expiry != 'infinity' ) {
+ // Bad expiry.
+ return array('ipb_expiry_temp');
}
# Create block
$block = new Block( $this->BlockAddress, $userId, $wgUser->getId(),
$reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly,
$this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName,
- $this->BlockEmail);
+ $this->BlockEmail );
- if ( $this->BlockWatchUser ) {
- $wgUser->addWatch ( Title::makeTitle( NS_USER, $this->BlockAddress ) );
- }
-
- if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) {
+ if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) {
if ( !$block->insert() ) {
return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress));
wfRunHooks('BlockIpComplete', array($block, $wgUser));
+ if ( $this->BlockWatchUser ) {
+ $wgUser->addWatch ( Title::makeTitle( NS_USER, $this->BlockAddress ) );
+ }
+
# Prepare log parameters
$logParams = array();
$logParams[] = $expirestr;