Index: trunk/extensions/Lockdown/Lockdown.php |
— | — | @@ -41,8 +41,10 @@ |
42 | 42 | |
43 | 43 | $wgNamespacePermissionLockdown = array(); |
44 | 44 | $wgSpecialPageLockdown = array(); |
| 45 | +$wgActionLockdown = array(); |
45 | 46 | |
46 | 47 | $wgHooks['userCan'][] = 'lockdownUserCan'; |
| 48 | +$wgHooks['MediaWikiPerformAction'][] = 'lockdownMediawikiPerformAction'; |
47 | 49 | |
48 | 50 | function lockdownUserCan($title, $user, $action, &$result) { |
49 | 51 | global $wgNamespacePermissionLockdown, $wgSpecialPageLockdown, $wgWhitelistRead; |
— | — | @@ -77,11 +79,12 @@ |
78 | 80 | } |
79 | 81 | else { |
80 | 82 | $groups = @$wgNamespacePermissionLockdown[$ns][$action]; |
81 | | - if (!$groups) $groups = @$wgNamespacePermissionLockdown['*'][$action]; |
82 | | - if (!$groups) $groups = @$wgNamespacePermissionLockdown[$ns]['*']; |
| 83 | + if ( $groups === NULL ) $groups = @$wgNamespacePermissionLockdown['*'][$action]; |
| 84 | + if ( $groups === NULL ) $groups = @$wgNamespacePermissionLockdown[$ns]['*']; |
83 | 85 | } |
84 | 86 | |
85 | | - if (!$groups) return true; |
| 87 | + if ( $groups === NULL ) return true; |
| 88 | + if ( count( $groups ) == 0 ) return false; |
86 | 89 | |
87 | 90 | #print "<br />nsAccessUserCan(".$title->getPrefixedDBkey().", ".$user->getName().", $action)<br />\n"; |
88 | 91 | #print_r($groups); |
— | — | @@ -106,3 +109,20 @@ |
107 | 110 | } |
108 | 111 | } |
109 | 112 | |
| 113 | +function lockdownMediawikiPerformAction ($output, $article, $title, $user, $request, $wiki) { |
| 114 | + global $wgActionLockdown; |
| 115 | + |
| 116 | + $action = $wiki->getVal( 'Action' ); |
| 117 | + |
| 118 | + if ( !isset( $wgActionLockdown[$action] ) ) return true; |
| 119 | + |
| 120 | + $groups = $wgActionLockdown[$action]; |
| 121 | + if ( $groups === NULL ) return true; |
| 122 | + if ( count( $groups ) == 0 ) return false; |
| 123 | + |
| 124 | + $ugroups = $user->getEffectiveGroups(); |
| 125 | + $match = array_intersect($ugroups, $groups); |
| 126 | + |
| 127 | + if ( $match ) return true; |
| 128 | + else return false; |
| 129 | +} |
\ No newline at end of file |