From e8248d94e047c5f36067ada8b3b43bc5f8f0ddfa Mon Sep 17 00:00:00 2001 From: Erik Moeller Date: Fri, 10 Feb 2006 09:34:31 +0000 Subject: [PATCH] very basic support for requiring email authentication before allowing users to edit --- includes/DefaultSettings.php | 6 ++++++ includes/EditPage.php | 20 +++++++++++++++++++- languages/Messages.php | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 1841eba487..7ebf727a73 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -778,6 +778,12 @@ $wgBlockAllowsUTEdit = false; # Blocks allow users to edit their own user tal # directory name unguessable, or use .htaccess to protect it. $wgWhitelistRead = false; +/** + * Should editors be required to have a validated e-mail + * address before being allowed to edit? + */ +$wgEmailConfirmToEdit=false; + /** * Permission keys given to users in each group. * All users are implicitly in the '*' group including anonymous visitors; diff --git a/includes/EditPage.php b/includes/EditPage.php index 66bf97f2f2..f66ce4aa6d 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -153,7 +153,8 @@ class EditPage { * the newly-edited page. */ function edit() { - global $wgOut, $wgUser, $wgRequest, $wgTitle; + global $wgOut, $wgUser, $wgRequest, $wgTitle, + $wgEmailConfirmToEdit; if ( ! wfRunHooks( 'AlternateEdit', array( &$this ) ) ) return; @@ -202,6 +203,12 @@ class EditPage { return; } } + if ($wgEmailConfirmToEdit && !$wgUser->isEmailConfirmed()) { + wfDebug("$fname: user must confirm e-mail address\n"); + $this->userNotConfirmedPage(); + wfProfileOut($fname); + return; + } if ( !$this->mTitle->userCan( 'create' ) && !$this->mTitle->exists() ) { wfDebug( "$fname: no create permission\n" ); $this->noCreatePermission(); @@ -1166,6 +1173,17 @@ END $wgOut->returnToMain( false ); } + function userNotConfirmedPage() { + + global $wgOut; + + $wgOut->setPageTitle( wfMsg( 'confirmedittitle' ) ); + $wgOut->setRobotpolicy( 'noindex,nofollow' ); + $wgOut->setArticleRelated( false ); + $wgOut->addWikiText( wfMsg( 'confirmedittext' ) ); + $wgOut->returnToMain( false ); + } + /** * @todo document */ diff --git a/languages/Messages.php b/languages/Messages.php index 1beb6a5dc9..527dcba002 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -465,6 +465,8 @@ Your IP address is $3. Please include this address in any queries you make.', 'whitelistreadtext' => 'You have to [[Special:Userlogin|login]] to read pages.', 'whitelistacctitle' => 'You are not allowed to create an account', 'whitelistacctext' => 'To be allowed to create accounts in this Wiki you have to [[Special:Userlogin|log]] in and have the appropriate permissions.', +'confirmedittitle' => 'E-mail confirmation required to edit', +'confirmedittext' => 'You must confirm your e-mail address before editing pages. Please set and validate your e-mail address through your [[Special:Preferences|user preferences]].', 'loginreqtitle' => 'Login Required', 'loginreqlink' => 'login', 'loginreqpagetext' => 'You must $1 to view other pages.', -- 2.20.1