r41595 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41594‎ | r41595 | r41596 >
Date:10:20, 3 October 2008
Author:nicdumz
Status:old (Comments)
Tags:
Comment:
Better implementation of r41465 (Adding a new right, move-rootuserpages.) which has been inadvertedly reverted since, in r41569.

Registers a function to AbortMove Hook to prevent certain users from moving from and to userpages. Right is given through 'renameuser-moverootuserpage' ; the whole system can be disabled throught a constant.
Modified paths:
  • /trunk/extensions/Renameuser/SpecialRenameuser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Renameuser/SpecialRenameuser.php
@@ -14,6 +14,9 @@
1515 $wgAvailableRights[] = 'renameuser';
1616 $wgGroupPermissions['bureaucrat']['renameuser'] = true;
1717
 18+$wgAvailableRights[] = 'renameuser-moverootuserpage';
 19+$wgGroupPermissions['bureaucrat']['renameuser-moverootuserpage'] = true;
 20+
1821 $wgExtensionCredits['specialpage'][] = array(
1922 'name' => 'Renameuser',
2023 'author' => array( 'Ævar Arnfjörð Bjarmason', 'Aaron Schulz' ),
@@ -35,6 +38,10 @@
3639 */
3740 define( 'RENAMEUSER_CONTRIBLIMIT', 2000000 );
3841 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 );
3946
4047 # Add a new log type
4148 global $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions;
@@ -56,7 +63,21 @@
5764 }
5865 return $rv;
5966 }
 67+if ( !RENAMEUSER_ROOTUSERPAGEMOVE )
 68+ $wgHooks['AbortMove'][] = 'wfRenameUserIsValidMove';
6069
 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+
6182 $wgAutoloadClasses['SpecialRenameuser'] = dirname( __FILE__ ) . '/SpecialRenameuser_body.php';
6283 $wgAutoloadClasses['RenameUserJob'] = dirname(__FILE__) . '/RenameUserJob.php';
6384 $wgSpecialPages['Renameuser'] = 'SpecialRenameuser';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r41465Adding a new right, move-rootuserpages....nicdumz07:51, 1 October 2008
r41569Re-commit r41410 (parts of at least) with fixes (case problems). Passes all t...mattj21:49, 2 October 2008

Comments

#Comment by Simetrical (talk | contribs)   17:26, 3 October 2008

Are you requiring that users actually edit the Renameuser files to change configuration? That's not a good idea at all. If they install an upgrade, it will overwrite their changes. Why don't you use a $wg... configuration setting? That's what they're meant for.

#Comment by NicDumZ (talk | contribs)   01:58, 4 October 2008

(who set this to resolved ? :) )

Special:Code/MediaWiki/41633 uses a $wg. I just had to defer the extension configuration to avoid registering the hook when not necessary.

Thanks !

#Comment by Tim Starling (talk | contribs)   11:57, 11 October 2008

See my idea of how it should be done in r41961/r41962/r41963.

Status & tagging log