Add the other existing $skin.css/.js to the message files too to be consistent
[lhc/web/wiklou.git] / includes / SpecialBlockip.php
index 0f503d2..5ea25ca 100644 (file)
@@ -314,9 +314,9 @@ class IPBlockForm {
                                # 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 ) );
@@ -342,32 +342,25 @@ class IPBlockForm {
                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
                # 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);
+                       $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));
@@ -375,6 +368,10 @@ class IPBlockForm {
 
                        wfRunHooks('BlockIpComplete', array($block, $wgUser));
 
+                       if ( $this->BlockWatchUser ) { 
+                               $wgUser->addWatch ( Title::makeTitle( NS_USER, $this->BlockAddress ) );
+                       }
+
                        # Prepare log parameters
                        $logParams = array();
                        $logParams[] = $expirestr;