Index: trunk/extensions/ConfirmAccount/ConfirmAccount_body.php |
— | — | @@ -335,7 +335,7 @@ |
336 | 336 | $form .= '</fieldset>'; |
337 | 337 | } |
338 | 338 | |
339 | | - |
| 339 | + |
340 | 340 | $form .= '<fieldset>'; |
341 | 341 | $form .= '<legend>' . wfMsgHtml('confirmaccount-legend') . '</legend>'; |
342 | 342 | $form .= "<strong>".wfMsgExt( 'confirmaccount-confirm', array('parseinline') )."</strong>\n"; |
— | — | @@ -359,7 +359,7 @@ |
360 | 360 | htmlspecialchars($this->reason) . "</textarea></p></div>\n"; |
361 | 361 | $form .= "<p>".Xml::submitButton( wfMsgHtml( 'confirmaccount-submit') )."</p>\n"; |
362 | 362 | $form .= '</fieldset>'; |
363 | | - |
| 363 | + |
364 | 364 | $form .= Xml::hidden( 'title', $titleObj->getPrefixedDBKey() )."\n"; |
365 | 365 | $form .= Xml::hidden( 'action', 'reject' ); |
366 | 366 | $form .= Xml::hidden( 'acrid', $row->acr_id ); |
— | — | @@ -400,18 +400,23 @@ |
401 | 401 | |
402 | 402 | protected function doSubmit() { |
403 | 403 | global $wgOut, $wgUser; |
| 404 | + |
404 | 405 | wfLoadExtensionMessages( 'ConfirmAccount' ); // load UI messages |
| 406 | + |
405 | 407 | $titleObj = SpecialPage::getTitleFor( 'ConfirmAccounts', $this->specialPageParameter ); |
| 408 | + |
406 | 409 | $row = $this->getRequest( true ); |
407 | 410 | if( !$row ) { |
408 | 411 | $wgOut->addHTML( wfMsgHtml('confirmaccount-badid') ); |
409 | 412 | $wgOut->returnToMain( true, $titleObj ); |
410 | 413 | return; |
411 | 414 | } |
| 415 | + |
412 | 416 | if( $this->submitType === 'reject' || $this->submitType === 'spam' ) { |
413 | 417 | # Make proxy user to email a rejection message :( |
414 | 418 | $u = User::newFromName( $row->acr_name, 'creatable' ); |
415 | 419 | $u->setEmail( $row->acr_email ); |
| 420 | + |
416 | 421 | # Request can later be recovered |
417 | 422 | $dbw = wfGetDB( DB_MASTER ); |
418 | 423 | $dbw->begin(); |
— | — | @@ -422,6 +427,7 @@ |
423 | 428 | 'acr_deleted' => 1 ), |
424 | 429 | array( 'acr_id' => $this->acrID, 'acr_deleted' => 0 ), |
425 | 430 | __METHOD__ ); |
| 431 | + |
426 | 432 | # Do not send multiple times, don't send for "spam" requests |
427 | 433 | if( !$row->acr_rejected && $this->submitType != 'spam' ) { |
428 | 434 | if( $this->reason ) { |
— | — | @@ -431,13 +437,16 @@ |
432 | 438 | $result = $u->sendMail( wfMsg( 'confirmaccount-email-subj' ), |
433 | 439 | wfMsgExt( 'confirmaccount-email-body3', array('parsemag'), $u->getName() ) ); |
434 | 440 | } |
| 441 | + |
435 | 442 | if( WikiError::isError( $result ) ) { |
436 | 443 | $error = wfMsg( 'mailerror', htmlspecialchars( $result->toString() ) ); |
437 | 444 | $this->showForm( $error ); |
438 | 445 | return false; |
439 | 446 | } |
440 | 447 | } |
| 448 | + |
441 | 449 | $dbw->commit(); |
| 450 | + |
442 | 451 | # Clear cache for notice of how many account requests there are |
443 | 452 | global $wgMemc; |
444 | 453 | $key = wfMemcKey( 'confirmaccount', 'noticecount' ); |
— | — | @@ -446,14 +455,17 @@ |
447 | 456 | $this->showSuccess( $this->submitType ); |
448 | 457 | } else if( $this->submitType === 'accept' ) { |
449 | 458 | global $wgAuth, $wgConfirmAccountSaveInfo, $wgAllowAccountRequestFiles; |
| 459 | + |
450 | 460 | # Now create user and check if the name is valid |
451 | 461 | $user = User::newFromName( $this->mUsername, 'creatable' ); |
452 | 462 | if( is_null($user) ) { |
453 | 463 | $this->showForm( wfMsgHtml('noname') ); |
454 | 464 | return; |
455 | 465 | } |
| 466 | + |
456 | 467 | # Make a random password |
457 | 468 | $p = User::randomPassword(); |
| 469 | + |
458 | 470 | # Check if already in use |
459 | 471 | if( 0 != $user->idForName() || $wgAuth->userExists( $user->getName() ) ) { |
460 | 472 | $this->showForm( wfMsgHtml('userexists') ); |
— | — | @@ -482,9 +494,11 @@ |
483 | 495 | array( 'user_id' => $user->getID() ), |
484 | 496 | __METHOD__ |
485 | 497 | ); |
| 498 | + |
486 | 499 | # Move to credentials if configured to do so |
487 | 500 | global $wgConfirmAccountFSRepos; |
488 | 501 | $key = $row->acr_storage_key; |
| 502 | + |
489 | 503 | if( $wgConfirmAccountSaveInfo ) { |
490 | 504 | # Copy any attached files to new storage group |
491 | 505 | if( $wgAllowAccountRequestFiles && $key ) { |
— | — | @@ -519,6 +533,7 @@ |
520 | 534 | __METHOD__ |
521 | 535 | ); |
522 | 536 | } |
| 537 | + |
523 | 538 | # Add to global user login system (if there is one) |
524 | 539 | if( !$wgAuth->addUser( $user, $p, $row->acr_email, $row->acr_real_name ) ) { |
525 | 540 | $dbw->delete( 'user', array( 'user_id' => $user->getID() ) ); |
— | — | @@ -568,7 +583,12 @@ |
569 | 584 | $ebody = wfMsgExt( 'confirmaccount-email-body', array('parsemag'), $user->getName(), $p, $this->reason ); |
570 | 585 | } |
571 | 586 | } |
| 587 | + |
572 | 588 | $result = $user->sendMail( wfMsg( 'confirmaccount-email-subj' ), $ebody ); |
| 589 | + |
| 590 | + // init $error |
| 591 | + $error = ''; |
| 592 | + |
573 | 593 | if( WikiError::isError( $result ) ) { |
574 | 594 | $error = wfMsg( 'mailerror', htmlspecialchars( $result->toString() ) ); |
575 | 595 | } |
— | — | @@ -576,10 +596,12 @@ |
577 | 597 | # Safe to hook/log now... |
578 | 598 | wfRunHooks( 'AddNewAccount', array( $user ) ); |
579 | 599 | $user->addNewUserLogEntry(); |
| 600 | + |
580 | 601 | # Clear cache for notice of how many account requests there are |
581 | 602 | global $wgMemc; |
582 | 603 | $memKey = wfMemcKey( 'confirmaccount', 'noticecount' ); |
583 | 604 | $wgMemc->delete( $memKey ); |
| 605 | + |
584 | 606 | # Delete any attached file. Do not stop the whole process if this fails |
585 | 607 | if( $key ) { |
586 | 608 | $repoOld = new FSRepo( $wgConfirmAccountFSRepos['accountreqs'] ); |
— | — | @@ -589,6 +611,7 @@ |
590 | 612 | unlink($oldPath); // delete! |
591 | 613 | } |
592 | 614 | } |
| 615 | + |
593 | 616 | # Start up the user's (presumedly brand new) userpages |
594 | 617 | # Will not append, so previous content will be blanked |
595 | 618 | global $wgMakeUserPageFromBio, $wgAutoUserBioText; |
— | — | @@ -599,6 +622,7 @@ |
600 | 623 | $autotext = strval($wgAutoUserBioText); |
601 | 624 | $body = $autotext ? "{$this->mBio}\n\n{$autotext}" : $this->mBio; |
602 | 625 | $body = $grouptext ? "{$body}\n\n{$grouptext}" : $body; |
| 626 | + |
603 | 627 | # Add any interest categories |
604 | 628 | if( !wfEmptyMsg( 'requestaccount-areas', wfMsg('requestaccount-areas') ) ) { |
605 | 629 | $areas = explode("\n*","\n".wfMsg('requestaccount-areas')); |
— | — | @@ -618,6 +642,7 @@ |
619 | 643 | } |
620 | 644 | } |
621 | 645 | } |
| 646 | + |
622 | 647 | # Set sortkey and use it on bio |
623 | 648 | global $wgConfirmAccountSortkey, $wgContLang; |
624 | 649 | if( !empty($wgConfirmAccountSortkey) ) { |
— | — | @@ -629,12 +654,15 @@ |
630 | 655 | $with = "[[{$catNS}:$1|".str_replace('$','\$',$sortKey)."]]"; // [[Category:x|sortkey]] |
631 | 656 | $body = preg_replace( $replace, $with, $body ); |
632 | 657 | } |
| 658 | + |
633 | 659 | # Create userpage! |
634 | 660 | $userpage->doEdit( $body, wfMsg('confirmaccount-summary'), EDIT_MINOR ); |
635 | 661 | } |
| 662 | + |
636 | 663 | # Update user count |
637 | 664 | $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); |
638 | 665 | $ssUpdate->doUpdate(); |
| 666 | + |
639 | 667 | # Greet user... |
640 | 668 | global $wgAutoWelcomeNewUsers; |
641 | 669 | if( $wgAutoWelcomeNewUsers ) { |
— | — | @@ -647,12 +675,14 @@ |
648 | 676 | $utalk->doEdit( $welcome . ' ~~~~', wfMsg('confirmaccount-wsum'), EDIT_MINOR ); |
649 | 677 | } |
650 | 678 | # Finally, done!!! |
651 | | - $this->showSuccess( $this->submitType, $user->getName(), array($error) ); |
| 679 | + $this->showSuccess( $this->submitType, $user->getName(), array( $error ) ); |
652 | 680 | } else if( $this->submitType === 'hold' ) { |
653 | 681 | global $wgUser; |
| 682 | + |
654 | 683 | # Make proxy user to email a message |
655 | 684 | $u = User::newFromName( $row->acr_name, 'creatable' ); |
656 | 685 | $u->setEmail( $row->acr_email ); |
| 686 | + |
657 | 687 | # Pointless without a summary... |
658 | 688 | if( $row->acr_held || ($row->acr_deleted && $row->acr_deleted !='f') ) { |
659 | 689 | $error = wfMsg( 'confirmaccount-canthold' ); |
— | — | @@ -663,6 +693,7 @@ |
664 | 694 | $this->showForm( $error ); |
665 | 695 | return false; |
666 | 696 | } |
| 697 | + |
667 | 698 | # If not already held or deleted, mark as held |
668 | 699 | $dbw = wfGetDB( DB_MASTER ); |
669 | 700 | $dbw->begin(); |
— | — | @@ -673,6 +704,7 @@ |
674 | 705 | array( 'acr_id' => $this->acrID, 'acr_held IS NULL', 'acr_deleted' => 0 ), |
675 | 706 | __METHOD__ |
676 | 707 | ); |
| 708 | + |
677 | 709 | # Do not send multiple times |
678 | 710 | if( !$row->acr_held && !($row->acr_deleted && $row->acr_deleted !='f') ) { |
679 | 711 | $result = $u->sendMail( wfMsg( 'confirmaccount-email-subj' ), |
— | — | @@ -685,6 +717,7 @@ |
686 | 718 | } |
687 | 719 | } |
688 | 720 | $dbw->commit(); |
| 721 | + |
689 | 722 | # Clear cache for notice of how many account requests there are |
690 | 723 | global $wgMemc; |
691 | 724 | $key = wfMemcKey( 'confirmaccount', 'noticecount' ); |