Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -202,6 +202,12 @@ |
203 | 203 | return; |
204 | 204 | } |
205 | 205 | } |
| 206 | + if ( !$this->mTitle->userCan( 'create' ) && !$this->mTitle->exists() ) { |
| 207 | + wfDebug( "$fname: no create permission\n" ); |
| 208 | + $this->noCreatePermission(); |
| 209 | + wfProfileOut( $fname ); |
| 210 | + return; |
| 211 | + } |
206 | 212 | if ( wfReadOnly() ) { |
207 | 213 | wfDebug( "$fname: read-only mode is engaged\n" ); |
208 | 214 | if( $this->save || $this->preview ) { |
— | — | @@ -513,6 +519,14 @@ |
514 | 520 | # If article is new, insert it. |
515 | 521 | $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE ); |
516 | 522 | if ( 0 == $aid ) { |
| 523 | + // Late check for create permission, just in case *PARANOIA* |
| 524 | + if ( !$this->mTitle->userCan( 'create' ) ) { |
| 525 | + wfDebug( "$fname: no create permission\n" ); |
| 526 | + $this->noCreatePermission(); |
| 527 | + wfProfileOut( $fname ); |
| 528 | + return; |
| 529 | + } |
| 530 | + |
517 | 531 | # Don't save a new article if it's blank. |
518 | 532 | if ( ( '' == $this->textbox1 ) ) { |
519 | 533 | $wgOut->redirect( $this->mTitle->getFullURL() ); |
— | — | @@ -1527,6 +1541,11 @@ |
1528 | 1542 | return strtr( $result, array( "�" => "&#x" ) ); |
1529 | 1543 | } |
1530 | 1544 | |
| 1545 | + function noCreatePermission() { |
| 1546 | + global $wgOut; |
| 1547 | + $wgOut->setPageTitle( wfMsg( 'nocreatetitle' ) ); |
| 1548 | + $wgOut->addWikiText( wfMsg( 'nocreatetext' ) ); |
| 1549 | + } |
1531 | 1550 | |
1532 | 1551 | } |
1533 | 1552 | |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -906,6 +906,13 @@ |
907 | 907 | wfProfileOut( $fname ); |
908 | 908 | return false; |
909 | 909 | } |
| 910 | + |
| 911 | + if( $action == 'create' ) { |
| 912 | + if( ( $this->isTalkPage() && !$wgUser->isAllowed( 'createtalk' ) ) || |
| 913 | + ( !$this->isTalkPage() && !$wgUser->isAllowed( 'createpage' ) ) ) { |
| 914 | + return false; |
| 915 | + } |
| 916 | + } |
910 | 917 | |
911 | 918 | wfProfileOut( $fname ); |
912 | 919 | return true; |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -771,10 +771,14 @@ |
772 | 772 | $wgGroupPermissions['*' ]['createaccount'] = true; |
773 | 773 | $wgGroupPermissions['*' ]['read'] = true; |
774 | 774 | $wgGroupPermissions['*' ]['edit'] = true; |
| 775 | +$wgGroupPermissions['*' ]['createpage'] = true; |
| 776 | +$wgGroupPermissions['*' ]['createtalk'] = true; |
775 | 777 | |
776 | 778 | $wgGroupPermissions['user' ]['move'] = true; |
777 | 779 | $wgGroupPermissions['user' ]['read'] = true; |
778 | 780 | $wgGroupPermissions['user' ]['edit'] = true; |
| 781 | +$wgGroupPermissions['user' ]['createpage'] = true; |
| 782 | +$wgGroupPermissions['user' ]['createtalk'] = true; |
779 | 783 | $wgGroupPermissions['user' ]['upload'] = true; |
780 | 784 | $wgGroupPermissions['user' ]['reupload'] = true; |
781 | 785 | $wgGroupPermissions['user' ]['reupload-shared'] = true; |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -292,6 +292,8 @@ |
293 | 293 | * (bug 4162) Add $wgThumbnailEpoch timestamp to force old thumbs to |
294 | 294 | be rerendered on demand, sitewide |
295 | 295 | * (bug 4165) Correct validation for user language selection (data taint) |
| 296 | +* Add createpage and createtalk permission keys, allowing a quick |
| 297 | + switch to disable page creation for anonymous users. |
296 | 298 | |
297 | 299 | |
298 | 300 | === Caveats === |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -785,6 +785,9 @@ |
786 | 786 | 'protectedpagewarning' => "<strong>WARNING: This page has been locked so that only users with sysop privileges can edit it. Be sure you are following the [[Project:Protected_page_guidelines|protected page guidelines]].</strong>", |
787 | 787 | 'templatesused' => 'Templates used on this page:', |
788 | 788 | 'edittools' => '<!-- Text here will be shown below edit and upload forms. -->', |
| 789 | +'nocreatetitle' => 'Page creation limited', |
| 790 | +'nocreatetext' => 'This site has restricted the ability to create new pages. |
| 791 | +You can go back and edit an existing page, or [[Special:Userlogin|log in or create an account]].', |
789 | 792 | |
790 | 793 | # History pages |
791 | 794 | # |