r98628 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98627‎ | r98628 | r98629 >
Date:21:24, 1 October 2011
Author:aaron
Status:deferred
Tags:
Comment:
ConfirmAccount special page cleanups:
* Actually give a session error instead of just showing the form again by itself
* Refactored out getOpenRequestCount() function
* Refactored out addQueueSubtitleLinks() function from execute()
* Renamed field names (like removing leading 'm')
* Don't load a bunch of fields that won't get used
* Use wfMsgForContent for accountrequest-areas msg (this stuff will still get rewriten anyway though)
* Renamed showForm() and doSubmit() to be more descriptive
Modified paths:
  • /trunk/extensions/ConfirmAccount/dataclasses/ConfirmAccount.class.php (modified) (history)
  • /trunk/extensions/ConfirmAccount/presentation/specialpages/actions/ConfirmAccount_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ConfirmAccount/dataclasses/ConfirmAccount.class.php
@@ -52,6 +52,7 @@
5353 */
5454 public static function confirmEmail( $name ) {
5555 global $wgMemc;
 56+
5657 $dbw = wfGetDB( DB_MASTER );
5758 $dbw->update( 'account_requests',
5859 array( 'acr_email_authenticated' => $dbw->timestamp() ),
@@ -85,6 +86,7 @@
8687 */
8788 public static function getConfirmationToken( $user, &$expiration ) {
8889 global $wgConfirmAccountRejectAge;
 90+
8991 $expires = time() + $wgConfirmAccountRejectAge;
9092 $expiration = wfTimestamp( TS_MW, $expires );
9193 $token = $user->generateToken( $user->getName() . $user->getEmail() . $expires );
@@ -103,6 +105,7 @@
104106 */
105107 public static function sendConfirmationMail( User $user, $ip, $token, $expiration ) {
106108 global $wgContLang;
 109+
107110 $url = self::confirmationTokenUrl( $token );
108111 $lang = $user->getOption( 'language' );
109112 return $user->sendMail(
@@ -125,8 +128,7 @@
126129 * @return string|false
127130 */
128131 public function requestNameFromEmailToken( $code ) {
129 - $dbr = wfGetDB( DB_SLAVE );
130 - return $dbr->selectField( 'account_requests',
 132+ return wfGetDB( DB_SLAVE )->selectField( 'account_requests',
131133 'acr_name',
132134 array(
133135 'acr_email_token' => md5( $code ),
@@ -136,6 +138,28 @@
137139 }
138140
139141 /**
 142+ * Get the number of account requests for a request type
 143+ * @param $type int
 144+ * @return Array Assosiative array with 'open', 'held', 'type' keys mapping to integers
 145+ */
 146+ public static function getOpenRequestCount( $type ) {
 147+ $dbr = wfGetDB( DB_SLAVE );
 148+ $open = (int)$dbr->selectField( 'account_requests', 'COUNT(*)',
 149+ array( 'acr_type' => $type, 'acr_deleted' => 0, 'acr_held IS NOT NULL' ),
 150+ __METHOD__
 151+ );
 152+ $held = (int)$dbr->selectField( 'account_requests', 'COUNT(*)',
 153+ array( 'acr_type' => $type, 'acr_deleted' => 0, 'acr_held IS NOT NULL' ),
 154+ __METHOD__
 155+ );
 156+ $rej = (int)$dbr->selectField( 'account_requests', 'COUNT(*)',
 157+ array( 'acr_type' => $type, 'acr_deleted' => 1, 'acr_user != 0' ),
 158+ __METHOD__
 159+ );
 160+ return array( 'open' => $open, 'held' => $held, 'rejected' => $rej );
 161+ }
 162+
 163+ /**
140164 * Verifies that it's ok to include the uploaded file
141165 *
142166 * @param string $tmpfile the full path of the temporary file to verify
Index: trunk/extensions/ConfirmAccount/presentation/specialpages/actions/ConfirmAccount_body.php
@@ -1,26 +1,37 @@
22 <?php
33
44 class ConfirmAccountsPage extends SpecialPage {
 5+ protected $queueType = -1;
 6+ protected $acrID = 0;
 7+ protected $file = '';
58
 9+ protected $showHeld = false;
 10+ protected $showRejects = false;
 11+ protected $showStale = false;
 12+
 13+ protected $reqUsername;
 14+ protected $reqType;
 15+ protected $reqBio;
 16+ protected $submitType;
 17+ protected $reqAreas;
 18+ protected $reqAreaset;
 19+ protected $reason;
 20+
621 function __construct() {
7 - parent::__construct('ConfirmAccounts','confirmaccount');
 22+ parent::__construct( 'ConfirmAccounts', 'confirmaccount' );
823 }
924
10 - // @TODO: split out listlink mess
1125 function execute( $par ) {
12 - global $wgAccountRequestTypes, $wgLang;
 26+ global $wgAccountRequestTypes;
1327
1428 $reqUser = $this->getUser();
1529 $request = $this->getRequest();
16 - $out = $this->getOutput();
17 - if( !$reqUser->isAllowed( 'confirmaccount' ) ) {
18 - $out->permissionRequired( 'confirmaccount' );
19 - return;
 30+
 31+ if ( !$reqUser->isAllowed( 'confirmaccount' ) ) {
 32+ throw new PermissionsError( 'confirmaccount' );
 33+ } elseif ( !$reqUser->getID() ) {
 34+ throw new PermissionsError( 'user' );
2035 }
21 - if( !$reqUser->getID() ) {
22 - $out->permissionRequired( 'user' );
23 - return;
24 - }
2536
2637 $this->setHeaders();
2738
@@ -28,170 +39,190 @@
2940 # Use the special page param to act as a super type.
3041 # Convert this to its integer form.
3142 $this->queueType = -1;
32 - foreach( $wgAccountRequestTypes as $i => $params ) {
33 - if( $params[0] == $par ) {
 43+ foreach ( $wgAccountRequestTypes as $i => $params ) {
 44+ if ( $params[0] === $par ) {
3445 $this->queueType = $i;
3546 break;
3647 }
3748 }
38 -
39 - # A target user
 49+ # User account request ID
4050 $this->acrID = $request->getIntOrNull( 'acrid' );
41 - # Attachments
 51+ # Attachment file name to view
4252 $this->file = $request->getVal( 'file' );
43 - # For renaming to alot for collisions with other local requests
44 - # that were added to some global $wgAuth system first.
45 - $this->mUsername = trim( $request->getText( 'wpNewName' ) );
46 - # Position sought
47 - $this->mType = $request->getIntOrNull( 'wpType' );
48 - $this->mType = ( !is_null($this->mType) && isset($wgAccountRequestTypes[$this->mType]) ) ?
49 - $this->mType : null;
50 - # For removing private info or such from bios
51 - $this->mBio = $request->getText( 'wpNewBio' );
52 - # Held requests hidden by default
53 - $this->showHeld = $request->getBool( 'wpShowHeld' );
54 - # Show stale requests
55 - $this->showStale = $request->getBool( 'wpShowStale' );
56 - # For viewing rejected requests (stale requests count as rejected)
57 - $this->showRejects = $request->getBool( 'wpShowRejects' );
5853
59 - $this->submitType = $request->getVal( 'wpSubmitType' );
60 - $this->reason = $request->getText( 'wpReason' );
61 -
6254 # Load areas user plans to be active in...
63 - $this->mAreas = $this->mAreaSet = array();
64 - if( wfMsg( 'requestaccount-areas' ) ) {
 55+ # @FIXME: move this down and refactor
 56+ $this->reqAreas = $this->reqAreaSet = array();
 57+ if ( wfMsgForContent( 'requestaccount-areas' ) ) {
6558 $areas = explode("\n*","\n".wfMsg('requestaccount-areas'));
6659 foreach( $areas as $area ) {
6760 $set = explode("|",$area,2);
68 - if( $set[0] && isset($set[1]) ) {
 61+ if ( $set[0] && isset($set[1]) ) {
6962 $formName = "wpArea-" . htmlspecialchars(str_replace(' ','_',$set[0]));
70 - $this->mAreas[$formName] = $request->getInt( $formName, -1 );
 63+ $this->reqAreas[$formName] = $request->getInt( $formName, -1 );
7164 # Make a simple list of interests
72 - if( $this->mAreas[$formName] > 0 )
73 - $this->mAreaSet[] = str_replace( '_', ' ', $set[0] );
 65+ if ( $this->reqAreas[$formName] > 0 ) {
 66+ $this->reqAreaSet[] = str_replace( '_', ' ', $set[0] );
 67+ }
7468 }
7569 }
7670 }
7771
78 - $this->skin = $reqUser->getSkin();
 72+ // Showing a file
 73+ if ( $this->file ) {
 74+ $this->showFile( $this->file );
 75+ return; // nothing else to do
 76+ // Showing or confirming an account request
 77+ } elseif ( $this->acrID ) {
 78+ if ( $request->wasPosted() ) {
 79+ # For renaming to alot for collisions with other local requests
 80+ # that were added to some global $wgAuth system first.
 81+ $this->reqUsername = trim( $request->getText( 'wpNewName' ) );
 82+ # Position sought
 83+ $this->reqType = $request->getIntOrNull( 'wpType' );
 84+ if ( !isset( $wgAccountRequestTypes[$this->reqType] ) ) {
 85+ $this->reqType = null;
 86+ }
 87+ # For removing private info or such from bios
 88+ $this->reqBio = $request->getText( 'wpNewBio' );
 89+ # Action the admin is taking and why
 90+ $this->submitType = $request->getVal( 'wpSubmitType' );
 91+ $this->reason = $request->getText( 'wpReason' );
 92+ # Check if this is a valid submission...
 93+ $token = $request->getVal( 'wpEditToken' );
 94+ if ( $reqUser->matchEditToken( $token, $this->acrID ) ) {
 95+ $this->doAccountConfirmSubmit();
 96+ } else {
 97+ $this->showAccountConfirmForm( wfMsgHtml( 'sessionfailure' ) );
 98+ }
 99+ } else {
 100+ $this->showAccountConfirmForm();
 101+ }
 102+ // Showing all account requests in a queue
 103+ } elseif ( $this->queueType != -1 ) {
 104+ # Held requests hidden by default
 105+ $this->showHeld = $request->getBool( 'wpShowHeld' );
 106+ # Show stale requests
 107+ $this->showStale = $request->getBool( 'wpShowStale' );
 108+ # For viewing rejected requests (stale requests count as rejected)
 109+ $this->showRejects = $request->getBool( 'wpShowRejects' );
79110
 111+ $this->showList();
 112+ // Showing all account request queues
 113+ } else {
 114+ $this->showQueues();
 115+ }
 116+
 117+ // Show what queue we are in and links to others
 118+ $this->addQueueSubtitleLinks();
 119+
 120+ $this->getOutput()->addModules( 'ext.confirmAccount' ); // CSS
 121+ }
 122+
 123+ protected function addQueueSubtitleLinks() {
80124 $titleObj = SpecialPage::getTitleFor( 'ConfirmAccounts', $this->specialPageParameter );
81125
82126 # Show other sub-queue links. Grey out the current one.
83127 # When viewing a request, show them all.
84 - if( $this->acrID || $this->showStale || $this->showRejects || $this->showHeld ) {
85 - $listLink = Linker::link( $titleObj, wfMsgHtml( 'confirmaccount-showopen' ), array(), array(), "known" );
 128+ if ( $this->acrID || $this->showStale || $this->showRejects || $this->showHeld ) {
 129+ $listLink = Linker::link( $titleObj,
 130+ wfMsgHtml( 'confirmaccount-showopen' ), array(), array(), "known" );
86131 } else {
87132 $listLink = wfMsgHtml( 'confirmaccount-showopen' );
88133 }
89 - if( $this->acrID || !$this->showHeld ) {
90 - $listLink = $wgLang->pipeList( array(
 134+ if ( $this->acrID || !$this->showHeld ) {
 135+ $listLink = $this->getLang()->pipeList( array(
91136 $listLink,
92 - $this->skin->makeKnownLinkObj( $titleObj,
93 - wfMsgHtml( 'confirmaccount-showheld' ), wfArrayToCGI( array( 'wpShowHeld' => 1 ) ) )
 137+ Linker::makeKnownLinkObj( $titleObj,
 138+ wfMsgHtml( 'confirmaccount-showheld' ),
 139+ wfArrayToCGI( array( 'wpShowHeld' => 1 ) ) )
94140 ) );
95141 } else {
96 - $listLink = $wgLang->pipeList( array(
 142+ $listLink = $this->getLang()->pipeList( array(
97143 $listLink,
98144 wfMsgHtml( 'confirmaccount-showheld' )
99145 ) );
100146 }
101 - if( $this->acrID || !$this->showRejects ) {
102 - $listLink = $wgLang->pipeList( array(
 147+ if ( $this->acrID || !$this->showRejects ) {
 148+ $listLink = $this->getLang()->pipeList( array(
103149 $listLink,
104 - $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml( 'confirmaccount-showrej' ),
 150+ Linker::makeKnownLinkObj( $titleObj,
 151+ wfMsgHtml( 'confirmaccount-showrej' ),
105152 wfArrayToCGI( array( 'wpShowRejects' => 1 ) ) )
106153 ) );
107154 } else {
108 - $listLink = $wgLang->pipeList( array(
 155+ $listLink = $this->getLang()->pipeList( array(
109156 $listLink,
110157 wfMsgHtml( 'confirmaccount-showrej' )
111158 ) );
112159 }
113 - if( $this->acrID || !$this->showStale ) {
114 - $listLink = $wgLang->pipeList( array(
 160+ if ( $this->acrID || !$this->showStale ) {
 161+ $listLink = $this->getLang()->pipeList( array(
115162 $listLink,
116 - $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml( 'confirmaccount-showexp' ),
 163+ Linker::makeKnownLinkObj( $titleObj,
 164+ wfMsgHtml( 'confirmaccount-showexp' ),
117165 wfArrayToCGI( array( 'wpShowStale' => 1 ) ) )
118166 ) );
119167 } else {
120 - $listLink = $wgLang->pipeList( array(
 168+ $listLink = $this->getLang()->pipeList( array(
121169 $listLink,
122170 wfMsgHtml( 'confirmaccount-showexp' )
123171 ) );
124172 }
125173
126174 # Say what queue we are in...
127 - if( $this->queueType != -1 ) {
128 - $titleObj = $this->getTitle();
129 - $viewall = $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml('confirmaccount-all') );
 175+ if ( $this->queueType != -1 ) {
 176+ $viewall = Linker::makeKnownLinkObj(
 177+ $this->getTitle(), wfMsgHtml('confirmaccount-all') );
130178
131 - $out->setSubtitle( "<strong>" . wfMsgHtml('confirmaccount-type') . " <i>" .
 179+ $this->getOutput()->setSubtitle(
 180+ "<strong>" . wfMsgHtml('confirmaccount-type') . " <i>" .
132181 wfMsgHtml("confirmaccount-type-{$this->queueType}") .
133182 "</i></strong> [{$listLink}] <strong>{$viewall}</strong>" );
134183 }
135 -
136 - if( $request->wasPosted() && $reqUser->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) {
137 - $this->doSubmit();
138 - } elseif( $this->file ) {
139 - $this->showFile( $this->file );
140 - } elseif( $this->acrID ) {
141 - $this->showForm();
142 - } elseif( $this->queueType != -1 ) {
143 - $this->showList();
144 - } else {
145 - $this->showQueues();
146 - }
147 - $out->addModules( 'ext.confirmAccount' ); // CSS
148184 }
149185
150186 protected function showQueues() {
151 - global $wgAccountRequestTypes, $wgLang;
 187+ global $wgAccountRequestTypes;
 188+
152189 $out = $this->getOutput();
153190
154191 $out->addWikiMsg( 'confirmaccount-maintext' );
 192+ $out->addHTML( '<p><strong>' . wfMsgHtml('confirmaccount-types') . '</strong></p>' );
155193
156 - $out->addHTML( '<p><strong>' . wfMsgHtml('confirmaccount-types') . '</strong></p>' );
 194+ # List each queue and some information about it...
157195 $out->addHTML( '<ul>' );
158 -
159 - $dbr = wfGetDB( DB_SLAVE );
160 - # List each queue
161 - foreach( $wgAccountRequestTypes as $i => $params ) {
 196+ foreach ( $wgAccountRequestTypes as $i => $params ) {
162197 $titleObj = SpecialPage::getTitleFor( 'ConfirmAccounts', $params[0] );
 198+ $counts = ConfirmAccount::getOpenRequestCount( $i );
163199
164 - $open = '<b>'.$this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml( 'confirmaccount-q-open' ),
165 - wfArrayToCGI( array('wpShowHeld' => 0) ) ).'</b>';
166 - $held = $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml( 'confirmaccount-q-held' ),
167 - wfArrayToCGI( array('wpShowHeld' => 1) ) );
168 - $rejects = $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml( 'confirmaccount-q-rej' ),
169 - wfArrayToCGI( array('wpShowRejects' => 1) ) );
170 - $stale = '<i>'.$this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml( 'confirmaccount-q-stale' ),
171 - wfArrayToCGI( array('wpShowStale' => 1) ) ).'</i>';;
 200+ $open = '<b>' . Linker::makeKnownLinkObj( $titleObj,
 201+ wfMsgHtml( 'confirmaccount-q-open' ),
 202+ wfArrayToCGI( array( 'wpShowHeld' => 0 ) ) ) . '</b>';
 203+ $open .= ' [' . $counts['open'] . ']';
172204
173 - $count = $dbr->selectField( 'account_requests', 'COUNT(*)',
174 - array( 'acr_type' => $i, 'acr_deleted' => 0, 'acr_held IS NULL' ),
175 - __METHOD__ );
176 - $open .= " [$count]";
 205+ $held = Linker::makeKnownLinkObj( $titleObj,
 206+ wfMsgHtml( 'confirmaccount-q-held' ),
 207+ wfArrayToCGI( array( 'wpShowHeld' => 1 ) ) );
 208+ $held .= ' [' . $counts['held'] . ']';
177209
178 - $count = $dbr->selectField( 'account_requests', 'COUNT(*)',
179 - array( 'acr_type' => $i, 'acr_deleted' => 0, 'acr_held IS NOT NULL' ),
180 - __METHOD__ );
181 - $held .= " [$count]";
 210+ $rejects = Linker::makeKnownLinkObj( $titleObj,
 211+ wfMsgHtml( 'confirmaccount-q-rej' ),
 212+ wfArrayToCGI( array( 'wpShowRejects' => 1 ) ) );
 213+ $rejects .= ' [' . $counts['rejected'] . ']';
182214
183 - $count = $dbr->selectField( 'account_requests', 'COUNT(*)',
184 - array( 'acr_type' => $i, 'acr_deleted' => 1, 'acr_user != 0' ),
185 - __METHOD__ );
186 - $rejects .= " [$count]";
 215+ $stale = '<i>'.Linker::makeKnownLinkObj( $titleObj,
 216+ wfMsgHtml( 'confirmaccount-q-stale' ),
 217+ wfArrayToCGI( array( 'wpShowStale' => 1 ) ) ).'</i>';
187218
188219 $out->addHTML( "<li><i>".wfMsgHtml("confirmaccount-type-$i")."</i> (" .
189 - $wgLang->pipeList( array( $open, $held, $rejects, $stale ) ) . ")</li>" );
 220+ $this->getLang()->pipeList( array( $open, $held, $rejects, $stale ) ) . ")</li>" );
190221 }
191222 $out->addHTML( '</ul>' );
192223 }
193224
194 - protected function showForm( $msg='' ) {
195 - global $wgLang, $wgAccountRequestTypes;
 225+ protected function showAccountConfirmForm( $msg='' ) {
 226+ global $wgAccountRequestTypes;
196227 $reqUser = $this->getUser();
197228 $out = $this->getOutput();
198229
@@ -212,9 +243,9 @@
213244 $out->addWikiMsg( 'confirmaccount-text' );
214245
215246 if( $row->acr_rejected ) {
216 - $datim = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->acr_rejected), true );
217 - $date = $wgLang->date( wfTimestamp(TS_MW, $row->acr_rejected), true );
218 - $time = $wgLang->time( wfTimestamp(TS_MW, $row->acr_rejected), true );
 247+ $datim = $this->getLang()->timeanddate( wfTimestamp(TS_MW, $row->acr_rejected), true );
 248+ $date = $this->getLang()->date( wfTimestamp(TS_MW, $row->acr_rejected), true );
 249+ $time = $this->getLang()->time( wfTimestamp(TS_MW, $row->acr_rejected), true );
219250 $reason = $row->acr_comment ?
220251 htmlspecialchars($row->acr_comment) : wfMsgHtml('confirmaccount-noreason');
221252 # Auto-rejected requests have a user ID of zero
@@ -227,9 +258,9 @@
228259 $out->addHTML( "<p><i> $reason </i></p>" );
229260 }
230261 } elseif( $row->acr_held ) {
231 - $datim = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->acr_held), true );
232 - $date = $wgLang->date( wfTimestamp(TS_MW, $row->acr_held), true );
233 - $time = $wgLang->time( wfTimestamp(TS_MW, $row->acr_held), true );
 262+ $datim = $this->getLang()->timeanddate( wfTimestamp(TS_MW, $row->acr_held), true );
 263+ $date = $this->getLang()->date( wfTimestamp(TS_MW, $row->acr_held), true );
 264+ $time = $this->getLang()->time( wfTimestamp(TS_MW, $row->acr_held), true );
234265 $reason = $row->acr_comment ? $row->acr_comment : wfMsgHtml('confirmaccount-noreason');
235266
236267 $out->addHTML('<p><b>'.wfMsgExt( 'confirmaccount-held', array('parseinline'),
@@ -244,7 +275,7 @@
245276 $form .= '<legend>' . wfMsgHtml('confirmaccount-leg-user') . '</legend>';
246277 $form .= '<table cellpadding=\'4\'>';
247278 $form .= "<tr><td>".Xml::label( wfMsgHtml('username'), 'wpNewName' )."</td>";
248 - $form .= "<td>".Xml::input( 'wpNewName', 30, $this->mUsername, array('id' => 'wpNewName') )."</td></tr>\n";
 279+ $form .= "<td>".Xml::input( 'wpNewName', 30, $this->reqUsername, array('id' => 'wpNewName') )."</td></tr>\n";
249280
250281 $econf = $row->acr_email_authenticated ? ' <strong>'.wfMsgHtml('confirmaccount-econf').'</strong>' : '';
251282 $form .= "<tr><td>".wfMsgHtml('confirmaccount-email')."</td>";
@@ -253,7 +284,7 @@
254285 $options = array();
255286 $form .= "<tr><td><strong>".wfMsgHtml('confirmaccount-reqtype')."</strong></td><td>";
256287 foreach( $wgAccountRequestTypes as $i => $params ) {
257 - $options[] = Xml::option( wfMsg( "confirmaccount-pos-$i" ), $i, ($i == $this->mType) );
 288+ $options[] = Xml::option( wfMsg( "confirmaccount-pos-$i" ), $i, ($i == $this->reqType) );
258289 }
259290 $form .= Xml::openElement( 'select', array( 'name' => "wpType" ) );
260291 $form .= implode( "\n", $options );
@@ -263,7 +294,7 @@
264295
265296 $form .= '</table></fieldset>';
266297
267 - if( wfMsg( 'requestaccount-areas' ) ) {
 298+ if( wfMsgForContent( 'requestaccount-areas' ) ) {
268299 $form .= '<fieldset>';
269300 $form .= '<legend>' . wfMsgHtml('confirmaccount-leg-areas') . '</legend>';
270301
@@ -286,7 +317,7 @@
287318 $pg = '';
288319 }
289320
290 - $form .= "<td>".Xml::checkLabel( $set[0], $formName, $formName, $this->mAreas[$formName] > 0 )." {$pg}</td>\n";
 321+ $form .= "<td>".Xml::checkLabel( $set[0], $formName, $formName, $this->reqAreas[$formName] > 0 )." {$pg}</td>\n";
291322 }
292323 }
293324 $form .= "</tr></table></div>";
@@ -304,7 +335,7 @@
305336 }
306337 $form .= "<p>".wfMsgHtml('confirmaccount-bio')."\n";
307338 $form .= "<textarea tabindex='1' name='wpNewBio' id='wpNewBio' rows='12' cols='80' style='width:100%; background-color:#f9f9f9;'>" .
308 - htmlspecialchars($this->mBio) .
 339+ htmlspecialchars($this->reqBio) .
309340 "</textarea></p>\n";
310341 $form .= '</fieldset>';
311342 global $wgAccountRequestExtraInfo;
@@ -314,7 +345,7 @@
315346 if( $wgAccountRequestExtraInfo ) {
316347 $form .= '<p>'.wfMsgHtml('confirmaccount-attach') . ' ';
317348 if( $row->acr_filename ) {
318 - $form .= $this->skin->makeKnownLinkObj( $titleObj, htmlspecialchars($row->acr_filename),
 349+ $form .= Linker::makeKnownLinkObj( $titleObj, htmlspecialchars($row->acr_filename),
319350 'file=' . $row->acr_storage_key );
320351 } else {
321352 $form .= wfMsgHtml('confirmaccount-none-p');
@@ -329,7 +360,7 @@
330361 if( $reqUser->isAllowed( 'requestips' ) ) {
331362 $blokip = SpecialPage::getTitleFor( 'Block' );
332363 $form .= "<p>".wfMsgHtml('confirmaccount-ip')." ".htmlspecialchars($row->acr_ip).
333 - " (" . $this->skin->makeKnownLinkObj( $blokip, wfMsgHtml('blockip'),
 364+ " (" . Linker::makeKnownLinkObj( $blokip, wfMsgHtml('blockip'),
334365 'ip=' . $row->acr_ip . '&wpCreateAccount=1' ).")</p>\n";
335366 }
336367 $form .= '</fieldset>';
@@ -364,7 +395,7 @@
365396 $form .= Html::Hidden( 'action', 'reject' );
366397 $form .= Html::Hidden( 'acrid', $row->acr_id );
367398 $form .= Html::Hidden( 'wpShowRejects', $this->showRejects );
368 - $form .= Html::Hidden( 'wpEditToken', $reqUser->editToken() )."\n";
 399+ $form .= Html::Hidden( 'wpEditToken', $reqUser->editToken( $row->acr_id ) )."\n";
369400 $form .= Xml::closeElement( 'form' );
370401
371402 $out->addHTML( $form );
@@ -402,7 +433,7 @@
403434 StreamFile::stream( $path );
404435 }
405436
406 - protected function doSubmit() {
 437+ protected function doAccountConfirmSubmit() {
407438 $reqUser = $this->getUser();
408439 $out = $this->getOutput();
409440
@@ -449,7 +480,7 @@
450481
451482 if( !$result->isOk() ) {
452483 $error = wfMsg( 'mailerror', $out->parse( $result->getWikiText() ) );
453 - $this->showForm( $error );
 484+ $this->showAccountConfirmForm( $error );
454485 return false;
455486 }
456487 }
@@ -466,9 +497,9 @@
467498 global $wgAuth, $wgConfirmAccountSaveInfo, $wgAllowAccountRequestFiles;
468499
469500 # Now create user and check if the name is valid
470 - $user = User::newFromName( $this->mUsername, 'creatable' );
 501+ $user = User::newFromName( $this->reqUsername, 'creatable' );
471502 if( is_null($user) ) {
472 - $this->showForm( wfMsgHtml('noname') );
 503+ $this->showAccountConfirmForm( wfMsgHtml('noname') );
473504 return;
474505 }
475506
@@ -477,7 +508,7 @@
478509
479510 # Check if already in use
480511 if( 0 != $user->idForName() || $wgAuth->userExists( $user->getName() ) ) {
481 - $this->showForm( wfMsgHtml('userexists') );
 512+ $this->showAccountConfirmForm( wfMsgHtml('userexists') );
482513 return;
483514 }
484515 # Add user to DB
@@ -547,15 +578,15 @@
548579 if( !$wgAuth->addUser( $user, $p, $row->acr_email, $row->acr_real_name ) ) {
549580 $dbw->delete( 'user', array( 'user_id' => $user->getID() ) );
550581 $dbw->rollback();
551 - $this->showForm( wfMsgHtml( 'externaldberror' ) );
 582+ $this->showAccountConfirmForm( wfMsgHtml( 'externaldberror' ) );
552583 return false;
553584 }
554585
555586 # Grant any necessary rights
556587 $grouptext = $group = '';
557588 global $wgAccountRequestTypes;
558 - if( array_key_exists($this->mType,$wgAccountRequestTypes) ) {
559 - $params = $wgAccountRequestTypes[$this->mType];
 589+ if( array_key_exists($this->reqType,$wgAccountRequestTypes) ) {
 590+ $params = $wgAccountRequestTypes[$this->reqType];
560591 $group = isset($params[1]) ? $params[1] : false;
561592 $grouptext = isset($params[2]) ? $params[2] : '';
562593 // Do not add blank or dummy groups
@@ -574,7 +605,7 @@
575606
576607 # Send out password
577608 if( $this->reason ) {
578 - $msg = "confirmaccount-email-body2-pos{$this->mType}";
 609+ $msg = "confirmaccount-email-body2-pos{$this->reqType}";
579610 # If the user is in a group and there is a welcome for that group, use it
580611 if( $group && !wfEmptyMsg( $msg, wfMsg($msg) ) ) {
581612 $ebody = wfMsgExt( $msg, array('parsemag','content'),
@@ -585,7 +616,7 @@
586617 array('parsemag','content'), $user->getName(), $p, $this->reason );
587618 }
588619 } else {
589 - $msg = "confirmaccount-email-body-pos{$this->mType}";
 620+ $msg = "confirmaccount-email-body-pos{$this->reqType}";
590621 # If the user is in a group and there is a welcome for that group, use it
591622 if( $group && !wfEmptyMsg( $msg, wfMsg($msg) ) ) {
592623 $ebody = wfMsgExt($msg, array('parsemag','content'),
@@ -627,30 +658,30 @@
628659
629660 # Start up the user's (presumedly brand new) userpages
630661 # Will not append, so previous content will be blanked
631 - global $wgMakeUserPageFromBio, $wgAutoUserBioText;
632 - if( $wgMakeUserPageFromBio ) {
 662+ global $wgMakeUserPageFroreqBio, $wgAutoUserBioText;
 663+ if( $wgMakeUserPageFroreqBio ) {
633664 $usertitle = $user->getUserPage();
634665 $userpage = new Article( $usertitle );
635666
636667 $autotext = strval($wgAutoUserBioText);
637 - $body = $autotext ? "{$this->mBio}\n\n{$autotext}" : $this->mBio;
 668+ $body = $autotext ? "{$this->reqBio}\n\n{$autotext}" : $this->reqBio;
638669 $body = $grouptext ? "{$body}\n\n{$grouptext}" : $body;
639670
640671 # Add any interest categories
641 - if( wfMsg( 'requestaccount-areas' ) ) {
 672+ if( wfMsgForContent( 'requestaccount-areas' ) ) {
642673 $areas = explode("\n*","\n".wfMsg('requestaccount-areas'));
643674 foreach( $areas as $n => $line ) {
644675 $set = explode("|",$line);
645676 //$name = str_replace("_"," ",$set[0]);
646 - if( in_array($set[0],$this->mAreaSet) ) {
 677+ if( in_array($set[0],$this->reqAreaSet) ) {
647678 # General userpage text for anyone with this interest
648679 if( isset($set[2]) ) {
649680 $body .= $set[2];
650681 }
651682 # Message for users with this interested with the given account type
652683 # MW: message of format <name>|<wiki page>|<anyone>|<group0>|<group1>...
653 - if( isset($set[3+$this->mType]) && $set[3+$this->mType] ) {
654 - $body .= $set[3+$this->mType];
 684+ if( isset($set[3+$this->reqType]) && $set[3+$this->reqType] ) {
 685+ $body .= $set[3+$this->reqType];
655686 }
656687 }
657688 }
@@ -680,7 +711,7 @@
681712 global $wgAutoWelcomeNewUsers;
682713 if( $wgAutoWelcomeNewUsers ) {
683714 $utalk = new Article( $user->getTalkPage() );
684 - $msg = "confirmaccount-welc-pos{$this->mType}";
 715+ $msg = "confirmaccount-welc-pos{$this->reqType}";
685716 # Is there a custom message?
686717 $welcome = wfEmptyMsg( $msg, wfMsg($msg) ) ?
687718 wfMsg('confirmaccount-welc') : wfMsg($msg);
@@ -699,11 +730,11 @@
700731 # Pointless without a summary...
701732 if( $row->acr_held || ($row->acr_deleted && $row->acr_deleted !='f') ) {
702733 $error = wfMsg( 'confirmaccount-canthold' );
703 - $this->showForm( $error );
 734+ $this->showAccountConfirmForm( $error );
704735 return false;
705736 } elseif( !$this->reason ) {
706737 $error = wfMsg( 'confirmaccount-needreason' );
707 - $this->showForm( $error );
 738+ $this->showAccountConfirmForm( $error );
708739 return false;
709740 }
710741
@@ -728,7 +759,7 @@
729760 if( !$result->isOK() ) {
730761 $dbw->rollback();
731762 $error = wfMsg( 'mailerror', $out->parse( $result->getWikiText() ) );
732 - $this->showForm( $error );
 763+ $this->showAccountConfirmForm( $error );
733764 return false;
734765 }
735766 }
@@ -741,7 +772,7 @@
742773
743774 $this->showSuccess( $this->submitType );
744775 } else {
745 - $this->showForm();
 776+ $this->showAccountConfirmForm();
746777 }
747778 }
748779
@@ -758,18 +789,18 @@
759790 );
760791 # Check if parameters are to be overridden
761792 if( $row ) {
762 - $this->mUsername = $this->mUsername ? $this->mUsername : $row->acr_name;
763 - $this->mBio = $this->mBio ? $this->mBio : $row->acr_bio;
764 - $this->mType = !is_null($this->mType) ? $this->mType : $row->acr_type;
 793+ $this->reqUsername = $this->reqUsername ? $this->reqUsername : $row->acr_name;
 794+ $this->reqBio = $this->reqBio ? $this->reqBio : $row->acr_bio;
 795+ $this->reqType = !is_null($this->reqType) ? $this->reqType : $row->acr_type;
765796 $rowareas = UserAccountRequest::expandAreas( $row->acr_areas );
766797
767 - foreach( $this->mAreas as $area => $within ) {
 798+ foreach( $this->reqAreas as $area => $within ) {
768799 # If admin didn't set any of these checks, go back to how the user set them
769800 if( $within == -1 ) {
770801 if( in_array($area,$rowareas) )
771 - $this->mAreas[$area] = 1;
 802+ $this->reqAreas[$area] = 1;
772803 else
773 - $this->mAreas[$area] = 0;
 804+ $this->reqAreas[$area] = 0;
774805 }
775806 }
776807 }
@@ -870,35 +901,34 @@
871902 }
872903
873904 public function formatRow( $row ) {
874 - global $wgLang, $wgUseRealNamesOnly, $wgAllowRealName;
 905+ global $wgUseRealNamesOnly, $wgAllowRealName, $wgMemc;
875906
876907 $titleObj = SpecialPage::getTitleFor( 'ConfirmAccounts', $this->specialPageParameter );
877908 if( $this->showRejects || $this->showStale ) {
878 - $link = $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml('confirmaccount-review'),
 909+ $link = Linker::makeKnownLinkObj( $titleObj, wfMsgHtml('confirmaccount-review'),
879910 'acrid='.$row->acr_id.'&wpShowRejects=1' );
880911 } else {
881 - $link = $this->skin->makeKnownLinkObj( $titleObj, wfMsgHtml('confirmaccount-review'),
 912+ $link = Linker::makeKnownLinkObj( $titleObj, wfMsgHtml('confirmaccount-review'),
882913 'acrid='.$row->acr_id );
883914 }
884 - $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->acr_registration), true );
 915+ $time = $this->getLang()->timeanddate( wfTimestamp(TS_MW, $row->acr_registration), true );
885916
886917 $r = "<li class='mw-confirmaccount-time-{$this->queueType}'>";
887918
888919 $r .= $time." (<strong>{$link}</strong>)";
889920 # Auto-rejected accounts have a user ID of zero
890921 if( $row->acr_rejected && $row->acr_user ) {
891 - $datim = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->acr_rejected), true );
892 - $date = $wgLang->date( wfTimestamp(TS_MW, $row->acr_rejected), true );
893 - $time = $wgLang->time( wfTimestamp(TS_MW, $row->acr_rejected), true );
 922+ $datim = $this->getLang()->timeanddate( wfTimestamp(TS_MW, $row->acr_rejected), true );
 923+ $date = $this->getLang()->date( wfTimestamp(TS_MW, $row->acr_rejected), true );
 924+ $time = $this->getLang()->time( wfTimestamp(TS_MW, $row->acr_rejected), true );
894925 $r .= ' <b>'.wfMsgExt( 'confirmaccount-reject', array('parseinline'), $row->user_name, $datim, $date, $time ).'</b>';
895926 } elseif( $row->acr_held && !$row->acr_rejected ) {
896 - $datim = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->acr_held), true );
897 - $date = $wgLang->date( wfTimestamp(TS_MW, $row->acr_held), true );
898 - $time = $wgLang->time( wfTimestamp(TS_MW, $row->acr_held), true );
 927+ $datim = $this->getLang()->timeanddate( wfTimestamp(TS_MW, $row->acr_held), true );
 928+ $date = $this->getLang()->date( wfTimestamp(TS_MW, $row->acr_held), true );
 929+ $time = $this->getLang()->time( wfTimestamp(TS_MW, $row->acr_held), true );
899930 $r .= ' <b>'.wfMsgExt( 'confirmaccount-held', array('parseinline'), User::whoIs($row->acr_user), $datim, $date, $time ).'</b>';
900931 }
901932 # Check if someone is viewing this request
902 - global $wgMemc;
903933 $key = wfMemcKey( 'acctrequest', 'view', $row->acr_id );
904934 $value = $wgMemc->get( $key );
905935 if( $value ) {
@@ -919,7 +949,7 @@
920950 htmlspecialchars($row->acr_email) . $econf.'</td></tr>';
921951 # Truncate this, blah blah...
922952 $bio = htmlspecialchars($row->acr_bio);
923 - $preview = $wgLang->truncate( $bio, 400, '' );
 953+ $preview = $this->getLang()->truncate( $bio, 400, '' );
924954 if( strlen($preview) < strlen($bio) ) {
925955 $preview = substr( $preview, 0, strrpos($preview,' ') );
926956 $preview .= " . . .";
@@ -954,10 +984,11 @@
955985 $this->mConds['acr_deleted'] = 1;
956986 } else {
957987 $this->mConds['acr_deleted'] = 0;
958 - if( $showHeld )
 988+ if( $showHeld ) {
959989 $this->mConds[] = 'acr_held IS NOT NULL';
960 - else
 990+ } else {
961991 $this->mConds[] = 'acr_held IS NULL';
 992+ }
962993
963994 }
964995 parent::__construct();

Follow-up revisions

RevisionCommit summaryAuthorDate
r98630FU r98628:...aaron21:28, 1 October 2011

Status & tagging log