Extension talk:Email required to sign up

$wgUserAccountEmailRequired

 * MediaWiki version: 1.8.2

I was trying to require an e-mail address and thought a simple variable could be added to accommodate this need in a generic way.

$wgUserAccountEmailRequired = true;
 * LocalSettings.php

251                if ( $wgUserAccountEmailRequired ) { 252                        if (!$this->mEmail) { 253                                $this->mainLoginForm( wfMsg( 'noemailonsignup' ) ); 254                                return false; 255                        } elseif (! User::isValidEmailAddr( $this->mEmail ) ) { 256                                $this->mainLoginForm( wfMsg( 'invalidemailonsignup' ) ); 257                                return false; 258                        }    259                 }
 * Mod's made to the login to require e-mail address - includes/specials/SpecialUserlogin.php:

694 'noemailonsignup'      => 'An email address is required to sign up.', 695 'invalidemailonsignup' => 'A valid email address is required to sign up.',
 * Here's the error message - languages/messages/MessagesEn.php :

Restrict a User's e-mail address by Pattern
I also wanted the ability to have users create their own accounts, but limit it to certain domains. To accommodate this, I had to change the User::isValidEmailAddr method to take check to see if a variable was set. If it is, then it should be an array and it should contain regular expression to match on.

365        function isValidEmailAddr ( $addr ) { 366                global $wgUserAccountEmailPattern; 367                $valid = false; 368                if ( $wgUserAccountEmailPattern ) { 369                        foreach ($wgUserAccountEmailPattern as $regex) { 370                                $re = '/^'. "$regex". '$/';   371                                 $valid = preg_match( $re, strtolower($addr)); 372                                if ( $valid ) { 373                                        break; 374                                }    375                         }    376                 } else { 377                        $valid = ( trim( $addr ) != '' ) && (false !== strpos( $addr, '@' ) ); 378                }    379     380                 return $valid; 381        }
 * Here's the change I made to includes/User.php:

$wgUserAccountEmailPattern = array( '.*@gmail\.com', '.*@yahoo\.com' );
 * Example LocalSettings.php to restrict addresses to *@gmail.com & *@yahoo.com :