r12991 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r12990 | r12991 (on ViewVC) | r12992 >
Date:09:34, 10 February 2006
Author:eloquence
Status:new
Tags:
Comment:very basic support for requiring email authentication before allowing users
to edit
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
===================================================================
--- trunk/phase3/includes/EditPage.php	(revision 12990)
+++ trunk/phase3/includes/EditPage.php	(revision 12991)
@@ -153,7 +153,8 @@
 	 * 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 @@
 				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 @@
 		$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
 	 */
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 12990)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 12991)
@@ -778,6 +778,12 @@
 # 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;
Index: trunk/phase3/languages/Messages.php
===================================================================
--- trunk/phase3/languages/Messages.php	(revision 12990)
+++ trunk/phase3/languages/Messages.php	(revision 12991)
@@ -465,6 +465,8 @@
 '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.',
Views
Toolbox