r62784 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62783‎ | r62784 | r62785 >
Date:18:19, 21 February 2010
Author:siebrand
Status:deferred
Tags:
Comment:
* Fix undefined variable $error notice
* Add some whitespace for readability
Modified paths:
  • /trunk/extensions/ConfirmAccount/ConfirmAccount_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ConfirmAccount/ConfirmAccount_body.php
@@ -335,7 +335,7 @@
336336 $form .= '</fieldset>';
337337 }
338338
339 -
 339+
340340 $form .= '<fieldset>';
341341 $form .= '<legend>' . wfMsgHtml('confirmaccount-legend') . '</legend>';
342342 $form .= "<strong>".wfMsgExt( 'confirmaccount-confirm', array('parseinline') )."</strong>\n";
@@ -359,7 +359,7 @@
360360 htmlspecialchars($this->reason) . "</textarea></p></div>\n";
361361 $form .= "<p>".Xml::submitButton( wfMsgHtml( 'confirmaccount-submit') )."</p>\n";
362362 $form .= '</fieldset>';
363 -
 363+
364364 $form .= Xml::hidden( 'title', $titleObj->getPrefixedDBKey() )."\n";
365365 $form .= Xml::hidden( 'action', 'reject' );
366366 $form .= Xml::hidden( 'acrid', $row->acr_id );
@@ -400,18 +400,23 @@
401401
402402 protected function doSubmit() {
403403 global $wgOut, $wgUser;
 404+
404405 wfLoadExtensionMessages( 'ConfirmAccount' ); // load UI messages
 406+
405407 $titleObj = SpecialPage::getTitleFor( 'ConfirmAccounts', $this->specialPageParameter );
 408+
406409 $row = $this->getRequest( true );
407410 if( !$row ) {
408411 $wgOut->addHTML( wfMsgHtml('confirmaccount-badid') );
409412 $wgOut->returnToMain( true, $titleObj );
410413 return;
411414 }
 415+
412416 if( $this->submitType === 'reject' || $this->submitType === 'spam' ) {
413417 # Make proxy user to email a rejection message :(
414418 $u = User::newFromName( $row->acr_name, 'creatable' );
415419 $u->setEmail( $row->acr_email );
 420+
416421 # Request can later be recovered
417422 $dbw = wfGetDB( DB_MASTER );
418423 $dbw->begin();
@@ -422,6 +427,7 @@
423428 'acr_deleted' => 1 ),
424429 array( 'acr_id' => $this->acrID, 'acr_deleted' => 0 ),
425430 __METHOD__ );
 431+
426432 # Do not send multiple times, don't send for "spam" requests
427433 if( !$row->acr_rejected && $this->submitType != 'spam' ) {
428434 if( $this->reason ) {
@@ -431,13 +437,16 @@
432438 $result = $u->sendMail( wfMsg( 'confirmaccount-email-subj' ),
433439 wfMsgExt( 'confirmaccount-email-body3', array('parsemag'), $u->getName() ) );
434440 }
 441+
435442 if( WikiError::isError( $result ) ) {
436443 $error = wfMsg( 'mailerror', htmlspecialchars( $result->toString() ) );
437444 $this->showForm( $error );
438445 return false;
439446 }
440447 }
 448+
441449 $dbw->commit();
 450+
442451 # Clear cache for notice of how many account requests there are
443452 global $wgMemc;
444453 $key = wfMemcKey( 'confirmaccount', 'noticecount' );
@@ -446,14 +455,17 @@
447456 $this->showSuccess( $this->submitType );
448457 } else if( $this->submitType === 'accept' ) {
449458 global $wgAuth, $wgConfirmAccountSaveInfo, $wgAllowAccountRequestFiles;
 459+
450460 # Now create user and check if the name is valid
451461 $user = User::newFromName( $this->mUsername, 'creatable' );
452462 if( is_null($user) ) {
453463 $this->showForm( wfMsgHtml('noname') );
454464 return;
455465 }
 466+
456467 # Make a random password
457468 $p = User::randomPassword();
 469+
458470 # Check if already in use
459471 if( 0 != $user->idForName() || $wgAuth->userExists( $user->getName() ) ) {
460472 $this->showForm( wfMsgHtml('userexists') );
@@ -482,9 +494,11 @@
483495 array( 'user_id' => $user->getID() ),
484496 __METHOD__
485497 );
 498+
486499 # Move to credentials if configured to do so
487500 global $wgConfirmAccountFSRepos;
488501 $key = $row->acr_storage_key;
 502+
489503 if( $wgConfirmAccountSaveInfo ) {
490504 # Copy any attached files to new storage group
491505 if( $wgAllowAccountRequestFiles && $key ) {
@@ -519,6 +533,7 @@
520534 __METHOD__
521535 );
522536 }
 537+
523538 # Add to global user login system (if there is one)
524539 if( !$wgAuth->addUser( $user, $p, $row->acr_email, $row->acr_real_name ) ) {
525540 $dbw->delete( 'user', array( 'user_id' => $user->getID() ) );
@@ -568,7 +583,12 @@
569584 $ebody = wfMsgExt( 'confirmaccount-email-body', array('parsemag'), $user->getName(), $p, $this->reason );
570585 }
571586 }
 587+
572588 $result = $user->sendMail( wfMsg( 'confirmaccount-email-subj' ), $ebody );
 589+
 590+ // init $error
 591+ $error = '';
 592+
573593 if( WikiError::isError( $result ) ) {
574594 $error = wfMsg( 'mailerror', htmlspecialchars( $result->toString() ) );
575595 }
@@ -576,10 +596,12 @@
577597 # Safe to hook/log now...
578598 wfRunHooks( 'AddNewAccount', array( $user ) );
579599 $user->addNewUserLogEntry();
 600+
580601 # Clear cache for notice of how many account requests there are
581602 global $wgMemc;
582603 $memKey = wfMemcKey( 'confirmaccount', 'noticecount' );
583604 $wgMemc->delete( $memKey );
 605+
584606 # Delete any attached file. Do not stop the whole process if this fails
585607 if( $key ) {
586608 $repoOld = new FSRepo( $wgConfirmAccountFSRepos['accountreqs'] );
@@ -589,6 +611,7 @@
590612 unlink($oldPath); // delete!
591613 }
592614 }
 615+
593616 # Start up the user's (presumedly brand new) userpages
594617 # Will not append, so previous content will be blanked
595618 global $wgMakeUserPageFromBio, $wgAutoUserBioText;
@@ -599,6 +622,7 @@
600623 $autotext = strval($wgAutoUserBioText);
601624 $body = $autotext ? "{$this->mBio}\n\n{$autotext}" : $this->mBio;
602625 $body = $grouptext ? "{$body}\n\n{$grouptext}" : $body;
 626+
603627 # Add any interest categories
604628 if( !wfEmptyMsg( 'requestaccount-areas', wfMsg('requestaccount-areas') ) ) {
605629 $areas = explode("\n*","\n".wfMsg('requestaccount-areas'));
@@ -618,6 +642,7 @@
619643 }
620644 }
621645 }
 646+
622647 # Set sortkey and use it on bio
623648 global $wgConfirmAccountSortkey, $wgContLang;
624649 if( !empty($wgConfirmAccountSortkey) ) {
@@ -629,12 +654,15 @@
630655 $with = "[[{$catNS}:$1|".str_replace('$','\$',$sortKey)."]]"; // [[Category:x|sortkey]]
631656 $body = preg_replace( $replace, $with, $body );
632657 }
 658+
633659 # Create userpage!
634660 $userpage->doEdit( $body, wfMsg('confirmaccount-summary'), EDIT_MINOR );
635661 }
 662+
636663 # Update user count
637664 $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
638665 $ssUpdate->doUpdate();
 666+
639667 # Greet user...
640668 global $wgAutoWelcomeNewUsers;
641669 if( $wgAutoWelcomeNewUsers ) {
@@ -647,12 +675,14 @@
648676 $utalk->doEdit( $welcome . ' ~~~~', wfMsg('confirmaccount-wsum'), EDIT_MINOR );
649677 }
650678 # Finally, done!!!
651 - $this->showSuccess( $this->submitType, $user->getName(), array($error) );
 679+ $this->showSuccess( $this->submitType, $user->getName(), array( $error ) );
652680 } else if( $this->submitType === 'hold' ) {
653681 global $wgUser;
 682+
654683 # Make proxy user to email a message
655684 $u = User::newFromName( $row->acr_name, 'creatable' );
656685 $u->setEmail( $row->acr_email );
 686+
657687 # Pointless without a summary...
658688 if( $row->acr_held || ($row->acr_deleted && $row->acr_deleted !='f') ) {
659689 $error = wfMsg( 'confirmaccount-canthold' );
@@ -663,6 +693,7 @@
664694 $this->showForm( $error );
665695 return false;
666696 }
 697+
667698 # If not already held or deleted, mark as held
668699 $dbw = wfGetDB( DB_MASTER );
669700 $dbw->begin();
@@ -673,6 +704,7 @@
674705 array( 'acr_id' => $this->acrID, 'acr_held IS NULL', 'acr_deleted' => 0 ),
675706 __METHOD__
676707 );
 708+
677709 # Do not send multiple times
678710 if( !$row->acr_held && !($row->acr_deleted && $row->acr_deleted !='f') ) {
679711 $result = $u->sendMail( wfMsg( 'confirmaccount-email-subj' ),
@@ -685,6 +717,7 @@
686718 }
687719 }
688720 $dbw->commit();
 721+
689722 # Clear cache for notice of how many account requests there are
690723 global $wgMemc;
691724 $key = wfMemcKey( 'confirmaccount', 'noticecount' );

Status & tagging log