From: Nicolas Dumazet Date: Wed, 1 Oct 2008 07:51:05 +0000 (+0000) Subject: Adding a new right, move-rootuserpages. X-Git-Tag: 1.31.0-rc.0~44976 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/%7B%7B%20url_for%28%27vote%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=commitdiff_plain;h=ad8b18b4c83ed4b678429fab452545f4f1ad6524;p=lhc%2Fweb%2Fwiklou.git Adding a new right, move-rootuserpages. 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 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 78b7327b7c..e8305a2320 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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; diff --git a/includes/Title.php b/includes/Title.php index c8de709da3..9694f8884c 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 7f66051d70..417b676c5e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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', diff --git a/languages/messages/MessagesFr.php b/languages/messages/MessagesFr.php index 43df5101c9..92f7222b86 100644 --- a/languages/messages/MessagesFr.php +++ b/languages/messages/MessagesFr.php @@ -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',