Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -40,15 +40,23 @@ |
41 | 41 | # Load default configuration variables |
42 | 42 | require( "FlaggedRevs.config.php" ); |
43 | 43 | |
44 | | -# This messes with dump HTML... |
| 44 | +# XXX: Don't mess with dump HTML... |
45 | 45 | if ( defined( 'MW_HTML_FOR_DUMP' ) ) { |
46 | | - return; |
| 46 | + return; // done after default config set to avoid LocalSettings errors |
47 | 47 | } |
48 | 48 | |
49 | | -# Bots are granted autoreview via hooks, mark in rights |
50 | | -# array so that it shows up in sp:ListGroupRights... |
51 | | -$wgGroupPermissions['bot']['autoreview'] = true; |
| 49 | +# Define were classes and i18n files are located |
| 50 | +require( "FlaggedRevs.setup.php" ); |
| 51 | +FlaggedRevsSetup::defineSourcePaths( |
| 52 | + $wgAutoloadClasses, |
| 53 | + $wgExtensionMessagesFiles, |
| 54 | + $wgExtensionAliasesFiles |
| 55 | +); |
52 | 56 | |
| 57 | +# Load hooks that are always set |
| 58 | +FlaggedRevsSetup::setUnconditionalHooks(); |
| 59 | + |
| 60 | +# Define new rights that FlaggedRevs creates |
53 | 61 | $wgAvailableRights[] = 'review'; # review pages to basic quality levels |
54 | 62 | $wgAvailableRights[] = 'validate'; # review pages to all quality levels |
55 | 63 | $wgAvailableRights[] = 'autoreview'; # auto-review one's own edits (including rollback) |
— | — | @@ -57,122 +65,10 @@ |
58 | 66 | $wgAvailableRights[] = 'movestable'; # move pages with stable versions |
59 | 67 | $wgAvailableRights[] = 'stablesettings'; # change page stability settings |
60 | 68 | |
61 | | -$wgExtensionFunctions[] = 'efLoadFlaggedRevs'; |
| 69 | +# Bots are granted autoreview via hooks, mark in rights |
| 70 | +# array so that it shows up in sp:ListGroupRights... |
| 71 | +$wgGroupPermissions['bot']['autoreview'] = true; |
62 | 72 | |
63 | | -$dir = dirname( __FILE__ ) . '/'; |
64 | | -$langDir = $dir . 'presentation/language/'; |
65 | | - |
66 | | -# Load main i18n file and special page alias file |
67 | | -$wgExtensionMessagesFiles['FlaggedRevs'] = $langDir . 'FlaggedRevs.i18n.php'; |
68 | | -$wgExtensionAliasesFiles['FlaggedRevs'] = $langDir . 'FlaggedRevs.alias.php'; |
69 | | - |
70 | | -$accessDir = $dir . 'dataclasses/'; |
71 | | -# Utility classes... |
72 | | -$wgAutoloadClasses['FlaggedRevs'] = $accessDir . 'FlaggedRevs.class.php'; |
73 | | -$wgAutoloadClasses['FRUserCounters'] = $accessDir . 'FRUserCounters.php'; |
74 | | -$wgAutoloadClasses['FRUserActivity'] = $accessDir . 'FRUserActivity.php'; |
75 | | -$wgAutoloadClasses['FRPageConfig'] = $accessDir . 'FRPageConfig.php'; |
76 | | -$wgAutoloadClasses['FlaggedRevsLog'] = $accessDir . 'FlaggedRevsLog.php'; |
77 | | -$wgAutoloadClasses['FRInclusionCache'] = $accessDir . 'FRInclusionCache.php'; |
78 | | -$wgAutoloadClasses['FlaggedRevsStats'] = $accessDir . 'FlaggedRevsStats.php'; |
79 | | -# Data object classes... |
80 | | -$wgAutoloadClasses['FRExtraCacheUpdate'] = $accessDir . 'FRExtraCacheUpdate.php'; |
81 | | -$wgAutoloadClasses['FRExtraCacheUpdateJob'] = $accessDir . 'FRExtraCacheUpdate.php'; |
82 | | -$wgAutoloadClasses['FRSquidUpdate'] = $accessDir . 'FRExtraCacheUpdate.php'; |
83 | | -$wgAutoloadClasses['FRDependencyUpdate'] = $accessDir . 'FRDependencyUpdate.php'; |
84 | | -$wgAutoloadClasses['FRInclusionManager'] = $accessDir . 'FRInclusionManager.php'; |
85 | | -$wgAutoloadClasses['FlaggableWikiPage'] = $accessDir . 'FlaggableWikiPage.php'; |
86 | | -$wgAutoloadClasses['FlaggedRevision'] = $accessDir . 'FlaggedRevision.php'; |
87 | | -$wgAutoloadClasses['FRParserCacheStable'] = $accessDir . 'FRParserCacheStable.php'; |
88 | | - |
89 | | -# Event handler classes... |
90 | | -$wgAutoloadClasses['FlaggedRevsHooks'] = $dir . 'dataclasses/FlaggedRevs.hooks.php'; |
91 | | -$wgAutoloadClasses['FlaggedRevsUIHooks'] = $dir . 'presentation/FlaggedRevsUI.hooks.php'; |
92 | | -$wgAutoloadClasses['FlaggedRevsApiHooks'] = $dir . 'api/FlaggedRevsApi.hooks.php'; |
93 | | -$wgAutoloadClasses['FlaggedRevsUpdaterHooks'] = $dir . 'schema/FlaggedRevsUpdater.hooks.php'; |
94 | | -$wgAutoloadClasses['FlaggedRevsTestHooks'] = $dir . 'tests/FlaggedRevsTest.hooks.php'; |
95 | | - |
96 | | -# Business object classes |
97 | | -$wgAutoloadClasses['FRGenericSubmitForm'] = $dir . 'business/FRGenericSubmitForm.php'; |
98 | | -$wgAutoloadClasses['RevisionReviewForm'] = $dir . 'business/RevisionReviewForm.php'; |
99 | | -$wgAutoloadClasses['PageStabilityForm'] = $dir . 'business/PageStabilityForm.php'; |
100 | | -$wgAutoloadClasses['PageStabilityGeneralForm'] = $dir . 'business/PageStabilityForm.php'; |
101 | | -$wgAutoloadClasses['PageStabilityProtectForm'] = $dir . 'business/PageStabilityForm.php'; |
102 | | - |
103 | | -# Presentation classes... |
104 | | -$wgAutoloadClasses['FlaggedRevsUISetup'] = $dir . 'presentation/FlaggedRevsUI.setup.php'; |
105 | | -$wgAutoloadClasses['FlaggablePageView'] = $dir . 'presentation/FlaggablePageView.php'; |
106 | | -$wgAutoloadClasses['FlaggedRevsLogView'] = $dir . 'presentation/FlaggedRevsLogView.php'; |
107 | | -$wgAutoloadClasses['FlaggedRevsXML'] = $dir . 'presentation/FlaggedRevsXML.php'; |
108 | | -$wgAutoloadClasses['RevisionReviewFormUI'] = $dir . 'presentation/RevisionReviewFormUI.php'; |
109 | | -$wgAutoloadClasses['RejectConfirmationFormUI'] = $dir . 'presentation/RejectConfirmationFormUI.php'; |
110 | | - |
111 | | -$specialActionDir = $dir . 'presentation/specialpages/actions/'; |
112 | | -# Load revision review UI |
113 | | -$wgAutoloadClasses['RevisionReview'] = $specialActionDir . 'RevisionReview_body.php'; |
114 | | -$wgExtensionMessagesFiles['RevisionReview'] = $langDir . 'RevisionReview.i18n.php'; |
115 | | -# Stable version config UI |
116 | | -$wgAutoloadClasses['Stabilization'] = $specialActionDir . 'Stabilization_body.php'; |
117 | | -$wgExtensionMessagesFiles['Stabilization'] = $langDir . 'Stabilization.i18n.php'; |
118 | | - |
119 | | -$specialReportDir = $dir . 'presentation/specialpages/reports/'; |
120 | | -# Reviewed versions list |
121 | | -$wgAutoloadClasses['ReviewedVersions'] = $specialReportDir . 'ReviewedVersions_body.php'; |
122 | | -$wgExtensionMessagesFiles['ReviewedVersions'] = $langDir . 'ReviewedVersions.i18n.php'; |
123 | | -# Unreviewed pages list |
124 | | -$wgAutoloadClasses['UnreviewedPages'] = $specialReportDir . 'UnreviewedPages_body.php'; |
125 | | -$wgExtensionMessagesFiles['UnreviewedPages'] = $langDir . 'UnreviewedPages.i18n.php'; |
126 | | -# Pages with pending changes list |
127 | | -$wgAutoloadClasses['PendingChanges'] = $specialReportDir . 'PendingChanges_body.php'; |
128 | | -$wgExtensionMessagesFiles['PendingChanges'] = $langDir . 'PendingChanges.i18n.php'; |
129 | | -# Pages with tagged pending changes list |
130 | | -$wgAutoloadClasses['ProblemChanges'] = $specialReportDir . 'ProblemChanges_body.php'; |
131 | | -$wgExtensionMessagesFiles['ProblemChanges'] = $langDir . 'ProblemChanges.i18n.php'; |
132 | | -# Reviewed pages list |
133 | | -$wgAutoloadClasses['ReviewedPages'] = $specialReportDir . 'ReviewedPages_body.php'; |
134 | | -$wgExtensionMessagesFiles['ReviewedPages'] = $langDir . 'ReviewedPages.i18n.php'; |
135 | | -# Stable pages list (for protection config) |
136 | | -$wgAutoloadClasses['StablePages'] = $specialReportDir . 'StablePages_body.php'; |
137 | | -$wgExtensionMessagesFiles['StablePages'] = $langDir . 'StablePages.i18n.php'; |
138 | | -# Configured pages list (non-protection config) |
139 | | -$wgAutoloadClasses['ConfiguredPages'] = $specialReportDir . 'ConfiguredPages_body.php'; |
140 | | -$wgExtensionMessagesFiles['ConfiguredPages'] = $langDir . 'ConfiguredPages.i18n.php'; |
141 | | -# Filterable review log page to oversee reviews |
142 | | -$wgAutoloadClasses['QualityOversight'] = $specialReportDir . 'QualityOversight_body.php'; |
143 | | -$wgExtensionMessagesFiles['QualityOversight'] = $langDir . 'QualityOversight.i18n.php'; |
144 | | -# Review statistics |
145 | | -$wgAutoloadClasses['ValidationStatistics'] = $specialReportDir . 'ValidationStatistics_body.php'; |
146 | | -$wgExtensionMessagesFiles['ValidationStatistics'] = $langDir . 'ValidationStatistics.i18n.php'; |
147 | | - |
148 | | -$apiActionDir = $dir . 'api/actions/'; |
149 | | -# Page review module for API |
150 | | -$wgAutoloadClasses['ApiReview'] = $apiActionDir . 'ApiReview.php'; |
151 | | -$wgAPIModules['review'] = 'ApiReview'; |
152 | | -# Page review activity module for API |
153 | | -$wgAutoloadClasses['ApiReviewActivity'] = $apiActionDir . 'ApiReviewActivity.php'; |
154 | | -$wgAPIModules['reviewactivity'] = 'ApiReviewActivity'; |
155 | | -# Stability config module for API |
156 | | -$wgAutoloadClasses['ApiStabilize'] = $apiActionDir . 'ApiStabilize.php'; |
157 | | -$wgAutoloadClasses['ApiStabilizeGeneral'] = $apiActionDir . 'ApiStabilize.php'; |
158 | | -$wgAutoloadClasses['ApiStabilizeProtect'] = $apiActionDir . 'ApiStabilize.php'; |
159 | | - |
160 | | -$apiReportDir = $dir . 'api/reports/'; |
161 | | -# OldReviewedPages for API |
162 | | -$wgAutoloadClasses['ApiQueryOldreviewedpages'] = $apiReportDir . 'ApiQueryOldreviewedpages.php'; |
163 | | -$wgAPIListModules['oldreviewedpages'] = 'ApiQueryOldreviewedpages'; |
164 | | -# UnreviewedPages for API |
165 | | -$wgAutoloadClasses['ApiQueryUnreviewedpages'] = $apiReportDir . 'ApiQueryUnreviewedpages.php'; |
166 | | -# ReviewedPages for API |
167 | | -$wgAutoloadClasses['ApiQueryReviewedpages'] = $apiReportDir . 'ApiQueryReviewedpages.php'; |
168 | | -# ConfiguredPages for API |
169 | | -$wgAutoloadClasses['ApiQueryConfiguredpages'] = $apiReportDir . 'ApiQueryConfiguredPages.php'; |
170 | | -# Flag metadata for pages for API |
171 | | -$wgAutoloadClasses['ApiQueryFlagged'] = $apiReportDir . 'ApiQueryFlagged.php'; |
172 | | -$wgAPIPropModules['flagged'] = 'ApiQueryFlagged'; |
173 | | -# Site flag config for API |
174 | | -$wgAutoloadClasses['ApiFlagConfig'] = $apiReportDir . 'ApiFlagConfig.php'; |
175 | | -$wgAPIModules['flagconfig'] = 'ApiFlagConfig'; |
176 | | - |
177 | 73 | # Special case cache invalidations |
178 | 74 | $wgJobClasses['flaggedrevs_CacheUpdate'] = 'FRExtraCacheUpdateJob'; |
179 | 75 | |
— | — | @@ -194,197 +90,33 @@ |
195 | 91 | # JS/CSS modules and message bundles used by JS scripts |
196 | 92 | FlaggedRevsUISetup::defineResourceModules( $wgResourceModules ); |
197 | 93 | |
198 | | -# ####### HOOK CALLBACK FUNCTIONS ######### |
| 94 | +# Load the extension after setup is finished |
| 95 | +$wgExtensionFunctions[] = 'efLoadFlaggedRevs'; |
199 | 96 | |
200 | | -# ######## API ######## |
201 | | -# Add flagging data to ApiQueryRevisions |
202 | | -$wgHooks['APIGetAllowedParams'][] = 'FlaggedRevsApiHooks::addApiRevisionParams'; |
203 | | -$wgHooks['APIQueryAfterExecute'][] = 'FlaggedRevsApiHooks::addApiRevisionData'; |
204 | | -# ######## |
205 | | - |
206 | | -# ######## Parser ######### |
207 | | -# Parser hooks, selects the desired images/templates |
208 | | -$wgHooks['BeforeParserFetchTemplateAndtitle'][] = 'FlaggedRevsHooks::parserFetchStableTemplate'; |
209 | | -$wgHooks['BeforeParserFetchFileAndTitle'][] = 'FlaggedRevsHooks::parserFetchStableFile'; |
210 | | -# B/C for before ParserOutput::mImageTimeKeys |
211 | | -$wgHooks['OutputPageParserOutput'][] = 'FlaggedRevsHooks::outputSetVersioningFlag'; |
212 | | -# ######## |
213 | | - |
214 | | -# ######## DB write operations ######### |
215 | | -# Autopromote Editors |
216 | | -$wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::onArticleSaveComplete'; |
217 | | -# Auto-reviewing |
218 | | -$wgHooks['RecentChange_save'][] = 'FlaggedRevsHooks::autoMarkPatrolled'; |
219 | | -$wgHooks['NewRevisionFromEditComplete'][] = 'FlaggedRevsHooks::maybeMakeEditReviewed'; |
220 | | -# Null edit review via checkbox |
221 | | -$wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::maybeNullEditReview'; |
222 | | -# User edit tallies |
223 | | -$wgHooks['ArticleRollbackComplete'][] = 'FlaggedRevsHooks::incrementRollbacks'; |
224 | | -$wgHooks['NewRevisionFromEditComplete'][] = 'FlaggedRevsHooks::incrementReverts'; |
225 | | -# Update fr_page_id and tracking rows on revision restore and merge |
226 | | -$wgHooks['ArticleRevisionUndeleted'][] = 'FlaggedRevsHooks::onRevisionRestore'; |
227 | | -$wgHooks['ArticleMergeComplete'][] = 'FlaggedRevsHooks::onArticleMergeComplete'; |
228 | | - |
229 | | -# Update tracking rows and cache on page changes (@TODO: this sucks): |
230 | | -# Article edit/create |
231 | | -$wgHooks['ArticleEditUpdates'][] = 'FlaggedRevsHooks::onArticleEditUpdates'; |
232 | | -# Article delete/restore |
233 | | -$wgHooks['ArticleDeleteComplete'][] = 'FlaggedRevsHooks::onArticleDelete'; |
234 | | -$wgHooks['ArticleUndelete'][] = 'FlaggedRevsHooks::onArticleUndelete'; |
235 | | -# Revision delete/restore |
236 | | -$wgHooks['ArticleRevisionVisibilitySet'][] = 'FlaggedRevsHooks::onRevisionDelete'; |
237 | | -# Article move |
238 | | -$wgHooks['TitleMoveComplete'][] = 'FlaggedRevsHooks::onTitleMoveComplete'; |
239 | | -# File upload |
240 | | -$wgHooks['FileUpload'][] = 'FlaggedRevsHooks::onFileUpload'; |
241 | | -# ######## |
242 | | - |
243 | | -# ######## Other ######### |
244 | | -# Determine what pages can be moved and patrolled |
245 | | -$wgHooks['getUserPermissionsErrors'][] = 'FlaggedRevsHooks::onUserCan'; |
246 | | -# Implicit autoreview rights group |
247 | | -$wgHooks['AutopromoteCondition'][] = 'FlaggedRevsHooks::checkAutoPromoteCond'; |
248 | | - |
249 | | -# Stable dump hook |
250 | | -$wgHooks['WikiExporter::dumpStableQuery'][] = 'FlaggedRevsHooks::stableDumpQuery'; |
251 | | - |
252 | | -# GNSM category hooks |
253 | | -$wgHooks['GoogleNewsSitemap::Query'][] = 'FlaggedRevsHooks::gnsmQueryModifier'; |
254 | | - |
255 | | -# Duplicate flagged* tables in parserTests.php |
256 | | -$wgHooks['ParserTestTables'][] = 'FlaggedRevsTestHooks::onParserTestTables'; |
257 | | -# Integration tests |
258 | | -$wgHooks['UnitTestsList'][] = 'FlaggedRevsTestHooks::getUnitTests'; |
259 | | - |
260 | | -# Database schema changes |
261 | | -$wgHooks['LoadExtensionSchemaUpdates'][] = 'FlaggedRevsUpdaterHooks::addSchemaUpdates'; |
262 | | -# ######## |
263 | | - |
264 | | -function efSetFlaggedRevsConditionalHooks() { |
265 | | - global $wgHooks; |
266 | | - |
267 | | - # ######## User interface ######### |
268 | | - FlaggedRevsUISetup::defineHookHandlers( $wgHooks ); |
269 | | - # ######## |
270 | | - |
271 | | - # Give bots the 'autoreview' right (here so it triggers after CentralAuth) |
272 | | - # @TODO: better way to ensure hook order |
273 | | - $wgHooks['UserGetRights'][] = 'FlaggedRevsHooks::onUserGetRights'; |
274 | | -} |
275 | | - |
276 | | -# ####### END HOOK CALLBACK FUNCTIONS ######### |
277 | | - |
278 | | -// Note: avoid calls to FlaggedRevs class here for performance |
| 97 | +/* |
| 98 | + * This function is for setup that has to happen in Setup.php |
| 99 | + * when the functions in $wgExtensionFunctions get executed. |
| 100 | + * Note: avoid calls to FlaggedRevs class here for performance. |
| 101 | + */ |
279 | 102 | function efLoadFlaggedRevs() { |
280 | 103 | # LocalSettings.php loaded, safe to load config |
281 | 104 | FlaggedRevs::ready(); |
282 | 105 | |
283 | 106 | # Conditional autopromote groups |
284 | | - efSetFlaggedRevsAutopromoteConfig(); |
| 107 | + FlaggedRevsSetup::setAutopromoteConfig(); |
285 | 108 | |
286 | 109 | # Register special pages (some are conditional) |
287 | | - efSetFlaggedRevsSpecialPages(); |
| 110 | + FlaggedRevsSetup::setSpecialPages(); |
288 | 111 | # Conditional API modules |
289 | | - efSetFlaggedRevsConditionalAPIModules(); |
| 112 | + FlaggedRevsSetup::setAPIModules(); |
290 | 113 | # Load hooks that aren't always set |
291 | | - efSetFlaggedRevsConditionalHooks(); |
| 114 | + FlaggedRevsSetup::setConditionalHooks(); |
292 | 115 | # Remove conditionally applicable rights |
293 | | - efSetFlaggedRevsConditionalRights(); |
| 116 | + FlaggedRevsSetup::setConditionalRights(); |
294 | 117 | # Defaults for user preferences |
295 | | - efSetFlaggedRevsConditionalPreferences(); |
| 118 | + FlaggedRevsSetup::setConditionalPreferences(); |
296 | 119 | } |
297 | 120 | |
298 | | -function efSetFlaggedRevsAutopromoteConfig() { |
299 | | - global $wgFlaggedRevsAutoconfirm, $wgFlaggedRevsAutopromote; |
300 | | - global $wgAutopromoteOnce, $wgGroupPermissions; |
301 | | - # $wgFlaggedRevsAutoconfirm is now a wrapper around $wgAutopromoteOnce |
302 | | - $req = $wgFlaggedRevsAutoconfirm; // convenience |
303 | | - if ( is_array( $req ) ) { |
304 | | - $criteria = array( '&', // AND |
305 | | - array( APCOND_AGE, $req['days']*86400 ), |
306 | | - array( APCOND_EDITCOUNT, $req['edits'], $req['excludeLastDays']*86400 ), |
307 | | - array( APCOND_FR_EDITSUMMARYCOUNT, $req['editComments'] ), |
308 | | - array( APCOND_FR_UNIQUEPAGECOUNT, $req['uniqueContentPages'] ), |
309 | | - array( APCOND_FR_EDITSPACING, $req['spacing'], $req['benchmarks'] ), |
310 | | - array( '|', // OR |
311 | | - array( APCOND_FR_CONTENTEDITCOUNT, |
312 | | - $req['totalContentEdits'], $req['excludeLastDays']*86400 ), |
313 | | - array( APCOND_FR_CHECKEDEDITCOUNT, |
314 | | - $req['totalCheckedEdits'], $req['excludeLastDays']*86400 ) |
315 | | - ), |
316 | | - ); |
317 | | - if ( $req['email'] ) { |
318 | | - $criteria[] = array( APCOND_EMAILCONFIRMED ); |
319 | | - } |
320 | | - if ( $req['neverBlocked'] ) { |
321 | | - $criteria[] = array( APCOND_FR_NEVERBOCKED ); |
322 | | - } |
323 | | - $wgAutopromoteOnce['onEdit']['autoreview'] = $criteria; |
324 | | - $wgGroupPermissions['autoreview']['autoreview'] = true; |
325 | | - } |
326 | | - |
327 | | - # $wgFlaggedRevsAutoconfirm is now a wrapper around $wgAutopromoteOnce |
328 | | - $req = $wgFlaggedRevsAutopromote; // convenience |
329 | | - if ( is_array( $req ) ) { |
330 | | - $criteria = array( '&', // AND |
331 | | - array( APCOND_AGE, $req['days']*86400 ), |
332 | | - array( APCOND_FR_EDITCOUNT, $req['edits'], $req['excludeLastDays']*86400 ), |
333 | | - array( APCOND_FR_EDITSUMMARYCOUNT, $req['editComments'] ), |
334 | | - array( APCOND_FR_UNIQUEPAGECOUNT, $req['uniqueContentPages'] ), |
335 | | - array( APCOND_FR_USERPAGEBYTES, $req['userpageBytes'] ), |
336 | | - array( APCOND_FR_NEVERDEMOTED ), // for b/c |
337 | | - array( APCOND_FR_EDITSPACING, $req['spacing'], $req['benchmarks'] ), |
338 | | - array( '|', // OR |
339 | | - array( APCOND_FR_CONTENTEDITCOUNT, |
340 | | - $req['totalContentEdits'], $req['excludeLastDays']*86400 ), |
341 | | - array( APCOND_FR_CHECKEDEDITCOUNT, |
342 | | - $req['totalCheckedEdits'], $req['excludeLastDays']*86400 ) |
343 | | - ), |
344 | | - array( APCOND_FR_MAXREVERTEDEDITRATIO, $req['maxRevertedEditRatio'] ), |
345 | | - array( '!', APCOND_ISBOT ) |
346 | | - ); |
347 | | - if ( $req['neverBlocked'] ) { |
348 | | - $criteria[] = array( APCOND_FR_NEVERBOCKED ); |
349 | | - } |
350 | | - $wgAutopromoteOnce['onEdit']['editor'] = $criteria; |
351 | | - } |
352 | | -} |
353 | | - |
354 | | -function efSetFlaggedRevsConditionalAPIModules() { |
355 | | - global $wgAPIModules, $wgAPIListModules, $wgFlaggedRevsProtection; |
356 | | - if ( $wgFlaggedRevsProtection ) { |
357 | | - $wgAPIModules['stabilize'] = 'ApiStabilizeProtect'; |
358 | | - } else { |
359 | | - $wgAPIModules['stabilize'] = 'ApiStabilizeGeneral'; |
360 | | - $wgAPIListModules['reviewedpages'] = 'ApiQueryReviewedpages'; |
361 | | - $wgAPIListModules['unreviewedpages'] = 'ApiQueryUnreviewedpages'; |
362 | | - $wgAPIListModules['configuredpages'] = 'ApiQueryConfiguredpages'; |
363 | | - } |
364 | | -} |
365 | | - |
366 | | -function efSetFlaggedRevsSpecialPages() { |
367 | | - global $wgSpecialPages, $wgSpecialPageGroups; |
368 | | - FlaggedRevsUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups ); |
369 | | -} |
370 | | - |
371 | | -function efSetFlaggedRevsConditionalRights() { |
372 | | - global $wgGroupPermissions, $wgFlaggedRevsProtection; |
373 | | - if ( $wgFlaggedRevsProtection ) { |
374 | | - // Removes sp:ListGroupRights cruft |
375 | | - if ( isset( $wgGroupPermissions['editor'] ) ) { |
376 | | - unset( $wgGroupPermissions['editor']['unreviewedpages'] ); |
377 | | - } |
378 | | - if ( isset( $wgGroupPermissions['reviewer'] ) ) { |
379 | | - unset( $wgGroupPermissions['reviewer']['unreviewedpages'] ); |
380 | | - } |
381 | | - } |
382 | | -} |
383 | | - |
384 | | -function efSetFlaggedRevsConditionalPreferences() { |
385 | | - global $wgDefaultUserOptions, $wgSimpleFlaggedRevsUI; |
386 | | - $wgDefaultUserOptions['flaggedrevssimpleui'] = (int)$wgSimpleFlaggedRevsUI; |
387 | | -} |
388 | | - |
389 | 121 | # AJAX functions |
390 | 122 | $wgAjaxExportList[] = 'RevisionReview::AjaxReview'; |
391 | 123 | $wgAjaxExportList[] = 'FlaggablePageView::AjaxBuildDiffHeaderItems'; |
Index: trunk/extensions/FlaggedRevs/tests/FlaggedRevsSetupTest.php |
— | — | @@ -0,0 +1,24 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class FlaggedRevsSetupTest extends PHPUnit_Framework_TestCase { |
| 5 | + /** |
| 6 | + * Constructs the test case. |
| 7 | + */ |
| 8 | + public function __construct() {} |
| 9 | + |
| 10 | + public function testDefineSourcePaths() { |
| 11 | + $autoloadClasses = $messagesFiles = $aliasesFiles = array(); |
| 12 | + FlaggedRevsSetup::defineSourcePaths( $autoloadClasses, $messagesFiles, $aliasesFiles ); |
| 13 | + $fileLists = array( |
| 14 | + '$autoloadClasses' => $autoloadClasses, |
| 15 | + '$messageFiles' => $messagesFiles, |
| 16 | + '$aliasFiles' => $aliasesFiles |
| 17 | + ); |
| 18 | + foreach ( $fileLists as $listName => $list ) { |
| 19 | + $this->assertNotEmpty( $list, "$listName variable is not empty" ); |
| 20 | + foreach ( $list as $name => $file ) { |
| 21 | + $this->assertEquals( true, file_exists( $file ), "$file exists" ); |
| 22 | + } |
| 23 | + } |
| 24 | + } |
| 25 | +} |
Property changes on: trunk/extensions/FlaggedRevs/tests/FlaggedRevsSetupTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 26 | + native |
Index: trunk/extensions/FlaggedRevs/tests/FlaggedRevsTest.hooks.php |
— | — | @@ -9,6 +9,7 @@ |
10 | 10 | $files[] = dirname( __FILE__ ) . '/FRUserActivityTest.php'; |
11 | 11 | $files[] = dirname( __FILE__ ) . '/FRParserCacheStableTest.php'; |
12 | 12 | $files[] = dirname( __FILE__ ) . '/FlaggedPageTest.php'; |
| 13 | + $files[] = dirname( __FILE__ ) . '/FlaggedRevsSetupTest.php'; |
13 | 14 | return true; |
14 | 15 | } |
15 | 16 | |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php |
— | — | @@ -0,0 +1,356 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Class containing basic setup functions for a FlaggedRevs environment. |
| 5 | + * This class depends on config variables in LocalSettings.php. |
| 6 | + * Note: avoid FlaggedRevs class calls here for performance (like load.php). |
| 7 | + */ |
| 8 | +class FlaggedRevsSetup { |
| 9 | + /** |
| 10 | + * Register FlaggedRevs source code paths. |
| 11 | + * This function must NOT depend on any config vars. |
| 12 | + * |
| 13 | + * @param $classes Array $wgAutoloadClasses |
| 14 | + * @param $messagesFiles Array $wgExtensionMessagesFiles |
| 15 | + * @param $aliasesFiles Array $wgExtensionAliasesFiles |
| 16 | + * @return void |
| 17 | + */ |
| 18 | + public static function defineSourcePaths( &$classes, &$messagesFiles, &$aliasesFiles ) { |
| 19 | + $dir = dirname( __FILE__ ); |
| 20 | + |
| 21 | + # Basic directory layout |
| 22 | + $schemaDir = "$dir/schema"; |
| 23 | + $backendDir = "$dir/dataclasses"; |
| 24 | + $businessDir = "$dir/business"; |
| 25 | + $apiDir = "$dir/api"; |
| 26 | + $apiActionDir = "$dir/api/actions"; |
| 27 | + $apiReportDir = "$dir/api/reports"; |
| 28 | + $frontendDir = "$dir/presentation"; |
| 29 | + $langDir = "$dir/presentation/language"; |
| 30 | + $spActionDir = "$dir/presentation/specialpages/actions"; |
| 31 | + $spReportDir = "$dir/presentation/specialpages/reports"; |
| 32 | + $testDir = "$dir/tests"; |
| 33 | + |
| 34 | + ### Backend classes ### |
| 35 | + # Utility classes... |
| 36 | + $classes['FlaggedRevs'] = "$backendDir/FlaggedRevs.class.php"; |
| 37 | + $classes['FRUserCounters'] = "$backendDir/FRUserCounters.php"; |
| 38 | + $classes['FRUserActivity'] = "$backendDir/FRUserActivity.php"; |
| 39 | + $classes['FRPageConfig'] = "$backendDir/FRPageConfig.php"; |
| 40 | + $classes['FlaggedRevsLog'] = "$backendDir/FlaggedRevsLog.php"; |
| 41 | + $classes['FRInclusionCache'] = "$backendDir/FRInclusionCache.php"; |
| 42 | + $classes['FlaggedRevsStats'] = "$backendDir/FlaggedRevsStats.php"; |
| 43 | + # Data access object classes... |
| 44 | + $classes['FRExtraCacheUpdate'] = "$backendDir/FRExtraCacheUpdate.php"; |
| 45 | + $classes['FRExtraCacheUpdateJob'] = "$backendDir/FRExtraCacheUpdate.php"; |
| 46 | + $classes['FRSquidUpdate'] = "$backendDir/FRExtraCacheUpdate.php"; |
| 47 | + $classes['FRDependencyUpdate'] = "$backendDir/FRDependencyUpdate.php"; |
| 48 | + $classes['FRInclusionManager'] = "$backendDir/FRInclusionManager.php"; |
| 49 | + $classes['FlaggableWikiPage'] = "$backendDir/FlaggableWikiPage.php"; |
| 50 | + $classes['FlaggedRevision'] = "$backendDir/FlaggedRevision.php"; |
| 51 | + $classes['FRParserCacheStable'] = "$backendDir/FRParserCacheStable.php"; |
| 52 | + ### End ### |
| 53 | + |
| 54 | + ### Business object classes ### |
| 55 | + $classes['FRGenericSubmitForm'] = "$businessDir/FRGenericSubmitForm.php"; |
| 56 | + $classes['RevisionReviewForm'] = "$businessDir/RevisionReviewForm.php"; |
| 57 | + $classes['PageStabilityForm'] = "$businessDir/PageStabilityForm.php"; |
| 58 | + $classes['PageStabilityGeneralForm'] = "$businessDir/PageStabilityForm.php"; |
| 59 | + $classes['PageStabilityProtectForm'] = "$businessDir/PageStabilityForm.php"; |
| 60 | + ### End ### |
| 61 | + |
| 62 | + ### Presentation classes ### |
| 63 | + # Main i18n file and special page alias file |
| 64 | + $messagesFiles['FlaggedRevs'] = "$langDir/FlaggedRevs.i18n.php"; |
| 65 | + $aliasesFiles['FlaggedRevs'] = "$langDir/FlaggedRevs.alias.php"; |
| 66 | + # UI setup, forms, and HTML elements |
| 67 | + $classes['FlaggedRevsUISetup'] = "$frontendDir/FlaggedRevsUI.setup.php"; |
| 68 | + $classes['FlaggablePageView'] = "$frontendDir/FlaggablePageView.php"; |
| 69 | + $classes['FlaggedRevsLogView'] = "$frontendDir/FlaggedRevsLogView.php"; |
| 70 | + $classes['FlaggedRevsXML'] = "$frontendDir/FlaggedRevsXML.php"; |
| 71 | + $classes['RevisionReviewFormUI'] = "$frontendDir/RevisionReviewFormUI.php"; |
| 72 | + $classes['RejectConfirmationFormUI'] = "$frontendDir/RejectConfirmationFormUI.php"; |
| 73 | + # Revision review UI |
| 74 | + $classes['RevisionReview'] = "$spActionDir/RevisionReview_body.php"; |
| 75 | + $messagesFiles['RevisionReview'] = "$langDir/RevisionReview.i18n.php"; |
| 76 | + # Stable version config UI |
| 77 | + $classes['Stabilization'] = "$spActionDir/Stabilization_body.php"; |
| 78 | + $messagesFiles['Stabilization'] = "$langDir/Stabilization.i18n.php"; |
| 79 | + # Reviewed versions list |
| 80 | + $classes['ReviewedVersions'] = "$spReportDir/ReviewedVersions_body.php"; |
| 81 | + $messagesFiles['ReviewedVersions'] = "$langDir/ReviewedVersions.i18n.php"; |
| 82 | + # Unreviewed pages list |
| 83 | + $classes['UnreviewedPages'] = "$spReportDir/UnreviewedPages_body.php"; |
| 84 | + $messagesFiles['UnreviewedPages'] = "$langDir/UnreviewedPages.i18n.php"; |
| 85 | + # Pages with pending changes list |
| 86 | + $classes['PendingChanges'] = "$spReportDir/PendingChanges_body.php"; |
| 87 | + $messagesFiles['PendingChanges'] = "$langDir/PendingChanges.i18n.php"; |
| 88 | + # Pages with tagged pending changes list |
| 89 | + $classes['ProblemChanges'] = "$spReportDir/ProblemChanges_body.php"; |
| 90 | + $messagesFiles['ProblemChanges'] = "$langDir/ProblemChanges.i18n.php"; |
| 91 | + # Reviewed pages list |
| 92 | + $classes['ReviewedPages'] = "$spReportDir/ReviewedPages_body.php"; |
| 93 | + $messagesFiles['ReviewedPages'] = "$langDir/ReviewedPages.i18n.php"; |
| 94 | + # Stable pages list (for protection config) |
| 95 | + $classes['StablePages'] = "$spReportDir/StablePages_body.php"; |
| 96 | + $messagesFiles['StablePages'] = "$langDir/StablePages.i18n.php"; |
| 97 | + # Configured pages list (non-protection config) |
| 98 | + $classes['ConfiguredPages'] = "$spReportDir/ConfiguredPages_body.php"; |
| 99 | + $messagesFiles['ConfiguredPages'] = "$langDir/ConfiguredPages.i18n.php"; |
| 100 | + # Filterable review log page to oversee reviews |
| 101 | + $classes['QualityOversight'] = "$spReportDir/QualityOversight_body.php"; |
| 102 | + $messagesFiles['QualityOversight'] = "$langDir/QualityOversight.i18n.php"; |
| 103 | + # Review statistics |
| 104 | + $classes['ValidationStatistics'] = "$spReportDir/ValidationStatistics_body.php"; |
| 105 | + $messagesFiles['ValidationStatistics'] = "$langDir/ValidationStatistics.i18n.php"; |
| 106 | + ### End ### |
| 107 | + |
| 108 | + ### API classes ### |
| 109 | + # Page review module for API |
| 110 | + $classes['ApiReview'] = "$apiActionDir/ApiReview.php"; |
| 111 | + # Page review activity module for API |
| 112 | + $classes['ApiReviewActivity'] = "$apiActionDir/ApiReviewActivity.php"; |
| 113 | + # Stability config module for API |
| 114 | + $classes['ApiStabilize'] = "$apiActionDir/ApiStabilize.php"; |
| 115 | + $classes['ApiStabilizeGeneral'] = "$apiActionDir/ApiStabilize.php"; |
| 116 | + $classes['ApiStabilizeProtect'] = "$apiActionDir/ApiStabilize.php"; |
| 117 | + # OldReviewedPages for API |
| 118 | + $classes['ApiQueryOldreviewedpages'] = "$apiReportDir/ApiQueryOldreviewedpages.php"; |
| 119 | + # UnreviewedPages for API |
| 120 | + $classes['ApiQueryUnreviewedpages'] = "$apiReportDir/ApiQueryUnreviewedpages.php"; |
| 121 | + # ReviewedPages for API |
| 122 | + $classes['ApiQueryReviewedpages'] = "$apiReportDir/ApiQueryReviewedpages.php"; |
| 123 | + # ConfiguredPages for API |
| 124 | + $classes['ApiQueryConfiguredpages'] = "$apiReportDir/ApiQueryConfiguredPages.php"; |
| 125 | + # Flag metadata for pages for API |
| 126 | + $classes['ApiQueryFlagged'] = "$apiReportDir/ApiQueryFlagged.php"; |
| 127 | + # Site flag config for API |
| 128 | + $classes['ApiFlagConfig'] = "$apiReportDir/ApiFlagConfig.php"; |
| 129 | + ### End ### |
| 130 | + |
| 131 | + ### Event handler classes ### |
| 132 | + $classes['FlaggedRevsHooks'] = "$backendDir/FlaggedRevs.hooks.php"; |
| 133 | + $classes['FlaggedRevsUIHooks'] = "$frontendDir/FlaggedRevsUI.hooks.php"; |
| 134 | + $classes['FlaggedRevsApiHooks'] = "$apiDir/FlaggedRevsApi.hooks.php"; |
| 135 | + $classes['FlaggedRevsUpdaterHooks'] = "$schemaDir/FlaggedRevsUpdater.hooks.php"; |
| 136 | + $classes['FlaggedRevsTestHooks'] = "$testDir/FlaggedRevsTest.hooks.php"; |
| 137 | + ### End ### |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + * Register backend and API hook handlers. |
| 142 | + * This function must NOT depend on any config vars. |
| 143 | + * |
| 144 | + * @return void |
| 145 | + */ |
| 146 | + public static function setUnconditionalHooks() { |
| 147 | + global $wgHooks; |
| 148 | + |
| 149 | + # ######## API ######## |
| 150 | + # Add flagging data to ApiQueryRevisions |
| 151 | + $wgHooks['APIGetAllowedParams'][] = 'FlaggedRevsApiHooks::addApiRevisionParams'; |
| 152 | + $wgHooks['APIQueryAfterExecute'][] = 'FlaggedRevsApiHooks::addApiRevisionData'; |
| 153 | + # ######## |
| 154 | + |
| 155 | + # ######## Parser ######### |
| 156 | + # Parser hooks, selects the desired images/templates |
| 157 | + $wgHooks['BeforeParserFetchTemplateAndtitle'][] = 'FlaggedRevsHooks::parserFetchStableTemplate'; |
| 158 | + $wgHooks['BeforeParserFetchFileAndTitle'][] = 'FlaggedRevsHooks::parserFetchStableFile'; |
| 159 | + # B/C for before ParserOutput::mImageTimeKeys |
| 160 | + $wgHooks['OutputPageParserOutput'][] = 'FlaggedRevsHooks::outputSetVersioningFlag'; |
| 161 | + # ######## |
| 162 | + |
| 163 | + # ######## DB write operations ######### |
| 164 | + # Autopromote Editors |
| 165 | + $wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::onArticleSaveComplete'; |
| 166 | + # Auto-reviewing |
| 167 | + $wgHooks['RecentChange_save'][] = 'FlaggedRevsHooks::autoMarkPatrolled'; |
| 168 | + $wgHooks['NewRevisionFromEditComplete'][] = 'FlaggedRevsHooks::maybeMakeEditReviewed'; |
| 169 | + # Null edit review via checkbox |
| 170 | + $wgHooks['ArticleSaveComplete'][] = 'FlaggedRevsHooks::maybeNullEditReview'; |
| 171 | + # User edit tallies |
| 172 | + $wgHooks['ArticleRollbackComplete'][] = 'FlaggedRevsHooks::incrementRollbacks'; |
| 173 | + $wgHooks['NewRevisionFromEditComplete'][] = 'FlaggedRevsHooks::incrementReverts'; |
| 174 | + # Update fr_page_id and tracking rows on revision restore and merge |
| 175 | + $wgHooks['ArticleRevisionUndeleted'][] = 'FlaggedRevsHooks::onRevisionRestore'; |
| 176 | + $wgHooks['ArticleMergeComplete'][] = 'FlaggedRevsHooks::onArticleMergeComplete'; |
| 177 | + |
| 178 | + # Update tracking rows and cache on page changes (@TODO: this sucks): |
| 179 | + # Article edit/create |
| 180 | + $wgHooks['ArticleEditUpdates'][] = 'FlaggedRevsHooks::onArticleEditUpdates'; |
| 181 | + # Article delete/restore |
| 182 | + $wgHooks['ArticleDeleteComplete'][] = 'FlaggedRevsHooks::onArticleDelete'; |
| 183 | + $wgHooks['ArticleUndelete'][] = 'FlaggedRevsHooks::onArticleUndelete'; |
| 184 | + # Revision delete/restore |
| 185 | + $wgHooks['ArticleRevisionVisibilitySet'][] = 'FlaggedRevsHooks::onRevisionDelete'; |
| 186 | + # Article move |
| 187 | + $wgHooks['TitleMoveComplete'][] = 'FlaggedRevsHooks::onTitleMoveComplete'; |
| 188 | + # File upload |
| 189 | + $wgHooks['FileUpload'][] = 'FlaggedRevsHooks::onFileUpload'; |
| 190 | + # ######## |
| 191 | + |
| 192 | + # ######## Other ######### |
| 193 | + # Determine what pages can be moved and patrolled |
| 194 | + $wgHooks['getUserPermissionsErrors'][] = 'FlaggedRevsHooks::onUserCan'; |
| 195 | + # Implicit autoreview rights group |
| 196 | + $wgHooks['AutopromoteCondition'][] = 'FlaggedRevsHooks::checkAutoPromoteCond'; |
| 197 | + |
| 198 | + # Stable dump hook |
| 199 | + $wgHooks['WikiExporter::dumpStableQuery'][] = 'FlaggedRevsHooks::stableDumpQuery'; |
| 200 | + |
| 201 | + # GNSM category hooks |
| 202 | + $wgHooks['GoogleNewsSitemap::Query'][] = 'FlaggedRevsHooks::gnsmQueryModifier'; |
| 203 | + |
| 204 | + # Duplicate flagged* tables in parserTests.php |
| 205 | + $wgHooks['ParserTestTables'][] = 'FlaggedRevsTestHooks::onParserTestTables'; |
| 206 | + # Integration tests |
| 207 | + $wgHooks['UnitTestsList'][] = 'FlaggedRevsTestHooks::getUnitTests'; |
| 208 | + |
| 209 | + # Database schema changes |
| 210 | + $wgHooks['LoadExtensionSchemaUpdates'][] = 'FlaggedRevsUpdaterHooks::addSchemaUpdates'; |
| 211 | + # ######## |
| 212 | + } |
| 213 | + |
| 214 | + /** |
| 215 | + * Register FlaggedRevs source code paths. |
| 216 | + * |
| 217 | + * @return void |
| 218 | + */ |
| 219 | + public static function setConditionalHooks() { |
| 220 | + global $wgHooks; |
| 221 | + |
| 222 | + # ######## User interface ######### |
| 223 | + FlaggedRevsUISetup::defineHookHandlers( $wgHooks ); |
| 224 | + # ######## |
| 225 | + |
| 226 | + # Give bots the 'autoreview' right (here so it triggers after CentralAuth) |
| 227 | + # @TODO: better way to ensure hook order |
| 228 | + $wgHooks['UserGetRights'][] = 'FlaggedRevsHooks::onUserGetRights'; |
| 229 | + } |
| 230 | + |
| 231 | + /** |
| 232 | + * Set $wgAutopromoteOnce |
| 233 | + * |
| 234 | + * @return void |
| 235 | + */ |
| 236 | + public static function setAutopromoteConfig() { |
| 237 | + global $wgFlaggedRevsAutoconfirm, $wgFlaggedRevsAutopromote; |
| 238 | + global $wgAutopromoteOnce, $wgGroupPermissions; |
| 239 | + # $wgFlaggedRevsAutoconfirm is now a wrapper around $wgAutopromoteOnce |
| 240 | + $req = $wgFlaggedRevsAutoconfirm; // convenience |
| 241 | + if ( is_array( $req ) ) { |
| 242 | + $criteria = array( '&', // AND |
| 243 | + array( APCOND_AGE, $req['days']*86400 ), |
| 244 | + array( APCOND_EDITCOUNT, $req['edits'], $req['excludeLastDays']*86400 ), |
| 245 | + array( APCOND_FR_EDITSUMMARYCOUNT, $req['editComments'] ), |
| 246 | + array( APCOND_FR_UNIQUEPAGECOUNT, $req['uniqueContentPages'] ), |
| 247 | + array( APCOND_FR_EDITSPACING, $req['spacing'], $req['benchmarks'] ), |
| 248 | + array( '|', // OR |
| 249 | + array( APCOND_FR_CONTENTEDITCOUNT, |
| 250 | + $req['totalContentEdits'], $req['excludeLastDays']*86400 ), |
| 251 | + array( APCOND_FR_CHECKEDEDITCOUNT, |
| 252 | + $req['totalCheckedEdits'], $req['excludeLastDays']*86400 ) |
| 253 | + ), |
| 254 | + ); |
| 255 | + if ( $req['email'] ) { |
| 256 | + $criteria[] = array( APCOND_EMAILCONFIRMED ); |
| 257 | + } |
| 258 | + if ( $req['neverBlocked'] ) { |
| 259 | + $criteria[] = array( APCOND_FR_NEVERBOCKED ); |
| 260 | + } |
| 261 | + $wgAutopromoteOnce['onEdit']['autoreview'] = $criteria; |
| 262 | + $wgGroupPermissions['autoreview']['autoreview'] = true; |
| 263 | + } |
| 264 | + |
| 265 | + # $wgFlaggedRevsAutoconfirm is now a wrapper around $wgAutopromoteOnce |
| 266 | + $req = $wgFlaggedRevsAutopromote; // convenience |
| 267 | + if ( is_array( $req ) ) { |
| 268 | + $criteria = array( '&', // AND |
| 269 | + array( APCOND_AGE, $req['days']*86400 ), |
| 270 | + array( APCOND_FR_EDITCOUNT, $req['edits'], $req['excludeLastDays']*86400 ), |
| 271 | + array( APCOND_FR_EDITSUMMARYCOUNT, $req['editComments'] ), |
| 272 | + array( APCOND_FR_UNIQUEPAGECOUNT, $req['uniqueContentPages'] ), |
| 273 | + array( APCOND_FR_USERPAGEBYTES, $req['userpageBytes'] ), |
| 274 | + array( APCOND_FR_NEVERDEMOTED ), // for b/c |
| 275 | + array( APCOND_FR_EDITSPACING, $req['spacing'], $req['benchmarks'] ), |
| 276 | + array( '|', // OR |
| 277 | + array( APCOND_FR_CONTENTEDITCOUNT, |
| 278 | + $req['totalContentEdits'], $req['excludeLastDays']*86400 ), |
| 279 | + array( APCOND_FR_CHECKEDEDITCOUNT, |
| 280 | + $req['totalCheckedEdits'], $req['excludeLastDays']*86400 ) |
| 281 | + ), |
| 282 | + array( APCOND_FR_MAXREVERTEDEDITRATIO, $req['maxRevertedEditRatio'] ), |
| 283 | + array( '!', APCOND_ISBOT ) |
| 284 | + ); |
| 285 | + if ( $req['neverBlocked'] ) { |
| 286 | + $criteria[] = array( APCOND_FR_NEVERBOCKED ); |
| 287 | + } |
| 288 | + $wgAutopromoteOnce['onEdit']['editor'] = $criteria; |
| 289 | + } |
| 290 | + } |
| 291 | + |
| 292 | + /** |
| 293 | + * Set $wgSpecialPages and $wgSpecialPageGroups |
| 294 | + * |
| 295 | + * @return void |
| 296 | + */ |
| 297 | + public static function setSpecialPages() { |
| 298 | + global $wgSpecialPages, $wgSpecialPageGroups; |
| 299 | + FlaggedRevsUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups ); |
| 300 | + } |
| 301 | + |
| 302 | + /** |
| 303 | + * Set API modules |
| 304 | + * |
| 305 | + * @return void |
| 306 | + */ |
| 307 | + public static function setAPIModules() { |
| 308 | + global $wgAPIModules, $wgAPIListModules, $wgAPIPropModules; |
| 309 | + global $wgFlaggedRevsProtection; |
| 310 | + if ( $wgFlaggedRevsProtection ) { |
| 311 | + $wgAPIModules['stabilize'] = 'ApiStabilizeProtect'; |
| 312 | + } else { |
| 313 | + $wgAPIModules['stabilize'] = 'ApiStabilizeGeneral'; |
| 314 | + $wgAPIListModules['reviewedpages'] = 'ApiQueryReviewedpages'; |
| 315 | + $wgAPIListModules['unreviewedpages'] = 'ApiQueryUnreviewedpages'; |
| 316 | + $wgAPIListModules['configuredpages'] = 'ApiQueryConfiguredpages'; |
| 317 | + } |
| 318 | + # Page review module for API |
| 319 | + $wgAPIModules['review'] = 'ApiReview'; |
| 320 | + # Page review activity module for API |
| 321 | + $wgAPIModules['reviewactivity'] = 'ApiReviewActivity'; |
| 322 | + # OldReviewedPages for API |
| 323 | + $wgAPIListModules['oldreviewedpages'] = 'ApiQueryOldreviewedpages'; |
| 324 | + # Flag metadata for pages for API |
| 325 | + $wgAPIPropModules['flagged'] = 'ApiQueryFlagged'; |
| 326 | + # Site flag config for API |
| 327 | + $wgAPIModules['flagconfig'] = 'ApiFlagConfig'; |
| 328 | + } |
| 329 | + |
| 330 | + /** |
| 331 | + * Remove irrelevant user rights |
| 332 | + * |
| 333 | + * @return void |
| 334 | + */ |
| 335 | + public static function setConditionalRights() { |
| 336 | + global $wgGroupPermissions, $wgFlaggedRevsProtection; |
| 337 | + if ( $wgFlaggedRevsProtection ) { |
| 338 | + // XXX: Removes sp:ListGroupRights cruft |
| 339 | + if ( isset( $wgGroupPermissions['editor'] ) ) { |
| 340 | + unset( $wgGroupPermissions['editor']['unreviewedpages'] ); |
| 341 | + } |
| 342 | + if ( isset( $wgGroupPermissions['reviewer'] ) ) { |
| 343 | + unset( $wgGroupPermissions['reviewer']['unreviewedpages'] ); |
| 344 | + } |
| 345 | + } |
| 346 | + } |
| 347 | + |
| 348 | + /** |
| 349 | + * Set $wgDefaultUserOptions |
| 350 | + * |
| 351 | + * @return void |
| 352 | + */ |
| 353 | + public static function setConditionalPreferences() { |
| 354 | + global $wgDefaultUserOptions, $wgSimpleFlaggedRevsUI; |
| 355 | + $wgDefaultUserOptions['flaggedrevssimpleui'] = (int)$wgSimpleFlaggedRevsUI; |
| 356 | + } |
| 357 | +} |
Property changes on: trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 358 | + native |
Added: svn:keywords |
2 | 359 | + LastChangedDate LastChangedRevision |