$this->hideuserblocks = $wgRequest->getBool( 'hideuserblocks' );
$this->hidetempblocks = $wgRequest->getBool( 'hidetempblocks' );
$this->hideaddressblocks = $wgRequest->getBool( 'hideaddressblocks' );
- $this->scanRange = $wgRequest->getBool( 'range' );
}
/**
* @return array array(message key, parameters) on failure, empty array on success
*/
- static function doUnblock(&$id, &$ip, &$reason, &$range = null) {
+ static function doUnblock(&$id, &$ip, &$reason, &$range = null, $blocker=null) {
if ( $id ) {
$block = Block::newFromID( $id );
if ( !$block ) {
if ( !$block ) {
return array('ipb_cant_unblock', htmlspecialchars($id));
}
- if( $block->mRangeStart != $block->mRangeEnd
- && !strstr( $ip, "/" ) ) {
+ if( $block->mRangeStart != $block->mRangeEnd && !strstr( $ip, "/" ) ) {
/* If the specified IP is a single address, and the block is
* a range block, don't unblock the range. */
$range = $block->mAddress;
}
// Yes, this is really necessary
$id = $block->mId;
+
+ # If the name was hidden and the blocking user cannot hide
+ # names, then don't allow any block removals...
+ if( $blocker && $block->mHideName && !$blocker->isAllowed('hideuser') ) {
+ return array('ipb_cant_unblock', htmlspecialchars($id));
+ }
# Delete block
if ( !$block->delete() ) {
return array('ipb_cant_unblock', htmlspecialchars($id));
}
+
+ # Unset _deleted fields as needed
+ if( $block->mHideName ) {
+ IPBlockForm::unsuppressUserName( $block->mAddress, $block->mUser );
+ }
# Make log entry
$log = new LogPage( 'block' );
}
function doSubmit() {
- global $wgOut;
- $retval = self::doUnblock($this->id, $this->ip, $this->reason, $range);
- if(!empty($retval))
- {
+ global $wgOut, $wgUser;
+ $retval = self::doUnblock($this->id, $this->ip, $this->reason, $range, $wgUser);
+ if( !empty($retval) ) {
$key = array_shift($retval);
$this->showForm(wfMsgReal($key, $retval));
return;
$conds = array();
$matches = array();
// Is user allowed to see all the blocks?
- if ( !$wgUser->isAllowed( 'suppress' ) )
+ if ( !$wgUser->isAllowed( 'hideuser' ) )
$conds['ipb_deleted'] = 0;
if ( $this->ip == '' ) {
// No extra conditions
$conds['ipb_id'] = substr( $this->ip, 1 );
// Single IPs
} elseif ( IP::isIPAddress($this->ip) && strpos($this->ip,'/') === false ) {
- if( $this->scanRange && $iaddr = IP::toHex($this->ip) ) {
+ if( $iaddr = IP::toHex($this->ip) ) {
# Only scan ranges which start in this /16, this improves search speed
# Blocks should not cross a /16 boundary.
$range = substr( $iaddr, 0, 4 );
- $conds[] = "(ipb_address = '" . IP::sanitizeIP($this->ip) . "') OR
- (ipb_range_start LIKE '$range%' AND ipb_range_start <= '$iaddr' AND ipb_range_end >= '$iaddr')";
+ // Fixme -- encapsulate this sort of query-building.
+ $dbr = wfGetDB( DB_SLAVE );
+ $encIp = $dbr->addQuotes( IP::sanitizeIP($this->ip) );
+ $encRange = $dbr->addQuotes( "$range%" );
+ $encAddr = $dbr->addQuotes( $iaddr );
+ $conds[] = "(ipb_address = $encIp) OR
+ (ipb_range_start LIKE $encRange AND
+ ipb_range_start <= $encAddr
+ AND ipb_range_end >= $encAddr)";
} else {
$conds['ipb_address'] = IP::sanitizeIP($this->ip);
}
if ( $pager->getNumRows() ) {
$wgOut->addHTML(
$this->searchForm() .
- $this->showhideLinks() .
$pager->getNavigationBar() .
Xml::tags( 'ul', null, $pager->getBody() ) .
$pager->getNavigationBar()
$wgOut->addHTML( $this->searchForm() );
$wgOut->addWikiMsg( 'ipblocklist-no-results' );
} else {
- $wgOut->addHTML( $this->searchForm() . $this->showhideLinks() );
+ $wgOut->addHTML( $this->searchForm() );
$wgOut->addWikiMsg( 'ipblocklist-empty' );
}
}
function searchForm() {
- global $wgTitle, $wgScript, $wgRequest;
- return
- Xml::tags( 'form', array( 'action' => $wgScript ),
- Xml::hidden( 'title', $wgTitle->getPrefixedDbKey() ) .
- Xml::openElement( 'fieldset' ) .
- Xml::element( 'legend', null, wfMsg( 'ipblocklist-legend' ) ) .
- Xml::inputLabel( wfMsg( 'ipblocklist-username' ), 'ip', 'ip', /* size */ false, $this->ip ) .
- '<br/>' .
- Xml::checkLabel( wfMsg('ipblocklist-scanrange'), 'range', 'range', $this->scanRange ) .
- ' ' . Xml::submitButton( wfMsg( 'ipblocklist-submit' ) ) .
- Xml::closeElement( 'fieldset' )
- );
- }
-
- function showhideLinks() {
+ global $wgScript, $wgRequest, $wgLang;
+
$showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ) );
$nondefaults = array();
if( $this->hideuserblocks ) {
array( 'hidetempblocks' => 1-$this->hidetempblocks ), $nondefaults);
$sipbLink = $this->makeOptionsLink( $showhide[1-$this->hideaddressblocks],
array( 'hideaddressblocks' => 1-$this->hideaddressblocks ), $nondefaults);
-
+
$links = array();
$links[] = wfMsgHtml( 'ipblocklist-sh-userblocks', $ubLink );
$links[] = wfMsgHtml( 'ipblocklist-sh-tempblocks', $tbLink );
$links[] = wfMsgHtml( 'ipblocklist-sh-addressblocks', $sipbLink );
-
- $hl = '(' . implode( ' | ', $links ) . ')<hr/>';
- return $hl;
+ $hl = $wgLang->pipeList( $links );
+
+ return
+ Xml::tags( 'form', array( 'action' => $wgScript ),
+ Xml::hidden( 'title', SpecialPage::getTitleFor( 'Ipblocklist' )->getPrefixedDbKey() ) .
+ Xml::openElement( 'fieldset' ) .
+ Xml::element( 'legend', null, wfMsg( 'ipblocklist-legend' ) ) .
+ Xml::inputLabel( wfMsg( 'ipblocklist-username' ), 'ip', 'ip', /* size */ false, $this->ip ) .
+ ' ' .
+ Xml::submitButton( wfMsg( 'ipblocklist-submit' ) ) . '<br />' .
+ $hl .
+ Xml::closeElement( 'fieldset' )
+ );
}
-
+
/**
* Makes change an option link which carries all the other options
* @param $title see Title
function makeOptionsLink( $title, $override, $options, $active = false ) {
global $wgUser;
$sk = $wgUser->getSkin();
- $params = wfArrayMerge( $options, $override );
+ $params = $override + $options;
$ipblocklist = SpecialPage::getTitleFor( 'IPBlockList' );
return $sk->link( $ipblocklist, htmlspecialchars( $title ),
( $active ? array( 'style'=>'font-weight: bold;' ) : array() ), $params, array( 'known' ) );
$sk = $wgUser->getSkin();
if( is_null( $msg ) ) {
$msg = array();
- $keys = array( 'infiniteblock', 'expiringblock', 'unblocklink',
- 'anononlyblock', 'createaccountblock', 'noautoblockblock', 'emailblock', 'blocklist-nousertalk' );
+ $keys = array( 'infiniteblock', 'expiringblock', 'unblocklink', 'change-blocklink',
+ 'anononlyblock', 'createaccountblock', 'noautoblockblock', 'emailblock', 'blocklist-nousertalk', 'blocklistline' );
foreach( $keys as $key ) {
$msg[$key] = wfMsgHtml( $key );
}
- $msg['blocklistline'] = wfMsg( 'blocklistline' );
}
# Prepare links to the blocker's user and talk pages
. $sk->userToolLinks( $block->mUser, $block->mAddress, false, Linker::TOOL_LINKS_NOBLOCK );
}
- $formattedTime = $wgLang->timeanddate( $block->mTimestamp, true );
+ $formattedTime = htmlspecialchars( $wgLang->timeanddate( $block->mTimestamp, true ) );
$properties = array();
$properties[] = Block::formatExpiry( $block->mExpiry );
$properties[] = $msg['blocklist-nousertalk'];
}
- $properties = implode( ', ', $properties );
+ $properties = $wgLang->commaList( $properties );
$line = wfMsgReplaceArgs( $msg['blocklistline'], array( $formattedTime, $blocker, $target, $properties ) );
$unblocklink = '';
- if ( $wgUser->isAllowed('block') ) {
- $titleObj = SpecialPage::getTitleFor( "Ipblocklist" );
- $unblocklink = ' (' . $sk->makeKnownLinkObj($titleObj, $msg['unblocklink'], 'action=unblock&id=' . urlencode( $block->mId ) ) . ')';
+ $changeblocklink = '';
+ $toolLinks = '';
+ if ( $wgUser->isAllowed( 'block' ) ) {
+ $unblocklink = $sk->link( SpecialPage::getTitleFor( 'Ipblocklist' ),
+ $msg['unblocklink'],
+ array(),
+ array( 'action' => 'unblock', 'id' => $block->mId ),
+ 'known' );
+
+ # Create changeblocklink for all blocks with exception of autoblocks
+ if( !$block->mAuto ) {
+ $changeblocklink = wfMsgExt( 'pipe-separator', 'escapenoentities' ) .
+ $sk->link( SpecialPage::getTitleFor( 'Blockip', $block->mAddress ),
+ $msg['change-blocklink'],
+ array(), array(), 'known' );
+ }
+ $toolLinks = "($unblocklink$changeblocklink)";
}
- $comment = $sk->commentBlock( $block->mReason );
+ $comment = $sk->commentBlock( htmlspecialchars($block->mReason) );
$s = "{$line} $comment";
if ( $block->mHideName )
$s = '<span class="history-deleted">' . $s . '</span>';
wfProfileOut( __METHOD__ );
- return "<li>$s $unblocklink</li>\n";
+ return "<li>$s $toolLinks</li>\n";
}
}