* @subpackage SpecialPage
*/
class LoginForm {
- private
- $mAction,
- $mCookieCheck,
- $mCreateaccount,
- $mCreateaccountMail,
- $mDomain,
- $mEmail, // Entered user email ??
- $mLoginattempt,
- $mMailmypassword,
- $mName, // Entered username
- $mPassword, // Entered user password
- $mPosted,
- $mRemember, // bool, if user want to be remembered
- $mReturnTo, // article to return to once logged in
- $mRetype ;
+ var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted;
+ var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
+ var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage;
/**
* Constructor
$this->mLoginattempt = $request->getCheck( 'wpLoginattempt' );
$this->mAction = $request->getVal( 'action' );
$this->mRemember = $request->getCheck( 'wpRemember' );
+ $this->mLanguage = $request->getText( 'uselang' );
if( $wgEnableEmail ) {
$this->mEmail = $request->getText( 'wpEmail' );
if( $u == NULL )
return;
+ # If we showed up language selection links, and one was in use, be
+ # smart (and sensible) and save that language as the user's preference
+ global $wgLoginLanguageSelector;
+ if( $wgLoginLanguageSelector && $this->mLanguage )
+ $u->setOption( 'language', $this->mLanguage );
+
# Save user settings and send out an email authentication message if needed
$u->saveSettings();
if( $wgEmailAuthentication && User::isValidEmailAddr( $u->getEmail() ) )
* @private
*/
function mailPassword() {
+ global $wgUser, $wgOut;
+
+ # Check against the rate limiter
+ if( $wgUser->pingLimiter( 'mailpassword' ) ) {
+ $wgOut->rateLimited();
+ return;
+ }
+
if ( '' == $this->mName ) {
$this->mainLoginForm( wfMsg( 'noname' ) );
return;
*/
function mailPasswordInternal( $u ) {
global $wgCookiePath, $wgCookieDomain, $wgCookiePrefix, $wgCookieSecure;
+ global $wgServer, $wgScript;
if ( '' == $u->getEmail() ) {
return wfMsg( 'noemail', $u->getName() );
$ip = wfGetIP();
if ( '' == $ip ) { $ip = '(Unknown)'; }
- $m = wfMsg( 'passwordremindertext', $ip, $u->getName(), $np );
+ $m = wfMsg( 'passwordremindertext', $ip, $u->getName(), $np, $wgServer . $wgScript );
$result = $u->sendMail( wfMsg( 'passwordremindertitle' ), $m );
return $result;
global $wgCookiePrefix;
global $wgAuth;
+ if ( $this->mType == 'signup' && !$wgUser->isAllowedToCreateAccount() ) {
+ $this->userNotPrivilegedMessage();
+ return;
+ }
+
if ( '' == $this->mName ) {
if ( $wgUser->isLoggedIn() ) {
$this->mName = $wgUser->getName();
$template->set( 'action', $titleObj->getLocalUrl( $q ) );
$template->set( 'message', $msg );
$template->set( 'messagetype', $msgtype );
- $template->set( 'create', $wgUser->isAllowedToCreateAccount() );
$template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
$template->set( 'userealname', $wgAllowRealName );
$template->set( 'useemail', $wgEnableEmail );
$template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) or $this->mRemember );
+
+ global $wgLoginLanguageSelector;
+ if( $wgLoginLanguageSelector ) {
+ $template->set( 'languages', $this->makeLanguageSelector() );
+ if( $this->mLanguage )
+ $template->set( 'uselang', $this->mLanguage );
+ }
// Give authentication and captcha plugins a chance to modify the form
$wgAuth->modifyUITemplate( $template );
$wgOut->addWikiText( wfMsg( 'acct_creation_throttle_hit', $limit ) );
}
+
+ /**
+ * Produce a bar of links which allow the user to select another language
+ * during login/registration but retain "returnto"
+ *
+ * @return string
+ */
+ function makeLanguageSelector() {
+ $msg = wfMsgForContent( 'loginlanguagelinks' );
+ if( $msg != '' && $msg != '<loginlanguagelinks>' ) {
+ $langs = explode( "\n", $msg );
+ $links = array();
+ foreach( $langs as $lang ) {
+ $lang = trim( $lang, '* ' );
+ $parts = explode( '|', $lang );
+ $links[] = $this->makeLanguageSelectorLink( $parts[0], $parts[1] );
+ }
+ return count( $links ) > 0 ? wfMsgHtml( 'loginlanguagelabel', implode( ' | ', $links ) ) : '';
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Create a language selector link for a particular language
+ * Links back to this page preserving type and returnto
+ *
+ * @param $text Link text
+ * @param $lang Language code
+ */
+ function makeLanguageSelectorLink( $text, $lang ) {
+ global $wgUser;
+ $self = Title::makeTitle( NS_SPECIAL, 'Userlogin' );
+ $attr[] = 'uselang=' . $lang;
+ if( $this->mType == 'signup' )
+ $attr[] = 'type=signup';
+ if( $this->mReturnTo )
+ $attr[] = 'returnto=' . $this->mReturnTo;
+ $skin =& $wgUser->getSkin();
+ return $skin->makeKnownLinkObj( $self, htmlspecialchars( $text ), implode( '&', $attr ) );
+ }
+
}
?>