From e786d61e2e41656c1f152743f7c849c32cfc2029 Mon Sep 17 00:00:00 2001 From: Matthias Jordan Date: Tue, 5 Aug 2003 11:04:02 +0000 Subject: [PATCH] If the global config variable $wgWhitelistEdit is true, only logged in users are allowed and able to edit articles. --- includes/DefaultSettings.php | 3 +++ includes/EditPage.php | 24 +++++++++++++++++++++++- languages/Language.php | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index edad2a6732..f15ea34f57 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -62,6 +62,9 @@ $wgSqlLogFile = "{$wgUploadDirectory}/sqllog_mFhyRe6"; $wgLogQueries = false; $wgUseBetterLinksUpdate = true; +# If wgWhitelistEdit is set to true, only logged in users +# are allowed to edit articles. +# $wgWhitelistEdit = true; # Client-side caching: $wgCachePages = true; # Allow client-side caching of pages diff --git a/includes/EditPage.php b/includes/EditPage.php index d2ee7d82a3..367e068faf 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -19,7 +19,7 @@ class EditPage { function edit() { - global $wgOut, $wgUser; + global $wgOut, $wgUser, $wgWhitelistEdit; global $wpTextbox1, $wpSummary, $wpSave, $wpPreview; global $wpMinoredit, $wpEdittime, $wpTextbox2; @@ -34,6 +34,10 @@ class EditPage { $this->blockedIPpage(); return; } + if ( !$wgUser->getID() && $wgWhitelistEdit ) { + $this->userNotLoggedInPage(); + return; + } if ( wfReadOnly() ) { if( isset( $wpSave ) or isset( $wpPreview ) ) { $this->editForm( "preview" ); @@ -103,6 +107,10 @@ class EditPage { $this->blockedIPpage(); return; } + if ( !$wgUser->getID() && $wgWhitelistEdit ) { + $this->userNotLoggedInPage(); + return; + } if ( wfReadOnly() ) { $wgOut->readOnlyPage(); return; @@ -338,6 +346,20 @@ $wgLang->recodeForEdit( $wpTextbox1 ) . } + + function userNotLoggedInPage() + { + global $wgOut, $wgUser, $wgLang; + + $wgOut->setPageTitle( wfMsg( "whitelistedittitle" ) ); + $wgOut->setRobotpolicy( "noindex,nofollow" ); + $wgOut->setArticleFlag( false ); + + $wgOut->addWikiText( wfMsg( "whitelistedittext" ) ); + $wgOut->returnToMain( false ); + } + + } ?> diff --git a/languages/Language.php b/languages/Language.php index 3ae261e4fe..dff60df648 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -506,6 +506,8 @@ Please log in again after you receive it.", "blockedtext" => "Your user name or IP address has been blocked by $1. The reason given is this:
''$2''

You may contact $1 or one of the other [[Wikipedia:administrators|administrators]] to discuss the block.", +"whitelistedittitle" => "User not logged in", +"whitelistedittext" => "You have to [[Spezial:Userlogin|login]] to edit articles.", "newarticle" => "(New)", "newarticletext" => "You've followed a link to a page that doesn't exist yet. -- 2.20.1