Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -408,10 +408,8 @@ |
409 | 409 | # Auto-reviewing |
410 | 410 | $wgHooks['RecentChange_save'][] = 'FlaggedRevsHooks::autoMarkPatrolled'; |
411 | 411 | $wgHooks['NewRevisionFromEditComplete'][] = 'FlaggedRevsHooks::maybeMakeEditReviewed'; |
412 | | -# Disallow moves of stable pages |
413 | | -$wgHooks['userCan'][] = 'FlaggedRevsHooks::userCanMove'; |
414 | | -# Determine what pages can be patrolled |
415 | | -$wgHooks['userCan'][] = 'FlaggedRevsHooks::userCanPatrol'; |
| 412 | +# Determine what pages can be moved and patrolled |
| 413 | +$wgHooks['userCan'][] = 'FlaggedRevsHooks::onUserCan'; |
416 | 414 | # Log parameter |
417 | 415 | $wgHooks['LogLine'][] = 'FlaggedRevsHooks::reviewLogLine'; |
418 | 416 | # Disable auto-promotion for demoted users |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -649,55 +649,50 @@ |
650 | 650 | } |
651 | 651 | |
652 | 652 | /** |
653 | | - * Don't let users vandalize pages by moving them |
| 653 | + * Check page move and patrol permissions for FlaggedRevs |
654 | 654 | */ |
655 | | - public static function userCanMove( $title, $user, $action, &$result ) { |
656 | | - if( $action != 'move' || $result===false || !FlaggedRevs::isPageReviewable($title) ) { |
657 | | - return true; |
658 | | - } |
659 | | - $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
660 | | - if( !$flaggedArticle->showStableByDefault() ) { |
661 | | - return true; |
662 | | - } |
663 | | - if( $frev = $flaggedArticle->getStableRev() ) { |
664 | | - # Allow for only editors/reviewers to move this |
665 | | - if( !$user->isAllowed('review') && !$user->isAllowed('movestable') ) { |
| 655 | + public static function onUserCan( $title, $user, $action, &$result ) { |
| 656 | + if( $result === false || !$title->exists() ) |
| 657 | + return true; // nothing to do |
| 658 | + # Don't let users vandalize pages by moving them... |
| 659 | + if( $action === 'move' ) { |
| 660 | + if( !FlaggedRevs::isPageReviewable($title) ) |
| 661 | + return true; |
| 662 | + $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
| 663 | + # If the current shows be default anyway, nothing to do... |
| 664 | + if( !$flaggedArticle->showStableByDefault() ) { |
| 665 | + return true; |
| 666 | + } |
| 667 | + $frev = $flaggedArticle->getStableRev(); |
| 668 | + if( $frev && !$user->isAllowed('review') && !$user->isAllowed('movestable') ) { |
| 669 | + # Allow for only editors/reviewers to move this page |
666 | 670 | $result = false; |
667 | 671 | return false; |
668 | 672 | } |
669 | | - } |
670 | | - return true; |
671 | | - } |
672 | | - |
673 | | - /** |
674 | | - * Don't let users patrol pages not in $wgFlaggedRevsPatrolNamespaces |
675 | | - */ |
676 | | - public static function userCanPatrol( $title, $user, $action, &$result ) { |
677 | | - if( $result === false ) return true; // nothing to do |
678 | | - if( $action != 'patrol' && $action != 'autopatrol' ) { |
679 | | - return true; |
680 | | - } |
681 | | - # Pages in reviewable namespace can be patrolled IF reviewing |
682 | | - # is disabled for pages that don't show the stable by default. |
683 | | - # In such cases, we let people with 'review' rights patrol them. |
684 | | - if( FlaggedRevs::isPageReviewable($title) && !$user->isAllowed('review') ) { |
685 | | - $result = false; |
686 | | - return false; |
687 | | - } |
688 | | - $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
689 | | - # The page must be in a patrollable namespace ($wgFlaggedRevsPatrolNamespaces)... |
690 | | - if( !$flaggedArticle->isPatrollable() ) { |
691 | | - global $wgUseNPPatrol; |
692 | | - # ...unless the page is not in a reviewable namespace and |
693 | | - # new page patrol is enabled. In this scenario, any edits |
694 | | - # to pages outside of patrollable namespaces would already |
695 | | - # be auto-patrolled, except for the new page edits. |
696 | | - if( $wgUseNPPatrol && !$flaggedArticle->isReviewable() ) { |
697 | | - return true; |
698 | | - } else { |
| 673 | + # Don't let users patrol pages not in $wgFlaggedRevsPatrolNamespaces |
| 674 | + } else if( $action === 'patrol' || $action === 'autopatrol' ) { |
| 675 | + # Pages in reviewable namespace can be patrolled IF reviewing |
| 676 | + # is disabled for pages that don't show the stable by default. |
| 677 | + # In such cases, we let people with 'review' rights patrol them. |
| 678 | + if( FlaggedRevs::isPageReviewable($title) && !$user->isAllowed('review') ) { |
699 | 679 | $result = false; |
700 | 680 | return false; |
701 | 681 | } |
| 682 | + $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
| 683 | + # The page must be in a patrollable namespace ($wgFlaggedRevsPatrolNamespaces)... |
| 684 | + if( !$flaggedArticle->isPatrollable() ) { |
| 685 | + global $wgUseNPPatrol; |
| 686 | + # ...unless the page is not in a reviewable namespace and |
| 687 | + # new page patrol is enabled. In this scenario, any edits |
| 688 | + # to pages outside of patrollable namespaces would already |
| 689 | + # be auto-patrolled, except for the new page edits. |
| 690 | + if( $wgUseNPPatrol && !$flaggedArticle->isReviewable() ) { |
| 691 | + return true; |
| 692 | + } else { |
| 693 | + $result = false; |
| 694 | + return false; |
| 695 | + } |
| 696 | + } |
702 | 697 | } |
703 | 698 | return true; |
704 | 699 | } |