r24135 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24134‎ | r24135 | r24136 >
Date:22:25, 15 July 2007
Author:aaron
Status:old
Tags:
Comment:
*Add option to simply flag off rejected requests and store them for a while.
Modified paths:
  • /trunk/extensions/ConfirmAccount/ConfirmAccount.i18n.php (modified) (history)
  • /trunk/extensions/ConfirmAccount/ConfirmAccount.pg.sql (modified) (history)
  • /trunk/extensions/ConfirmAccount/ConfirmAccount.sql (modified) (history)
  • /trunk/extensions/ConfirmAccount/ConfirmAccount_body.php (modified) (history)
  • /trunk/extensions/ConfirmAccount/SpecialConfirmAccount.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ConfirmAccount/SpecialConfirmAccount.php
@@ -21,6 +21,8 @@
2222
2323 # Set the person's bio as their userpage?
2424 $wgMakeUserPageFromBio = true;
 25+$wgSaveRejectedAccountReqs = true;
 26+$wgRejectedAccountMaxAge = 7 * 24 * 3600; // One week
2527
2628 $wgGroupPermissions['*']['createaccount'] = false;
2729 $wgGroupPermissions['sysop']['createaccount'] = false;
Index: trunk/extensions/ConfirmAccount/ConfirmAccount.sql
@@ -27,9 +27,6 @@
2828 acr_email_token binary(32),
2929 -- Expiration date for the user_email_token
3030 acr_email_token_expires binary(14),
31 - -- Timestamp of account registration.
32 - -- Accounts predating this schema addition may contain NULL.
33 - acr_registration char(14) NOT NULL,
3431 -- A little about this user
3532 acr_bio mediumblob default '',
3633 -- Private info for reviewers to look at when considering request
@@ -39,8 +36,13 @@
4037 -- IP address
4138 acr_ip VARCHAR(255) NULL default '',
4239
 40+ -- Timestamp of account registration.
 41+ acr_registration char(14) NOT NULL,
 42+ -- Flag for rejected requests
 43+ acr_rejected bool NOT NULL,
 44+
4345 PRIMARY KEY (acr_id),
4446 UNIQUE KEY (acr_name),
45 - INDEX (acr_registration),
46 - INDEX (acr_email_token)
 47+ INDEX (acr_email_token),
 48+ INDEX acr_rejected_reg (acr_rejected,acr_registration)
4749 ) TYPE=InnoDB;
\ No newline at end of file
Index: trunk/extensions/ConfirmAccount/ConfirmAccount.pg.sql
@@ -18,10 +18,11 @@
1919 acr_bio TEXT,
2020 acr_notes TEXT,
2121 acr_url TEXT,
22 - acr_ip CIDR
 22+ acr_ip CIDR,
 23+ acr_rejected BOOL NOT NULL,
2324 );
2425
25 -CREATE INDEX acr_registration ON account_requests (acr_registration),
 26+CREATE INDEX acr_rejected_reg ON account_requests (acr_rejected,acr_registration),
2627 CREATE INDEX acr_email_token ON account_requests (acr_email_token);
2728
2829 COMMIT;
Index: trunk/extensions/ConfirmAccount/ConfirmAccount_body.php
@@ -360,6 +360,8 @@
361361 # For renaming to alot for collisions with other local requests
362362 # that were added to some global $wgAuth system first.
363363 $this->mUsername = $wgRequest->getText( 'wpNewName' );
 364+ # For viewing rejects
 365+ $this->showRejects = $wgRequest->getBool( 'wpShowRejects' );
364366
365367 $this->skin = $wgUser->getSkin();
366368
@@ -395,7 +397,16 @@
396398 }
397399
398400 $dbw = wfGetDB( DB_MASTER );
399 - $dbw->delete( 'account_requests', array('acr_id' => $this->acrID), __METHOD__ );
 401+ # Either mark off the row as deleted or wipe it completely
 402+ global $wgSaveRejectedAccountReqs;
 403+ if( $wgSaveRejectedAccountReqs ) {
 404+ # Request can later be recovered
 405+ $dbw->update( 'account_requests', array('acr_rejected' => 1),
 406+ array('acr_id' => $this->acrID),
 407+ __METHOD__ );
 408+ } else {
 409+ $dbw->delete( 'account_requests', array('acr_id' => $this->acrID), __METHOD__ );
 410+ }
400411
401412 $this->showSuccess( $action );
402413 } else if( $action == 'accept' ) {
@@ -466,16 +477,20 @@
467478 $wgOut->addHTML( '<div class="errorbox">' . $msg . '</div><div class="visualClear"></div>' );
468479 }
469480
470 - $listLink = $this->skin->makeKnownLinkObj( $wgTitle, wfMsgHtml( 'confirmaccount-back' ) );
471 - $wgOut->setSubtitle( '<p>'.$listLink.'</p>' );
472 -
473481 $row = $this->getRequest();
474 - if( !$row ) {
 482+ if( !$row || $row->acr_rejected && !$this->showRejects ) {
475483 $wgOut->addHTML( wfMsg('confirmaccount-badid') );
476484 $wgOut->returnToMain( true, $wgTitle );
477485 return;
478486 }
479487
 488+ $listLink = $this->skin->makeKnownLinkObj( $wgTitle, wfMsgHtml( 'confirmaccount-back' ) );
 489+ if( $this->showRejects ) {
 490+ $listLink .= ' / '.$this->skin->makeKnownLinkObj( $wgTitle, wfMsgHtml( 'confirmaccount-back2' ),
 491+ wfArrayToCGI( array('wpShowRejects' => 1 ) ) );
 492+ }
 493+ $wgOut->setSubtitle( '<p>'.$listLink.'</p>' );
 494+
480495 $wgOut->addWikiText( wfMsg( "confirmacount-text" ) );
481496
482497 $action = $wgTitle->escapeLocalUrl( 'action=submit' );
@@ -557,16 +572,42 @@
558573 }
559574
560575 function showList() {
561 - global $wgOut, $wgUser, $wgLang;
 576+ global $wgOut, $wgUser, $wgTitle, $wgLang;
 577+
 578+ if( $this->showRejects ) {
 579+ $listLink = $this->skin->makeKnownLinkObj( $wgTitle, wfMsgHtml( 'confirmaccount-back' ) );
 580+ } else {
 581+ $listLink = $this->skin->makeKnownLinkObj( $wgTitle, wfMsgHtml( 'confirmaccount-back2' ),
 582+ wfArrayToCGI( array('wpShowRejects' => 1 ) ) );
 583+ }
 584+ $wgOut->setSubtitle( '<p>'.$listLink.'</p>' );
 585+
 586+ global $wgSaveRejectedAccountReqs;
 587+ if( $wgSaveRejectedAccountReqs ) {
 588+ # Every 100th view, prune old deleted items
 589+ wfSeedRandom();
 590+ if( 0 == mt_rand( 0, 99 ) ) {
 591+ global $wgRejectedAccountMaxAge;
562592
563 - $pager = new ConfirmAccountsPager( $this, array() );
 593+ $dbw = wfGetDB( DB_MASTER );
 594+ $cutoff = $dbw->timestamp( time() - $wgRejectedAccountMaxAge );
 595+ $accountrequests = $dbw->tableName( 'account_requests' );
 596+ $sql = "DELETE FROM $accountrequests WHERE acr_registration < '{$cutoff}'";
 597+ $dbw->query( $sql );
 598+ }
 599+ }
 600+
 601+ $pager = new ConfirmAccountsPager( $this, array(), $this->showRejects );
564602 if ( $pager->getNumRows() ) {
565603 $wgOut->addHTML( wfMsgExt('confirmacount-list', array('parse') ) );
566604 $wgOut->addHTML( $pager->getNavigationBar() );
567605 $wgOut->addHTML( "<ul>" . $pager->getBody() . "</ul>" );
568606 $wgOut->addHTML( $pager->getNavigationBar() );
569607 } else {
570 - $wgOut->addHTML( wfMsgExt('confirmacount-none', array('parse')) );
 608+ if( $this->showRejects )
 609+ $wgOut->addHTML( wfMsgExt('confirmacount-none2', array('parse')) );
 610+ else
 611+ $wgOut->addHTML( wfMsgExt('confirmacount-none', array('parse')) );
571612 }
572613 }
573614
@@ -574,7 +615,12 @@
575616 global $wgLang, $wgUser;
576617
577618 $title = SpecialPage::getTitleFor( 'ConfirmAccounts' );
578 - $link = $this->skin->makeKnownLinkObj( $title, wfMsg('confirmaccount-review'), 'acrid='.$row->acr_id );
 619+ if( $this->showRejects ) {
 620+ $link = $this->skin->makeKnownLinkObj( $title, wfMsg('confirmaccount-review'),
 621+ 'acrid='.$row->acr_id.'&wpShowRejects=1' );
 622+ } else {
 623+ $link = $this->skin->makeKnownLinkObj( $title, wfMsg('confirmaccount-review'), 'acrid='.$row->acr_id );
 624+ }
579625 $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->acr_registration), true );
580626
581627 $r = '<li>';
@@ -607,9 +653,10 @@
608654 class ConfirmAccountsPager extends ReverseChronologicalPager {
609655 public $mForm, $mConds;
610656
611 - function __construct( $form, $conds = array() ) {
 657+ function __construct( $form, $conds = array(), $rejects=0 ) {
612658 $this->mForm = $form;
613659 $this->mConds = $conds;
 660+ $this->mConds['acr_rejected'] = $rejects;
614661 parent::__construct();
615662 }
616663
Index: trunk/extensions/ConfirmAccount/ConfirmAccount.i18n.php
@@ -62,8 +62,10 @@
6363
6464 If you simply leave this page without confirming or denying this request, it will remain pending.',
6565 'confirmacount-none' => 'There are currently no pending account requests.',
 66+ 'confirmacount-none2' => 'There are currently no recently rejected account requests.',
6667 'confirmaccount-badid' => 'There is no pending request corresponding to the given ID. It may have already been handled.',
6768 'confirmaccount-back' => 'View pending account list',
 69+ 'confirmaccount-back2' => 'View recently rejected account list',
6870 'confirmaccount-name' => 'Username',
6971 'confirmaccount-real' => 'Name',
7072 'confirmaccount-email' => 'Email',

Status & tagging log