Index: trunk/phase3/includes/Title.php |
— | — | @@ -1166,49 +1166,6 @@ |
1167 | 1167 | |
1168 | 1168 | $errors = array(); |
1169 | 1169 | |
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 ) ) { |
1195 | | - $return = null; |
1196 | | - $groups = array_map( array( 'User', 'makeGroupLinkWiki' ), |
1197 | | - User::getGroupsWithPermission( $action ) ); |
1198 | | - if( $groups ) { |
1199 | | - $return = array( 'badaccess-groups', |
1200 | | - array( implode( ', ', $groups ), count( $groups ) ) ); |
1201 | | - } else { |
1202 | | - $return = array( "badaccess-group0" ); |
1203 | | - } |
1204 | | - $errors[] = $return; |
1205 | | - } |
1206 | | - |
1207 | | - # Short-circuit point |
1208 | | - if( $short && count($errors) > 0 ) { |
1209 | | - wfProfileOut( __METHOD__ ); |
1210 | | - return $errors; |
1211 | | - } |
1212 | | - |
1213 | 1170 | // Use getUserPermissionsErrors instead |
1214 | 1171 | if( !wfRunHooks( 'userCan', array( &$this, &$user, $action, &$result ) ) ) { |
1215 | 1172 | wfProfileOut( __METHOD__ ); |
— | — | @@ -1339,7 +1296,26 @@ |
1340 | 1297 | $errors[] = array( 'titleprotected', User::whoIs($pt_user), $pt_reason ); |
1341 | 1298 | } |
1342 | 1299 | } |
| 1300 | + |
| 1301 | + if( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) || |
| 1302 | + ( !$this->isTalkPage() && !$user->isAllowed( 'createpage' ) ) ) |
| 1303 | + { |
| 1304 | + $errors[] = $user->isAnon() ? array ('nocreatetext') : array ('nocreate-loggedin'); |
| 1305 | + } |
1343 | 1306 | } elseif( $action == 'move' ) { |
| 1307 | + if( !$user->isAllowed( 'move' ) ) { |
| 1308 | + // User can't move anything |
| 1309 | + $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed'); |
| 1310 | + } elseif( !$user->isAllowed( 'move-rootuserpages' ) |
| 1311 | + && $this->getNamespace() == NS_USER && !$this->isSubpage() ) |
| 1312 | + { |
| 1313 | + // Show user page-specific message only if the user can move other pages |
| 1314 | + $errors[] = array( 'cant-move-user-page' ); |
| 1315 | + } |
| 1316 | + // Check if user is allowed to move files if it's a file |
| 1317 | + if( $this->getNamespace() == NS_FILE && !$user->isAllowed( 'movefile' ) ) { |
| 1318 | + $errors[] = array( 'movenotallowedfile' ); |
| 1319 | + } |
1344 | 1320 | // Check for immobile pages |
1345 | 1321 | if( !MWNamespace::isMovable( $this->getNamespace() ) ) { |
1346 | 1322 | // Specific message for this case |
— | — | @@ -1363,6 +1339,17 @@ |
1364 | 1340 | } elseif( !$this->isMovable() ) { |
1365 | 1341 | $errors[] = array( 'immobile-target-page' ); |
1366 | 1342 | } |
| 1343 | + } elseif( !$user->isAllowed( $action ) ) { |
| 1344 | + $return = null; |
| 1345 | + $groups = array_map( array( 'User', 'makeGroupLinkWiki' ), |
| 1346 | + User::getGroupsWithPermission( $action ) ); |
| 1347 | + if( $groups ) { |
| 1348 | + $return = array( 'badaccess-groups', |
| 1349 | + array( implode( ', ', $groups ), count( $groups ) ) ); |
| 1350 | + } else { |
| 1351 | + $return = array( "badaccess-group0" ); |
| 1352 | + } |
| 1353 | + $errors[] = $return; |
1367 | 1354 | } |
1368 | 1355 | |
1369 | 1356 | wfProfileOut( __METHOD__ ); |