r96267 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96266‎ | r96267 | r96268 >
Date:01:47, 5 September 2011
Author:robin
Status:resolved (Comments)
Tags:
Comment:
(bug 26170) MediaWiki:Globalblocking-blocked should have a variable for the user's IP address
Some other tweaks (whitespace, docs, ..)
Modified paths:
  • /trunk/extensions/GlobalBlocking/GlobalBlocking.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GlobalBlocking/GlobalBlocking.class.php
@@ -1,9 +1,12 @@
22 <?php
33
44 class GlobalBlocking {
 5+ /**
 6+ * @return Boolean
 7+ */
58 static function getUserPermissionsErrors( &$title, &$user, $action, &$result ) {
69 global $wgApplyGlobalBlocks;
7 - if ($action == 'read' || !$wgApplyGlobalBlocks) {
 10+ if ( $action == 'read' || !$wgApplyGlobalBlocks ) {
811 return true;
912 }
1013 if ( $user->isAllowed( 'ipblock-exempt' ) ||
@@ -13,13 +16,16 @@
1417 }
1518 $ip = wfGetIp();
1619 $blockError = self::getUserBlockErrors( $user, $ip );
17 - if( !empty($blockError) ) {
 20+ if( !empty( $blockError ) ) {
1821 $result[] = $blockError;
1922 return false;
2023 }
2124 return true;
2225 }
23 -
 26+
 27+ /**
 28+ * @return Boolean
 29+ */
2430 static function isBlockedGlobally( &$user, $ip, &$blocked ) {
2531 $blockError = self::getUserBlockErrors( $user, $ip );
2632 if( $blockError ) {
@@ -28,18 +34,22 @@
2935 }
3036 return true;
3137 }
32 -
 38+
 39+ /**
 40+ * @return Array: empty or a message key with parameters
 41+ */
3342 static function getUserBlockErrors( $user, $ip ) {
34 - global $wgLang;
3543 static $result = null;
3644
3745 // Instance cache
38 - if (!is_null($result)) return $result;
 46+ if ( !is_null( $result ) ) { return $result; }
3947
4048 $block = self::getGlobalBlockingBlock( $ip, $user->isAnon() );
4149 if ( $block ) {
 50+ global $wgLang;
 51+
4252 // Check for local whitelisting
43 - if (GlobalBlocking::getWhitelistInfo( $block->gb_id ) ) {
 53+ if ( GlobalBlocking::getWhitelistInfo( $block->gb_id ) ) {
4454 // Block has been whitelisted.
4555 return $result = array();
4656 }
@@ -65,7 +75,8 @@
6676 $display_wiki = self::getWikiName( $block->gb_by_wiki );
6777 $user_display = self::maybeLinkUserpage( $block->gb_by_wiki, $block->gb_by );
6878
69 - return $result = array('globalblocking-blocked', $user_display, $display_wiki, $block->gb_reason, $expiry);
 79+ return $result = array( 'globalblocking-blocked',
 80+ $user_display, $display_wiki, $block->gb_reason, $expiry, $ip );
7081 }
7182 return $result = array();
7283 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r96407r96267: add the IP address parameter to the messagerobin05:32, 7 September 2011

Comments

#Comment by Raymond (talk | contribs)   06:32, 5 September 2011

Why not add the IP address to the message itself?

#Comment by SPQRobin (talk | contribs)   03:35, 7 September 2011

Yeah we could do that if it's wanted..

#Comment by SPQRobin (talk | contribs)   03:37, 7 September 2011

Is it better to change the i18n file, or edit the message on TWN?

#Comment by Raymond (talk | contribs)   04:46, 7 September 2011

Never edit the English source in translatewiki.net. It will be ignored from the scripts. Change 'en' in the i18n file and translatewiki.net will handle the rest.

Status & tagging log