Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -144,6 +144,9 @@ |
145 | 145 | 'style' => array( 'review' => 3 ), |
146 | 146 | ); |
147 | 147 | |
| 148 | +# Restriction levels for auto-review right at Stabilization page |
| 149 | +$wgFlaggedRevsRestrictionLevels = array( '', 'sysop' ); |
| 150 | + |
148 | 151 | # Please set these as something different. Any text will do, though it probably |
149 | 152 | # shouldn't be very short (less secure) or very long (waste of resources). |
150 | 153 | # There must be two codes, and only the first two are checked. |
— | — | @@ -549,6 +552,7 @@ |
550 | 553 | $wgExtNewFields[] = array( 'flaggedpages', 'fp_pending_since', "$base/archives/patch-fp_pending_since.sql" ); |
551 | 554 | $wgExtNewFields[] = array( 'reader_feedback', 'rfb_timestamp', "$base/archives/patch-rfb_timestamp.sql" ); |
552 | 555 | $wgExtNewFields[] = array( 'reader_feedback', 'rfb_ratings', "$base/archives/patch-rfb_ratings.sql" ); |
| 556 | + $wgExtNewFields[] = array( 'flaggedpage_config', 'fpc_level', "$base/archives/patch-fpc_level.sql" ); |
553 | 557 | } else if( $wgDBtype == 'postgres' ) { |
554 | 558 | $wgExtNewTables[] = array( 'flaggedrevs', "$base/FlaggedRevs.pg.sql" ); // Initial install tables |
555 | 559 | $wgExtPGNewFields[] = array('flaggedpage_config', 'fpc_expiry', "TIMESTAMPTZ NULL" ); |
— | — | @@ -559,6 +563,7 @@ |
560 | 564 | $wgExtNewTables[] = array( 'reader_feedback', "$base/postgres/patch-reader_feedback.sql" ); |
561 | 565 | $wgExtNewTables[] = array( 'flaggedrevs_tracking', "$base/postgres/patch-flaggedrevs_tracking.sql" ); |
562 | 566 | $wgExtNewIndexes[] = array('flaggedpages', 'fp_pending_since', "$base/postgres/patch-fp_pending_since.sql" ); |
| 567 | + $wgExtPGNewFields[] = array('flaggedpage_config', 'fpc_level', "TEXT NULL" ); |
563 | 568 | } |
564 | 569 | return true; |
565 | 570 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -831,7 +831,7 @@ |
832 | 832 | public static function getPageVisibilitySettings( &$title, $forUpdate=false ) { |
833 | 833 | $db = $forUpdate ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); |
834 | 834 | $row = $db->selectRow( 'flaggedpage_config', |
835 | | - array( 'fpc_select', 'fpc_override', 'fpc_expiry' ), |
| 835 | + array( 'fpc_select', 'fpc_override', 'fpc_level', 'fpc_expiry' ), |
836 | 836 | array( 'fpc_page_id' => $title->getArticleID() ), |
837 | 837 | __METHOD__ |
838 | 838 | ); |
— | — | @@ -855,10 +855,11 @@ |
856 | 856 | ## 1 = quality -> stable |
857 | 857 | ## 0 = none |
858 | 858 | $select = self::getPrecedence(); |
859 | | - return array( 'select' => $select, 'override' => $override, 'expiry' => 'infinity' ); |
| 859 | + return array( 'select' => $select, 'override' => $override, |
| 860 | + 'autoreview' => '', 'expiry' => 'infinity' ); |
860 | 861 | } |
861 | 862 | return array('select' => $row->fpc_select, 'override' => $row->fpc_override, |
862 | | - 'expiry' => $row->fpc_expiry ); |
| 863 | + 'autoreview' => $row->fpc_level, 'expiry' => $row->fpc_expiry ); |
863 | 864 | } |
864 | 865 | |
865 | 866 | /** |
Index: trunk/extensions/FlaggedRevs/language/Stabilization.i18n.php |
— | — | @@ -20,11 +20,13 @@ |
21 | 21 | 'stabilization-leg' => 'Confirm stable version settings', |
22 | 22 | 'stabilization-select' => 'Stable version selection', |
23 | 23 | 'stabilization-select1' => 'The latest quality revision; if not present, then the latest sighted one', |
24 | | - 'stabilization-select2' => 'The latest reviewed revision', |
| 24 | + 'stabilization-select2' => 'The latest reviewed revision, regardless of validation level', |
25 | 25 | 'stabilization-select3' => 'The latest pristine revision; if not present, then the latest quality or sighted one', |
26 | 26 | 'stabilization-def' => 'Revision displayed on default page view', |
27 | 27 | 'stabilization-def1' => 'The stable revision; if not present, then the current one', |
28 | 28 | 'stabilization-def2' => 'The current revision', |
| 29 | + 'stabilization-restrict' => 'Auto-review restrictions', |
| 30 | + 'stabilization-restrict-none' => 'No extra restrictions', |
29 | 31 | 'stabilization-submit' => 'Confirm', |
30 | 32 | 'stabilization-notexists' => 'There is no page called "[[:$1|$1]]". |
31 | 33 | No configuration is possible.', |
— | — | @@ -41,6 +43,7 @@ |
42 | 44 | 'stabilization-def-short' => 'Default', |
43 | 45 | 'stabilization-def-short-0' => 'Current', |
44 | 46 | 'stabilization-def-short-1' => 'Stable', |
| 47 | + 'stabilization-rest-short' => 'autoreview=$1', |
45 | 48 | 'stabilize_expiry_invalid' => 'Invalid expiration date.', |
46 | 49 | 'stabilize_expiry_old' => 'This expiration time has already passed.', |
47 | 50 | 'stabilize-expiring' => 'expires $1 (UTC)', |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.sql |
— | — | @@ -69,6 +69,8 @@ |
70 | 70 | fpc_select integer NOT NULL, |
71 | 71 | -- Override the page? |
72 | 72 | fpc_override bool NOT NULL, |
| 73 | + -- The protection level (Sysop, etc) for autoreview |
| 74 | + fpc_level varbinary(60) NULL, |
73 | 75 | -- Field for time-limited settings |
74 | 76 | fpc_expiry varbinary(14) NOT NULL default 'infinity', |
75 | 77 | |
Index: trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php |
— | — | @@ -64,6 +64,8 @@ |
65 | 65 | $this->config = FlaggedRevs::getPageVisibilitySettings( $this->page, true ); |
66 | 66 | $this->select = $this->config['select']; |
67 | 67 | $this->override = $this->config['override']; |
| 68 | + # Get autoreview restrictions... |
| 69 | + $this->autoreview = $this->config['autoreview']; |
68 | 70 | # Make user readable date for GET requests |
69 | 71 | $this->oldExpiry = $this->config['expiry'] !== 'infinity' ? |
70 | 72 | wfTimestamp( TS_RFC2822, $this->config['expiry'] ) : 'infinite'; |
— | — | @@ -71,11 +73,14 @@ |
72 | 74 | if( $wgRequest->wasPosted() ) { |
73 | 75 | $this->select = $wgRequest->getInt( 'wpStableconfig-select' ); |
74 | 76 | $this->override = intval( $wgRequest->getBool( 'wpStableconfig-override' ) ); |
| 77 | + # Get autoreview restrictions... |
| 78 | + $this->autoreview = $wgRequest->getVal( 'mwProtect-level-autoreview' ); |
75 | 79 | // Custom expiry takes precedence |
76 | 80 | $this->expiry = strlen($this->expiry) ? $this->expiry : $this->expirySelection; |
77 | 81 | if( $this->expiry == 'existing' ) $this->expiry = $this->oldExpiry; |
78 | 82 | // Custom reason takes precedence |
79 | | - $this->reason = strlen($this->reason) ? $this->reason : $this->reasonSelection; |
| 83 | + $this->reason = strlen($this->reason) || $this->reasonSelection == 'other' ? |
| 84 | + $this->reason : $this->reasonSelection; |
80 | 85 | // Validate precedence setting |
81 | 86 | $allowed = array(FLAGGED_VIS_QUALITY,FLAGGED_VIS_LATEST,FLAGGED_VIS_PRISTINE); |
82 | 87 | if( $this->select && !in_array( $this->select, $allowed ) ) { |
— | — | @@ -175,6 +180,10 @@ |
176 | 181 | Xml::radioLabel( wfMsg( 'stabilization-select2' ), 'wpStableconfig-select', FLAGGED_VIS_LATEST, |
177 | 182 | 'stable-select2', FLAGGED_VIS_LATEST == $this->select, $this->disabledAttrib ) . '<br />' . "\n" . |
178 | 183 | Xml::closeElement( 'fieldset' ) . |
| 184 | + |
| 185 | + Xml::fieldset( wfMsg( 'stabilization-restrict' ), false ) . |
| 186 | + $this->buildSelector( $this->autoreview ) . |
| 187 | + Xml::closeElement( 'fieldset' ) . |
179 | 188 | |
180 | 189 | Xml::fieldset( wfMsg( 'stabilization-leg' ), false ) . |
181 | 190 | Xml::openElement( 'table' ); |
— | — | @@ -256,18 +265,68 @@ |
257 | 266 | $wgOut->addHTML( Xml::element( 'h2', NULL, htmlspecialchars( LogPage::logName( 'stable' ) ) ) ); |
258 | 267 | LogEventsList::showLogExtract( $wgOut, 'stable', $this->page->getPrefixedText() ); |
259 | 268 | } |
| 269 | + |
| 270 | + protected function buildSelector( $selected ) { |
| 271 | + global $wgUser, $wgFlaggedRevsRestrictionLevels; |
| 272 | + $levels = array(); |
| 273 | + foreach( $wgFlaggedRevsRestrictionLevels as $key ) { |
| 274 | + # Don't let them choose levels above their own (aka so they can still unprotect and edit the page). |
| 275 | + # but only when the form isn't disabled |
| 276 | + if( $key == 'sysop' ) { |
| 277 | + // special case, rewrite sysop to protect and editprotected |
| 278 | + if( !$wgUser->isAllowed('protect') && !$wgUser->isAllowed('editprotected') && $this->isAllowed ) |
| 279 | + continue; |
| 280 | + } else { |
| 281 | + if( !$wgUser->isAllowed($key) && $this->isAllowed ) |
| 282 | + continue; |
| 283 | + } |
| 284 | + $levels[] = $key; |
| 285 | + } |
| 286 | + $id = 'mwProtect-level-autoreview'; |
| 287 | + $attribs = array( |
| 288 | + 'id' => $id, |
| 289 | + 'name' => $id, |
| 290 | + 'size' => count( $levels ), |
| 291 | + ) + $this->disabledAttrib; |
260 | 292 | |
| 293 | + $out = Xml::openElement( 'select', $attribs ); |
| 294 | + foreach( $levels as $key ) { |
| 295 | + $out .= Xml::option( $this->getOptionLabel( $key ), $key, $key == $selected ); |
| 296 | + } |
| 297 | + $out .= Xml::closeElement( 'select' ); |
| 298 | + return $out; |
| 299 | + } |
| 300 | + |
| 301 | + /** |
| 302 | + * Prepare the label for a protection selector option |
| 303 | + * |
| 304 | + * @param string $permission Permission required |
| 305 | + * @return string |
| 306 | + */ |
| 307 | + protected function getOptionLabel( $permission ) { |
| 308 | + if( $permission == '' ) { |
| 309 | + return wfMsg( 'stabilization-restrict-none' ); |
| 310 | + } else { |
| 311 | + $key = "protect-level-{$permission}"; |
| 312 | + $msg = wfMsg( $key ); |
| 313 | + if( wfEmptyMsg( $key, $msg ) ) |
| 314 | + $msg = wfMsg( 'protect-fallback', $permission ); |
| 315 | + return $msg; |
| 316 | + } |
| 317 | + } |
| 318 | + |
261 | 319 | protected function submit() { |
262 | | - global $wgOut, $wgUser, $wgParser, $wgFlaggedRevsOverride; |
| 320 | + global $wgOut, $wgUser, $wgParser; |
263 | 321 | |
264 | 322 | $changed = $reset = false; |
265 | 323 | $defaultPrecedence = FlaggedRevs::getPrecedence(); |
266 | | - if( $this->select == $defaultPrecedence && $this->override == $wgFlaggedRevsOverride ) { |
| 324 | + $defaultOverride = FlaggedRevs::showStableByDefault(); |
| 325 | + if( $this->select == $defaultPrecedence && $this->override == $defaultOverride && !$this->autoreview ) { |
267 | 326 | $reset = true; // we are going back to site defaults |
268 | 327 | } |
269 | 328 | # Take this opportunity to purge out expired configurations |
270 | 329 | FlaggedRevs::purgeExpiredConfigurations(); |
271 | | - |
| 330 | + # Parse expiry time given... |
272 | 331 | if( $reset || $this->expiry == 'infinite' || $this->expiry == 'indefinite' ) { |
273 | 332 | $expiry = Block::infinity(); |
274 | 333 | } else { |
— | — | @@ -287,9 +346,10 @@ |
288 | 347 | $dbw = wfGetDB( DB_MASTER ); |
289 | 348 | # Get current config |
290 | 349 | $row = $dbw->selectRow( 'flaggedpage_config', |
291 | | - array( 'fpc_select', 'fpc_override', 'fpc_expiry' ), |
| 350 | + array( 'fpc_select', 'fpc_override', 'fpc_level', 'fpc_expiry' ), |
292 | 351 | array( 'fpc_page_id' => $this->page->getArticleID() ), |
293 | | - __METHOD__ ); |
| 352 | + __METHOD__ |
| 353 | + ); |
294 | 354 | # If setting to site default values, erase the row if there is one... |
295 | 355 | if( $row && $reset ) { |
296 | 356 | $dbw->delete( 'flaggedpage_config', |
— | — | @@ -297,14 +357,17 @@ |
298 | 358 | __METHOD__ ); |
299 | 359 | $changed = ($dbw->affectedRows() != 0); // did this do anything? |
300 | 360 | # Otherwise, add a row unless we are just setting it as the site default, or it is the same the current one... |
301 | | - } else if( $this->select !=0 || $this->override != $wgFlaggedRevsOverride ) { |
302 | | - if( !$row || $row->fpc_select != $this->select || $row->fpc_override != $this->override || $row->fpc_expiry != $expiry ) { |
| 361 | + } else if( !$reset ) { |
| 362 | + if( !$row || $row->fpc_select != $this->select || $row->fpc_override != $this->override |
| 363 | + || $row->fpc_level != $this->autoreview || $row->fpc_expiry != $expiry ) |
| 364 | + { |
303 | 365 | $changed = true; |
304 | 366 | $dbw->replace( 'flaggedpage_config', |
305 | 367 | array( 'PRIMARY' ), |
306 | 368 | array( 'fpc_page_id' => $this->page->getArticleID(), |
307 | 369 | 'fpc_select' => $this->select, |
308 | 370 | 'fpc_override' => $this->override, |
| 371 | + 'fpc_level' => $this->autoreview, |
309 | 372 | 'fpc_expiry' => $expiry ), |
310 | 373 | __METHOD__ ); |
311 | 374 | } |
— | — | @@ -321,6 +384,9 @@ |
322 | 385 | wfMsgForContent("stabilization-sel-short-{$this->select}"); |
323 | 386 | $set[] = wfMsgForContent( "stabilization-def-short" ) . wfMsgForContent( 'colon-separator' ) . |
324 | 387 | wfMsgForContent("stabilization-def-short-{$this->override}"); |
| 388 | + if( strlen($this->autoreview) ) { |
| 389 | + $set[] = "autoreview={$this->autoreview}"; |
| 390 | + } |
325 | 391 | $settings = '[' . implode(', ',$set). ']'; |
326 | 392 | |
327 | 393 | $reason = ''; |
— | — | @@ -373,7 +439,7 @@ |
374 | 440 | # Take the user to the diff to make sure an outdated version isn't |
375 | 441 | # being set at the default. This is really an issue with configs |
376 | 442 | # that only let certain pages be reviewed. |
377 | | - if( $this->select != FLAGGED_VIS_LATEST ) { |
| 443 | + if( $changed && $this->select != FLAGGED_VIS_LATEST ) { |
378 | 444 | $frev = FlaggedRevision::newFromStable( $this->page, FR_MASTER ); |
379 | 445 | if( $frev && $frev->getRevId() != $latest ) { |
380 | 446 | $query = "oldid={$frev->getRevId()}&diff=cur&diffonly=0"; // override diff-only |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -718,7 +718,18 @@ |
719 | 719 | $key = wfMemcKey( 'flaggedrevs', 'includesSynced', $rev->getPage() ); |
720 | 720 | global $wgMemc, $wgParserCacheExpireTime; |
721 | 721 | # Auto-reviewing must be enabled and user must have the required permissions |
722 | | - if( !$wgFlaggedRevsAutoReview || (!$user->isAllowed('autoreview') && !$user->isAllowed('bot')) ) { |
| 722 | + if( !$wgFlaggedRevsAutoReview || !$user->isAllowed('autoreview') ) { |
| 723 | + $isAllowed = false; |
| 724 | + } else { |
| 725 | + # Get autoreview restriction settings... |
| 726 | + $config = FlaggedRevs::getPageVisibilitySettings( $title, true ); |
| 727 | + # Convert Sysop -> protect |
| 728 | + $right = ($config['autoreview'] === 'sysop') ? 'protect' : $config['autoreview']; |
| 729 | + # Check if the user has the required right, if any |
| 730 | + $isAllowed = !$right || $user->isAllowed($right); |
| 731 | + } |
| 732 | + # Auto-reviewing must be enabled and user must have the required permissions |
| 733 | + if( !$isAllowed ) { |
723 | 734 | $wgMemc->set( $key, FlaggedRevs::makeMemcObj('false'), $wgParserCacheExpireTime ); |
724 | 735 | return true; // done! edit pending! |
725 | 736 | } |
— | — | @@ -894,8 +905,13 @@ |
895 | 906 | */ |
896 | 907 | public static function checkAutoPromote( $user, &$promote ) { |
897 | 908 | global $wgFlaggedRevsAutopromote; |
| 909 | + # Make sure bots always have autoreview |
| 910 | + if( $user->isAllowed('bot') ) { |
| 911 | + $promote[] = 'autoreview'; |
| 912 | + return true; |
| 913 | + } |
898 | 914 | if( empty($wgFlaggedRevsAutopromote) || !$user->getId() || $user->isAllowed('autoreview') ) { |
899 | | - return true; // not needed |
| 915 | + return true; // not needed or $wgFlaggedRevsAutopromote is off |
900 | 916 | } |
901 | 917 | # Check user email |
902 | 918 | if( $wgFlaggedRevsAutopromote['email'] && !$user->isEmailConfirmed() ) { |
Index: trunk/extensions/FlaggedRevs/archives/patch-fpc_level.sql |
— | — | @@ -0,0 +1,3 @@ |
| 2 | +-- The protection level (Sysop, autoconfirmed, etc) for autoreview |
| 3 | +ALTER TABLE /*$wgDBprefix*/flaggedpage_config |
| 4 | + ADD fpc_level varbinary(60) NULL; |
Property changes on: trunk/extensions/FlaggedRevs/archives/patch-fpc_level.sql |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 5 | + native |