Index: trunk/phase3/includes/Title.php |
— | — | @@ -1204,12 +1204,14 @@ |
1205 | 1205 | return $errors; |
1206 | 1206 | } |
1207 | 1207 | |
1208 | | - // TODO: document |
| 1208 | + # Only 'createaccount' and 'execute' can be performed on |
| 1209 | + # special pages, which don't actually exist in the DB. |
1209 | 1210 | $specialOKActions = array( 'createaccount', 'execute' ); |
1210 | 1211 | if( NS_SPECIAL == $this->mNamespace && !in_array( $action, $specialOKActions) ) { |
1211 | 1212 | $errors[] = array('ns-specialprotected'); |
1212 | 1213 | } |
1213 | 1214 | |
| 1215 | + # Check $wgNamespaceProtection for restricted namespaces |
1214 | 1216 | if( $this->isNamespaceProtected() ) { |
1215 | 1217 | $ns = $this->getNamespace() == NS_MAIN ? |
1216 | 1218 | wfMsg( 'nstab-main' ) : $this->getNsText(); |
— | — | @@ -1217,7 +1219,7 @@ |
1218 | 1220 | array('protectedinterface') : array( 'namespaceprotected', $ns ); |
1219 | 1221 | } |
1220 | 1222 | |
1221 | | - # protect css/js subpages of user pages |
| 1223 | + # Protect css/js subpages of user pages |
1222 | 1224 | # XXX: this might be better using restrictions |
1223 | 1225 | # XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssJsSubpage() from working |
1224 | 1226 | if( $this->isCssJsSubpage() && !$user->isAllowed('editusercssjs') |
— | — | @@ -1226,6 +1228,32 @@ |
1227 | 1229 | $errors[] = array('customcssjsprotected'); |
1228 | 1230 | } |
1229 | 1231 | |
| 1232 | + # Check against page_restrictions table requirements on this |
| 1233 | + # page. The user must possess all required rights for this action. |
| 1234 | + foreach( $this->getRestrictions($action) as $right ) { |
| 1235 | + // Backwards compatibility, rewrite sysop -> protect |
| 1236 | + if( $right == 'sysop' ) { |
| 1237 | + $right = 'protect'; |
| 1238 | + } |
| 1239 | + if( '' != $right && !$user->isAllowed( $right ) ) { |
| 1240 | + // Users with 'editprotected' permission can edit protected pages |
| 1241 | + if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) { |
| 1242 | + // Users with 'editprotected' permission cannot edit protected pages |
| 1243 | + // with cascading option turned on. |
| 1244 | + if( $this->mCascadeRestriction ) { |
| 1245 | + $errors[] = array( 'protectedpagetext', $right ); |
| 1246 | + } |
| 1247 | + } else { |
| 1248 | + $errors[] = array( 'protectedpagetext', $right ); |
| 1249 | + } |
| 1250 | + } |
| 1251 | + } |
| 1252 | + # Short-circuit point |
| 1253 | + if( $short && count($errors) > 0 ) { |
| 1254 | + wfProfileOut( __METHOD__ ); |
| 1255 | + return $errors; |
| 1256 | + } |
| 1257 | + |
1230 | 1258 | if( $doExpensiveQueries && !$this->isCssJsSubpage() ) { |
1231 | 1259 | # We /could/ use the protection level on the source page, but it's fairly ugly |
1232 | 1260 | # as we have to establish a precedence hierarchy for pages included by multiple |
— | — | @@ -1254,30 +1282,6 @@ |
1255 | 1283 | return $errors; |
1256 | 1284 | } |
1257 | 1285 | |
1258 | | - foreach( $this->getRestrictions($action) as $right ) { |
1259 | | - // Backwards compatibility, rewrite sysop -> protect |
1260 | | - if( $right == 'sysop' ) { |
1261 | | - $right = 'protect'; |
1262 | | - } |
1263 | | - if( '' != $right && !$user->isAllowed( $right ) ) { |
1264 | | - // Users with 'editprotected' permission can edit protected pages |
1265 | | - if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) { |
1266 | | - // Users with 'editprotected' permission cannot edit protected pages |
1267 | | - // with cascading option turned on. |
1268 | | - if( $this->mCascadeRestriction ) { |
1269 | | - $errors[] = array( 'protectedpagetext', $right ); |
1270 | | - } |
1271 | | - } else { |
1272 | | - $errors[] = array( 'protectedpagetext', $right ); |
1273 | | - } |
1274 | | - } |
1275 | | - } |
1276 | | - # Short-circuit point |
1277 | | - if( $short && count($errors) > 0 ) { |
1278 | | - wfProfileOut( __METHOD__ ); |
1279 | | - return $errors; |
1280 | | - } |
1281 | | - |
1282 | 1286 | if( $action == 'protect' ) { |
1283 | 1287 | if( $this->getUserPermissionsErrors('edit', $user) != array() ) { |
1284 | 1288 | $errors[] = array( 'protect-cantedit' ); // If they can't edit, they shouldn't protect. |