Index: trunk/extensions/SignupAPI/includes/SpecialUserSignup.php |
— | — | @@ -49,13 +49,13 @@ |
50 | 50 | const INIT_FAILED = 18; |
51 | 51 | |
52 | 52 | //Initialise all variables to be used |
53 | | - var $mUsername, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted; |
| 53 | + var $tempUsername, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted; |
54 | 54 | var $mAction, $mCreateaccount, $mCreateaccountMail; |
55 | 55 | var $mRemember, $mEmail, $mDomain, $mLanguage; |
56 | 56 | var $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS; |
57 | 57 | var $mType, $mReason, $mRealName; |
58 | 58 | var $abortError = ''; |
59 | | - var $mUser, $mConfirmationMailStatus, $mRunCookieRedirect, $mRunCreationConfirmation; |
| 59 | + var $tempUser, $mConfirmationMailStatus, $mRunCookieRedirect, $mRunCreationConfirmation; |
60 | 60 | var $mSourceAction, $mSourceNS, $msourceArticle; |
61 | 61 | |
62 | 62 | /** |
— | — | @@ -167,26 +167,26 @@ |
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | | - $mUser = $this->addNewaccountInternal(); |
| 171 | + $tempUser = $this->addNewaccountInternal(); |
172 | 172 | |
173 | | - if ( $mUser == null ) { |
| 173 | + if ( $tempUser == null ) { |
174 | 174 | return; |
175 | 175 | } |
176 | 176 | |
177 | 177 | // Wipe the initial password and mail a temporary one |
178 | | - $mUser->setPassword( null ); |
179 | | - $mUser->saveSettings(); |
180 | | - $result = $this->mailPasswordInternal( $mUser, false, 'createaccount-title', 'createaccount-text' ); |
| 178 | + $tempUser->setPassword( null ); |
| 179 | + $tempUser->saveSettings(); |
| 180 | + $result = $this->mailPasswordInternal( $tempUser, false, 'createaccount-title', 'createaccount-text' ); |
181 | 181 | |
182 | | - wfRunHooks( 'AddNewAccount', array( $mUser, true ) ); |
183 | | - $mUser->addNewUserLogEntry( true, $this->mReason ); |
| 182 | + wfRunHooks( 'AddNewAccount', array( $tempUser, true ) ); |
| 183 | + $tempUser->addNewUserLogEntry( true, $this->mReason ); |
184 | 184 | |
185 | 185 | $wgOut->setPageTitle( wfMsg( 'accmailtitle' ) ); |
186 | 186 | |
187 | 187 | if( !$result->isGood() ) { |
188 | 188 | $this->mainSignupForm( wfMsg( 'mailerror', $result->getWikiText() ) ); |
189 | 189 | } else { |
190 | | - $wgOut->addWikiMsg( 'accmailtext', $mUser->getName(), $mUser->getEmail() ); |
| 190 | + $wgOut->addWikiMsg( 'accmailtext', $tempUser->getName(), $tempUser->getEmail() ); |
191 | 191 | $wgOut->returnToMain( false ); |
192 | 192 | } |
193 | 193 | } |
— | — | @@ -194,29 +194,29 @@ |
195 | 195 | /** |
196 | 196 | * @private |
197 | 197 | */ |
198 | | - function addNewAccount($mUser) { |
| 198 | + function addNewAccount($tempUser) { |
199 | 199 | global $wgUser, $wgEmailAuthentication, $wgOut; |
200 | 200 | |
201 | 201 | # If we showed up language selection links, and one was in use, be |
202 | 202 | # smart (and sensible) and save that language as the user's preference |
203 | 203 | global $wgLoginLanguageSelector; |
204 | 204 | if( $wgLoginLanguageSelector && $this->mLanguage ) { |
205 | | - $mUser->setOption( 'language', $this->mLanguage ); |
| 205 | + $tempUser->setOption( 'language', $this->mLanguage ); |
206 | 206 | } |
207 | 207 | |
208 | 208 | # Send out an email authentication message if needed |
209 | 209 | if( $wgEmailAuthentication ) { |
210 | | - $this->mConfirmationMailStatus = $mUser->sendConfirmationMail(); |
| 210 | + $this->mConfirmationMailStatus = $tempUser->sendConfirmationMail(); |
211 | 211 | } |
212 | 212 | |
213 | 213 | # Save settings (including confirmation token) |
214 | | - $mUser->saveSettings(); |
| 214 | + $tempUser->saveSettings(); |
215 | 215 | |
216 | 216 | # If not logged in, assume the new account as the current one and set |
217 | 217 | # session cookies then show a "welcome" message or a "need cookies" |
218 | 218 | # message as needed |
219 | 219 | if( $wgUser->isAnon() ) { |
220 | | - $wgUser = $mUser; |
| 220 | + $wgUser = $tempUser; |
221 | 221 | $wgUser->setCookies(); |
222 | 222 | wfRunHooks( 'AddNewAccount', array( $wgUser, false ) ); |
223 | 223 | $wgUser->addNewUserLogEntry(); |
— | — | @@ -228,8 +228,8 @@ |
229 | 229 | } |
230 | 230 | } else { |
231 | 231 | $this->mRunCreationConfirmation = true; |
232 | | - wfRunHooks( 'AddNewAccount', array( $mUser, false ) ); |
233 | | - $mUser->addNewUserLogEntry( false, $this->mReason ); |
| 232 | + wfRunHooks( 'AddNewAccount', array( $tempUser, false ) ); |
| 233 | + $tempUser->addNewUserLogEntry( false, $this->mReason ); |
234 | 234 | return true; |
235 | 235 | } |
236 | 236 | } |
— | — | @@ -293,14 +293,14 @@ |
294 | 294 | return self::IP_BLOCKED; |
295 | 295 | } |
296 | 296 | |
297 | | - # Now create a dummy user ($mUser) and check if it is valid |
| 297 | + # Now create a dummy user ($tempUser) and check if it is valid |
298 | 298 | $name = trim( $this->mUsername ); |
299 | | - $mUser = User::newFromName( $name, 'creatable' ); |
300 | | - if ( !is_object( $mUser ) ) { |
| 299 | + $tempUser = User::newFromName( $name, 'creatable' ); |
| 300 | + if ( !is_object( $tempUser ) ) { |
301 | 301 | return self::NO_NAME; |
302 | 302 | } |
303 | 303 | |
304 | | - if ( 0 != $mUser->idForName() ) { |
| 304 | + if ( 0 != $tempUser->idForName() ) { |
305 | 305 | return self::USER_EXISTS; |
306 | 306 | } |
307 | 307 | |
— | — | @@ -309,7 +309,7 @@ |
310 | 310 | } |
311 | 311 | |
312 | 312 | # check for minimal password length |
313 | | - $valid = $mUser->getPasswordValidity( $this->mPassword ); |
| 313 | + $valid = $tempUser->getPasswordValidity( $this->mPassword ); |
314 | 314 | if ( $valid !== true ) { |
315 | 315 | if ( !$this->mCreateaccountMail ) { |
316 | 316 | return self::INVALID_PASS; |
— | — | @@ -333,11 +333,11 @@ |
334 | 334 | |
335 | 335 | # Set some additional data so the AbortNewAccount hook can be used for |
336 | 336 | # more than just username validation |
337 | | - $mUser->setEmail( $this->mEmail ); |
338 | | - $mUser->setRealName( $this->mRealName ); |
| 337 | + $tempUser->setEmail( $this->mEmail ); |
| 338 | + $tempUser->setRealName( $this->mRealName ); |
339 | 339 | |
340 | 340 | $abortError = ''; |
341 | | - if( !wfRunHooks( 'AbortNewAccount', array( $mUser, &$abortError ) ) ) { |
| 341 | + if( !wfRunHooks( 'AbortNewAccount', array( $tempUser, &$abortError ) ) ) { |
342 | 342 | // Hook point to add extra creation throttles and blocks |
343 | 343 | return self::BLOCKED_BY_HOOK; |
344 | 344 | } |
— | — | @@ -354,18 +354,18 @@ |
355 | 355 | $wgMemc->incr( $key ); |
356 | 356 | } |
357 | 357 | |
358 | | - if( !$wgAuth->addUser( $mUser, $this->mPassword, $this->mEmail, $this->mRealName ) ) { |
| 358 | + if( !$wgAuth->addUser( $tempUser, $this->mPassword, $this->mEmail, $this->mRealName ) ) { |
359 | 359 | return self::EXTR_DB_ERROR; |
360 | 360 | } |
361 | 361 | |
362 | 362 | self::clearCreateaccountToken(); |
363 | 363 | |
364 | | - $mUser = $this->initUser( $mUser, false ); |
365 | | - if( $mUser == null ) { |
| 364 | + $tempUser = $this->initUser( $tempUser, false ); |
| 365 | + if( $tempUser == null ) { |
366 | 366 | return self::INIT_FAILED; |
367 | 367 | } |
368 | 368 | |
369 | | - $this->addNewAccount( $mUser ); |
| 369 | + $this->addNewAccount( $tempUser ); |
370 | 370 | return self::SUCCESS; |
371 | 371 | } |
372 | 372 | |
— | — | @@ -373,44 +373,44 @@ |
374 | 374 | * Actually add a user to the database. |
375 | 375 | * Give it a User object that has been initialised with a name. |
376 | 376 | * |
377 | | - * @param $mUser User object. |
| 377 | + * @param $tempUser User object. |
378 | 378 | * @param $autocreate boolean -- true if this is an autocreation via auth plugin |
379 | 379 | * @return User object. |
380 | 380 | * @private |
381 | 381 | */ |
382 | | - function initUser( $mUser, $autocreate = false ) { |
| 382 | + function initUser( $tempUser, $autocreate = false ) { |
383 | 383 | global $wgAuth; |
384 | 384 | |
385 | | - $mUser->addToDatabase(); |
| 385 | + $tempUser->addToDatabase(); |
386 | 386 | |
387 | 387 | if ( $wgAuth->allowPasswordChange() ) { |
388 | | - $mUser->setPassword( $this->mPassword ); |
| 388 | + $tempUser->setPassword( $this->mPassword ); |
389 | 389 | } |
390 | 390 | |
391 | | - $mUser->setEmail( $this->mEmail ); |
392 | | - $mUser->setRealName( $this->mRealName ); |
393 | | - $mUser->setToken(); |
| 391 | + $tempUser->setEmail( $this->mEmail ); |
| 392 | + $tempUser->setRealName( $this->mRealName ); |
| 393 | + $tempUser->setToken(); |
394 | 394 | |
395 | | - $wgAuth->initUser( $mUser, $autocreate ); |
| 395 | + $wgAuth->initUser( $tempUser, $autocreate ); |
396 | 396 | |
397 | 397 | if ( $this->mExtUser ) { |
398 | | - $this->mExtUser->linkToLocal( $mUser->getId() ); |
| 398 | + $this->mExtUser->linkToLocal( $tempUser->getId() ); |
399 | 399 | $email = $this->mExtUser->getPref( 'emailaddress' ); |
400 | 400 | if ( $email && !$this->mEmail ) { |
401 | | - $mUser->setEmail( $email ); |
| 401 | + $tempUser->setEmail( $email ); |
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | | - $mUser->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 ); |
406 | | - $mUser->saveSettings(); |
| 405 | + $tempUser->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 ); |
| 406 | + $tempUser->saveSettings(); |
407 | 407 | |
408 | 408 | # Update user count |
409 | 409 | $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); |
410 | 410 | $ssUpdate->doUpdate(); |
411 | 411 | |
412 | | - $this->addToSourceTracking( $mUser ); |
| 412 | + $this->addToSourceTracking( $tempUser ); |
413 | 413 | |
414 | | - return $mUser; |
| 414 | + return $tempUser; |
415 | 415 | } |
416 | 416 | |
417 | 417 | function processSignup() { |
— | — | @@ -434,7 +434,7 @@ |
435 | 435 | if( $this->mRunCreationConfirmation ) { |
436 | 436 | $self = SpecialPage::getTitleFor( 'Userlogin' ); |
437 | 437 | $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) ); |
438 | | - $wgOut->addWikiMsg( 'accountcreatedtext', $mUser->getName() ); |
| 438 | + $wgOut->addWikiMsg( 'accountcreatedtext', $tempUser->getName() ); |
439 | 439 | $wgOut->returnToMain( false, $self ); |
440 | 440 | } |
441 | 441 | |
— | — | @@ -529,33 +529,33 @@ |
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
533 | | - * @param $mUser User object |
| 533 | + * @param $tempUser User object |
534 | 534 | * @param $throttle Boolean |
535 | 535 | * @param $emailTitle String: message name of email title |
536 | 536 | * @param $emailText String: message name of email text |
537 | 537 | * @return Status object |
538 | 538 | * @private |
539 | 539 | */ |
540 | | - function mailPasswordInternal( $mUser, $throttle = true, $emailTitle = 'passwordremindertitle', $emailText = 'passwordremindertext' ) { |
| 540 | + function mailPasswordInternal( $tempUser, $throttle = true, $emailTitle = 'passwordremindertitle', $emailText = 'passwordremindertext' ) { |
541 | 541 | global $wgServer, $wgScript, $wgUser, $wgNewPasswordExpiry; |
542 | 542 | |
543 | | - if ( $mUser->getEmail() == '' ) { |
544 | | - return Status::newFatal( 'noemail', $mUser->getName() ); |
| 543 | + if ( $tempUser->getEmail() == '' ) { |
| 544 | + return Status::newFatal( 'noemail', $tempUser->getName() ); |
545 | 545 | } |
546 | 546 | $ip = wfGetIP(); |
547 | 547 | if( !$ip ) { |
548 | 548 | return Status::newFatal( 'badipaddress' ); |
549 | 549 | } |
550 | 550 | |
551 | | - wfRunHooks( 'User::mailPasswordInternal', array( &$wgUser, &$ip, &$mUser ) ); |
| 551 | + wfRunHooks( 'User::mailPasswordInternal', array( &$wgUser, &$ip, &$tempUser ) ); |
552 | 552 | |
553 | | - $np = $mUser->randomPassword(); |
554 | | - $mUser->setNewpassword( $np, $throttle ); |
555 | | - $mUser->saveSettings(); |
556 | | - $mUserserLanguage = $mUser->getOption( 'language' ); |
557 | | - $m = wfMsgExt( $emailText, array( 'parsemag', 'language' => $mUserserLanguage ), $ip, $mUser->getName(), $np, |
| 553 | + $np = $tempUser->randomPassword(); |
| 554 | + $tempUser->setNewpassword( $np, $throttle ); |
| 555 | + $tempUser->saveSettings(); |
| 556 | + $tempUserserLanguage = $tempUser->getOption( 'language' ); |
| 557 | + $m = wfMsgExt( $emailText, array( 'parsemag', 'language' => $tempUserserLanguage ), $ip, $tempUser->getName(), $np, |
558 | 558 | $wgServer . $wgScript, round( $wgNewPasswordExpiry / 86400 ) ); |
559 | | - $result = $mUser->sendMail( wfMsgExt( $emailTitle, array( 'parsemag', 'language' => $mUserserLanguage ) ), $m ); |
| 559 | + $result = $tempUser->sendMail( wfMsgExt( $emailTitle, array( 'parsemag', 'language' => $tempUserserLanguage ) ), $m ); |
560 | 560 | |
561 | 561 | return $result; |
562 | 562 | } |
— | — | @@ -730,6 +730,7 @@ |
731 | 731 | $wgAuth->modifyUITemplate( $template, $this->mType ); |
732 | 732 | |
733 | 733 | wfRunHooks( 'UserCreateForm', array( &$template ) ); |
| 734 | + wfRunHooks( 'SignupForm' ); |
734 | 735 | |
735 | 736 | // Changes the title depending on permissions for creating account |
736 | 737 | if ( $wgUser->isAllowed( 'createaccount' ) ) { |
— | — | @@ -740,20 +741,20 @@ |
741 | 742 | |
742 | 743 | $wgOut->disallowUserJs(); // just in case... |
743 | 744 | $wgOut->addTemplate( $template ); |
744 | | - $wgOut->addModules( 'ext.SignupAPI' ); |
| 745 | + |
745 | 746 | } |
746 | 747 | |
747 | 748 | /** |
748 | 749 | * @private |
749 | 750 | * |
750 | | - * @param $mUserser User |
| 751 | + * @param $tempUserser User |
751 | 752 | * |
752 | 753 | * @return Boolean |
753 | 754 | */ |
754 | | - function showCreateOrLoginLink( &$mUserser ) { |
| 755 | + function showCreateOrLoginLink( &$tempUserser ) { |
755 | 756 | if( $this->mType == 'signup' ) { |
756 | 757 | return true; |
757 | | - } elseif( $mUserser->isAllowed( 'createaccount' ) ) { |
| 758 | + } elseif( $tempUserser->isAllowed( 'createaccount' ) ) { |
758 | 759 | return true; |
759 | 760 | } else { |
760 | 761 | return false; |
— | — | @@ -905,9 +906,9 @@ |
906 | 907 | } |
907 | 908 | } |
908 | 909 | |
909 | | - private function addToSourceTracking( $mUser ) { |
| 910 | + private function addToSourceTracking( $tempUser ) { |
910 | 911 | $sourcetracking_data = array( |
911 | | - 'userid' => $mUser->getId(), |
| 912 | + 'userid' => $tempUser->getId(), |
912 | 913 | 'source_action' => $this->mSourceAction, |
913 | 914 | 'source_ns' => $this->mSourceNS, |
914 | 915 | 'source_article' => $this->msourceArticle |