r11973 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r11972‎ | r11973 | r11974 >
Date:05:37, 5 December 2005
Author:vibber
Status:old
Tags:
Comment:
* Add createpage and createtalk permission keys, allowing a quick
switch to disable page creation for anonymous users.
Jimmy requested we have this ability available.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
@@ -202,6 +202,12 @@
203203 return;
204204 }
205205 }
 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+ }
206212 if ( wfReadOnly() ) {
207213 wfDebug( "$fname: read-only mode is engaged\n" );
208214 if( $this->save || $this->preview ) {
@@ -513,6 +519,14 @@
514520 # If article is new, insert it.
515521 $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
516522 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+
517531 # Don't save a new article if it's blank.
518532 if ( ( '' == $this->textbox1 ) ) {
519533 $wgOut->redirect( $this->mTitle->getFullURL() );
@@ -1527,6 +1541,11 @@
15281542 return strtr( $result, array( "&#x0" => "&#x" ) );
15291543 }
15301544
 1545+ function noCreatePermission() {
 1546+ global $wgOut;
 1547+ $wgOut->setPageTitle( wfMsg( 'nocreatetitle' ) );
 1548+ $wgOut->addWikiText( wfMsg( 'nocreatetext' ) );
 1549+ }
15311550
15321551 }
15331552
Index: trunk/phase3/includes/Title.php
@@ -906,6 +906,13 @@
907907 wfProfileOut( $fname );
908908 return false;
909909 }
 910+
 911+ if( $action == 'create' ) {
 912+ if( ( $this->isTalkPage() && !$wgUser->isAllowed( 'createtalk' ) ) ||
 913+ ( !$this->isTalkPage() && !$wgUser->isAllowed( 'createpage' ) ) ) {
 914+ return false;
 915+ }
 916+ }
910917
911918 wfProfileOut( $fname );
912919 return true;
Index: trunk/phase3/includes/DefaultSettings.php
@@ -771,10 +771,14 @@
772772 $wgGroupPermissions['*' ]['createaccount'] = true;
773773 $wgGroupPermissions['*' ]['read'] = true;
774774 $wgGroupPermissions['*' ]['edit'] = true;
 775+$wgGroupPermissions['*' ]['createpage'] = true;
 776+$wgGroupPermissions['*' ]['createtalk'] = true;
775777
776778 $wgGroupPermissions['user' ]['move'] = true;
777779 $wgGroupPermissions['user' ]['read'] = true;
778780 $wgGroupPermissions['user' ]['edit'] = true;
 781+$wgGroupPermissions['user' ]['createpage'] = true;
 782+$wgGroupPermissions['user' ]['createtalk'] = true;
779783 $wgGroupPermissions['user' ]['upload'] = true;
780784 $wgGroupPermissions['user' ]['reupload'] = true;
781785 $wgGroupPermissions['user' ]['reupload-shared'] = true;
Index: trunk/phase3/RELEASE-NOTES
@@ -292,6 +292,8 @@
293293 * (bug 4162) Add $wgThumbnailEpoch timestamp to force old thumbs to
294294 be rerendered on demand, sitewide
295295 * (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.
296298
297299
298300 === Caveats ===
Index: trunk/phase3/languages/Language.php
@@ -785,6 +785,9 @@
786786 '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>",
787787 'templatesused' => 'Templates used on this page:',
788788 '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]].',
789792
790793 # History pages
791794 #

Status & tagging log