Index: trunk/extensions/ConfirmAccount/ConfirmAccount.php |
— | — | @@ -171,6 +171,10 @@ |
172 | 172 | # Data access objects |
173 | 173 | $wgAutoloadClasses['UserAccountRequest'] = "$dir/UserAccountRequest.php"; |
174 | 174 | |
| 175 | +$dir = dirname( __FILE__ ) . '/business'; |
| 176 | +# Business logic |
| 177 | +$wgAutoloadClasses['AccountRequestSubmission'] = "$dir/AccountRequestSubmission.php"; |
| 178 | + |
175 | 179 | $dir = dirname( __FILE__ ) . '/schema'; |
176 | 180 | # Schema changes |
177 | 181 | $wgAutoloadClasses['ConfirmAccountUpdaterHooks'] = "$dir/ConfirmAccountUpdater.hooks.php"; |
Index: trunk/extensions/ConfirmAccount/dataclasses/ConfirmAccount.class.php |
— | — | @@ -122,7 +122,7 @@ |
123 | 123 | * Get a request name from an email confirmation token |
124 | 124 | * |
125 | 125 | * @param sring $code |
126 | | - * @returns string|false |
| 126 | + * @return string|false |
127 | 127 | */ |
128 | 128 | public function requestNameFromEmailToken( $code ) { |
129 | 129 | $dbr = wfGetDB( DB_SLAVE ); |
Index: trunk/extensions/ConfirmAccount/dataclasses/UserAccountRequest.php |
— | — | @@ -231,7 +231,9 @@ |
232 | 232 | /** |
233 | 233 | * Flatten areas of interest array |
234 | 234 | * Used by ConfirmAccountsPage |
| 235 | + * @param $areas Array |
235 | 236 | * @todo just serialize() |
| 237 | + * @return string |
236 | 238 | */ |
237 | 239 | protected static function flattenAreas( array $areas ) { |
238 | 240 | $flatAreas = ''; |
— | — | @@ -244,7 +246,9 @@ |
245 | 247 | /** |
246 | 248 | * Expand areas of interest to array |
247 | 249 | * Used by ConfirmAccountsPage |
| 250 | + * @param $areas string |
248 | 251 | * @todo just unserialize() |
| 252 | + * @return Array |
249 | 253 | */ |
250 | 254 | public static function expandAreas( $areas ) { |
251 | 255 | $list = explode( "\n", $areas ); |
Index: trunk/extensions/ConfirmAccount/business/AccountRequestSubmission.php |
— | — | @@ -0,0 +1,209 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class AccountRequestSubmission { |
| 5 | + /* User making the request */ |
| 6 | + protected $requester; |
| 7 | + /* Desired name and fields filled from form */ |
| 8 | + protected $userName; |
| 9 | + protected $realName; |
| 10 | + protected $tosAccepted; |
| 11 | + protected $email; |
| 12 | + protected $bio; |
| 13 | + protected $notes; |
| 14 | + protected $urls; |
| 15 | + protected $type; |
| 16 | + protected $areas; |
| 17 | + protected $registration; |
| 18 | + /* File attachment fields */ |
| 19 | + protected $attachmentSrcName; // user given attachment base name |
| 20 | + protected $attachmentPrevName; // user given attachment base name last attempt |
| 21 | + protected $attachmentDidNotForget; // user already saw "please re-attach" notice |
| 22 | + protected $attachmentSize; // bytes size of file |
| 23 | + protected $attachmentTempPath; // tmp path file was uploaded to FS |
| 24 | + |
| 25 | + public function __construct( User $requester, array $params ) { |
| 26 | + $this->requester = $requester; |
| 27 | + $this->userName = $params['userName']; |
| 28 | + $this->realName = $params['realName']; |
| 29 | + $this->tosAccepted = $params['tosAccepted']; |
| 30 | + $this->email = $params['email']; |
| 31 | + $this->bio = $params['bio']; |
| 32 | + $this->notes = $params['notes']; |
| 33 | + $this->urls = $params['urls']; |
| 34 | + $this->type = $params['type']; |
| 35 | + $this->areas = $params['areas']; |
| 36 | + $this->attachmentPrevName = $params['attachmentPrevName']; |
| 37 | + $this->attachmentSrcName = $params['attachmentSrcName']; |
| 38 | + $this->attachmentDidNotForget = $params['attachmentDidNotForget']; |
| 39 | + $this->attachmentSize = $params['attachmentSize']; |
| 40 | + $this->attachmentTempPath = $params['attachmentTempPath']; |
| 41 | + $this->registration = wfTimestamp( TS_MW, $params['registration'] ); |
| 42 | + } |
| 43 | + |
| 44 | + public function getAttachmentDidNotForget() { |
| 45 | + return $this->attachmentDidNotForget; |
| 46 | + } |
| 47 | + |
| 48 | + public function getAttachtmentPrevName() { |
| 49 | + return $this->attachmentPrevName; |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Attempt to validate and submit this data to the DB |
| 54 | + * @param $context IContextSource |
| 55 | + * @return array( true or error key string, html error msg or null ) |
| 56 | + */ |
| 57 | + public function submit( IContextSource $context ) { |
| 58 | + global $wgAuth, $wgAccountRequestThrottle, $wgMemc, $wgContLang; |
| 59 | + $reqUser = $this->requester; |
| 60 | + |
| 61 | + # Now create a dummy user ($u) and check if it is valid |
| 62 | + $name = trim( $this->userName ); |
| 63 | + if ( $name === '' ) { |
| 64 | + return array( 'accountreq_no_name', wfMsgHtml( 'noname' ) ); |
| 65 | + } |
| 66 | + $u = User::newFromName( $name, 'creatable' ); |
| 67 | + if ( !$u ) { |
| 68 | + return array( 'accountreq_invalid_name', wfMsgHtml( 'noname' ) ); |
| 69 | + } |
| 70 | + # No request spamming... |
| 71 | + if ( $wgAccountRequestThrottle && $reqUser->isPingLimitable() ) { |
| 72 | + $key = wfMemcKey( 'acctrequest', 'ip', wfGetIP() ); |
| 73 | + $value = (int)$wgMemc->get( $key ); |
| 74 | + if ( $value > $wgAccountRequestThrottle ) { |
| 75 | + return array( 'accountreq_throttled', |
| 76 | + wfMsgExt( 'acct_request_throttle_hit', 'parsemag', $wgAccountRequestThrottle ) |
| 77 | + ); |
| 78 | + } |
| 79 | + } |
| 80 | + # Check if already in use |
| 81 | + if ( 0 != $u->idForName() || $wgAuth->userExists( $u->getName() ) ) { |
| 82 | + return array( 'accountreq_username_exists', wfMsgHtml( 'userexists' ) ); |
| 83 | + } |
| 84 | + # Check pending accounts for name use |
| 85 | + $dbw = wfGetDB( DB_MASTER ); |
| 86 | + $dup = $dbw->selectField( 'account_requests', '1', |
| 87 | + array( 'acr_name' => $u->getName() ), __METHOD__ ); |
| 88 | + if ( $dup ) { |
| 89 | + return array( 'accountreq_username_pending', wfMsgHtml( 'requestaccount-inuse' ) ); |
| 90 | + } |
| 91 | + # Make sure user agrees to policy here |
| 92 | + global $wgAccountRequestToS; |
| 93 | + if ( $wgAccountRequestToS && !$this->tosAccepted ) { |
| 94 | + return array( 'acct_request_skipped_tos', wfMsgHtml( 'requestaccount-agree' ) ); |
| 95 | + } |
| 96 | + # Validate email address |
| 97 | + if ( !$u->isValidEmailAddr( $this->email ) ) { |
| 98 | + return array( 'acct_request_invalid_email', wfMsgHtml( 'invalidemailaddress' ) ); |
| 99 | + } |
| 100 | + # Check if biography is long enough |
| 101 | + global $wgAccountRequestMinWords; |
| 102 | + if ( str_word_count( $this->bio ) < $wgAccountRequestMinWords ) { |
| 103 | + return array( 'acct_request_short_bio', |
| 104 | + wfMsgExt( 'requestaccount-tooshort', 'parsemag', |
| 105 | + $wgContLang->formatNum( $wgAccountRequestMinWords ) ) |
| 106 | + ); |
| 107 | + } |
| 108 | + # Set some additional data so the AbortNewAccount hook can be |
| 109 | + # used for more than just username validation |
| 110 | + $u->setEmail( $this->email ); |
| 111 | + # Check if someone else has an account request with the same email |
| 112 | + $dup = $dbw->selectField( 'account_requests', '1', |
| 113 | + array( 'acr_email' => $u->getEmail() ), __METHOD__ ); |
| 114 | + if ( $dup ) { |
| 115 | + return array( 'acct_request_email_exists', wfMsgHtml( 'requestaccount-emaildup' ) ); |
| 116 | + } |
| 117 | + $u->setRealName( $this->realName ); |
| 118 | + # Per security reasons, file dir cannot be pulled from client, |
| 119 | + # so ask them to resubmit it then... |
| 120 | + global $wgAllowAccountRequestFiles, $wgAccountRequestExtraInfo; |
| 121 | + # If the extra fields are off, then uploads are off |
| 122 | + $allowFiles = $wgAccountRequestExtraInfo && $wgAllowAccountRequestFiles; |
| 123 | + if ( $allowFiles && $this->attachmentPrevName && !$this->attachmentSrcName ) { |
| 124 | + # If the user is submitting forgotAttachment as true with no file, |
| 125 | + # then they saw the notice and choose not to re-select the file. |
| 126 | + # Assume that they don't want to send one anymore. |
| 127 | + if ( !$this->attachmentDidNotForget ) { |
| 128 | + $this->attachmentPrevName = ''; |
| 129 | + $this->attachmentDidNotForget = 0; |
| 130 | + return array( false, wfMsgHtml( 'requestaccount-resub' ) ); |
| 131 | + } |
| 132 | + } |
| 133 | + # Process upload... |
| 134 | + if ( $allowFiles && $this->attachmentSrcName ) { |
| 135 | + $ext = explode( '.', $this->attachmentSrcName ); |
| 136 | + $finalExt = $ext[count( $ext ) - 1]; |
| 137 | + # File must have size. |
| 138 | + if ( trim( $this->attachmentSrcName ) == '' || empty( $this->attachmentSize ) ) { |
| 139 | + $this->attachmentPrevName = ''; |
| 140 | + return array( 'acct_request_empty_file', wfMsgHtml( 'emptyfile' ) ); |
| 141 | + } |
| 142 | + # Look at the contents of the file; if we can recognize the |
| 143 | + # type but it's corrupt or data of the wrong type, we should |
| 144 | + # probably not accept it. |
| 145 | + global $wgAccountRequestExts; |
| 146 | + if ( !in_array( $finalExt, $wgAccountRequestExts ) ) { |
| 147 | + $this->attachmentPrevName = ''; |
| 148 | + return array( 'acct_request_bad_file_ext', wfMsgHtml( 'requestaccount-exts' ) ); |
| 149 | + } |
| 150 | + $veri = ConfirmAccount::verifyAttachment( $this->attachmentTempPath, $finalExt ); |
| 151 | + if ( !$veri->isGood() ) { |
| 152 | + $this->attachmentPrevName = ''; |
| 153 | + return array( 'acct_request_corrupt_file', wfMsgHtml( 'uploadcorrupt' ) ); |
| 154 | + } |
| 155 | + # Start a transaction, move file from temp to account request directory. |
| 156 | + global $wgConfirmAccountFSRepos; |
| 157 | + $repo = new FSRepo( $wgConfirmAccountFSRepos['accountreqs'] ); |
| 158 | + $key = sha1_file( $this->attachmentTempPath ) . '.' . $finalExt; |
| 159 | + $pathRel = $key[0].'/'.$key[0].$key[1].'/'.$key[0].$key[1].$key[2].'/'.$key; |
| 160 | + $triplet = array( $this->attachmentTempPath, 'public', $pathRel ); |
| 161 | + $repo->storeBatch( array($triplet) ); // save! |
| 162 | + } |
| 163 | + $expires = null; // passed by reference |
| 164 | + $token = ConfirmAccount::getConfirmationToken( $u, $expires ); |
| 165 | + # Insert into pending requests... |
| 166 | + $req = UserAccountRequest::newFromArray( array( |
| 167 | + 'name' => $u->getName(), |
| 168 | + 'email' => $u->getEmail(), |
| 169 | + 'real_name' => $u->getRealName(), |
| 170 | + 'registration' => $this->registration, |
| 171 | + 'bio' => $this->bio, |
| 172 | + 'notes' => $this->notes, |
| 173 | + 'urls' => $this->urls, |
| 174 | + 'filename' => isset( $this->attachmentSrcName ) |
| 175 | + ? $this->attachmentSrcName |
| 176 | + : null, |
| 177 | + 'type' => $this->type, |
| 178 | + 'areas' => $this->areas, |
| 179 | + 'storage_key' => isset( $key ) ? $key : null, |
| 180 | + 'comment' => '', |
| 181 | + 'email_token' => md5( $token ), |
| 182 | + 'email_token_expires' => $expires, |
| 183 | + 'ip' => wfGetIP(), |
| 184 | + ) ); |
| 185 | + $dbw->begin(); |
| 186 | + $req->insertOn(); |
| 187 | + # Send confirmation, required! |
| 188 | + $result = ConfirmAccount::sendConfirmationMail( $u, wfGetIP(), $token, $expires ); |
| 189 | + if ( !$result->isOK() ) { |
| 190 | + $dbw->rollback(); // Nevermind |
| 191 | + return array( 'acct_request_mail_failed', |
| 192 | + wfMsg( 'mailerror', $context->getOutput()->parse( $result->getWikiText() ) ) ); |
| 193 | + } |
| 194 | + $dbw->commit(); |
| 195 | + # Clear cache for notice of how many account requests there are |
| 196 | + $key = wfMemcKey( 'confirmaccount', 'noticecount' ); |
| 197 | + $wgMemc->delete( $key ); |
| 198 | + # No request spamming... |
| 199 | + # BC: check if isPingLimitable() exists |
| 200 | + if ( $wgAccountRequestThrottle && $reqUser->isPingLimitable() ) { |
| 201 | + $key = wfMemcKey( 'acctrequest', 'ip', wfGetIP() ); |
| 202 | + $value = $wgMemc->incr( $key ); |
| 203 | + if ( !$value ) { |
| 204 | + $wgMemc->set( $key, 1, 86400 ); |
| 205 | + } |
| 206 | + } |
| 207 | + # Done! |
| 208 | + return array( true, null ); |
| 209 | + } |
| 210 | +} |
Property changes on: trunk/extensions/ConfirmAccount/business/AccountRequestSubmission.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 211 | + native |
Index: trunk/extensions/ConfirmAccount/presentation/specialpages/actions/UserCredentials_body.php |
— | — | @@ -185,6 +185,8 @@ |
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Show a private file requested by the visitor. |
| 189 | + * @param $key string |
| 190 | + * @return void |
189 | 191 | */ |
190 | 192 | function showFile( $key ) { |
191 | 193 | global $wgConfirmAccountFSRepos, $IP; |
— | — | @@ -201,11 +203,10 @@ |
202 | 204 | $request->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' ); |
203 | 205 | $request->response()->header( 'Pragma: no-cache' ); |
204 | 206 | |
205 | | - require_once( "$IP/includes/StreamFile.php" ); |
206 | 207 | $repo = new FSRepo( $wgConfirmAccountFSRepos['accountcreds'] ); |
207 | 208 | $path = $repo->getZonePath( 'public' ).'/'. |
208 | 209 | $key[0].'/'.$key[0].$key[1].'/'.$key[0].$key[1].$key[2].'/'.$key; |
209 | | - wfStreamFile( $path ); |
| 210 | + StreamFile::stream( $path ); |
210 | 211 | } |
211 | 212 | |
212 | 213 | function getAccountData() { |
Index: trunk/extensions/ConfirmAccount/presentation/specialpages/actions/RequestAccount_body.php |
— | — | @@ -224,8 +224,8 @@ |
225 | 225 | |
226 | 226 | protected function doSubmit() { |
227 | 227 | global $wgAuth, $wgAccountRequestThrottle; |
228 | | - $reqUser = $this->getUser(); |
229 | 228 | $out = $this->getOutput(); |
| 229 | + |
230 | 230 | # Now create a dummy user ($u) and check if it is valid |
231 | 231 | $name = trim( $this->mUsername ); |
232 | 232 | $u = User::newFromName( $name, 'creatable' ); |
— | — | @@ -250,152 +250,40 @@ |
251 | 251 | if ( !$wgConfirmAccountCaptchas && isset( $wgCaptchaTriggers ) ) { |
252 | 252 | $wgCaptchaTriggers['createaccount'] = $old; |
253 | 253 | } |
254 | | - # No request spamming... |
255 | | - if ( $wgAccountRequestThrottle && $reqUser->isPingLimitable() ) { |
256 | | - global $wgMemc; |
257 | | - $key = wfMemcKey( 'acctrequest', 'ip', wfGetIP() ); |
258 | | - $value = $wgMemc->get( $key ); |
259 | | - if ( $value > $wgAccountRequestThrottle ) { |
260 | | - $this->throttleHit( $wgAccountRequestThrottle ); |
261 | | - return; |
262 | | - } |
263 | | - } |
264 | | - # Check if already in use |
265 | | - if ( 0 != $u->idForName() || $wgAuth->userExists( $u->getName() ) ) { |
266 | | - $this->showForm( wfMsgHtml( 'userexists' ) ); |
| 254 | + |
| 255 | + # Build submission object... |
| 256 | + $submission = new AccountRequestSubmission( |
| 257 | + $this->getUser(), |
| 258 | + array( |
| 259 | + 'userName' => $name, |
| 260 | + 'realName' => $this->mRealName, |
| 261 | + 'tosAccepted' => $this->mToS, |
| 262 | + 'email' => $this->mEmail, |
| 263 | + 'bio' => $this->mBio, |
| 264 | + 'notes' => $this->mNotes, |
| 265 | + 'urls' => $this->mUrls, |
| 266 | + 'type' => $this->mType, |
| 267 | + 'areas' => $this->mAreaSet, |
| 268 | + 'registration' => wfTimestampNow(), |
| 269 | + 'attachmentPrevName' => $this->mPrevAttachment, |
| 270 | + 'attachmentSrcName' => $this->mSrcName, |
| 271 | + 'attachmentDidNotForget' => $this->mForgotAttachment, // confusing name :) |
| 272 | + 'attachmentSize' => $this->mFileSize, |
| 273 | + 'attachmentTempPath' => $this->mTempPath |
| 274 | + ) |
| 275 | + ); |
| 276 | + |
| 277 | + # Actually submit! |
| 278 | + list( $status, $msg ) = $submission->submit( $this->getContext() ); |
| 279 | + # Account for state changes |
| 280 | + $this->mForgotAttachment = $submission->getAttachmentDidNotForget(); |
| 281 | + $this->mPrevAttachment = $submission->getAttachtmentPrevName(); |
| 282 | + # Check for error messages |
| 283 | + if ( $status !== true ) { |
| 284 | + $this->showForm( $msg ); |
267 | 285 | return; |
268 | 286 | } |
269 | | - # Check pending accounts for name use |
270 | | - $dbw = wfGetDB( DB_MASTER ); |
271 | | - $dup = $dbw->selectField( 'account_requests', '1', |
272 | | - array( 'acr_name' => $u->getName() ), |
273 | | - __METHOD__ ); |
274 | | - if ( $dup ) { |
275 | | - $this->showForm( wfMsgHtml( 'requestaccount-inuse' ) ); |
276 | | - return; |
277 | | - } |
278 | | - # Make sure user agrees to policy here |
279 | | - global $wgAccountRequestToS; |
280 | | - if ( $wgAccountRequestToS && !$this->mToS ) { |
281 | | - $this->showForm( wfMsgHtml( 'requestaccount-agree' ) ); |
282 | | - return; |
283 | | - } |
284 | | - # Validate email address |
285 | | - if ( !$u->isValidEmailAddr( $this->mEmail ) ) { |
286 | | - $this->showForm( wfMsgHtml( 'invalidemailaddress' ) ); |
287 | | - return; |
288 | | - } |
289 | | - global $wgAccountRequestMinWords; |
290 | | - # Check if biography is long enough |
291 | | - if ( str_word_count( $this->mBio ) < $wgAccountRequestMinWords ) { |
292 | | - global $wgLang; |
293 | | - $this->showForm( wfMsgExt( 'requestaccount-tooshort', 'parsemag', |
294 | | - $wgLang->formatNum( $wgAccountRequestMinWords ) ) ); |
295 | | - return; |
296 | | - } |
297 | | - # Set some additional data so the AbortNewAccount hook can be |
298 | | - # used for more than just username validation |
299 | | - $u->setEmail( $this->mEmail ); |
300 | | - # Check if someone else has an account request with the same email |
301 | | - $dup = $dbw->selectField( 'account_requests', '1', |
302 | | - array( 'acr_email' => $u->getEmail() ), |
303 | | - __METHOD__ ); |
304 | | - if ( $dup ) { |
305 | | - $this->showForm( wfMsgHtml( 'requestaccount-emaildup' ) ); |
306 | | - return; |
307 | | - } |
308 | | - $u->setRealName( $this->mRealName ); |
309 | | - # Per security reasons, file dir cannot be pulled from client, |
310 | | - # so ask them to resubmit it then... |
311 | | - global $wgAllowAccountRequestFiles, $wgAccountRequestExtraInfo; |
312 | | - # If the extra fields are off, then uploads are off |
313 | | - $allowFiles = $wgAccountRequestExtraInfo && $wgAllowAccountRequestFiles; |
314 | | - if ( $allowFiles && $this->mPrevAttachment && !$this->mSrcName ) { |
315 | | - # If the user is submitting forgotAttachment as true with no file, |
316 | | - # then they saw the notice and choose not to re-select the file. |
317 | | - # Assume that they don't want to send one anymore. |
318 | | - if ( !$this->mForgotAttachment ) { |
319 | | - $this->mPrevAttachment = ''; |
320 | | - $this->showForm( wfMsgHtml( 'requestaccount-resub' ), 1 ); |
321 | | - return false; |
322 | | - } |
323 | | - } |
324 | | - # Process upload... |
325 | | - if ( $allowFiles && $this->mSrcName ) { |
326 | | - $ext = explode( '.', $this->mSrcName ); |
327 | | - $finalExt = $ext[count( $ext ) - 1]; |
328 | | - # File must have size. |
329 | | - if ( trim( $this->mSrcName ) == '' || empty( $this->mFileSize ) ) { |
330 | | - $this->mPrevAttachment = ''; |
331 | | - $this->showForm( wfMsgHtml( 'emptyfile' ) ); |
332 | | - return false; |
333 | | - } |
334 | | - # Look at the contents of the file; if we can recognize the |
335 | | - # type but it's corrupt or data of the wrong type, we should |
336 | | - # probably not accept it. |
337 | | - global $wgAccountRequestExts; |
338 | | - if ( !in_array( $finalExt, $wgAccountRequestExts ) ) { |
339 | | - $this->mPrevAttachment = ''; |
340 | | - $this->showForm( wfMsgHtml( 'requestaccount-exts' ) ); |
341 | | - return false; |
342 | | - } |
343 | | - $veri = ConfirmAccount::verifyAttachment( $this->mTempPath, $finalExt ); |
344 | | - if ( !$veri->isGood() ) { |
345 | | - $this->mPrevAttachment = ''; |
346 | | - $this->showForm( wfMsgHtml( 'uploadcorrupt' ) ); |
347 | | - return false; |
348 | | - } |
349 | | - # Start a transaction, move file from temp to account request directory. |
350 | | - global $wgConfirmAccountFSRepos; |
351 | | - $repo = new FSRepo( $wgConfirmAccountFSRepos['accountreqs'] ); |
352 | | - $key = sha1_file($this->mTempPath) . '.' . $finalExt; |
353 | | - $pathRel = $key[0].'/'.$key[0].$key[1].'/'.$key[0].$key[1].$key[2].'/'.$key; |
354 | | - $triplet = array( $this->mTempPath, 'public', $pathRel ); |
355 | | - $repo->storeBatch( array($triplet) ); // save! |
356 | | - } |
357 | | - $expires = null; // passed by reference |
358 | | - $token = ConfirmAccount::getConfirmationToken( $u, $expires ); |
359 | | - # Insert into pending requests... |
360 | | - $req = UserAccountRequest::newFromArray( array( |
361 | | - 'name' => $u->getName(), |
362 | | - 'email' => $u->getEmail(), |
363 | | - 'real_name' => $u->getRealName(), |
364 | | - 'registration' => wfTimestampNow(), |
365 | | - 'bio' => $this->mBio, |
366 | | - 'notes' => $this->mNotes, |
367 | | - 'urls' => $this->mUrls, |
368 | | - 'filename' => isset( $this->mSrcName ) ? $this->mSrcName : null, |
369 | | - 'type' => $this->mType, |
370 | | - 'areas' => $this->mAreaSet, |
371 | | - 'storage_key' => isset( $key ) ? $key : null, |
372 | | - 'comment' => '', |
373 | | - 'email_token' => md5( $token ), |
374 | | - 'email_token_expires' => $expires, |
375 | | - 'ip' => wfGetIP(), |
376 | | - ) ); |
377 | | - $dbw->begin(); |
378 | | - $req->insertOn(); |
379 | | - # Send confirmation, required! |
380 | | - $result = ConfirmAccount::sendConfirmationMail( $u, wfGetIP(), $token, $expires ); |
381 | | - if ( !$result->isOK() ) { |
382 | | - $dbw->rollback(); // Nevermind |
383 | | - $error = wfMsg( 'mailerror', $out->parse( $result->getWikiText() ) ); |
384 | | - $this->showForm( $error ); |
385 | | - return false; |
386 | | - } |
387 | | - $dbw->commit(); |
388 | | - # Clear cache for notice of how many account requests there are |
389 | | - global $wgMemc; |
390 | | - $key = wfMemcKey( 'confirmaccount', 'noticecount' ); |
391 | | - $wgMemc->delete( $key ); |
392 | | - # No request spamming... |
393 | | - # BC: check if isPingLimitable() exists |
394 | | - if ( $wgAccountRequestThrottle && $reqUser->isPingLimitable() ) { |
395 | | - $key = wfMemcKey( 'acctrequest', 'ip', wfGetIP() ); |
396 | | - if ( !$value = $wgMemc->incr( $key ) ) { |
397 | | - $wgMemc->set( $key, 1, 86400 ); |
398 | | - } |
399 | | - } |
| 287 | + |
400 | 288 | # Done! |
401 | 289 | $this->showSuccess(); |
402 | 290 | } |
— | — | @@ -409,6 +297,7 @@ |
410 | 298 | |
411 | 299 | /** |
412 | 300 | * Initialize the uploaded file from PHP data |
| 301 | + * @param $request WebRequest |
413 | 302 | */ |
414 | 303 | protected function initializeUpload( $request ) { |
415 | 304 | $this->mTempPath = $request->getFileTempName( 'wpUploadFile' ); |
— | — | @@ -418,18 +307,10 @@ |
419 | 308 | } |
420 | 309 | |
421 | 310 | /** |
422 | | - * @private |
423 | | - * @param int $limit number of accounts allowed to be requested from the same IP |
424 | | - */ |
425 | | - protected function throttleHit( $limit ) { |
426 | | - $out = $this->getOutput(); |
427 | | - $out->addHTML( wfMsgExt( 'acct_request_throttle_hit', 'parsemag', $limit ) ); |
428 | | - } |
429 | | - |
430 | | - /** |
431 | 311 | * (a) Try to confirm an email address via a token |
432 | 312 | * (b) Notify $wgConfirmAccountContact on success |
433 | | - * @param int $limit number of accounts allowed to be requested from the same IP |
| 313 | + * @param $code string The token |
| 314 | + * @return void |
434 | 315 | */ |
435 | 316 | protected function confirmEmailToken( $code ) { |
436 | 317 | global $wgConfirmAccountContact, $wgPasswordSender; |
Index: trunk/extensions/ConfirmAccount/presentation/specialpages/actions/ConfirmAccount_body.php |
— | — | @@ -378,6 +378,7 @@ |
379 | 379 | |
380 | 380 | /** |
381 | 381 | * Show a private file requested by the visitor. |
| 382 | + * @param $key string |
382 | 383 | */ |
383 | 384 | protected function showFile( $key ) { |
384 | 385 | global $wgConfirmAccountFSRepos, $IP; |