Index: trunk/phase3/includes/Title.php |
— | — | @@ -1166,7 +1166,31 @@ |
1167 | 1167 | |
1168 | 1168 | $errors = array(); |
1169 | 1169 | |
1170 | | - if( !$user->isAllowed( $action ) ) { |
| 1170 | + // First stop is permissions checks, which fail most often, and which are easiest to test. |
| 1171 | + if ( $action == 'move' ) { |
| 1172 | + if( !$user->isAllowed( 'move-rootuserpages' ) |
| 1173 | + && $this->getNamespace() == NS_USER && !$this->isSubpage() ) |
| 1174 | + { |
| 1175 | + // Show user page-specific message only if the user can move other pages |
| 1176 | + $errors[] = array( 'cant-move-user-page' ); |
| 1177 | + } |
| 1178 | + |
| 1179 | + // Check if user is allowed to move files if it's a file |
| 1180 | + if( $this->getNamespace() == NS_FILE && !$user->isAllowed( 'movefile' ) ) { |
| 1181 | + $errors[] = array( 'movenotallowedfile' ); |
| 1182 | + } |
| 1183 | + |
| 1184 | + if( !$user->isAllowed( 'move' ) ) { |
| 1185 | + // User can't move anything |
| 1186 | + $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed'); |
| 1187 | + } |
| 1188 | + } elseif ( $action == 'create' ) { |
| 1189 | + if( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) || |
| 1190 | + ( !$this->isTalkPage() && !$user->isAllowed( 'createpage' ) ) ) |
| 1191 | + { |
| 1192 | + $errors[] = $user->isAnon() ? array ('nocreatetext') : array ('nocreate-loggedin'); |
| 1193 | + } |
| 1194 | + } elseif( !$user->isAllowed( $action ) ) { |
1171 | 1195 | $return = null; |
1172 | 1196 | $groups = array_map( array( 'User', 'makeGroupLinkWiki' ), |
1173 | 1197 | User::getGroupsWithPermission( $action ) ); |
— | — | @@ -1315,26 +1339,7 @@ |
1316 | 1340 | $errors[] = array( 'titleprotected', User::whoIs($pt_user), $pt_reason ); |
1317 | 1341 | } |
1318 | 1342 | } |
1319 | | - |
1320 | | - if( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) || |
1321 | | - ( !$this->isTalkPage() && !$user->isAllowed( 'createpage' ) ) ) |
1322 | | - { |
1323 | | - $errors[] = $user->isAnon() ? array ('nocreatetext') : array ('nocreate-loggedin'); |
1324 | | - } |
1325 | 1343 | } elseif( $action == 'move' ) { |
1326 | | - if( !$user->isAllowed( 'move' ) ) { |
1327 | | - // User can't move anything |
1328 | | - $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed'); |
1329 | | - } elseif( !$user->isAllowed( 'move-rootuserpages' ) |
1330 | | - && $this->getNamespace() == NS_USER && !$this->isSubpage() ) |
1331 | | - { |
1332 | | - // Show user page-specific message only if the user can move other pages |
1333 | | - $errors[] = array( 'cant-move-user-page' ); |
1334 | | - } |
1335 | | - // Check if user is allowed to move files if it's a file |
1336 | | - if( $this->getNamespace() == NS_FILE && !$user->isAllowed( 'movefile' ) ) { |
1337 | | - $errors[] = array( 'movenotallowedfile' ); |
1338 | | - } |
1339 | 1344 | // Check for immobile pages |
1340 | 1345 | if( !MWNamespace::isMovable( $this->getNamespace() ) ) { |
1341 | 1346 | // Specific message for this case |