Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -28,30 +28,6 @@ |
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | | -# SELECT parameters... |
33 | | -if ( !defined( 'FR_FOR_UPDATE' ) ) |
34 | | - define( 'FR_FOR_UPDATE', 1 ); |
35 | | -if ( !defined( 'FR_MASTER' ) ) |
36 | | - define( 'FR_MASTER', 2 ); |
37 | | -if ( !defined( 'FR_TEXT' ) ) |
38 | | - define( 'FR_TEXT', 3 ); |
39 | | - |
40 | | -# Level constants... |
41 | | -if ( !defined( 'FR_CHECKED' ) ) |
42 | | - define( 'FR_CHECKED', 0 ); // "basic"/"checked" |
43 | | -if ( !defined( 'FR_QUALITY' ) ) |
44 | | - define( 'FR_QUALITY', 1 ); |
45 | | -if ( !defined( 'FR_PRISTINE' ) ) |
46 | | - define( 'FR_PRISTINE', 2 ); |
47 | | - |
48 | | -# Include settings |
49 | | -if ( !defined( 'FR_INCLUDES_CURRENT' ) ) |
50 | | - define( 'FR_INCLUDES_CURRENT', 0 ); |
51 | | -if ( !defined( 'FR_INCLUDES_FREEZE' ) ) |
52 | | - define( 'FR_INCLUDES_FREEZE', 1 ); |
53 | | -if ( !defined( 'FR_INCLUDES_STABLE' ) ) |
54 | | - define( 'FR_INCLUDES_STABLE', 2 ); |
55 | | - |
56 | 32 | $wgExtensionCredits['specialpage'][] = array( |
57 | 33 | 'path' => __FILE__, |
58 | 34 | 'name' => 'Flagged Revisions', |
— | — | @@ -60,6 +36,9 @@ |
61 | 37 | 'descriptionmsg' => 'flaggedrevs-desc', |
62 | 38 | ); |
63 | 39 | |
| 40 | +# Load global constants |
| 41 | +include_once( "FlaggedRevsDefines.php" ); |
| 42 | + |
64 | 43 | # ######## Configuration variables ######## |
65 | 44 | # IMPORTANT: DO NOT EDIT THIS FILE |
66 | 45 | # When configuring globals, set them at LocalSettings.php instead |
— | — | @@ -87,12 +66,19 @@ |
88 | 67 | # Can users make comments that will show up below flagged revisions? |
89 | 68 | # NOTE: this is NOT the same as the simple log comment |
90 | 69 | $wgFlaggedRevsComments = false; // @TODO: remove when ready? |
91 | | -# Auto-review edits that are: |
92 | | -# (a) directly to the stable version by users with 'autoreview'/'bot' |
93 | | -# (b) self-reversions back to the stable version by any user |
94 | | -$wgFlaggedRevsAutoReview = true; |
95 | | -# If $wgFlaggedRevsAutoReview, auto-review new pages as minimally "checked"? |
96 | | -$wgFlaggedRevsAutoReviewNew = true; |
| 70 | +# Auto-review settings for edits/new pages: |
| 71 | +# FR_AUTOREVIEW_NONE |
| 72 | +# Don't auto-review any edits or new pages |
| 73 | +# FR_AUTOREVIEW_CHANGES |
| 74 | +# Auto-review the following types of edits (to existing pages): |
| 75 | +# (a) changes directly to the stable version by users with 'autoreview'/'bot' |
| 76 | +# (b) reversions to old reviewed versions by users with 'autoreview'/'bot' |
| 77 | +# (c) self-reversions back to the stable version by any user |
| 78 | +# FR_AUTOREVIEW_CREATION |
| 79 | +# Auto-review new pages as minimally "checked" |
| 80 | +# FR_AUTOREVIEW_BOTH |
| 81 | +# Combines FR_AUTOREVIEW_CHANGES and FR_AUTOREVIEW_CREATION |
| 82 | +$wgFlaggedRevsAutoReview = FR_AUTOREVIEW_BOTH; |
97 | 83 | |
98 | 84 | # Define the tags we can use to rate an article, number of levels, |
99 | 85 | # and set the minimum level to have it become a "quality" or "pristine" version. |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -19,6 +19,8 @@ |
20 | 20 | protected static $patrolNamespaces = array(); |
21 | 21 | # Restriction levels/config |
22 | 22 | protected static $restrictionLevels = array(); |
| 23 | + # Autoreview config |
| 24 | + protected static $autoReviewConfig = 0; |
23 | 25 | |
24 | 26 | protected static $loaded = false; |
25 | 27 | |
— | — | @@ -108,10 +110,18 @@ |
109 | 111 | self::$reviewNamespaces = $wgFlaggedRevsNamespaces; |
110 | 112 | # Note: reviewable *pages* override patrollable ones |
111 | 113 | self::$patrolNamespaces = $wgFlaggedRevsPatrolNamespaces; |
112 | | - # !$wgFlaggedRevsAutoReview => !$wgFlaggedRevsAutoReviewNew |
| 114 | + # B/C for $wgFlaggedRevsAutoReview |
113 | 115 | global $wgFlaggedRevsAutoReview, $wgFlaggedRevsAutoReviewNew; |
114 | | - if ( !$wgFlaggedRevsAutoReview ) { |
115 | | - $wgFlaggedRevsAutoReviewNew = false; |
| 116 | + if ( is_int( $wgFlaggedRevsAutoReview ) ) { |
| 117 | + self::$autoReviewConfig = $wgFlaggedRevsAutoReview; |
| 118 | + } else { |
| 119 | + if ( $wgFlaggedRevsAutoReview ) { |
| 120 | + self::$autoReviewConfig |= FR_AUTOREVIEW_CHANGES; // b/c |
| 121 | + } |
| 122 | + if ( $wgFlaggedRevsAutoReviewNew ) { |
| 123 | + self::$autoReviewConfig |= FR_AUTOREVIEW_CREATION; // b/c |
| 124 | + } |
| 125 | + wfWarn( '$wgFlaggedRevsAutoReview is now a bitfield instead of a boolean. $wgFlaggedRevsAutoReviewNew is deprecated.' ); |
116 | 126 | } |
117 | 127 | } |
118 | 128 | |
— | — | @@ -162,8 +172,8 @@ |
163 | 173 | * @returns bool |
164 | 174 | */ |
165 | 175 | public static function autoReviewEdits() { |
166 | | - global $wgFlaggedRevsAutoReview; |
167 | | - return (bool)$wgFlaggedRevsAutoReview; |
| 176 | + self::load(); |
| 177 | + return self::$autoReviewConfig & FR_AUTOREVIEW_CHANGES; |
168 | 178 | } |
169 | 179 | |
170 | 180 | /** |
— | — | @@ -171,11 +181,19 @@ |
172 | 182 | * @returns bool |
173 | 183 | */ |
174 | 184 | public static function autoReviewNewPages() { |
175 | | - global $wgFlaggedRevsAutoReviewNew; |
176 | | - return (bool)$wgFlaggedRevsAutoReviewNew; |
| 185 | + self::load(); |
| 186 | + return self::$autoReviewConfig & FR_AUTOREVIEW_CREATION; |
177 | 187 | } |
178 | 188 | |
179 | 189 | /** |
| 190 | + * Auto-review of new pages or edits to pages enabled? |
| 191 | + * @returns bool |
| 192 | + */ |
| 193 | + public static function autoReviewEnabled() { |
| 194 | + return self::autoReviewEdits() || self::autoReviewNewPages(); |
| 195 | + } |
| 196 | + |
| 197 | + /** |
180 | 198 | * Get the maximum level that $tag can be autoreviewed to |
181 | 199 | * @param string $tag |
182 | 200 | * @returns int |
— | — | @@ -183,8 +201,8 @@ |
184 | 202 | public static function maxAutoReviewLevel( $tag ) { |
185 | 203 | global $wgFlaggedRevsTagsAuto; |
186 | 204 | self::load(); |
187 | | - if ( !self::autoReviewEdits() ) { |
188 | | - return 0; // no auto-review allowed at all |
| 205 | + if ( !self::autoReviewEnabled() ) { |
| 206 | + return 0; // shouldn't happen |
189 | 207 | } |
190 | 208 | if ( isset( $wgFlaggedRevsTagsAuto[$tag] ) ) { |
191 | 209 | return (int)$wgFlaggedRevsTagsAuto[$tag]; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -618,7 +618,7 @@ |
619 | 619 | } |
620 | 620 | } |
621 | 621 | # All cases below require auto-review of edits to be enabled |
622 | | - if ( !FlaggedRevs::autoReviewEdits() ) { |
| 622 | + if ( !FlaggedRevs::autoReviewEnabled() ) { |
623 | 623 | return true; |
624 | 624 | } |
625 | 625 | # If a $baseRevId is passed in, the edit is using an old revision's text |
— | — | @@ -653,7 +653,9 @@ |
654 | 654 | } elseif ( $baseRevId ) { |
655 | 655 | $reviewableNewPage = false; // had previous rev |
656 | 656 | # Check if the base revision was reviewed... |
657 | | - $frev = FlaggedRevision::newFromTitle( $title, $baseRevId, FR_MASTER ); |
| 657 | + if ( FlaggedRevs::autoReviewEdits() ) { |
| 658 | + $frev = FlaggedRevision::newFromTitle( $title, $baseRevId, FR_MASTER ); |
| 659 | + } |
658 | 660 | $reviewableChange = (bool)$frev; |
659 | 661 | } |
660 | 662 | // Is this an edit directly to a reviewed version or a new page? |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsDefines.php |
— | — | @@ -0,0 +1,25 @@ |
| 2 | +<?php |
| 3 | +/* |
| 4 | +* Defines global constants, some of which are used in LocalSettings.php |
| 5 | +*/ |
| 6 | + |
| 7 | +# Query SELECT parameters... |
| 8 | +define( 'FR_FOR_UPDATE', 1 ); |
| 9 | +define( 'FR_MASTER', 2 ); |
| 10 | +define( 'FR_TEXT', 3 ); |
| 11 | + |
| 12 | +# Review tier constants... |
| 13 | +define( 'FR_CHECKED', 0 ); // "basic"/"checked" |
| 14 | +define( 'FR_QUALITY', 1 ); |
| 15 | +define( 'FR_PRISTINE', 2 ); |
| 16 | + |
| 17 | +# Inclusion (templates/files) settings |
| 18 | +define( 'FR_INCLUDES_CURRENT', 0 ); |
| 19 | +define( 'FR_INCLUDES_FREEZE', 1 ); |
| 20 | +define( 'FR_INCLUDES_STABLE', 2 ); |
| 21 | + |
| 22 | +# Autoreview settings for priviledged users |
| 23 | +define( 'FR_AUTOREVIEW_NONE', 0 ); |
| 24 | +define( 'FR_AUTOREVIEW_CHANGES', 1 ); |
| 25 | +define( 'FR_AUTOREVIEW_CREATION', 2 ); |
| 26 | +define( 'FR_AUTOREVIEW_BOTH', FR_AUTOREVIEW_CHANGES | FR_AUTOREVIEW_CREATION ); |
Property changes on: trunk/extensions/FlaggedRevs/FlaggedRevsDefines.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 27 | + native |