$this->reason = $reason;
}
+ /**
+ * Generates the unblock form
+ * @param $err string: error message
+ * @return $out string: HTML form
+ */
function showForm( $err ) {
global $wgOut, $wgUser, $wgSysopUserBans, $wgContLang;
$wgOut->setPagetitle( wfMsg( 'unblockip' ) );
- $wgOut->addWikiText( wfMsg( 'unblockiptext' ) );
+ $wgOut->addWikiMsg( 'unblockiptext' );
$ipa = wfMsgHtml( $wgSysopUserBans ? 'ipadressorusername' : 'ipaddress' );
- $ipr = wfMsgHtml( 'ipbreason' );
- $ipus = wfMsgHtml( 'ipusubmit' );
$titleObj = SpecialPage::getTitleFor( "Ipblocklist" );
$action = $titleObj->getLocalURL( "action=submit" );
$alignRight = $wgContLang->isRtl() ? 'left' : 'right';
if ( "" != $err ) {
$wgOut->setSubtitle( wfMsg( "formerror" ) );
- $wgOut->addWikitext( "<span class='error'>{$err}</span>\n" );
+ $wgOut->addWikiText( "<span class='error'>{$err}</span>\n" );
}
$token = htmlspecialchars( $wgUser->editToken() );
$wgOut->addHTML(
Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'unblockip' ) ) .
- Xml::openElement( 'table', array( 'border' => '0' ) ).
+ Xml::openElement( 'fieldset' ) .
+ Xml::element( 'legend', null, wfMsg( 'ipb-unblock' ) ) .
+ Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-unblock-table' ) ).
"<tr>
<td align='$alignRight'>
{$ipa}
</td>
</tr>
<tr>
- <td align='$alignRight'>
- {$ipr}
- </td>
+ <td align='$alignRight'>" .
+ Xml::label( wfMsg( 'ipbreason' ), 'wpUnblockReason' ) .
+ "</td>
<td>" .
Xml::input( 'wpUnblockReason', 40, $this->reason, array( 'type' => 'text', 'tabindex' => '2' ) ) .
"</td>
<tr>
<td> </td>
<td>" .
- Xml::submitButton( $ipus, array( 'name' => 'wpBlock', 'tabindex' => '3' ) ) .
+ Xml::submitButton( wfMsg( 'ipusubmit' ), array( 'name' => 'wpBlock', 'tabindex' => '3' ) ) .
"</td>
</tr>" .
Xml::closeElement( 'table' ) .
+ Xml::closeElement( 'fieldset' ) .
Xml::hidden( 'wpEditToken', $token ) .
Xml::closeElement( 'form' ) . "\n"
);
* Backend code for unblocking. doSubmit() wraps around this.
* $range is only used when UNBLOCK_BLOCKED_AS_RANGE is returned, in which
* case it contains the range $ip is part of.
- * Returns one of UNBLOCK_*
+ * @return array array(message key, parameters) on failure, empty array on success
*/
static function doUnblock(&$id, &$ip, &$reason, &$range = null)
if ( $id ) {
$block = Block::newFromID( $id );
if ( !$block ) {
- return self::UNBLOCK_NO_SUCH_ID;
+ return array('ipb_cant_unblock', htmlspecialchars($id));
}
$ip = $block->getRedactedName();
} else {
$id = substr( $ip, 1 );
$block = Block::newFromID( $id );
if( !$block ) {
- return self::UNBLOCK_NO_SUCH_ID;
+ return array('ipb_cant_unblock', htmlspecialchars($id));
}
+ $ip = $block->getRedactedName();
} else {
$block = Block::newFromDB( $ip );
if ( !$block ) {
- return self::UNBLOCK_USER_NOT_BLOCKED;
+ return array('ipb_cant_unblock', htmlspecialchars($id));
}
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;
- return self::UNBLOCK_BLOCKED_AS_RANGE;
+ return array('ipb_blocked_as_range', $ip, $range);
}
}
}
# Delete block
if ( !$block->delete() ) {
- return self::UNBLOCK_UNKNOWNERR;
+ return array('ipb_cant_unblock', htmlspecialchars($id));
}
# Make log entry
$log = new LogPage( 'block' );
$log->addEntry( 'unblock', Title::makeTitle( NS_USER, $ip ), $reason );
- return self::UNBLOCK_SUCCESS;
+ return array();
}
function doSubmit() {
global $wgOut;
$retval = self::doUnblock($this->id, $this->ip, $this->reason, $range);
- if($retval == self::UNBLOCK_SUCCESS) {
- # Report to the user
- $titleObj = SpecialPage::getTitleFor( "Ipblocklist" );
- $success = $titleObj->getFullURL( "action=success&successip=" . urlencode( $this->ip ) );
- $wgOut->redirect( $success );
- } else if($retval == self::UNBLOCK_BLOCKED_AS_RANGE) {
- $this->showForm( wfMsg( 'ipb_blocked_as_range', $this->ip, $range ) );
- } else { // UI code doesn't distinguish between errors much. Maybe it should
- if ( !$this->ip && $this->id ) {
- $this->ip = '#' . $this->id;
- }
- $this->showForm( wfMsg( 'ipb_cant_unblock', htmlspecialchars( $this->id ) ) );
+ if(!empty($retval))
+ {
+ $key = array_shift($retval);
+ $this->showForm(wfMsgReal($key, $retval));
+ return;
}
+ # Report to the user
+ $titleObj = SpecialPage::getTitleFor( "Ipblocklist" );
+ $success = $titleObj->getFullURL( "action=success&successip=" . urlencode( $this->ip ) );
+ $wgOut->redirect( $success );
}
function showList( $msg ) {
);
} elseif ( $this->ip != '') {
$wgOut->addHTML( $this->searchForm() );
- $wgOut->addWikiText( wfMsg( 'ipblocklist-no-results' ) );
+ $wgOut->addWikiMsg( 'ipblocklist-no-results' );
} else {
- $wgOut->addWikiText( wfMsg( 'ipblocklist-empty' ) );
+ $wgOut->addWikiMsg( 'ipblocklist-empty' );
}
}
# Usernames and titles are in fact related by a simple substitution of space -> underscore
# The last few lines of Title::secureAndSplit() tell the story.
while ( $row = $this->mResult->fetchObject() ) {
- $name = str_replace( ' ', '_', $row->user_name );
+ $name = str_replace( ' ', '_', $row->ipb_by_text );
$lb->add( NS_USER, $name );
$lb->add( NS_USER_TALK, $name );
$name = str_replace( ' ', '_', $row->ipb_address );
function getQueryInfo() {
$conds = $this->mConds;
$conds[] = 'ipb_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() );
- $conds[] = 'ipb_by=user_id';
return array(
- 'tables' => array( 'ipblocks', 'user' ),
- 'fields' => $this->mDb->tableName( 'ipblocks' ) . '.*,user_name',
+ 'tables' => 'ipblocks',
+ 'fields' => '*',
'conds' => $conds,
);
}