Index: trunk/extensions/Lockdown/Lockdown.php |
— | — | @@ -11,8 +11,8 @@ |
12 | 12 | */ |
13 | 13 | |
14 | 14 | /* |
15 | | -* WARNING: you can use this extension to deny read access to some namespaces. Keep in mind that this |
16 | | -* may be circumvented in several ways. This extension doesn't try to |
| 15 | +* WARNING: you can use this extension to deny read access to some namespaces. Keep in mind that this |
| 16 | +* may be circumvented in several ways. This extension doesn't try to |
17 | 17 | * plug such holes. Also note that pages that are not readable will still be shown in listings, |
18 | 18 | * such as the search page, categories, etc. |
19 | 19 | * |
— | — | @@ -20,15 +20,15 @@ |
21 | 21 | * - transcluding as template (can't really be fixed without disabling inclusion for specific namespaces; |
22 | 22 | * that could be done by adding a hook to Parser::fetchTemplate) |
23 | 23 | * - Special:export (easily fixed using $wgSpecialPageLockdown) |
24 | | -* - the search page may find text and show excerpts from hidden pages (should be fixed from MediaWiki 1.16). |
25 | | -* Some search messages may reveal the page existance by producing links to it (MediaWiki:searchsubtitle, |
| 24 | +* - the search page may find text and show excerpts from hidden pages (should be fixed from MediaWiki 1.16). |
| 25 | +* Some search messages may reveal the page existance by producing links to it (MediaWiki:searchsubtitle, |
26 | 26 | * MediaWiki:noexactmatch, MediaWiki:searchmenu-exists, MediaWiki:searchmenu-new...). |
27 | 27 | * - supplying oldid=<revisionfromhiddenpage> may work in some versions of mediawiki. Same with diff, etc. |
28 | 28 | * |
29 | 29 | * NOTE: you cannot GRANT access to things forbidden by $wgGroupPermissions. You can only DENY access |
30 | 30 | * granted there. |
31 | 31 | */ |
32 | | - |
| 32 | + |
33 | 33 | if ( !defined( 'MEDIAWIKI' ) ) { |
34 | 34 | echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); |
35 | 35 | die( 1 ); |
— | — | @@ -36,8 +36,8 @@ |
37 | 37 | |
38 | 38 | $wgExtensionCredits['other'][] = array( |
39 | 39 | 'path' => __FILE__, |
40 | | - 'name' => 'Lockdown', |
41 | | - 'author' => array( 'Daniel Kinzler', 'Platonides'), |
| 40 | + 'name' => 'Lockdown', |
| 41 | + 'author' => array( 'Daniel Kinzler', 'Platonides'), |
42 | 42 | 'url' => 'http://mediawiki.org/wiki/Extension:Lockdown', |
43 | 43 | 'descriptionmsg' => 'lockdown-desc', |
44 | 44 | ); |
— | — | @@ -153,12 +153,12 @@ |
154 | 154 | |
155 | 155 | function lockdownSearchableNamespaces($arr) { |
156 | 156 | global $wgUser, $wgNamespacePermissionLockdown; |
157 | | - |
| 157 | + |
158 | 158 | //don't continue if $wgUser's name and id are both null (bug 28842) |
159 | 159 | if ( $wgUser->getId() === null && $wgUser->getName() === null ) { |
160 | 160 | return true; |
161 | 161 | } |
162 | | - |
| 162 | + |
163 | 163 | $ugroups = $wgUser->getEffectiveGroups(); |
164 | 164 | |
165 | 165 | foreach ( $arr as $ns => $name ) { |
— | — | @@ -169,11 +169,11 @@ |
170 | 170 | if ( $groups === null ) { |
171 | 171 | $groups = @$wgNamespacePermissionLockdown[$ns]['*']; |
172 | 172 | } |
173 | | - |
| 173 | + |
174 | 174 | if ( $groups === null ) { |
175 | 175 | continue; |
176 | 176 | } |
177 | | - |
| 177 | + |
178 | 178 | if ( ( count( $groups ) == 0 ) || !array_intersect( $ugroups, $groups ) ) { |
179 | 179 | unset( $arr[$ns] ); |
180 | 180 | } |
— | — | @@ -185,7 +185,7 @@ |
186 | 186 | if ( is_object($title) ) { |
187 | 187 | global $wgUser, $wgNamespacePermissionLockdown; |
188 | 188 | $ugroups = $wgUser->getEffectiveGroups(); |
189 | | - |
| 189 | + |
190 | 190 | $groups = @$wgNamespacePermissionLockdown[$title->getNamespace()]['read']; |
191 | 191 | if ( $groups === null ) { |
192 | 192 | $groups = @$wgNamespacePermissionLockdown['*']['read']; |
— | — | @@ -193,17 +193,17 @@ |
194 | 194 | if ( $groups === null ) { |
195 | 195 | $groups = @$wgNamespacePermissionLockdown[$title->getNamespace()]['*']; |
196 | 196 | } |
197 | | - |
| 197 | + |
198 | 198 | if ( $groups === null ) { |
199 | 199 | return false; |
200 | 200 | } |
201 | | - |
| 201 | + |
202 | 202 | if ( ( count( $groups ) == 0 ) || !array_intersect($ugroups, $groups) ) { |
203 | 203 | $title = null; |
204 | 204 | return false; |
205 | | - } |
| 205 | + } |
206 | 206 | } |
207 | | - return true; |
| 207 | + return true; |
208 | 208 | } |
209 | 209 | |
210 | 210 | #Stop a Go search for a hidden title to send you to the login required page. Will show a no such page message instead. |
— | — | @@ -218,7 +218,7 @@ |
219 | 219 | $searchEngine->namespaces = array_keys( SearchEngine::searchableNamespaces() ); #Use the namespaces... filtered |
220 | 220 | return true; |
221 | 221 | } |
222 | | - |
| 222 | + |
223 | 223 | $ugroups = $wgUser->getEffectiveGroups(); |
224 | 224 | |
225 | 225 | foreach ( $searchEngine->namespaces as $key => $ns ) { |
— | — | @@ -229,16 +229,16 @@ |
230 | 230 | if ( $groups === null ) { |
231 | 231 | $groups = @$wgNamespacePermissionLockdown[$ns]['*']; |
232 | 232 | } |
233 | | - |
| 233 | + |
234 | 234 | if ( $groups === null ) { |
235 | 235 | continue; |
236 | 236 | } |
237 | | - |
| 237 | + |
238 | 238 | if ( ( count( $groups ) == 0 ) || !array_intersect( $ugroups, $groups ) ) { |
239 | 239 | unset( $searchEngine->namespaces[$key] ); |
240 | 240 | } |
241 | 241 | } |
242 | | - |
| 242 | + |
243 | 243 | if ( count( $searchEngine->namespaces ) == 0 ) { |
244 | 244 | $searchEngine->namespaces = array_keys( SearchEngine::searchableNamespaces() ); |
245 | 245 | } |