Disable fulltext image name search in Special:Imagelist during MiserMode
[mediawiki.git] / includes / SpecialIpblocklist.php
blob492f78db26c9d6c45f22974087ac75af71e6617e
1 <?php
2 /**
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
8 /**
9 * @todo document
11 function wfSpecialIpblocklist() {
12 global $wgUser, $wgOut, $wgRequest;
14 $ip = $wgRequest->getVal( 'wpUnblockAddress', $wgRequest->getVal( 'ip' ) );
15 $reason = $wgRequest->getText( 'wpUnblockReason' );
16 $action = $wgRequest->getText( 'action' );
18 $ipu = new IPUnblockForm( $ip, $reason );
20 if ( "success" == $action ) {
21 $msg = wfMsg( "ipusuccess", htmlspecialchars( $ip ) );
22 $ipu->showList( $msg );
23 } else if ( "submit" == $action && $wgRequest->wasPosted() &&
24 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
25 if ( ! $wgUser->isAllowed('block') ) {
26 $wgOut->sysopRequired();
27 return;
29 $ipu->doSubmit();
30 } else if ( "unblock" == $action ) {
31 $ipu->showForm( "" );
32 } else {
33 $ipu->showList( "" );
37 /**
39 * @package MediaWiki
40 * @subpackage SpecialPage
42 class IPUnblockForm {
43 var $ip, $reason;
45 function IPUnblockForm( $ip, $reason ) {
46 $this->ip = $ip;
47 $this->reason = $reason;
50 function showForm( $err )
52 global $wgOut, $wgUser, $wgLang;
54 $wgOut->setPagetitle( wfMsg( "unblockip" ) );
55 $wgOut->addWikiText( wfMsg( "unblockiptext" ) );
57 $ipa = wfMsg( "ipaddress" );
58 $ipr = wfMsg( "ipbreason" );
59 $ipus = htmlspecialchars( wfMsg( "ipusubmit" ) );
60 $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" );
61 $action = $titleObj->escapeLocalURL( "action=submit" );
63 if ( "" != $err ) {
64 $wgOut->setSubtitle( wfMsg( "formerror" ) );
65 $wgOut->addHTML( "<p class='error'>{$err}</p>\n" );
67 $token = htmlspecialchars( $wgUser->editToken() );
69 $wgOut->addHTML( "
70 <form id=\"unblockip\" method=\"post\" action=\"{$action}\">
71 <table border='0'>
72 <tr>
73 <td align='right'>{$ipa}:</td>
74 <td align='left'>
75 <input tabindex='1' type='text' size='20' name=\"wpUnblockAddress\" value=\"" . htmlspecialchars( $this->ip ) . "\" />
76 </td>
77 </tr>
78 <tr>
79 <td align='right'>{$ipr}:</td>
80 <td align='left'>
81 <input tabindex='1' type='text' size='40' name=\"wpUnblockReason\" value=\"" . htmlspecialchars( $this->reason ) . "\" />
82 </td>
83 </tr>
84 <tr>
85 <td>&nbsp;</td>
86 <td align='left'>
87 <input tabindex='2' type='submit' name=\"wpBlock\" value=\"{$ipus}\" />
88 </td>
89 </tr>
90 </table>
91 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
92 </form>\n" );
96 function doSubmit() {
97 global $wgOut, $wgUser, $wgLang;
99 $block = new Block();
100 $this->ip = trim( $this->ip );
102 if ( $this->ip{0} == "#" ) {
103 $block->mId = substr( $this->ip, 1 );
104 } else {
105 $block->mAddress = $this->ip;
108 # Delete block (if it exists)
109 # We should probably check for errors rather than just declaring success
110 $block->delete();
112 # Make log entry
113 $log = new LogPage( 'block' );
114 $log->addEntry( 'unblock', Title::makeTitle( NS_USER, $this->ip ), $this->reason );
116 # Report to the user
117 $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" );
118 $success = $titleObj->getFullURL( "action=success&ip=" . urlencode( $this->ip ) );
119 $wgOut->redirect( $success );
122 function showList( $msg ) {
123 global $wgOut;
125 $wgOut->setPagetitle( wfMsg( "ipblocklist" ) );
126 if ( "" != $msg ) {
127 $wgOut->setSubtitle( $msg );
129 $wgOut->addHTML( "<ul>" );
130 Block::enumBlocks( "wfAddRow", 0 );
131 $wgOut->addHTML( "</ul>\n" );
136 * Callback function to output a block
138 function wfAddRow( $block, $tag ) {
139 global $wgOut, $wgUser, $wgLang, $wgContLang;
141 $sk = $wgUser->getSkin();
143 # Hide addresses blocked by User::spreadBlocks, for privacy
144 $addr = $block->mAuto ? "#{$block->mId}" : $block->mAddress;
146 $name = User::whoIs( $block->mBy );
147 $ulink = $sk->makeKnownLinkObj( Title::makeTitle( NS_USER, $name ), $name );
148 $formattedTime = $wgLang->timeanddate( $block->mTimestamp, true );
150 if ( $block->mExpiry === "" ) {
151 $formattedExpiry = "indefinite";
152 } else {
153 $formattedExpiry = $wgLang->timeanddate( $block->mExpiry, true );
156 $line = wfMsg( "blocklistline", $formattedTime, $ulink, $addr, $formattedExpiry );
158 $wgOut->addHTML( "<li>{$line}" );
160 if ( !$block->mAuto ) {
161 $titleObj = Title::makeTitle( NS_SPECIAL, "Contributions" );
162 $clink = "<a href=\"" . $titleObj->escapeLocalURL( "target={$block->mAddress}" ) . "\">" .
163 wfMsg( "contribslink" ) . "</a>";
164 $wgOut->addHTML( " ({$clink})" );
167 if ( $wgUser->isAllowed('block') ) {
168 $titleObj = Title::makeTitle( NS_SPECIAL, "Ipblocklist" );
169 $ublink = "<a href=\"" .
170 $titleObj->escapeLocalURL( "action=unblock&ip=" . urlencode( $addr ) ) . "\">" .
171 wfMsg( "unblocklink" ) . "</a>";
172 $wgOut->addHTML( " ({$ublink})" );
174 $wgOut->addHTML( $sk->commentBlock( $block->mReason ) );
175 $wgOut->addHTML( "</li>\n" );