* Add createpage and createtalk permission keys, allowing a quick
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 5 Dec 2005 05:37:10 +0000 (05:37 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 5 Dec 2005 05:37:10 +0000 (05:37 +0000)
  switch to disable page creation for anonymous users.
Jimmy requested we have this ability available.

RELEASE-NOTES
includes/DefaultSettings.php
includes/EditPage.php
includes/Title.php
languages/Language.php

index b13845e..843c5eb 100644 (file)
@@ -292,6 +292,8 @@ fully support the editing toolbar, but was found to be too confusing.
 * (bug 4162) Add $wgThumbnailEpoch timestamp to force old thumbs to
   be rerendered on demand, sitewide
 * (bug 4165) Correct validation for user language selection (data taint)
+* Add createpage and createtalk permission keys, allowing a quick
+  switch to disable page creation for anonymous users.
 
 
 === Caveats ===
index f4e6027..35483d4 100644 (file)
@@ -771,10 +771,14 @@ $wgGroupPermissions = array();
 $wgGroupPermissions['*'    ]['createaccount']   = true;
 $wgGroupPermissions['*'    ]['read']            = true;
 $wgGroupPermissions['*'    ]['edit']            = true;
+$wgGroupPermissions['*'    ]['createpage']      = true;
+$wgGroupPermissions['*'    ]['createtalk']      = true;
 
 $wgGroupPermissions['user' ]['move']            = true;
 $wgGroupPermissions['user' ]['read']            = true;
 $wgGroupPermissions['user' ]['edit']            = true;
+$wgGroupPermissions['user' ]['createpage']      = true;
+$wgGroupPermissions['user' ]['createtalk']      = true;
 $wgGroupPermissions['user' ]['upload']          = true;
 $wgGroupPermissions['user' ]['reupload']        = true;
 $wgGroupPermissions['user' ]['reupload-shared'] = true;
index 8c73af6..d6d714d 100644 (file)
@@ -202,6 +202,12 @@ class EditPage {
                                return;
                        }
                }
+               if ( !$this->mTitle->userCan( 'create' ) && !$this->mTitle->exists() ) {
+                       wfDebug( "$fname: no create permission\n" );
+                       $this->noCreatePermission();
+                       wfProfileOut( $fname );
+                       return;
+               }
                if ( wfReadOnly() ) {
                        wfDebug( "$fname: read-only mode is engaged\n" );
                        if( $this->save || $this->preview ) {
@@ -513,6 +519,14 @@ class EditPage {
                # If article is new, insert it.
                $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
                if ( 0 == $aid ) {
+                       // Late check for create permission, just in case *PARANOIA*
+                       if ( !$this->mTitle->userCan( 'create' ) ) {
+                               wfDebug( "$fname: no create permission\n" );
+                               $this->noCreatePermission();
+                               wfProfileOut( $fname );
+                               return;
+                       }
+                       
                        # Don't save a new article if it's blank.
                        if ( ( '' == $this->textbox1 ) ) {
                                        $wgOut->redirect( $this->mTitle->getFullURL() );
@@ -1527,6 +1541,11 @@ END
                return strtr( $result, array( "&#x0" => "&#x" ) );
        }
        
+       function noCreatePermission() {
+               global $wgOut;
+               $wgOut->setPageTitle( wfMsg( 'nocreatetitle' ) );
+               $wgOut->addWikiText( wfMsg( 'nocreatetext' ) );
+       }
 
 }
 
index 433187e..0d5d1c7 100644 (file)
@@ -906,6 +906,13 @@ class Title {
                        wfProfileOut( $fname );
                        return false;
                }
+               
+               if( $action == 'create' ) {
+                       if( (  $this->isTalkPage() && !$wgUser->isAllowed( 'createtalk' ) ) ||
+                               ( !$this->isTalkPage() && !$wgUser->isAllowed( 'createpage' ) ) ) {
+                               return false;
+                       }
+               }
 
                wfProfileOut( $fname );
                return true;
index 743b744..e5ab125 100644 (file)
@@ -785,6 +785,9 @@ the text into a text file and save it for later.</strong>',
 '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>",
 'templatesused'        => 'Templates used on this page:',
 'edittools' => '<!-- Text here will be shown below edit and upload forms. -->',
+'nocreatetitle' => 'Page creation limited',
+'nocreatetext' => 'This site has restricted the ability to create new pages.
+You can go back and edit an existing page, or [[Special:Userlogin|log in or create an account]].',
 
 # History pages
 #