Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -418,12 +418,12 @@ |
419 | 419 | } |
420 | 420 | } |
421 | 421 | } |
422 | | - |
423 | | - // If they used redlink=1 and the page exists, redirect to the main article |
424 | | - if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) { |
425 | | - $wgOut->redirect( $this->mTitle->getFullURL() ); |
426 | | - } |
427 | 422 | |
| 423 | + # Evaluate if the edit interface should be shown or |
| 424 | + # if the page should be shown, in case redlink=true |
| 425 | + if ( $wgRequest->getBool( 'redlink' ) ) |
| 426 | + $this->showPageOnRedlink(); |
| 427 | + |
428 | 428 | wfProfileIn( __METHOD__."-business-end" ); |
429 | 429 | |
430 | 430 | $this->isConflict = false; |
— | — | @@ -487,7 +487,45 @@ |
488 | 488 | wfProfileOut( __METHOD__."-business-end" ); |
489 | 489 | wfProfileOut( __METHOD__ ); |
490 | 490 | } |
491 | | - |
| 491 | + |
| 492 | + /* |
| 493 | + * Evaluate if the edit interface should be shown or the page, in case redlink=true. |
| 494 | + * If the page exists, it is always shown. If it doesn't, it depends on the settings |
| 495 | + * of $wgShowPageOnRedlink (see DefaultSettings for documentation). |
| 496 | + */ |
| 497 | + protected function showPageOnRedlink() { |
| 498 | + global $wgShowPageOnRedlink, $wgUser, $wgRequest, $wgOut; |
| 499 | + $redirectToPage = false; |
| 500 | + # If the page exists (it has been created after the link has been emerged), |
| 501 | + # redirect to the page instead of editing the current page |
| 502 | + if ( $this->mTitle->exists() ) |
| 503 | + $wgOut->redirect( $this->mTitle->getFullURL() ); |
| 504 | + # Check site configuration ($wgShowPageOnRedlink) |
| 505 | + if ( is_array( $wgShowPageOnRedlink ) ) { |
| 506 | + $ns = $this->mTitle->getNamespace(); |
| 507 | + $groups = $wgUser->getEffectiveGroups(); |
| 508 | + # Gets overwritten if user is member of a group that has been specified: |
| 509 | + $redirectToPage = true; |
| 510 | + foreach ( $groups as $i => $group ) { |
| 511 | + # Test if there is a rule for a specific usergroup and a specific namespace |
| 512 | + if ( isset( $wgShowPageOnRedlink[$group][$ns] ) && $wgShowPageOnRedlink[$group][$ns] == false ) { |
| 513 | + $redirectToPage = false; |
| 514 | + } |
| 515 | + # Test if there is a rule for a specific usergroup in all namespaces |
| 516 | + elseif ( isset( $wgShowPageOnRedlink[$group] ) && !is_array( $wgShowPageOnRedlink[$group] ) |
| 517 | + && $wgShowPageOnRedlink[$group] == false ) { |
| 518 | + $redirectToPage = false; |
| 519 | + } |
| 520 | + } |
| 521 | + } |
| 522 | + else { |
| 523 | + $redirectToPage = $wgShowPageOnRedlink; |
| 524 | + } |
| 525 | + if ( $redirectToPage ) { |
| 526 | + $wgOut->redirect( $this->mTitle->getFullURL() ); |
| 527 | + } |
| 528 | + } |
| 529 | + |
492 | 530 | protected function getEditPermissionErrors() { |
493 | 531 | global $wgUser; |
494 | 532 | $permErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser ); |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -4269,3 +4269,16 @@ |
4270 | 4270 | * Use old names for change_tags indices. |
4271 | 4271 | */ |
4272 | 4272 | $wgOldChangeTagsIndex = false; |
| 4273 | + |
| 4274 | +/** |
| 4275 | + * View page instead of edit interface when visiting a red link |
| 4276 | + * There are three ways to define this variable: |
| 4277 | + * 1. Set $wgShowPageOnRedlink to true (false is default) |
| 4278 | + * 2. Set $wgShowPageOnRedlink['usergroup'] to false. If a user is member of at least one usergroup for which the variable |
| 4279 | + * has been set to false, the edit interface will be shown. Otherwise the page is shown. |
| 4280 | + * 3. Set $wgShowPageOnRedlink['usergroup'][NS_XY] to false. Same as 2., but you can specify the namespace. The namespace |
| 4281 | + * is a numerical value (namespace index), you can use constants such as NS_MAIN or NS_USER_TALK. |
| 4282 | + * If you use an array (2. or 3.), the default will be true (for 1. it's false). In 2. and 3. there is no way to overwrite |
| 4283 | + * a value 'false' once it has already been set (this is due to the undefined order of usergroups). |
| 4284 | + */ |
| 4285 | +$wgShowPageOnRedlink = false; |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -239,6 +239,9 @@ |
240 | 240 | the root permission effectively grants all other permissions on a wiki. Useful |
241 | 241 | for debugging and administration. |
242 | 242 | * (bug 16979) Tracking categories for __INDEX__ and __NOINDEX__ |
| 243 | +* New configuration variable $wgShowPageOnRedlink that can be set to show the page |
| 244 | + instead of an edit interface when visiting a red link. The value can be specified |
| 245 | + for specific usergroups and namespaces. |
243 | 246 | |
244 | 247 | === Bug fixes in 1.16 === |
245 | 248 | |