return null;
}
}
-
+
/**
* Check if two blocks are effectively equal
*
* @return Boolean
*/
public function equals( Block $block ) {
- return (
+ return (
$this->mAddress == $block->mAddress
&& $this->mUser == $block->mUser
&& $this->mAuto == $block->mAuto
global $wgAntiLockFlags;
if ( $this->mForUpdate || $this->mFromMaster ) {
$db = wfGetDB( DB_MASTER );
- if ( !$this->mForUpdate || ($wgAntiLockFlags & ALF_NO_BLOCK_LOCK) ) {
+ if ( !$this->mForUpdate || ( $wgAntiLockFlags & ALF_NO_BLOCK_LOCK ) ) {
$options = array();
} else {
$options = array( 'FOR UPDATE' );
);
$affected = $dbw->affectedRows();
- if ($affected)
+ if ( $affected )
$this->doRetroactiveAutoblock();
return (bool)$affected;
# Unset ipb_enable_autoblock for IP blocks, makes no sense
if ( !$this->mUser ) {
$this->mEnableAutoblock = 0;
-
}
+
# bug 18860: non-anon-only IP blocks should be allowed to block email
if ( !$this->mUser && $this->mAnonOnly ) {
$this->mBlockEmail = 0;
}
}
}
-
-
+
/**
- * Retroactively autoblocks the last IP used by the user (if it is a user)
- * blocked by this Block.
- *
- * @return Boolean: whether or not a retroactive autoblock was made.
- */
+ * Retroactively autoblocks the last IP used by the user (if it is a user)
+ * blocked by this Block.
+ *
+ * @return Boolean: whether or not a retroactive autoblock was made.
+ */
public function doRetroactiveAutoblock() {
$dbr = wfGetDB( DB_SLAVE );
- #If autoblock is enabled, autoblock the LAST IP used
+ # If autoblock is enabled, autoblock the LAST IP used
# - stolen shamelessly from CheckUser_body.php
- if ($this->mEnableAutoblock && $this->mUser) {
+ if ( $this->mEnableAutoblock && $this->mUser ) {
wfDebug("Doing retroactive autoblocks for " . $this->mAddress . "\n");
-
+
$options = array( 'ORDER BY' => 'rc_timestamp DESC' );
$conds = array( 'rc_user_text' => $this->mAddress );
-
- if ($this->mAngryAutoblock) {
+
+ if ( $this->mAngryAutoblock ) {
// Block any IP used in the last 7 days. Up to five IPs.
- $conds[] = 'rc_timestamp < ' . $dbr->addQuotes( $dbr->timestamp( time() - (7*86400) ) );
+ $conds[] = 'rc_timestamp < ' . $dbr->addQuotes( $dbr->timestamp( time() - ( 7 * 86400 ) ) );
$options['LIMIT'] = 5;
} else {
// Just the last IP used.
}
$res = $dbr->select( 'recentchanges', array( 'rc_ip' ), $conds,
- __METHOD__ , $options);
+ __METHOD__ , $options );
if ( !$dbr->numRows( $res ) ) {
- #No results, don't autoblock anything
+ # No results, don't autoblock anything
wfDebug("No IP found to retroactively autoblock\n");
} else {
while ( $row = $dbr->fetchObject( $res ) ) {
}
}
}
-
+
/**
* Checks whether a given IP is on the autoblock whitelist.
*
*/
public static function isWhitelistedFromAutoblocks( $ip ) {
global $wgMemc;
-
+
// Try to get the autoblock_whitelist from the cache, as it's faster
// than getting the msg raw and explode()'ing it.
$key = wfMemcKey( 'ipb', 'autoblock', 'whitelist' );
continue;
}
- $wlEntry = substr($line, 1);
- $wlEntry = trim($wlEntry);
+ $wlEntry = substr( $line, 1 );
+ $wlEntry = trim( $wlEntry );
wfDebug("Checking $ip against $wlEntry...");
# Is the IP in this range?
- if (IP::isInRange( $ip, $wlEntry )) {
+ if ( IP::isInRange( $ip, $wlEntry ) ) {
wfDebug(" IP $ip matches $wlEntry, not autoblocking\n");
return true;
} else {
wfDebug( " No match\n" );
}
}
-
+
return false;
}
}
# Check for presence on the autoblock whitelist
- if (Block::isWhitelistedFromAutoblocks($autoblockIP)) {
+ if ( Block::isWhitelistedFromAutoblocks( $autoblockIP ) ) {
return;
}
## Allow hooks to cancel the autoblock.
- if (!wfRunHooks( 'AbortAutoblock', array( $autoblockIP, &$this ) )) {
+ if ( !wfRunHooks( 'AbortAutoblock', array( $autoblockIP, &$this ) ) ) {
wfDebug( "Autoblock aborted by hook.\n" );
return false;
}
# If the user is already blocked. Then check if the autoblock would
# exceed the user block. If it would exceed, then do nothing, else
# prolong block time
- if ($this->mExpiry &&
- ($this->mExpiry < Block::getAutoblockExpiry($ipblock->mTimestamp))) {
+ if ( $this->mExpiry &&
+ ( $this->mExpiry < Block::getAutoblockExpiry( $ipblock->mTimestamp ) ) ) {
return;
}
# Just update the timestamp
$ipblock->mAllowUsertalk = $this->mAllowUsertalk;
# If the user is already blocked with an expiry date, we don't
# want to pile on top of that!
- if($this->mExpiry) {
- $ipblock->mExpiry = min ( $this->mExpiry, Block::getAutoblockExpiry( $this->mTimestamp ));
+ if( $this->mExpiry ) {
+ $ipblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( $this->mTimestamp ) );
} else {
$ipblock->mExpiry = Block::getAutoblockExpiry( $this->mTimestamp );
}
* @return Boolean
*/
public function deleteIfExpired() {
- $fname = 'Block::deleteIfExpired';
- wfProfileIn( $fname );
+ wfProfileIn( __METHOD__ );
if ( $this->isExpired() ) {
wfDebug( "Block::deleteIfExpired() -- deleting\n" );
$this->delete();
wfDebug( "Block::deleteIfExpired() -- not expired\n" );
$retVal = false;
}
- wfProfileOut( $fname );
+ wfProfileOut( __METHOD__ );
return $retVal;
}
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'ipblocks',
array( /* SET */
- 'ipb_timestamp' => $dbw->timestamp($this->mTimestamp),
- 'ipb_expiry' => $dbw->timestamp($this->mExpiry),
+ 'ipb_timestamp' => $dbw->timestamp( $this->mTimestamp ),
+ 'ipb_expiry' => $dbw->timestamp( $this->mExpiry ),
), array( /* WHERE */
'ipb_address' => $this->mAddress
), 'Block::updateTimestamp'
/**
* Get/set the SELECT ... FOR UPDATE flag
*/
- public function forUpdate( $x = NULL ) {
+ public function forUpdate( $x = null ) {
return wfSetVar( $this->mForUpdate, $x );
}
/**
* Get/set a flag determining whether the master is used for reads
*/
- public function fromMaster( $x = NULL ) {
+ public function fromMaster( $x = null ) {
return wfSetVar( $this->mFromMaster, $x );
}
$parts = explode( '/', $range );
if ( count( $parts ) == 2 ) {
// IPv6
- if ( IP::isIPv6($range) && $parts[1] >= 64 && $parts[1] <= 128 ) {
+ if ( IP::isIPv6( $range ) && $parts[1] >= 64 && $parts[1] <= 128 ) {
$bits = $parts[1];
$ipint = IP::toUnsigned6( $parts[0] );
- # Native 32 bit functions WONT work here!!!
+ # Native 32 bit functions WON'T work here!!!
# Convert to a padded binary number
$network = wfBaseConvert( $ipint, 10, 2, 128 );
# Truncate the last (128-$bits) bits and replace them with zeros
$newip = IP::toOctet( $network );
$range = "$newip/{$parts[1]}";
} // IPv4
- else if ( IP::isIPv4($range) && $parts[1] >= 16 && $parts[1] <= 32 ) {
+ elseif ( IP::isIPv4( $range ) && $parts[1] >= 16 && $parts[1] <= 32 ) {
$shift = 32 - $parts[1];
$ipint = IP::toUnsigned( $parts[0] );
$ipint = $ipint >> $shift << $shift;
# works with CHAR(14) as well because "i" sorts after all numbers.
return 'infinity';
}
-
+
/**
* Convert a DB-encoded expiry into a real string that humans can read.
*
*/
public static function formatExpiry( $encoded_expiry ) {
static $msg = null;
-
+
if( is_null( $msg ) ) {
$msg = array();
$keys = array( 'infiniteblock', 'expiringblock' );
$msg[$key] = wfMsgHtml( $key );
}
}
-
+
$expiry = Block::decodeExpiry( $encoded_expiry );
- if ($expiry == 'infinity') {
+ if ( $expiry == 'infinity' ) {
$expirystr = $msg['infiniteblock'];
} else {
global $wgLang;
- $expiredatestr = htmlspecialchars($wgLang->date( $expiry, true ));
- $expiretimestr = htmlspecialchars($wgLang->time( $expiry, true ));
+ $expiredatestr = htmlspecialchars( $wgLang->date( $expiry, true ) );
+ $expiretimestr = htmlspecialchars( $wgLang->time( $expiry, true ) );
$expirystr = wfMsgReplaceArgs( $msg['expiringblock'], array( $expiredatestr, $expiretimestr ) );
}
return $expirystr;
}
-
+
/**
* Convert a typed-in expiry time into something we can put into the database.
* @param $expiry_input String: whatever was typed into the form
$expiry = 'infinity';
} else {
$expiry = strtotime( $expiry_input );
- if ($expiry < 0 || $expiry === false) {
+ if ( $expiry < 0 || $expiry === false ) {
return false;
}
}
* @static
*/
public static function loadFromPageId( $db, $pageid, $id = 0 ) {
- $conds=array('page_id=rev_page','rev_page'=>intval( $pageid ), 'page_id'=>intval( $pageid ));
+ $conds = array( 'page_id=rev_page','rev_page' => intval( $pageid ), 'page_id'=>intval( $pageid ) );
if( $id ) {
- $conds['rev_id']=intval($id);
+ $conds['rev_id'] = intval( $id );
} else {
- $conds[]='rev_id=page_latest';
+ $conds[] = 'rev_id=page_latest';
}
return Revision::loadFromConds( $db, $conds );
}
'old_flags'
);
}
+
/**
* Return the list of page fields that should be selected from page table
*/
$this->mCurrent = false;
# If we still have no len_size, see it we have the text to figure it out
if ( !$this->mSize )
- $this->mSize = is_null($this->mText) ? null : strlen($this->mText);
+ $this->mSize = is_null( $this->mText ) ? null : strlen( $this->mText );
} else {
throw new MWException( 'Revision constructor passed invalid row format.' );
}
- $this->mUnpatrolled = NULL;
+ $this->mUnpatrolled = null;
}
/**#@+
*/
public function getUserText( $audience = self::FOR_PUBLIC ) {
if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) {
- return "";
+ return '';
} elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER ) ) {
- return "";
+ return '';
} else {
return $this->mUserText;
}
*/
function getComment( $audience = self::FOR_PUBLIC ) {
if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_COMMENT ) ) {
- return "";
+ return '';
} elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_COMMENT ) ) {
- return "";
+ return '';
} else {
return $this->mComment;
}
* @return int rcid of the unpatrolled row, zero if there isn't one
*/
public function isUnpatrolled() {
- if( $this->mUnpatrolled !== NULL ) {
+ if( $this->mUnpatrolled !== null ) {
return $this->mUnpatrolled;
}
$dbr = wfGetDB( DB_SLAVE );
* @return bool
*/
public function isDeleted( $field ) {
- return ($this->mDeleted & $field) == $field;
+ return ( $this->mDeleted & $field ) == $field;
}
-
+
/**
* Get the deletion bitfield of the revision
*/
*/
public function getText( $audience = self::FOR_PUBLIC ) {
if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_TEXT ) ) {
- return "";
+ return '';
} elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_TEXT ) ) {
- return "";
+ return '';
} else {
return $this->getRawText();
}
* @return int
*/
private function getPreviousRevisionId( $db ) {
- if( is_null($this->mPage) ) {
+ if( is_null( $this->mPage ) ) {
return 0;
}
# Use page_latest if ID is not given
__METHOD__,
array( 'ORDER BY' => 'rev_id DESC' ) );
}
- return intval($prevId);
+ return intval( $prevId );
}
/**
# Use external methods for external objects, text in table is URL-only then
if ( in_array( 'external', $flags ) ) {
- $url=$text;
- @list(/* $proto */,$path)=explode('://',$url,2);
- if ($path=="") {
+ $url = $text;
+ @list(/* $proto */, $path ) = explode( '://', $url, 2 );
+ if( $path == '' ) {
wfProfileOut( __METHOD__ );
return false;
}
- $text=ExternalStore::fetchFromURL($url);
+ $text = ExternalStore::fetchFromURL( $url );
}
// If the text was fetched without an error, convert it
), __METHOD__
);
- $this->mId = !is_null($rev_id) ? $rev_id : $dbw->insertId();
-
+ $this->mId = !is_null( $rev_id ) ? $rev_id : $dbw->insertId();
+
wfRunHooks( 'RevisionInsertComplete', array( &$this, $data, $flags ) );
-
+
wfProfileOut( __METHOD__ );
return $this->mId;
}
if( $wgRevisionCacheExpiry ) {
$text = $wgMemc->get( $key );
if( is_string( $text ) ) {
- wfDebug( __METHOD__. ": got id $textId from cache\n" );
+ wfDebug( __METHOD__ . ": got id $textId from cache\n" );
wfProfileOut( __METHOD__ );
return $text;
}
static function getTimestampFromId( $title, $id ) {
$dbr = wfGetDB( DB_SLAVE );
// Casting fix for DB2
- if ($id == '') {
+ if ( $id == '' ) {
$id = 0;
}
$conds = array( 'rev_id' => $id );
*/
function wfSpecialBlockip( $par ) {
global $wgUser, $wgOut, $wgRequest;
+
# Can't block when the database is locked
if( wfReadOnly() ) {
$wgOut->readOnlyPage();
$action = $wgRequest->getVal( 'action' );
if( 'success' == $action ) {
$ipb->showSuccess();
- } else if( $wgRequest->wasPosted() && 'submit' == $action &&
+ } elseif( $wgRequest->wasPosted() && 'submit' == $action &&
$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
$ipb->doSubmit();
} else {
$this->BlockAddress = strtr( $this->BlockAddress, '_', ' ' );
$this->BlockReason = $wgRequest->getText( 'wpBlockReason' );
$this->BlockReasonList = $wgRequest->getText( 'wpBlockReasonList' );
- $this->BlockExpiry = $wgRequest->getVal( 'wpBlockExpiry', wfMsg('ipbotheroption') );
+ $this->BlockExpiry = $wgRequest->getVal( 'wpBlockExpiry', wfMsg( 'ipbotheroption' ) );
$this->BlockOther = $wgRequest->getVal( 'wpBlockOther', '' );
# Unchecked checkboxes are not included in the form data at all, so having one
public function showForm( $err ) {
global $wgOut, $wgUser, $wgSysopUserBans;
- $wgOut->setPagetitle( wfMsg( 'blockip' ) );
+ $wgOut->setPageTitle( wfMsg( 'blockip' ) );
$wgOut->addWikiMsg( 'blockiptext' );
- if($wgSysopUserBans) {
+ if( $wgSysopUserBans ) {
$mIpaddress = Xml::label( wfMsg( 'ipadressorusername' ), 'mw-bi-target' );
} else {
$mIpaddress = Xml::label( wfMsg( 'ipaddress' ), 'mw-bi-target' );
$titleObj = SpecialPage::getTitleFor( 'Blockip' );
$user = User::newFromName( $this->BlockAddress );
-
+
$alreadyBlocked = false;
if( $err && $err[0] != 'ipb_already_blocked' ) {
- $key = array_shift($err);
- $msg = wfMsgReal($key, $err);
+ $key = array_shift( $err );
+ $msg = wfMsgReal( $key, $err );
$wgOut->setSubtitle( wfMsgHtml( 'formerror' ) );
$wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $msg ) );
} elseif( $this->BlockAddress ) {
if( is_object( $user ) )
$userId = $user->getId();
$currentBlock = Block::newFromDB( $this->BlockAddress, $userId );
- if( !is_null($currentBlock) && !$currentBlock->mAuto && # The block exists and isn't an autoblock
+ if( !is_null( $currentBlock ) && !$currentBlock->mAuto && # The block exists and isn't an autoblock
( $currentBlock->mRangeStart == $currentBlock->mRangeEnd || # The block isn't a rangeblock
# or if it is, the range is what we're about to block
( $currentBlock->mAddress == $this->BlockAddress ) ) ) {
if( !$showblockoptions ) $mIpbother = $mIpbexpiry;
$blockExpiryFormOptions = Xml::option( wfMsg( 'ipbotheroption' ), 'other' );
- foreach (explode(',', $scBlockExpiryOptions) as $option) {
- if( strpos($option, ":") === false ) $option = "$option:$option";
- list($show, $value) = explode(":", $option);
- $show = htmlspecialchars($show);
- $value = htmlspecialchars($value);
+ foreach( explode( ',', $scBlockExpiryOptions ) as $option ) {
+ if( strpos( $option, ':' ) === false ) $option = "$option:$option";
+ list( $show, $value ) = explode( ':', $option );
+ $show = htmlspecialchars( $show );
+ $value = htmlspecialchars( $value );
$blockExpiryFormOptions .= Xml::option( $show, $value, $this->BlockExpiry === $value ? true : false ) . "\n";
}
global $wgStylePath, $wgStyleVersion;
$wgOut->addHTML(
Xml::tags( 'script', array( 'type' => 'text/javascript', 'src' => "$wgStylePath/common/block.js?$wgStyleVersion" ), '' ) .
- Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL( "action=submit" ), 'id' => 'blockip' ) ) .
+ Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL( 'action=submit' ), 'id' => 'blockip' ) ) .
Xml::openElement( 'fieldset' ) .
Xml::element( 'legend', null, wfMsg( 'blockip-legend' ) ) .
- Xml::openElement( 'table', array ( 'border' => '0', 'id' => 'mw-blockip-table' ) ) .
+ Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-blockip-table' ) ) .
"<tr>
<td class='mw-label'>
{$mIpaddress}
<td class='mw-input'>" .
Xml::checkLabel( wfMsg( 'ipbemailban' ),
'wpEmailBan', 'wpEmailBan', $this->BlockEmail,
- array( 'tabindex' => '9' )) . "
+ array( 'tabindex' => '9' ) ) . "
</td>
</tr>"
);
</tr>"
);
}
-
+
# Watchlist their user page?
$wgOut->addHTML("
<tr id='wpEnableWatchUser'>
</td>
</tr>"
);
-
+
# Can we explicitly disallow the use of user_talk?
global $wgBlockAllowsUTEdit;
if( $wgBlockAllowsUTEdit ){
$this->showLogFragment( $wgOut, Title::makeTitle( NS_USER, $this->BlockAddress ) );
}
}
-
+
/**
* Can we do an email block?
* @param User $user The sysop wanting to make a block
*/
public static function canBlockEmail( $user ) {
global $wgEnableUserEmail, $wgSysopEmailBans;
- return ($wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' ));
+ return ( $wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' ) );
}
/**
# IPv4
if( $wgSysopRangeBans ) {
if( !IP::isIPv4( $this->BlockAddress ) || $matches[2] < 16 || $matches[2] > 32 ) {
- return array('ip_range_invalid');
+ return array( 'ip_range_invalid' );
}
$this->BlockAddress = Block::normaliseRange( $this->BlockAddress );
} else {
# Range block illegal
- return array('range_block_disabled');
+ return array( 'range_block_disabled' );
}
- } else if( preg_match( "/^($rxIP6)\\/(\\d{1,3})$/", $this->BlockAddress, $matches ) ) {
+ } elseif( preg_match( "/^($rxIP6)\\/(\\d{1,3})$/", $this->BlockAddress, $matches ) ) {
# IPv6
if( $wgSysopRangeBans ) {
if( !IP::isIPv6( $this->BlockAddress ) || $matches[2] < 64 || $matches[2] > 128 ) {
- return array('ip_range_invalid');
+ return array( 'ip_range_invalid' );
}
$this->BlockAddress = Block::normaliseRange( $this->BlockAddress );
} else {
$userId = $user->getId();
$this->BlockAddress = $user->getName();
} else {
- return array('nosuchusershort', htmlspecialchars( $user ? $user->getName() : $this->BlockAddress ) );
+ return array( 'nosuchusershort', htmlspecialchars( $user ? $user->getName() : $this->BlockAddress ) );
}
} else {
- return array('badipaddress');
+ return array( 'badipaddress' );
}
}
}
if( $expirestr == 'other' )
$expirestr = $this->BlockOther;
- if( ( strlen( $expirestr ) == 0) || ( strlen( $expirestr ) > 50) ) {
- return array('ipb_expiry_invalid');
+ if( ( strlen( $expirestr ) == 0) || ( strlen( $expirestr ) > 50 ) ) {
+ return array( 'ipb_expiry_invalid' );
}
- if( false === ($expiry = Block::parseExpiryInput( $expirestr )) ) {
+ if( false === ( $expiry = Block::parseExpiryInput( $expirestr ) ) ) {
// Bad expiry.
- return array('ipb_expiry_invalid');
+ return array( 'ipb_expiry_invalid' );
}
-
+
if( $this->BlockHideName ) {
// Recheck params here...
if( !$userId || !$wgUser->isAllowed('hideuser') ) {
$this->BlockHideName = false; // IP users should not be hidden
- } else if( $expiry !== 'infinity' ) {
+ } elseif( $expiry !== 'infinity' ) {
// Bad expiry.
- return array('ipb_expiry_temp');
- } else if( User::edits($userId) > self::HIDEUSER_CONTRIBLIMIT ) {
+ return array( 'ipb_expiry_temp' );
+ } elseif( User::edits( $userId ) > self::HIDEUSER_CONTRIBLIMIT ) {
// Typically, the user should have a handful of edits.
// Disallow hiding users with many edits for performance.
- return array('ipb_hide_invalid');
+ return array( 'ipb_hide_invalid' );
}
}
# Should this be privately logged?
$suppressLog = (bool)$this->BlockHideName;
- if( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) {
+ if( wfRunHooks( 'BlockIp', array( &$block, &$wgUser ) ) ) {
# Try to insert block. Is there a conflicting block?
if( !$block->insert() ) {
# Show form unless the user is already aware of this...
}
# If the name was hidden and the blocking user cannot hide
# names, then don't allow any block changes...
- if( $currentBlock->mHideName && !$wgUser->isAllowed('hideuser') ) {
+ if( $currentBlock->mHideName && !$wgUser->isAllowed( 'hideuser' ) ) {
return array( 'cant-see-hidden-user' );
}
$currentBlock->delete();
} else {
$log_action = 'block';
}
- wfRunHooks('BlockIpComplete', array($block, $wgUser));
+ wfRunHooks( 'BlockIpComplete', array( $block, $wgUser ) );
# Set *_deleted fields if requested
if( $this->BlockHideName ) {
if( $this->BlockWatchUser && $block->mRangeStart == $block->mRangeEnd ) {
$wgUser->addWatch( Title::makeTitle( NS_USER, $this->BlockAddress ) );
}
-
+
# Block constructor sanitizes certain block options on insert
$this->BlockEmail = $block->mBlockEmail;
$this->BlockEnableAutoblock = $block->mEnableAutoblock;
# Report to the user
return array();
} else {
- return array('hookaborted');
+ return array( 'hookaborted' );
}
}
-
+
public static function suppressUserName( $name, $userId ) {
$op = '|'; // bitwise OR
return self::setUsernameBitfields( $name, $userId, $op );
}
-
+
public static function unsuppressUserName( $name, $userId ) {
$op = '&'; // bitwise AND
return self::setUsernameBitfields( $name, $userId, $op );
}
-
+
private static function setUsernameBitfields( $name, $userId, $op ) {
if( $op !== '|' && $op !== '&' ) return false; // sanity check
$dbw = wfGetDB( DB_MASTER );
$delAction = "~{$delAction}";
}
# Hide name from live edits
- $dbw->update( 'revision', array("rev_deleted = rev_deleted $op $delUser"),
- array('rev_user' => $userId), __METHOD__ );
+ $dbw->update( 'revision', array( "rev_deleted = rev_deleted $op $delUser" ),
+ array( 'rev_user' => $userId ), __METHOD__ );
# Hide name from deleted edits
- $dbw->update( 'archive', array("ar_deleted = ar_deleted $op $delUser"),
- array('ar_user_text' => $name), __METHOD__ );
+ $dbw->update( 'archive', array( "ar_deleted = ar_deleted $op $delUser" ),
+ array( 'ar_user_text' => $name ), __METHOD__ );
# Hide name from logs
- $dbw->update( 'logging', array("log_deleted = log_deleted $op $delUser"),
- array('log_user' => $userId, "log_type != 'suppress'"), __METHOD__ );
- $dbw->update( 'logging', array("log_deleted = log_deleted $op $delAction"),
- array('log_namespace' => NS_USER, 'log_title' => $userDbKey,
- "log_type != 'suppress'"), __METHOD__ );
+ $dbw->update( 'logging', array( "log_deleted = log_deleted $op $delUser" ),
+ array( 'log_user' => $userId, "log_type != 'suppress'" ), __METHOD__ );
+ $dbw->update( 'logging', array( "log_deleted = log_deleted $op $delAction" ),
+ array( 'log_namespace' => NS_USER, 'log_title' => $userDbKey,
+ "log_type != 'suppress'" ), __METHOD__ );
# Hide name from RC
- $dbw->update( 'recentchanges', array("rc_deleted = rc_deleted $op $delUser"),
- array('rc_user_text' => $name), __METHOD__ );
- $dbw->update( 'recentchanges', array("rc_deleted = rc_deleted $op $delAction"),
- array('rc_namespace' => NS_USER, 'rc_title' => $userDbKey, 'rc_logid > 0'), __METHOD__ );
+ $dbw->update( 'recentchanges', array( "rc_deleted = rc_deleted $op $delUser" ),
+ array( 'rc_user_text' => $name ), __METHOD__ );
+ $dbw->update( 'recentchanges', array( "rc_deleted = rc_deleted $op $delAction" ),
+ array( 'rc_namespace' => NS_USER, 'rc_title' => $userDbKey, 'rc_logid > 0' ), __METHOD__ );
# Hide name from live images
- $dbw->update( 'oldimage', array("oi_deleted = oi_deleted $op $delUser"),
- array('oi_user_text' => $name), __METHOD__ );
+ $dbw->update( 'oldimage', array( "oi_deleted = oi_deleted $op $delUser" ),
+ array( 'oi_user_text' => $name ), __METHOD__ );
# Hide name from deleted images
# WMF - schema change pending
- # $dbw->update( 'filearchive', array("fa_deleted = fa_deleted $op $delUser"),
- # array('fa_user_text' => $name), __METHOD__ );
+ # $dbw->update( 'filearchive', array( "fa_deleted = fa_deleted $op $delUser" ),
+ # array( 'fa_user_text' => $name ), __METHOD__ );
# Done!
return true;
}
public function doSubmit() {
global $wgOut;
$retval = $this->doBlock();
- if( empty($retval) ) {
+ if( empty( $retval ) ) {
$titleObj = SpecialPage::getTitleFor( 'Blockip' );
$wgOut->redirect( $titleObj->getFullURL( 'action=success&ip=' .
urlencode( $this->BlockAddress ) ) );
public function showSuccess() {
global $wgOut;
- $wgOut->setPagetitle( wfMsg( 'blockip' ) );
+ $wgOut->setPageTitle( wfMsg( 'blockip' ) );
$wgOut->setSubtitle( wfMsg( 'blockipsuccesssub' ) );
$text = wfMsgExt( 'blockipsuccesstext', array( 'parse' ), $this->BlockAddress );
$wgOut->addHTML( $text );
);
return '<p class="mw-ipb-conveniencelinks">' . $wgLang->pipeList( $links ) . '</p>';
}
-
+
/**
* Build a convenient link to a user or IP's contribs
* form
}
return $skin->linkKnown(
$list,
- htmlspecialchars($message),
+ htmlspecialchars( $message ),
array(),
$query
);
return $skin->linkKnown(
$list,
- htmlspecialchars($message),
+ htmlspecialchars( $message ),
array(),
$query
);
}
-
+
/**
- * Block a list of selected users
- * @param array $users
- * @param string $reason
- * @param string $tag replaces user pages
- * @param string $talkTag replaces user talk pages
- * @returns array, list of html-safe usernames
- */
+ * Block a list of selected users
+ * @param array $users
+ * @param string $reason
+ * @param string $tag replaces user pages
+ * @param string $talkTag replaces user talk pages
+ * @returns array, list of html-safe usernames
+ */
public static function doMassUserBlock( $users, $reason = '', $tag = '', $talkTag = '' ) {
global $wgUser;
$counter = $blockSize = 0;
}
$u = User::newFromName( $name, false );
// If user doesn't exist, it ought to be an IP then
- if( is_null($u) || (!$u->getId() && !IP::isIPAddress( $u->getName() )) ) {
+ if( is_null( $u ) || ( !$u->getId() && !IP::isIPAddress( $u->getName() ) ) ) {
continue;
}
$userTitle = $u->getUserPage();
$log->addEntry( 'block', $userTitle, $reason, $logParams );
}
# Tag userpage! (check length to avoid mistakes)
- if( strlen($tag) > 2 ) {
+ if( strlen( $tag ) > 2 ) {
$userpage->doEdit( $tag, $reason, EDIT_MINOR );
}
- if( strlen($talkTag) > 2 ) {
+ if( strlen( $talkTag ) > 2 ) {
$usertalk->doEdit( $talkTag, $reason, EDIT_MINOR );
}
}