X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialIpblocklist.php;h=c947cb515ac89de10d4f5a905875e19dda407a1b;hb=35e5762255b8cba9759a2db7e23dc2b785ff4444;hp=b90799f4c1437e8fd21a4b203e5eb6fa4b088333;hpb=217c8f104763e8e01312602c394d71c5532e5fb8;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialIpblocklist.php b/includes/SpecialIpblocklist.php index b90799f4c1..c947cb515a 100644 --- a/includes/SpecialIpblocklist.php +++ b/includes/SpecialIpblocklist.php @@ -1,8 +1,7 @@ showList( $wgOut->parse( wfMsg( 'unblocked', $successip ) ) ); - } else if ( "submit" == $action && $wgRequest->wasPosted() && - $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { - if ( ! $wgUser->isAllowed('block') ) { + if( $action == 'unblock' ) { + # Check permissions + if( !$wgUser->isAllowed( 'block' ) ) { $wgOut->permissionRequired( 'block' ); return; } - # Can't unblock when the database is locked + # Check for database lock if( wfReadOnly() ) { $wgOut->readOnlyPage(); return; } - $ipu->doSubmit(); - } else if ( "unblock" == $action ) { - # Can't unblock when the database is locked + # Show unblock form + $ipu->showForm( '' ); + } elseif( $action == 'submit' && $wgRequest->wasPosted() + && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { + # Check permissions + if( !$wgUser->isAllowed( 'block' ) ) { + $wgOut->permissionRequired( 'block' ); + return; + } + # Check for database lock if( wfReadOnly() ) { $wgOut->readOnlyPage(); return; } - $ipu->showForm( "" ); + # Remove blocks and redirect user to success page + $ipu->doSubmit(); + } elseif( $action == 'success' ) { + # Inform the user of a successful unblock + # (No need to check permissions or locks here, + # if something was done, then it's too late!) + if ( substr( $successip, 0, 1) == '#' ) { + // A block ID was unblocked + $ipu->showList( $wgOut->parse( wfMsg( 'unblocked-id', $successip ) ) ); + } else { + // A username/IP was unblocked + $ipu->showList( $wgOut->parse( wfMsg( 'unblocked', $successip ) ) ); + } } else { - $ipu->showList( "" ); + # Just show the block list + $ipu->showList( '' ); } + } /** - * - * @package MediaWiki - * @subpackage SpecialPage + * implements Special:ipblocklist GUI + * @addtogroup SpecialPage */ class IPUnblockForm { var $ip, $reason, $id; @@ -60,7 +77,7 @@ class IPUnblockForm { } function showForm( $err ) { - global $wgOut, $wgUser, $wgSysopUserBans; + global $wgOut, $wgUser, $wgSysopUserBans, $wgContLang; $wgOut->setPagetitle( wfMsg( 'unblockip' ) ); $wgOut->addWikiText( wfMsg( 'unblockiptext' ) ); @@ -69,7 +86,8 @@ class IPUnblockForm { $ipr = wfMsgHtml( 'ipbreason' ); $ipus = wfMsgHtml( 'ipusubmit' ); $titleObj = SpecialPage::getTitleFor( "Ipblocklist" ); - $action = $titleObj->escapeLocalURL( "action=submit" ); + $action = $titleObj->getLocalURL( "action=submit" ); + $alignRight = $wgContLang->isRtl() ? 'left' : 'right'; if ( "" != $err ) { $wgOut->setSubtitle( wfMsg( "formerror" ) ); @@ -82,39 +100,43 @@ class IPUnblockForm { $block = Block::newFromID( $this->id ); if ( $block ) { $encName = htmlspecialchars( $block->getRedactedName() ); - $encId = htmlspecialchars( $this->id ); - $addressPart = $encName . ""; + $encId = $this->id; + $addressPart = $encName . Xml::hidden( 'id', $encId ); } } if ( !$addressPart ) { - $addressPart = "ip ) . "\" />"; + $addressPart = Xml::input( 'wpUnblockAddress', 20, $this->ip, array( 'type' => 'text', 'tabindex' => '1' ) ); } - $wgOut->addHTML( " -
- - - - - - - - - - - - - -
{$ipa}: - {$addressPart} -
{$ipr}: - reason ) . "\" /> -
  - -
- -
\n" ); + $wgOut->addHTML( + Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'unblockip' ) ) . + Xml::openElement( 'table', array( 'border' => '0' ) ). + " + + {$ipa} + + + {$addressPart} + + + + + {$ipr} + + " . + Xml::input( 'wpUnblockReason', 40, $this->reason, array( 'type' => 'text', 'tabindex' => '2' ) ) . + " + + +   + " . + Xml::submitButton( $ipus, array( 'name' => 'wpBlock', 'tabindex' => '3' ) ) . + " + " . + Xml::closeElement( 'table' ) . + Xml::hidden( 'wpEditToken', $token ) . + Xml::closeElement( 'form' ) . "\n" + ); } @@ -164,7 +186,7 @@ class IPUnblockForm { } function showList( $msg ) { - global $wgOut; + global $wgOut, $wgUser; $wgOut->setPagetitle( wfMsg( "ipblocklist" ) ); if ( "" != $msg ) { @@ -178,6 +200,9 @@ class IPUnblockForm { $conds = array(); $matches = array(); + // Is user allowed to see all the blocks? + if ( !$wgUser->isAllowed( 'oversight' ) ) + $conds['ipb_deleted'] = 0; if ( $this->ip == '' ) { // No extra conditions } elseif ( substr( $this->ip, 0, 1 ) == '#' ) { @@ -200,41 +225,29 @@ class IPUnblockForm { } $pager = new IPBlocklistPager( $this, $conds ); - $s = $pager->getNavigationBar() . - $this->searchForm(); if ( $pager->getNumRows() ) { - $s .= ""; + $wgOut->addHTML( + $this->searchForm() . + $pager->getNavigationBar() . + Xml::tags( 'ul', null, $pager->getBody() ) . + $pager->getNavigationBar() + ); + } elseif ( $this->ip != '') { + $wgOut->addHTML( $this->searchForm() ); + $wgOut->addWikiText( wfMsg( 'ipblocklist-no-results' ) ); } else { - $s .= '

' . wfMsgHTML( 'ipblocklistempty' ) . '

'; + $wgOut->addWikiText( wfMsg( 'ipblocklist-empty' ) ); } - $s .= $pager->getNavigationBar(); - $wgOut->addHTML( $s ); } function searchForm() { global $wgTitle, $wgScript, $wgRequest; return - wfElement( 'form', array( - 'action' => $wgScript ), - null ) . - wfHidden( 'title', $wgTitle->getPrefixedDbKey() ) . - wfElement( 'input', array( - 'type' => 'hidden', - 'name' => 'action', - 'value' => 'search' ) ). - wfElement( 'input', array( - 'type' => 'hidden', - 'name' => 'limit', - 'value' => $wgRequest->getText( 'limit' ) ) ) . - wfElement( 'input', array( - 'name' => 'ip', - 'value' => $this->ip ) ) . - wfElement( 'input', array( - 'type' => 'submit', - 'value' => wfMsg( 'searchbutton' ) ) ) . - ''; + Xml::tags( 'form', array( 'action' => $wgScript ), + Xml::hidden( 'title', $wgTitle->getPrefixedDbKey() ) . + Xml::input( 'ip', /*size*/ false, $this->ip ) . + Xml::submitButton( wfMsg( 'ipblocklist-submit' ) ) + ); } /** @@ -297,19 +310,27 @@ class IPUnblockForm { $line = wfMsgReplaceArgs( $msg['blocklistline'], array( $formattedTime, $blocker, $target, $properties ) ); - $s = "
  • {$line}"; - + $unblocklink = ''; if ( $wgUser->isAllowed('block') ) { $titleObj = SpecialPage::getTitleFor( "Ipblocklist" ); - $s .= ' (' . $sk->makeKnownLinkObj($titleObj, $msg['unblocklink'], 'action=unblock&id=' . urlencode( $block->mId ) ) . ')'; + $unblocklink = ' (' . $sk->makeKnownLinkObj($titleObj, $msg['unblocklink'], 'action=unblock&id=' . urlencode( $block->mId ) ) . ')'; } - $s .= $sk->commentBlock( $block->mReason ); - $s .= "
  • \n"; + + $comment = $sk->commentBlock( $block->mReason ); + + $s = "{$line} $comment"; + if ( $block->mHideName ) + $s = '' . $s . ''; + wfProfileOut( __METHOD__ ); - return $s; + return "
  • $s $unblocklink
  • \n"; } } +/** + * @todo document + * @addtogroup Pager + */ class IPBlocklistPager extends ReverseChronologicalPager { public $mForm, $mConds;