Adding a new right, move-rootuserpages.
authorNicolas Dumazet <nicdumz@users.mediawiki.org>
Wed, 1 Oct 2008 07:51:05 +0000 (07:51 +0000)
committerNicolas Dumazet <nicdumz@users.mediawiki.org>
Wed, 1 Oct 2008 07:51:05 +0000 (07:51 +0000)
This is a feature request by French crats :
the idea is to prevent users from wrongly attempting to userrename through Special:Movepage/User:xx . When this happens, a 'crat has to revert the move (deleting the redirects, sometimes with a lot of subpages) before being able to rename the user.

Default permission scheme still allows users to move root userpages

includes/DefaultSettings.php
includes/Title.php
languages/messages/MessagesEn.php
languages/messages/MessagesFr.php

index 78b7327..e8305a2 100644 (file)
@@ -1126,6 +1126,7 @@ $wgGroupPermissions['*'    ]['writeapi']         = true;
 // Implicit group for all logged-in accounts
 $wgGroupPermissions['user' ]['move']             = true;
 $wgGroupPermissions['user' ]['move-subpages']    = true;
+$wgGroupPermissions['user' ]['move-rootuserpages'] = true; // can move root userpages
 $wgGroupPermissions['user' ]['read']             = true;
 $wgGroupPermissions['user' ]['edit']             = true;
 $wgGroupPermissions['user' ]['createpage']       = true;
@@ -1164,6 +1165,7 @@ $wgGroupPermissions['sysop']['import']           = true;
 $wgGroupPermissions['sysop']['importupload']     = true;
 $wgGroupPermissions['sysop']['move']             = true;
 $wgGroupPermissions['sysop']['move-subpages']    = true;
+$wgGroupPermissions['sysop']['move-rootuserpages'] = true;
 $wgGroupPermissions['sysop']['patrol']           = true;
 $wgGroupPermissions['sysop']['autopatrol']       = true;
 $wgGroupPermissions['sysop']['protect']          = true;
index c8de709..9694f88 100644 (file)
@@ -2379,6 +2379,8 @@ class Title {
         * @return \type{\mixed} True on success, getUserPermissionsErrors()-like array on failure
         */
        public function isValidMoveOperation( &$nt, $auth = true, $reason = '' ) {
+               global $wgUser;
+
                $errors = array();      
                if( !$nt ) {
                        // Normally we'd add this to $errors, but we'll get
@@ -2421,12 +2423,16 @@ class Title {
                }
 
                if ( $auth ) {
-                       global $wgUser;
                        $errors = wfArrayMerge($errors, 
                                        $this->getUserPermissionsErrors('move', $wgUser),
                                        $this->getUserPermissionsErrors('edit', $wgUser),
                                        $nt->getUserPermissionsErrors('move', $wgUser),
                                        $nt->getUserPermissionsErrors('edit', $wgUser));
+
+                       # Root userpage ?
+                       if ( $nt->getNamespace() == NS_USER && !$nt->isSubpage() && !$wgUser->isAllowed('move-rootuserpages') ) {
+                                       $errors[] = array('moverootuserpagesnotallowed');
+                       }
                }
 
                $match = EditPage::matchSpamRegex( $reason );
@@ -2435,7 +2441,6 @@ class Title {
                        $errors[] = array('spamprotectiontext');
                }
                
-               global $wgUser;
                $err = null;
                if( !wfRunHooks( 'AbortMove', array( $this, $nt, $wgUser, &$err, $reason ) ) ) {
                        $errors[] = array('hookaborted', $err);
index 7f66051..417b676 100644 (file)
@@ -2616,6 +2616,7 @@ please be sure you understand the consequences of this before proceeding.",
 In those cases, you will have to move or merge the page manually if desired.",
 'movearticle'             => 'Move page:',
 'movenotallowed'          => 'You do not have permission to move pages on {{SITENAME}}.',
+'moverootuserpagesnotallowed' => 'You do not have permission to move root user pages on {{SITENAME}}.',
 'newtitle'                => 'To new title:',
 'move-watch'              => 'Watch this page',
 'movepagebtn'             => 'Move page',
index 43df510..92f7222 100644 (file)
@@ -2120,6 +2120,7 @@ Assurez-vous d’en avoir compris les conséquences avant de continuer.",
 Dans ce cas, vous devrez renommer ou fusionner la page manuellement si vous le désirez.',
 'movearticle'             => 'Renommer l’article',
 'movenotallowed'          => 'Vous n’avez pas la permission de renommer des pages sur ce wiki.',
+'moverootuserpagesnotallowed' => 'Vous n’avez pas la permission de renommer des pages utilisateurs racines sur ce wiki.',
 'newtitle'                => 'Nouveau titre',
 'move-watch'              => 'Suivre cette page',
 'movepagebtn'             => 'Renommer l’article',