r58199 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58198‎ | r58199 | r58200 >
Date:16:28, 27 October 2009
Author:raymond
Status:ok
Tags:
Comment:
Use the new hook from r58192: Creates a "is blocked as a Tor exit node" message for Special:IPBlockList
Modified paths:
  • /trunk/extensions/TorBlock/TorBlock.class.php (modified) (history)
  • /trunk/extensions/TorBlock/TorBlock.i18n.php (modified) (history)
  • /trunk/extensions/TorBlock/TorBlock.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TorBlock/TorBlock.i18n.php
@@ -14,6 +14,7 @@
1515 'torblock-desc' => 'Allows tor exit nodes to be blocked from editing a wiki',
1616 'torblock-blocked' => 'Your IP address, <tt>$1</tt>, has been automatically identified as a tor exit node.
1717 Editing through tor is blocked to prevent abuse.',
 18+ 'torblock-isexitnode' => 'The IP address $1 is blocked as a Tor exit node.',
1819 'right-torunblocked' => 'Bypass automatic blocks of tor exit nodes',
1920 'tag-tor-description' => 'If this tag is set, an edit was made from a Tor exit node.',
2021 'tag-tor' => 'Made through tor',
Index: trunk/extensions/TorBlock/TorBlock.php
@@ -37,6 +37,7 @@
3838 $wgHooks['AbuseFilter-filterAction'][] = 'TorBlock::onAbuseFilterFilterAction';
3939 $wgHooks['AbuseFilter-builder'][] = 'TorBlock::onAbuseFilterBuilder';
4040 $wgHooks['EmailUserPermissionsErrors'][] = 'TorBlock::onEmailUserPermissionsErrors';
 41+$wgHooks['getOtherBlockLogLink'][] = 'TorBlock::getTorBlockStatus';
4142
4243 // Define new autopromote condition
4344 define('APCOND_TOR', 'tor'); // Numbers won't work, we'll get collisions
Index: trunk/extensions/TorBlock/TorBlock.class.php
@@ -159,7 +159,6 @@
160160 }
161161
162162 public static function isExitNode($ip = null) {
163 - #return true; ## FOR DEBUGGING
164163 if ($ip == null) {
165164 $ip = wfGetIp();
166165 }
@@ -233,4 +232,26 @@
234233 $emptyTags[] = 'tor';
235234 return true;
236235 }
 236+
 237+ /**
 238+ * Creates a message with the status
 239+ * @param array $msg Message with the status
 240+ * @param string $ip The IP address to be checked
 241+ * @return boolean true
 242+ */
 243+ public static function getTorBlockStatus( &$msg, $ip ) {
 244+ // IP addresses can be blocked only
 245+ // Fast return if IP is not an exit node
 246+ if ( !IP::isIPAddress( $ip ) || !self::isExitNode( $ip ) ) {
 247+ return true;
 248+ }
 249+
 250+ wfLoadExtensionMessages( 'TorBlock' );
 251+ $msg[] = Html::rawElement(
 252+ 'span',
 253+ array( 'class' => 'mw-torblock-isexitnode' ),
 254+ wfMsgExt( 'torblock-isexitnode', 'parseinline', $ip )
 255+ );
 256+ return true;
 257+ }
237258 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r58192New hook getOtherBlockLogLink, called in Special:IPBlockList to show links to...raymond14:08, 27 October 2009

Status & tagging log