Index: trunk/extensions/GlobalBlocking/GlobalBlocking.class.php |
— | — | @@ -1,9 +1,12 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class GlobalBlocking { |
| 5 | + /** |
| 6 | + * @return Boolean |
| 7 | + */ |
5 | 8 | static function getUserPermissionsErrors( &$title, &$user, $action, &$result ) { |
6 | 9 | global $wgApplyGlobalBlocks; |
7 | | - if ($action == 'read' || !$wgApplyGlobalBlocks) { |
| 10 | + if ( $action == 'read' || !$wgApplyGlobalBlocks ) { |
8 | 11 | return true; |
9 | 12 | } |
10 | 13 | if ( $user->isAllowed( 'ipblock-exempt' ) || |
— | — | @@ -13,13 +16,16 @@ |
14 | 17 | } |
15 | 18 | $ip = wfGetIp(); |
16 | 19 | $blockError = self::getUserBlockErrors( $user, $ip ); |
17 | | - if( !empty($blockError) ) { |
| 20 | + if( !empty( $blockError ) ) { |
18 | 21 | $result[] = $blockError; |
19 | 22 | return false; |
20 | 23 | } |
21 | 24 | return true; |
22 | 25 | } |
23 | | - |
| 26 | + |
| 27 | + /** |
| 28 | + * @return Boolean |
| 29 | + */ |
24 | 30 | static function isBlockedGlobally( &$user, $ip, &$blocked ) { |
25 | 31 | $blockError = self::getUserBlockErrors( $user, $ip ); |
26 | 32 | if( $blockError ) { |
— | — | @@ -28,18 +34,22 @@ |
29 | 35 | } |
30 | 36 | return true; |
31 | 37 | } |
32 | | - |
| 38 | + |
| 39 | + /** |
| 40 | + * @return Array: empty or a message key with parameters |
| 41 | + */ |
33 | 42 | static function getUserBlockErrors( $user, $ip ) { |
34 | | - global $wgLang; |
35 | 43 | static $result = null; |
36 | 44 | |
37 | 45 | // Instance cache |
38 | | - if (!is_null($result)) return $result; |
| 46 | + if ( !is_null( $result ) ) { return $result; } |
39 | 47 | |
40 | 48 | $block = self::getGlobalBlockingBlock( $ip, $user->isAnon() ); |
41 | 49 | if ( $block ) { |
| 50 | + global $wgLang; |
| 51 | + |
42 | 52 | // Check for local whitelisting |
43 | | - if (GlobalBlocking::getWhitelistInfo( $block->gb_id ) ) { |
| 53 | + if ( GlobalBlocking::getWhitelistInfo( $block->gb_id ) ) { |
44 | 54 | // Block has been whitelisted. |
45 | 55 | return $result = array(); |
46 | 56 | } |
— | — | @@ -65,7 +75,8 @@ |
66 | 76 | $display_wiki = self::getWikiName( $block->gb_by_wiki ); |
67 | 77 | $user_display = self::maybeLinkUserpage( $block->gb_by_wiki, $block->gb_by ); |
68 | 78 | |
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 ); |
70 | 81 | } |
71 | 82 | return $result = array(); |
72 | 83 | } |