Index: trunk/extensions/FlaggedRevs/backend/FlaggedRevs.hooks.php |
— | — | @@ -295,7 +295,7 @@ |
296 | 296 | /** |
297 | 297 | * Check page move and patrol permissions for FlaggedRevs |
298 | 298 | */ |
299 | | - public static function onUserCan( Title $title, $user, $action, &$result ) { |
| 299 | + public static function onGetUserPermissionsErrors( Title $title, $user, $action, &$result ) { |
300 | 300 | if ( $result === false ) { |
301 | 301 | return true; // nothing to do |
302 | 302 | } |
— | — | @@ -336,6 +336,20 @@ |
337 | 337 | $result = false; |
338 | 338 | return false; |
339 | 339 | } |
| 340 | + # Respect page protection to handle cases of "review wars". |
| 341 | + # If a page is restricted from editing such that a user cannot |
| 342 | + # edit it, then said user should not be able to review it. |
| 343 | + foreach ( $title->getRestrictions( 'edit' ) as $right ) { |
| 344 | + // Backwards compatibility, rewrite sysop -> protect |
| 345 | + $right = ( $right === 'sysop' ) ? 'protect' : $right; |
| 346 | + if ( $right != '' && !$user->isAllowed( $right ) ) { |
| 347 | + // 'editprotected' bypasses this restriction |
| 348 | + if ( !$user->isAllowed( 'editprotected' ) ) { |
| 349 | + $result = false; |
| 350 | + return false; |
| 351 | + } |
| 352 | + } |
| 353 | + } |
340 | 354 | } |
341 | 355 | return true; |
342 | 356 | } |
Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php |
— | — | @@ -228,10 +228,7 @@ |
229 | 229 | |
230 | 230 | public function isAllowed() { |
231 | 231 | // Basic permission check |
232 | | - return ( $this->page |
233 | | - && $this->page->userCan( 'review' ) |
234 | | - && $this->page->userCan( 'edit' ) |
235 | | - ); |
| 232 | + return ( $this->page && $this->page->userCan( 'review' ) ); |
236 | 233 | } |
237 | 234 | |
238 | 235 | // implicit dims for binary flag case |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php |
— | — | @@ -211,7 +211,7 @@ |
212 | 212 | |
213 | 213 | # ######## Other ######### |
214 | 214 | # Determine what pages can be moved and patrolled |
215 | | - $wgHooks['getUserPermissionsErrors'][] = 'FlaggedRevsHooks::onUserCan'; |
| 215 | + $wgHooks['getUserPermissionsErrors'][] = 'FlaggedRevsHooks::onGetUserPermissionsErrors'; |
216 | 216 | # Implicit autoreview rights group |
217 | 217 | $wgHooks['AutopromoteCondition'][] = 'FlaggedRevsHooks::checkAutoPromoteCond'; |
218 | 218 | $wgHooks['UserLoadAfterLoadFromSession'][] = 'FlaggedRevsHooks::setSessionKey'; |