Index: trunk/extensions/AntiSpoof/AntiSpoof.php |
— | — | @@ -40,6 +40,7 @@ |
41 | 41 | $wgHooks['AbortNewAccount'][] = 'asAbortNewAccountHook'; |
42 | 42 | $wgHooks['UserCreateForm'][] = 'asUserCreateFormHook'; |
43 | 43 | $wgHooks['AddNewAccount'][] = 'asAddNewAccountHook'; |
| 44 | +$wgHooks['RenameUserComplete'][] = 'asAddRenameUserHook'; |
44 | 45 | |
45 | 46 | function asUpdateSchema( $updater = null ) { |
46 | 47 | if ( $updater === null ) { |
— | — | @@ -130,3 +131,12 @@ |
131 | 132 | $spoof->record(); |
132 | 133 | return true; |
133 | 134 | } |
| 135 | + |
| 136 | +/** |
| 137 | + * On rename, remove the old entry and add the new |
| 138 | + */ |
| 139 | +function asAddRenameUserHook( $uid, $oldName, $newName ) { |
| 140 | + $spoof = new SpoofUser( $newName ); |
| 141 | + $spoof->update( $oldName ); |
| 142 | + return true; |
| 143 | +} |
Index: trunk/extensions/AntiSpoof/SpoofUser.php |
— | — | @@ -102,4 +102,17 @@ |
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | } |
| 106 | + |
| 107 | + public function update( $oldName ) { |
| 108 | + |
| 109 | + $dbw = wfGetDB( DB_MASTER ); |
| 110 | + |
| 111 | + if( $this->record() ) { |
| 112 | + $dbw->delete( |
| 113 | + 'spoofuser', |
| 114 | + array( 'su_name' => $oldName ), |
| 115 | + __METHOD__ |
| 116 | + ); |
| 117 | + } |
| 118 | + } |
106 | 119 | } |