Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -172,14 +172,14 @@ |
173 | 173 | $wgGroupPermissions['editor']['review'] = true; |
174 | 174 | $wgGroupPermissions['editor']['autoreview'] = true; |
175 | 175 | $wgGroupPermissions['editor']['autoconfirmed'] = true; |
176 | | -$wgGroupPermissions['editor']['patrolmarks'] = true; |
177 | | -$wgGroupPermissions['editor']['autopatrolother'] = true; |
| 176 | +$wgGroupPermissions['editor']['patrol'] = true; |
178 | 177 | $wgGroupPermissions['editor']['unreviewedpages'] = true; |
179 | 178 | |
180 | 179 | # Defines extra rights for advanced reviewer class |
181 | 180 | $wgGroupPermissions['reviewer']['validate'] = true; |
182 | 181 | # Let this stand alone just in case... |
183 | 182 | $wgGroupPermissions['reviewer']['review'] = true; |
| 183 | +$wgGroupPermissions['reviewer']['patrol'] = true; |
184 | 184 | |
185 | 185 | $wgGroupPermissions['bot']['autoreview'] = true; |
186 | 186 | |
— | — | @@ -373,6 +373,8 @@ |
374 | 374 | $wgHooks['NewRevisionFromEditComplete'][] = 'FlaggedRevsHooks::maybeMakeEditReviewed'; |
375 | 375 | # Disallow moves of stable pages |
376 | 376 | $wgHooks['userCan'][] = 'FlaggedRevsHooks::userCanMove'; |
| 377 | +# Determine what pages can be patrolled |
| 378 | +$wgHooks['userCan'][] = 'FlaggedRevsHooks::userCanPatrol'; |
377 | 379 | # Log parameter |
378 | 380 | $wgHooks['LogLine'][] = 'FlaggedRevsHooks::reviewLogLine'; |
379 | 381 | # Disable auto-promotion for demoted users |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -1139,7 +1139,7 @@ |
1140 | 1140 | * Add a link to patrol non-reviewable pages. |
1141 | 1141 | * Also add a diff to stable for other pages if possible. |
1142 | 1142 | */ |
1143 | | - public function addPatrolAndDiffLink( $diff, $oldRev, $newRev ) { |
| 1143 | + public function addDiffLink( $diff, $oldRev, $newRev ) { |
1144 | 1144 | global $wgUser, $wgOut; |
1145 | 1145 | // Is there a stable version? |
1146 | 1146 | if( $oldRev && $this->isReviewable() ) { |
— | — | @@ -1158,42 +1158,6 @@ |
1159 | 1159 | $wgOut->addHTML( "<div class='fr-diff-to-stable' align='center'>$patrol</div>" ); |
1160 | 1160 | } |
1161 | 1161 | } |
1162 | | - // Prepare a change patrol link, if applicable |
1163 | | - } else if( $this->isPatrollable() && $wgUser->isAllowed( 'review' ) ) { |
1164 | | - wfLoadExtensionMessages( 'FlaggedRevs' ); |
1165 | | - // If we've been given an explicit change identifier, use it; saves time |
1166 | | - if( $diff->mRcidMarkPatrolled ) { |
1167 | | - $rcid = $diff->mRcidMarkPatrolled; |
1168 | | - } else { |
1169 | | - # Look for an unpatrolled change corresponding to this diff |
1170 | | - $change = RecentChange::newFromConds( |
1171 | | - array( |
1172 | | - # Add redundant user,timestamp condition so we can use the existing index |
1173 | | - 'rc_user_text' => $diff->mNewRev->getRawUserText(), |
1174 | | - 'rc_timestamp' => wfGetDB( DB_SLAVE )->timestamp( $diff->mNewRev->getTimestamp() ), |
1175 | | - 'rc_this_oldid' => $diff->mNewid, |
1176 | | - 'rc_last_oldid' => $diff->mOldid, |
1177 | | - 'rc_patrolled' => 0 |
1178 | | - ), |
1179 | | - __METHOD__ |
1180 | | - ); |
1181 | | - if( $change instanceof RecentChange ) { |
1182 | | - $rcid = $change->mAttribs['rc_id']; |
1183 | | - } else { |
1184 | | - $rcid = 0; // None found |
1185 | | - } |
1186 | | - } |
1187 | | - // Build the link |
1188 | | - if( $rcid ) { |
1189 | | - $reviewTitle = SpecialPage::getTitleFor( 'RevisionReview' ); |
1190 | | - $token = $wgUser->editToken( $newRev->getTitle()->getPrefixedText(), $rcid ); |
1191 | | - $patrol = '[' . $wgUser->getSkin()->makeKnownLinkObj( $reviewTitle, wfMsgHtml( 'revreview-patrol' ), |
1192 | | - wfArrayToCGI( array( 'patrolonly' => 1, 'target' => $newRev->getTitle()->getPrefixedDBKey(), |
1193 | | - 'rcid' => $rcid, 'token' => $token ) ) ) . ']'; |
1194 | | - } else { |
1195 | | - $patrol = ''; |
1196 | | - } |
1197 | | - $wgOut->addHTML( '<div class="fr-diff-patrollink">' . $patrol . '</div>' ); |
1198 | 1162 | } |
1199 | 1163 | return true; |
1200 | 1164 | } |
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php |
— | — | @@ -51,50 +51,12 @@ |
52 | 52 | $wgOut->showErrorPage('notargettitle', 'notargettext' ); |
53 | 53 | return; |
54 | 54 | } |
55 | | - # Basic patrolling |
56 | | - $this->patrolonly = $wgRequest->getBool( 'patrolonly' ); |
57 | | - $this->rcid = $wgRequest->getIntOrNull( 'rcid' ); |
58 | 55 | # Param for sites with no tags, otherwise discarded |
59 | 56 | $this->approve = $wgRequest->getBool( 'wpApprove' ); |
60 | 57 | # Patrol the edit if requested... |
61 | | - if( $this->patrolonly && $this->rcid ) { |
62 | | - $this->markPatrolled(); |
63 | | - # Otherwise, do a regular review... |
64 | | - } else { |
65 | | - $this->markReviewed(); |
66 | | - } |
| 58 | + $this->markReviewed(); |
67 | 59 | } |
68 | 60 | |
69 | | - private function markPatrolled() { |
70 | | - global $wgRequest, $wgOut, $wgUser; |
71 | | - |
72 | | - $token = $wgRequest->getVal('token'); |
73 | | - $wgOut->setPageTitle( wfMsg( 'revreview-patrol-title' ) ); |
74 | | - # Prevent hijacking |
75 | | - if( !$wgUser->matchEditToken( $token, $this->page->getPrefixedText(), $this->rcid ) ) { |
76 | | - $wgOut->addWikiText( wfMsg('sessionfailure') ); |
77 | | - return; |
78 | | - } |
79 | | - # Make sure page is not reviewable. This can be spoofed in theory, |
80 | | - # but the token is salted with the id and title and this should |
81 | | - # be a trusted user...so it is not worth doing extra query work. |
82 | | - $fa = FlaggedArticle::getTitleInstance( $this->page ); |
83 | | - if( $fa->isReviewable() ) { |
84 | | - $wgOut->showErrorPage('notargettitle', 'notargettext' ); |
85 | | - return; |
86 | | - } |
87 | | - # Mark as patrolled |
88 | | - $dbw = wfGetDB( DB_MASTER ); |
89 | | - if( ( $rc = RecentChange::newFromId($this->rcid) ) ) { |
90 | | - $rc->reallyMarkPatrolled(); |
91 | | - // Log this patrol event |
92 | | - PatrolLog::record( $rc, false ); |
93 | | - } |
94 | | - # Inform the user |
95 | | - $wgOut->addWikiText( wfMsg( 'revreview-patrolled', $this->page->getPrefixedText() ) ); |
96 | | - $wgOut->returnToMain( false, SpecialPage::getTitleFor( 'Recentchanges' ) ); |
97 | | - } |
98 | | - |
99 | 61 | private function markReviewed() { |
100 | 62 | global $wgRequest, $wgOut, $wgUser; |
101 | 63 | # Must be in reviewable namespace |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | public static function stripPatrolRights( $user, &$rights ) { |
9 | 9 | # Use only our extension mechanisms |
10 | 10 | foreach( $rights as $n => $right ) { |
11 | | - if( $right == 'patrol' || $right == 'autopatrol' ) { |
| 11 | + if( $right == 'autopatrol' ) { |
12 | 12 | unset($rights[$n]); |
13 | 13 | } |
14 | 14 | } |
— | — | @@ -577,7 +577,7 @@ |
578 | 578 | * Don't let users vandalize pages by moving them |
579 | 579 | */ |
580 | 580 | public static function userCanMove( $title, $user, &$action, &$result ) { |
581 | | - if( $action != 'move' || !FlaggedRevs::isPageReviewable( $title ) ) { |
| 581 | + if( $action != 'move' || $result===false || !FlaggedRevs::isPageReviewable($title) ) { |
582 | 582 | return true; |
583 | 583 | } |
584 | 584 | $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
— | — | @@ -594,6 +594,28 @@ |
595 | 595 | return true; |
596 | 596 | } |
597 | 597 | |
| 598 | + /** |
| 599 | + * Don't let users pages pages not in $wgFlaggedRevsPatrolNamespaces |
| 600 | + */ |
| 601 | + public static function userCanPatrol( $title, $user, &$action, &$result ) { |
| 602 | + if( $action != 'patrol' || $result===false ) { |
| 603 | + return true; |
| 604 | + } |
| 605 | + # Pages in reviewable namespace can be patrolled IF reviewing |
| 606 | + # is disabled for pages that don't show the stable by default. |
| 607 | + # In such cases, we let people with 'review' rights patrol them. |
| 608 | + if( FlaggedRevs::isPageReviewable($title) && !$user->isAllowed( 'review' ) ) { |
| 609 | + $result = false; |
| 610 | + return false; |
| 611 | + } |
| 612 | + $flaggedArticle = FlaggedArticle::getTitleInstance( $title ); |
| 613 | + if( !$flaggedArticle->isPatrollable() ) { |
| 614 | + $result = false; |
| 615 | + return false; |
| 616 | + } |
| 617 | + return true; |
| 618 | + } |
| 619 | + |
598 | 620 | /** |
599 | 621 | * Allow users to view reviewed pages |
600 | 622 | */ |
— | — | @@ -601,7 +623,7 @@ |
602 | 624 | global $wgFlaggedRevsVisible, $wgFlaggedRevsTalkVisible, $wgTitle; |
603 | 625 | # Assume $action may still not be set, in which case, treat it as 'view'... |
604 | 626 | # Return out if $result set to false by some other hooked call. |
605 | | - if( empty($wgFlaggedRevsVisible) || $action !== 'read' || $result===false ) |
| 627 | + if( $action !== 'read' || $result===false || empty($wgFlaggedRevsVisible) ) |
606 | 628 | return true; |
607 | 629 | # Admin may set this to false, rather than array()... |
608 | 630 | $groups = $user->getGroups(); |
— | — | @@ -1229,7 +1251,7 @@ |
1230 | 1252 | public static function onDiffViewHeader( $diff, $oldRev, $newRev ) { |
1231 | 1253 | self::injectStyleAndJS(); |
1232 | 1254 | $flaggedArticle = FlaggedArticle::getTitleInstance( $diff->getTitle() ); |
1233 | | - $flaggedArticle->addPatrolAndDiffLink( $diff, $oldRev, $newRev ); |
| 1255 | + $flaggedArticle->addDiffLink( $diff, $oldRev, $newRev ); |
1234 | 1256 | $flaggedArticle->addDiffNoticeAndIncludes( $diff, $oldRev, $newRev ); |
1235 | 1257 | return true; |
1236 | 1258 | } |