Index: trunk/extensions/Renameuser/SpecialRenameuser.php |
— | — | @@ -14,6 +14,9 @@ |
15 | 15 | $wgAvailableRights[] = 'renameuser'; |
16 | 16 | $wgGroupPermissions['bureaucrat']['renameuser'] = true; |
17 | 17 | |
| 18 | +$wgAvailableRights[] = 'renameuser-moverootuserpage'; |
| 19 | +$wgGroupPermissions['bureaucrat']['renameuser-moverootuserpage'] = true; |
| 20 | + |
18 | 21 | $wgExtensionCredits['specialpage'][] = array( |
19 | 22 | 'name' => 'Renameuser', |
20 | 23 | 'author' => array( 'Ævar Arnfjörð Bjarmason', 'Aaron Schulz' ), |
— | — | @@ -35,6 +38,10 @@ |
36 | 39 | */ |
37 | 40 | define( 'RENAMEUSER_CONTRIBLIMIT', 2000000 ); |
38 | 41 | define( 'RENAMEUSER_CONTRIBJOB', 10000 ); |
| 42 | +/** |
| 43 | + * If you do not want to disallow the move of root userpages, set this to true |
| 44 | + */ |
| 45 | +define( 'RENAMEUSER_ROOTUSERPAGEMOVE', false ); |
39 | 46 | |
40 | 47 | # Add a new log type |
41 | 48 | global $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions; |
— | — | @@ -56,7 +63,21 @@ |
57 | 64 | } |
58 | 65 | return $rv; |
59 | 66 | } |
| 67 | +if ( !RENAMEUSER_ROOTUSERPAGEMOVE ) |
| 68 | + $wgHooks['AbortMove'][] = 'wfRenameUserIsValidMove'; |
60 | 69 | |
| 70 | +function wfRenameUserIsValidMove ($oldtitle, $newtitle, $user, &$error) { |
| 71 | + // Disallow moves from and to root userpages |
| 72 | + if ( ( |
| 73 | + ( $oldtitle->getNamespace() == NS_USER && !$oldtitle->isSubPage() ) |
| 74 | + || ($newtitle->getNamespace() == NS_USER && !$newtitle->isSubPage() ) |
| 75 | + ) && !$user->isAllowed('renameuser-moverootuserpage') ) { |
| 76 | + $error = wfMsg('moverootuserpagesnotallowed'); |
| 77 | + return false; |
| 78 | + } |
| 79 | + return true; |
| 80 | +} |
| 81 | + |
61 | 82 | $wgAutoloadClasses['SpecialRenameuser'] = dirname( __FILE__ ) . '/SpecialRenameuser_body.php'; |
62 | 83 | $wgAutoloadClasses['RenameUserJob'] = dirname(__FILE__) . '/RenameUserJob.php'; |
63 | 84 | $wgSpecialPages['Renameuser'] = 'SpecialRenameuser'; |