Tighten up the handling of $wgEmailConfirmToEdit , plus related functionality:
authorNick Jenkins <nickj@users.mediawiki.org>
Thu, 11 Oct 2007 07:11:51 +0000 (07:11 +0000)
committerNick Jenkins <nickj@users.mediawiki.org>
Thu, 11 Oct 2007 07:11:51 +0000 (07:11 +0000)
* Bug 11620 - Added call to User::isValidEmailAddr during accout creation.
* Bug 11629 - If $wgEmailConfirmToEdit is true, require people to supply an
  email address when registering.
* adding "prefs-help-email-required" message (which says an email address is required)
  to complement the existing "prefs-help-email" (which says an email address is optional).
  The former makes sense when $wgEmailConfirmToEdit is true, whereas the latter makes
  sense for the default behaviour (which is for $wgEmailConfirmToEdit to be false).
* Using the "prefs-help-email-required" message in Special:Userlogin and Special:Preferences
  when it makes sense to do so.
* Removing EditPage::userNotConfirmedPage() - as far as I can tell, it is not being
  used internally, or by any extensions. Furthermore, its functionality is superceded by
  the $wgEmailConfirmToEdit global and the check on it in Title.php

RELEASE-NOTES
includes/EditPage.php
includes/SpecialPreferences.php
includes/SpecialUserlogin.php
includes/Title.php
includes/templates/Userlogin.php
languages/messages/MessagesEn.php

index c61d452..f0a23a1 100644 (file)
@@ -94,6 +94,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Do not cache category pages if using 'from' or 'until'
 * Created new hook getUserPermissionsErrors, to go with userCan changes.
 * Diff pages did not properly display css/js pages.
+* (bug 11620) Add call to User::isValidEmailAddr during accout creation.
+* (bug 11629) If $wgEmailConfirmToEdit is true, require people to supply an
+  email address when registering.
+
 
 === API changes in 1.12 ===
 
index 3a19c45..ad5c759 100644 (file)
@@ -1496,22 +1496,6 @@ END
                $wgOut->returnToMain( false, $this->mTitle );
        }
 
-       /**
-        * Creates a basic error page which informs the user that
-        * they have to validate their email address before being
-        * allowed to edit.
-        */
-       function userNotConfirmedPage() {
-               global $wgOut;
-
-               $wgOut->setPageTitle( wfMsg( 'confirmedittitle' ) );
-               $wgOut->setRobotPolicy( 'noindex,nofollow' );
-               $wgOut->setArticleRelated( false );
-
-               $wgOut->addWikiText( wfMsg( 'confirmedittext' ) );
-               $wgOut->returnToMain( false, $this->mTitle );
-       }
-
        /**
         * Creates a basic error page which informs the user that
         * they have attempted to edit a nonexistant section.
index a36be28..851eda2 100644 (file)
@@ -208,7 +208,7 @@ class PreferencesForm {
                global $wgUser, $wgOut, $wgParser;
                global $wgEnableUserEmail, $wgEnableEmail;
                global $wgEmailAuthentication;
-               global $wgAuth;
+               global $wgAuth, $wgEmailConfirmToEdit;
 
 
                if ( '' != $this->mNewpass && $wgAuth->allowPasswordChange() ) {
@@ -338,6 +338,10 @@ class PreferencesForm {
                                        $error = wfMsg( 'invalidemailaddress' );
                                }
                        } else {
+                               if( $wgEmailConfirmToEdit && empty( $newadr ) ) {
+                                       $this->mainPrefsForm( 'error', wfMsg( 'noemailtitle' ) );
+                                       return;
+                               }
                                $wgUser->setEmail( $this->mUserEmail );
                                $wgUser->setCookies();
                                $wgUser->saveSettings();
@@ -510,6 +514,7 @@ class PreferencesForm {
                global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
                global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
                global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth;
+               global $wgEmailConfirmToEdit;
 
                $wgOut->setPageTitle( wfMsg( 'preferences' ) );
                $wgOut->setArticleRelated( false );
@@ -619,7 +624,7 @@ class PreferencesForm {
                                        Xml::label( wfMsg('youremail'), 'wpUserEmail' ),
                                        Xml::input( 'wpUserEmail', 25, $this->mUserEmail, array( 'id' => 'wpUserEmail' ) ),
                                        Xml::tags('div', array( 'class' => 'prefsectiontip' ),
-                                               wfMsgExt( 'prefs-help-email', 'parseinline' )
+                                               wfMsgExt( $wgEmailConfirmToEdit ? 'prefs-help-email-required' : 'prefs-help-email', 'parseinline' )
                                        )
                                )
                        );
index 7ddb723..4b099f0 100644 (file)
@@ -203,6 +203,7 @@ class LoginForm {
                global $wgEnableSorbs, $wgProxyWhitelist;
                global $wgMemc, $wgAccountCreationThrottle;
                global $wgAuth, $wgMinimalPasswordLength;
+               global $wgEmailConfirmToEdit;
 
                // If the user passes an invalid domain, something is fishy
                if( !$wgAuth->validDomain( $this->mDomain ) ) {
@@ -268,6 +269,17 @@ class LoginForm {
                        return false;
                }
                
+               # if you need a confirmed email address to edit, then obviously you need an email address.
+               if ( $wgEmailConfirmToEdit && empty( $this->mEmail ) ) {
+                       $this->mainLoginForm( wfMsg( 'noemailtitle' ) );
+                       return false;
+               }
+               
+               if( !empty( $this->mEmail ) && !User::isValidEmailAddr( $this->mEmail ) ) {
+                       $this->mainLoginForm( wfMsg( 'invalidemailaddress' ) );
+                       return false;
+               }
+               
                # Set some additional data so the AbortNewAccount hook can be
                # used for more than just username validation
                $u->setEmail( $this->mEmail );
@@ -627,7 +639,7 @@ class LoginForm {
        function mainLoginForm( $msg, $msgtype = 'error' ) {
                global $wgUser, $wgOut, $wgAllowRealName, $wgEnableEmail;
                global $wgCookiePrefix, $wgAuth, $wgLoginLanguageSelector;
-               global $wgAuth;
+               global $wgAuth, $wgEmailConfirmToEdit;
 
                if ( $this->mType == 'signup' ) {
                        if ( !$wgUser->isAllowed( 'createaccount' ) ) {
@@ -695,6 +707,7 @@ class LoginForm {
                $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
                $template->set( 'userealname', $wgAllowRealName );
                $template->set( 'useemail', $wgEnableEmail );
+               $template->set( 'emailrequired', $wgEmailConfirmToEdit );
                $template->set( 'canreset', $wgAuth->allowPasswordChange() );
                $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) or $this->mRemember  );
 
index 15be69b..5a62261 100644 (file)
@@ -1029,7 +1029,7 @@ class Title {
         * @param string $action action that permission needs to be checked for
         * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries.
         * @return array Array of arrays of the arguments to wfMsg to explain permissions problems.
-       */
+        */
        public function getUserPermissionsErrors( $action, $user, $doExpensiveQueries = true ) {
                $errors = $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries );
 
index e2eb19e..ac24800 100644 (file)
@@ -166,7 +166,11 @@ class UsercreateTemplate extends QuickTemplate {
                                                tabindex="5"
                                                value="<?php $this->text('email') ?>" size='20' />
                                        <div class="prefsectiontip">
-                                               <?php $this->msgWiki('prefs-help-email'); ?>
+                                               <?php if( $this->data['emailrequired'] ) {
+                                                                       $this->msgWiki('prefs-help-email-required');
+                                                     } else {
+                                                                       $this->msgWiki('prefs-help-email');
+                                                     } ?>
                                        </div>
                                </td>
                        <?php } ?>
index 37d3803..461d864 100644 (file)
@@ -849,6 +849,7 @@ Your account has been created. Don't forget to change your {{SITENAME}} preferen
 'prefs-help-realname'        => 'Real name is optional and if you choose to provide it this will be used for giving you attribution for your work.',
 'loginerror'                 => 'Login error',
 'prefs-help-email'           => 'E-mail address is optional, but it enables others to contact you through your user or user_talk page without needing to reveal your identity.',
+'prefs-help-email-required'  => 'E-mail address is required.',
 'nocookiesnew'               => 'The user account was created, but you are not logged in. {{SITENAME}} uses cookies to log in users. You have cookies disabled. Please enable them, then log in with your new username and password.',
 'nocookieslogin'             => '{{SITENAME}} uses cookies to log in users. You have cookies disabled. Please enable them and try again.',
 'noname'                     => 'You have not specified a valid user name.',