X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialIpblocklist.php;h=696c7efe8497cd23aca6e997d8f9b86d38fb6c00;hb=ab8784dcdb591360e78f218c479d7f84b1f5dfca;hp=f65fe5af12fcf3a6656bd98e550c0c0a7e82c10a;hpb=c771fc9c96aacb44b86ade5ecca68334c5d8213f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialIpblocklist.php b/includes/SpecialIpblocklist.php index f65fe5af12..696c7efe84 100644 --- a/includes/SpecialIpblocklist.php +++ b/includes/SpecialIpblocklist.php @@ -1,7 +1,7 @@ getVal( 'wpUnblockAddress', $wgRequest->getVal( 'ip' ) ); $id = $wgRequest->getVal( 'id' ); $reason = $wgRequest->getText( 'wpUnblockReason' ); @@ -18,35 +18,54 @@ function wfSpecialIpblocklist() { $ipu = new IPUnblockForm( $ip, $id, $reason ); - if ( "success" == $action ) { - $ipu->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( '' ); } + } /** - * - * @addtogroup SpecialPage + * implements Special:ipblocklist GUI + * @ingroup SpecialPage */ class IPUnblockForm { var $ip, $reason, $id; @@ -57,112 +76,151 @@ class IPUnblockForm { $this->reason = $reason; } + /** + * Generates the unblock form + * @param $err string: error message + * @return $out string: HTML form + */ function showForm( $err ) { global $wgOut, $wgUser, $wgSysopUserBans; $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->escapeLocalURL( "action=submit" ); + $action = $titleObj->getLocalURL( "action=submit" ); if ( "" != $err ) { $wgOut->setSubtitle( wfMsg( "formerror" ) ); - $wgOut->addWikitext( "{$err}\n" ); + $wgOut->addWikiText( Xml::tags( 'span', array( 'class' => 'error' ), $err ) . "\n" ); } - $token = htmlspecialchars( $wgUser->editToken() ); $addressPart = false; if ( $this->id ) { $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 ); + $ipa = wfMsgHtml( $wgSysopUserBans ? 'ipadressorusername' : 'ipaddress' ); } } if ( !$addressPart ) { - $addressPart = "ip ) . "\" />"; + $addressPart = Xml::input( 'wpUnblockAddress', 40, $this->ip, array( 'type' => 'text', 'tabindex' => '1' ) ); + $ipa = Xml::label( wfMsg( $wgSysopUserBans ? 'ipadressorusername' : 'ipaddress' ), 'wpUnblockAddress' ); } - $wgOut->addHTML( " -
\n" ); + $wgOut->addHTML( + Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'unblockip' ) ) . + Xml::openElement( 'fieldset' ) . + Xml::element( 'legend', null, wfMsg( 'ipb-unblock' ) ) . + Xml::openElement( 'table', array( 'id' => 'mw-unblock-table' ) ). + "' . wfMsgHTML( 'ipblocklistempty' ) . '
'; + $wgOut->addWikiMsg( '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::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' ) ) . + Xml::closeElement( 'fieldset' ) + ); } /** @@ -249,13 +302,12 @@ class IPUnblockForm { $sk = $wgUser->getSkin(); if( is_null( $msg ) ) { $msg = array(); - $keys = array( 'infiniteblock', 'expiringblock', 'contribslink', 'unblocklink', - 'anononlyblock', 'createaccountblock', 'noautoblockblock' ); + $keys = array( 'infiniteblock', 'expiringblock', 'unblocklink', + 'anononlyblock', 'createaccountblock', 'noautoblockblock', 'emailblock' ); foreach( $keys as $key ) { $msg[$key] = wfMsgHtml( $key ); } $msg['blocklistline'] = wfMsg( 'blocklistline' ); - $msg['contribslink'] = wfMsg( 'contribslink' ); } # Prepare links to the blocker's user and talk pages @@ -268,19 +320,14 @@ class IPUnblockForm { if( $block->mAuto ) { $target = $block->getRedactedName(); # Hide the IP addresses of auto-blocks; privacy } else { - $target = $sk->makeLinkObj( Title::makeTitle( NS_USER, $block->mAddress ), $block->mAddress ); - $target .= ' (' . $sk->makeKnownLinkObj( SpecialPage::getSafeTitleFor( 'Contributions', $block->mAddress ), $msg['contribslink'] ) . ')'; + $target = $sk->userLink( $block->mUser, $block->mAddress ) + . $sk->userToolLinks( $block->mUser, $block->mAddress, false, Linker::TOOL_LINKS_NOBLOCK ); } - + $formattedTime = $wgLang->timeanddate( $block->mTimestamp, true ); $properties = array(); - if ( $block->mExpiry === "" || $block->mExpiry === Block::infinity() ) { - $properties[] = $msg['infiniteblock']; - } else { - $properties[] = wfMsgReplaceArgs( $msg['expiringblock'], - array( $wgLang->timeanddate( $block->mExpiry, true ) ) ); - } + $properties[] = Block::formatExpiry( $block->mExpiry ); if ( $block->mAnonOnly ) { $properties[] = $msg['anononlyblock']; } @@ -291,23 +338,35 @@ class IPUnblockForm { $properties[] = $msg['noautoblockblock']; } + if ( $block->mBlockEmail && $block->mUser ) { + $properties[] = $msg['emailblock']; + } + $properties = implode( ', ', $properties ); $line = wfMsgReplaceArgs( $msg['blocklistline'], array( $formattedTime, $blocker, $target, $properties ) ); - $s = "