* Reintroduce user page move permission as per r41465, generally useful regardless...
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 11 Oct 2008 08:26:01 +0000 (08:26 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 11 Oct 2008 08:26:01 +0000 (08:26 +0000)
* Use error message text suitable for humans. Be specific about whether the source or the destination is the problem, say what the namespace is for those people who don't get namespaces, don't introduce unnecessary jargon words like "root" for a page that isn't a subpage.
* Fixed incorrect display of movenotallowed for immobile namespaces, use the new specific error messages.

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

index afa4548..0a2b817 100644 (file)
@@ -1128,6 +1128,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;
@@ -1166,6 +1167,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 7f1179e..36d0f2c 100644 (file)
@@ -1221,8 +1221,43 @@ class Title {
                                ( !$this->isTalkPage() && !$user->isAllowed( 'createpage' ) ) ) {
                                $errors[] = $user->isAnon() ? array ('nocreatetext') : array ('nocreate-loggedin');
                        }
-               } elseif( $action == 'move' && !( $this->isMovable() && $user->isAllowed( 'move' ) ) ) {
-                       $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
+
+               } elseif ( $action == 'move' ) {
+                       if ( !$user->isAllowed( 'move' ) ) {
+                               // User can't move anything
+                               $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
+                       } elseif ( !$user->isAllowed( 'move-rootuserpages' ) 
+                                       && $this->getNamespace() == NS_USER && !$this->isSubpage() ) 
+                       {
+                               // Show user page-specific message only if the user can move other pages
+                               $errors[] = array( 'cant-move-user-page' );
+                       }
+
+                       // Check for immobile pages
+                       if ( !MWNamespace::isMovable( $this->getNamespace() ) ) {
+                               // Specific message for this case
+                               $errors[] = array( 'immobile-source-namespace', $this->getNsText() );
+                       } elseif ( !$this->isMovable() ) {
+                               // Less specific message for rarer cases
+                               $errors[] = array( 'immobile-page' );
+                       }
+
+               } elseif ( $action == 'move-target' ) {
+                       if ( !$user->isAllowed( 'move' ) ) {
+                               // User can't move anything
+                               $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
+                       } elseif ( !$user->isAllowed( 'move-rootuserpages' ) 
+                                       && $this->getNamespace() == NS_USER && !$this->isSubpage() ) 
+                       {
+                               // Show user page-specific message only if the user can move other pages
+                               $errors[] = array( 'cant-move-to-user-page' );
+                       }
+                       if ( !MWNamespace::isMovable( $this->getNamespace() ) ) {
+                               $errors[] = array( 'immobile-target-namespace', $this->getNsText() );
+                       } elseif ( !$this->isMovable() ) {
+                               $errors[] = array( 'immobile-target-page' );
+                       }
+
                } elseif ( !$user->isAllowed( $action ) ) {
                        $return = null;
                        $groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
@@ -2380,6 +2415,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
@@ -2389,8 +2426,11 @@ class Title {
                if( $this->equals( $nt ) ) {
                        $errors[] = array('selfmove');
                }
-               if( !$this->isMovable() || !$nt->isMovable() ) {
-                       $errors[] = array('immobile_namespace');
+               if( !$this->isMovable() ) {
+                       $errors[] = array( 'immobile-source-namespace', $this->getNsText() );
+               }
+               if ( !$nt->isMovable() ) {
+                       $errors[] = array('immobile-target-namespace', $nt->getNsText() );
                }
 
                $oldid = $this->getArticleID();
@@ -2422,11 +2462,10 @@ class Title {
                }
 
                if ( $auth ) {
-                       global $wgUser;
                        $errors = wfArrayMerge($errors, 
                                        $this->getUserPermissionsErrors('move', $wgUser),
                                        $this->getUserPermissionsErrors('edit', $wgUser),
-                                       $nt->getUserPermissionsErrors('move', $wgUser),
+                                       $nt->getUserPermissionsErrors('move-target', $wgUser),
                                        $nt->getUserPermissionsErrors('edit', $wgUser));
                }
 
@@ -2436,7 +2475,6 @@ class Title {
                        $errors[] = array('spamprotectiontext');
                }
                
-               global $wgUser;
                $err = null;
                if( !wfRunHooks( 'AbortMove', array( $this, $nt, $wgUser, &$err, $reason ) ) ) {
                        $errors[] = array('hookaborted', $err);
index e94c2ba..0b1b11d 100644 (file)
@@ -2660,7 +2660,11 @@ 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:',
+'movenologin'             => 'Not logged in',
+'movenologintext'         => 'You must be a registered user and [[Special:Userlogin|logged in]] to move a page.',
 'movenotallowed'          => 'You do not have permission to move pages.',
+'cant-move-user-page' => 'You do not have permission to move user pages (apart from subpages).',
+'cant-move-to-user-page'  => 'You do not have permission to move a page to a user page (except to a user subpage).',
 'newtitle'                => 'To new title:',
 'move-watch'              => 'Watch this page',
 'movepagebtn'             => 'Move page',
@@ -2693,8 +2697,10 @@ Do you want to delete it to make way for the move?',
 'delete_and_move_reason'  => 'Deleted to make way for move',
 'selfmove'                => 'Source and destination titles are the same;
 cannot move a page over itself.',
-'immobile_namespace'      => 'Source or destination title is of a special type;
-cannot move pages from and into that namespace.',
+'immobile-source-namespace' => 'Cannot move pages in namespace "$1"',
+'immobile-target-namespace' => 'Cannot move pages into namespace "$1"',
+'immobile-source-page'      => 'This page is not movable.',
+'immobile-target-page'      => 'Cannot move to that destination title.',
 'imagenocrossnamespace'   => 'Cannot move file to non-file namespace',
 'imagetypemismatch'       => 'The new file extension does not match its type',
 'imageinvalidfilename'    => 'The target file name is invalid',