r33941 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r33940‎ | r33941 | r33942 >
Date:17:48, 27 April 2008
Author:aaron
Status:old
Tags:
Comment:
Expand sortkey replace
Modified paths:
  • /trunk/extensions/ConfirmAccount/ConfirmAccount_body.php (modified) (history)
  • /trunk/extensions/ConfirmAccount/SpecialConfirmAccount.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ConfirmAccount/SpecialConfirmAccount.php
@@ -12,7 +12,7 @@
1313 'descriptionmsg' => 'confirmedit-desc',
1414 'author' => 'Aaron Schulz',
1515 'url' => 'http://www.mediawiki.org/wiki/Extension:ConfirmAccount',
16 - 'version' => '1.45',
 16+ 'version' => '1.46',
1717 );
1818
1919 # This extension needs email enabled!
Index: trunk/extensions/ConfirmAccount/ConfirmAccount_body.php
@@ -1142,7 +1142,9 @@
11431143 }
11441144 $transaction = new FSTransaction();
11451145 if( !FileStore::lock() ) {
 1146+ $dbw->delete( 'user', array( 'user_id' => $user->getID() ) );
11461147 wfDebug( __METHOD__.": failed to acquire file store lock, aborting\n" );
 1148+ return false;
11471149 }
11481150 $path = $storeOld->filePath( $key );
11491151 if( $path && file_exists($path) ) {
@@ -1190,8 +1192,8 @@
11911193 $transaction->commit();
11921194 }
11931195
 1196+ # Grant any necessary rights
11941197 $grouptext = $group = '';
1195 - # Grant any necessary rights
11961198 global $wgAccountRequestTypes;
11971199 if( array_key_exists($this->mType,$wgAccountRequestTypes) ) {
11981200 $params = $wgAccountRequestTypes[$this->mType];
@@ -1203,8 +1205,8 @@
12041206 }
12051207 }
12061208
 1209+ # Send out password
12071210 $ebody = '';
1208 - # Send out password
12091211 if( $this->reason ) {
12101212 # If the user is in a group and there is a welcome for that group, use it
12111213 if( $group && !wfEmptyMsg( "confirmaccount-email-body2-pos{$this->mType}", wfMsg("confirmaccount-email-body2-pos{$this->mType}") ) ) {
@@ -1225,10 +1227,10 @@
12261228 }
12271229 }
12281230 $result = $user->sendMail( wfMsg( 'confirmaccount-email-subj' ), $ebody );
1229 -
12301231 if( WikiError::isError( $result ) ) {
12311232 $errors[] = wfMsg( 'mailerror', htmlspecialchars( $result->toString() ) );
12321233 }
 1234+
12331235 # Safe to hook/log now...
12341236 wfRunHooks( 'AddNewAccount', array( $user ) );
12351237 # OK, now remove the request from the queue
@@ -1257,10 +1259,8 @@
12581260 }
12591261 # Start up the user's (presumedly brand new) userpages
12601262 # Will not append, so previous content will be blanked
1261 - global $wgMakeUserPageFromBio;
 1263+ global $wgMakeUserPageFromBio, $wgAutoUserBioText;
12621264 if( $wgMakeUserPageFromBio ) {
1263 - global $wgAutoUserBioText;
1264 -
12651265 $usertitle = $user->getUserPage();
12661266 $userpage = new Article( $usertitle );
12671267
@@ -1273,7 +1273,6 @@
12741274 foreach( $areas as $n => $line ) {
12751275 $set = explode("|",$line);
12761276 $name = str_replace("_"," ",$set[0]);
1277 -
12781277 if( in_array($set[0],$this->mAreaSet) ) {
12791278 # General userpage text for anyone with this interest
12801279 if( isset($set[2]) ) {
@@ -1287,12 +1286,16 @@
12881287 }
12891288 }
12901289 }
1291 - # Set sortkey
1292 - global $wgConfirmAccountSortkey;
 1290+ # Set sortkey and use it on bio
 1291+ global $wgConfirmAccountSortkey, $wgContLang;
12931292 if( !empty($wgConfirmAccountSortkey) ) {
1294 - $sortKey = $usertitle->getText();
1295 - $sortKey = preg_replace( $wgConfirmAccountSortkey[0], $wgConfirmAccountSortkey[1], $sortKey );
 1293+ $sortKey = preg_replace($wgConfirmAccountSortkey[0],$wgConfirmAccountSortkey[1],$usertitle->getText());
12961294 $body .= "\n{{DEFAULTSORT:{$sortKey}}}";
 1295+ # Clean up any other categories...
 1296+ $catNS = $wgContLang->getNSText(NS_CATEGORY);
 1297+ $replace = '/\[\['.preg_quote($catNS).':([^\]]+)\]\]/i'; // [[Category:x]]
 1298+ $with = "[[{$catNS}:$1|".str_replace('$','\$',$sortKey)."]]"; // [[Category:x|sortkey]]
 1299+ $body = preg_replace( $replace, $with, $body );
12971300 }
12981301 # Create userpage!
12991302 $userpage->doEdit( $body, wfMsg('confirmaccount-summary'), EDIT_MINOR );
@@ -1310,7 +1313,7 @@
13111314 # Add user welcome message!
13121315 $utalk->doEdit( $welcome . ' ~~~~', wfMsg('confirmaccount-wsum'), EDIT_MINOR );
13131316 }
1314 -
 1317+ # Finally, done!!!
13151318 $this->showSuccess( $this->submitType, $user->getName(), $errors );
13161319 } else if( $this->submitType == 'hold' ) {
13171320 global $wgUser;

Status & tagging log