Introduce 'FetchChangesList' hook; see docs/hooks.txt for more information
[lhc/web/wiklou.git] / includes / Block.php
index 8277746..26fa444 100644 (file)
@@ -4,13 +4,6 @@
  * @package MediaWiki
  */
 
-/**
- * Some globals
- */
-define ( 'EB_KEEP_EXPIRED', 1 );
-define ( 'EB_FOR_UPDATE', 2 );
-define ( 'EB_RANGE_ONLY', 4 );
-
 /**
  * The block class
  * All the functions in this class assume the object is either explicitly
@@ -27,6 +20,10 @@ class Block
        /* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry,
                            $mRangeStart, $mRangeEnd;
        /* private */ var $mNetworkBits, $mIntegerAddr, $mForUpdate, $mFromMaster, $mByName;
+       
+       const EB_KEEP_EXPIRED = 1;
+       const EB_FOR_UPDATE = 2;
+       const EB_RANGE_ONLY = 4;
 
        function Block( $address = '', $user = '', $by = 0, $reason = '',
                $timestamp = '' , $auto = 0, $expiry = '' )
@@ -67,7 +64,7 @@ class Block
        /**
         * Get the DB object and set the reference parameter to the query options
         */
-       function &getDBOptions( &$options ) 
+       function &getDBOptions( &$options )
        {
                global $wgAntiLockFlags;
                if ( $this->mForUpdate || $this->mFromMaster ) {
@@ -162,7 +159,7 @@ class Block
        }
 
        /**
-        * Search the database for any range blocks matching the given address, and 
+        * Search the database for any range blocks matching the given address, and
         * load the row if one is found.
         */
        function loadRange( $address, $killExpired = true )
@@ -178,7 +175,7 @@ class Block
                # Only scan ranges which start in this /16, this improves search speed
                # Blocks should not cross a /16 boundary.
                $range = substr( $iaddr, 0, 4 );
-               
+
                $options = '';
                $db =& $this->getDBOptions( $options );
                $ipblocks = $db->tableName( 'ipblocks' );
@@ -196,9 +193,9 @@ class Block
                        if ( !$killExpired || !$this->deleteIfExpired() ) {
                                # No, return true
                                $success = true;
-                       } 
+                       }
                }
-               
+
                $db->freeResult( $res );
                return $success;
        }
@@ -246,7 +243,7 @@ class Block
                                $this->mRangeStart = sprintf( '%08X', $network );
                                $this->mRangeEnd = sprintf( '%08X', $network + (1 << (32 - $bits)) - 1 );
                        }
-               }       
+               }
        }
 
        /**
@@ -258,7 +255,7 @@ class Block
                global $wgAntiLockFlags;
 
                $block = new Block();
-               if ( $flags & EB_FOR_UPDATE ) {
+               if ( $flags & Block::EB_FOR_UPDATE ) {
                        $db =& wfGetDB( DB_MASTER );
                        if ( $wgAntiLockFlags & ALF_NO_BLOCK_LOCK ) {
                                $options = '';
@@ -270,7 +267,7 @@ class Block
                        $db =& wfGetDB( DB_SLAVE );
                        $options = '';
                }
-               if ( $flags & EB_RANGE_ONLY ) {
+               if ( $flags & Block::EB_RANGE_ONLY ) {
                        $cond = " AND ipb_range_start <> ''";
                } else {
                        $cond = '';
@@ -287,11 +284,11 @@ class Block
 
                while ( $row = $db->fetchObject( $res ) ) {
                        $block->initFromRow( $row );
-                       if ( ( $flags & EB_RANGE_ONLY ) && $block->mRangeStart == '' ) {
+                       if ( ( $flags & Block::EB_RANGE_ONLY ) && $block->mRangeStart == '' ) {
                                continue;
                        }
 
-                       if ( !( $flags & EB_KEEP_EXPIRED ) ) {
+                       if ( !( $flags & Block::EB_KEEP_EXPIRED ) ) {
                                if ( $block->mExpiry && $now > $block->mExpiry ) {
                                        $block->delete();
                                } else {
@@ -318,7 +315,7 @@ class Block
                } else {
                        $condition = array( 'ipb_address' => $this->mAddress );
                }
-               $dbw->delete( 'ipblocks', $condition, $fname );
+               return( $dbw->delete( 'ipblocks', $condition, $fname ) > 0 ? true : false );
        }
 
        function insert()