Handle multiple warnings correctly in ApiBase::setWarning(). Calling this function...
[lhc/web/wiklou.git] / includes / SpecialBlockip.php
index 20063c0..0f503d2 100644 (file)
@@ -2,7 +2,8 @@
 /**
  * Constructor for Special:Blockip page
  *
- * @addtogroup SpecialPage
+ * @file
+ * @ingroup SpecialPage
  */
 
 /**
@@ -39,7 +40,7 @@ function wfSpecialBlockip( $par ) {
 /**
  * Form object for the Special:Blockip page.
  *
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
  */
 class IPBlockForm {
        var $BlockAddress, $BlockExpiry, $BlockReason;
@@ -62,6 +63,7 @@ class IPBlockForm {
                $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;
        }
@@ -226,13 +228,25 @@ class IPBlockForm {
                                </tr>"
                        );
                }
+               
+               # Watchlist their user page?
+               $wgOut->addHTML("
+                       <tr id='wpEnableWatchUser'>
+                               <td>&nbsp;</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'>&nbsp;</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' ) .
@@ -349,14 +363,18 @@ class IPBlockForm {
                        $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName,
                        $this->BlockEmail);
 
-               if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) {
-                       $dbw = wfGetDB( DB_MASTER );
-                       $dbw->begin();
-                       if ( !$block->insert( $dbw ) ) {
-                               $dbw->rollback(); // this could be commit as well; zero rows either way
+               if ( $this->BlockWatchUser ) { 
+                       $wgUser->addWatch ( Title::makeTitle( NS_USER, $this->BlockAddress ) );
+               }
+               
+               if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) {
+
+                       if ( !$block->insert() ) {
                                return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress));
                        }
 
+                       wfRunHooks('BlockIpComplete', array($block, $wgUser));
+
                        # Prepare log parameters
                        $logParams = array();
                        $logParams[] = $expirestr;
@@ -365,20 +383,14 @@ class IPBlockForm {
                        # Make log entry, if the name is hidden, put it in the oversight log
                        $log_type = ($this->BlockHideName) ? 'suppress' : 'block';
                        $log = new LogPage( $log_type );
-                       $ok = $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ),
-                         $reasonstr, $logParams, $dbw );
-                       # Make sure logging got through
-                       if( !$ok ) {
-                               $dbw->rollback();
-                               return array('databaseerror');
-                       }
-                       $dbw->commit();
-                       wfRunHooks('BlockIpComplete', array($block, $wgUser));
+                       $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ),
+                         $reasonstr, $logParams );
+
                        # Report to the user
                        return array();
-               } else {
-                       return array('hookaborted');
                }
+               else
+                       return array('hookaborted');
        }
 
        /**