Index: trunk/extensions/FlaggedRevs/language/Stabilization.i18n.php |
— | — | @@ -46,6 +46,7 @@ |
47 | 47 | 'stabilize_expiry_invalid' => 'Invalid expiration date.', |
48 | 48 | 'stabilize_expiry_old' => 'This expiration time has already passed.', |
49 | 49 | 'stabilize-expiring' => 'expires $1 (UTC)', |
| 50 | + 'stabilization-review' => 'Review the current version', |
50 | 51 | ); |
51 | 52 | |
52 | 53 | /** Message documentation (Message documentation) |
Index: trunk/extensions/FlaggedRevs/specialpages/Stabilization_body.php |
— | — | @@ -48,6 +48,10 @@ |
49 | 49 | return $wgOut->addHTML( wfMsgExt( 'stabilization-notcontent', array('parseinline'), |
50 | 50 | $this->page->getPrefixedText() ) ); |
51 | 51 | } |
| 52 | + |
| 53 | + # Users who cannot edit or review the page cannot set this |
| 54 | + if( $this->isAllowed && !($this->page->userCan('edit') && $this->page->userCan('review')) ) |
| 55 | + $this->isAllowed = false; |
52 | 56 | |
53 | 57 | # Watch checkbox |
54 | 58 | $this->watchThis = $wgRequest->getCheck( 'wpWatchthis' ); |
— | — | @@ -60,6 +64,8 @@ |
61 | 65 | $this->config = FlaggedRevs::getPageVisibilitySettings( $this->page, true ); |
62 | 66 | $this->select = $this->config['select']; |
63 | 67 | $this->override = $this->config['override']; |
| 68 | + # Get auto-review option... |
| 69 | + $this->reviewThis = $wgRequest->getBool( 'wpReviewthis', true ); |
64 | 70 | # Get autoreview restrictions... |
65 | 71 | $this->autoreview = $this->config['autoreview']; |
66 | 72 | # Make user readable date for GET requests |
— | — | @@ -215,6 +221,7 @@ |
216 | 222 | $watchLabel = wfMsgExt( 'watchthis', array('parseinline') ); |
217 | 223 | $watchAttribs = array('accesskey' => wfMsg( 'accesskey-watch' ), 'id' => 'wpWatchthis'); |
218 | 224 | $watchChecked = ( $wgUser->getOption( 'watchdefault' ) || $this->page->userIsWatching() ); |
| 225 | + $reviewLabel = wfMsgExt( 'stabilization-review', array('parseinline') ); |
219 | 226 | |
220 | 227 | $form .= ' <tr> |
221 | 228 | <td class="mw-label">' . |
— | — | @@ -235,6 +242,9 @@ |
236 | 243 | <tr> |
237 | 244 | <td></td> |
238 | 245 | <td class="mw-input">' . |
| 246 | + Xml::check( 'wpReviewthis', $this->reviewThis, array('id'=>'wpReviewthis') ) . |
| 247 | + "<label for='wpReviewthis'>{$reviewLabel}</label>" . |
| 248 | + ' ' . |
239 | 249 | Xml::check( 'wpWatchthis', $watchChecked, $watchAttribs ) . |
240 | 250 | "<label for='wpWatchthis'" . $this->skin->tooltipAndAccesskey( 'watch' ) . |
241 | 251 | ">{$watchLabel}</label>" . |
— | — | @@ -311,7 +321,6 @@ |
312 | 322 | |
313 | 323 | protected function submit() { |
314 | 324 | global $wgOut, $wgUser, $wgContLang; |
315 | | - |
316 | 325 | $changed = $reset = false; |
317 | 326 | $defaultPrecedence = FlaggedRevs::getPrecedence(); |
318 | 327 | $defaultOverride = FlaggedRevs::showStableByDefault(); |
— | — | @@ -364,15 +373,18 @@ |
365 | 374 | 'fpc_override' => $this->override, |
366 | 375 | 'fpc_level' => $this->autoreview, |
367 | 376 | 'fpc_expiry' => $expiry ), |
368 | | - __METHOD__ ); |
| 377 | + __METHOD__ |
| 378 | + ); |
369 | 379 | } |
370 | 380 | } |
371 | | - # Log if changed |
372 | | - # @FIXME: do this better |
| 381 | + $query = ''; |
| 382 | + // Check if this actually changed anything... |
373 | 383 | if( $changed ) { |
374 | | - $log = new LogPage( 'stable' ); |
| 384 | + $id = $this->page->getArticleId(); |
| 385 | + $latest = $this->page->getLatestRevID( GAID_FOR_UPDATE ); |
375 | 386 | # ID, accuracy, depth, style |
376 | 387 | $set = array(); |
| 388 | + # @FIXME: do this better |
377 | 389 | $set[] = wfMsgForContent( "stabilization-sel-short" ) . wfMsgForContent( 'colon-separator' ) . |
378 | 390 | wfMsgForContent("stabilization-sel-short-{$this->select}"); |
379 | 391 | $set[] = wfMsgForContent( "stabilization-def-short" ) . wfMsgForContent( 'colon-separator' ) . |
— | — | @@ -381,12 +393,10 @@ |
382 | 394 | $set[] = "autoreview={$this->autoreview}"; |
383 | 395 | } |
384 | 396 | $settings = '[' . implode(', ',$set). ']'; |
385 | | - |
| 397 | + # Append comment with settings (other than for resets) |
386 | 398 | $reason = ''; |
387 | | - # Append comment with settings (other than for resets) |
388 | 399 | if( !$reset ) { |
389 | 400 | $reason = $this->reason ? "{$this->reason} $settings" : "$settings"; |
390 | | - |
391 | 401 | $encodedExpiry = Block::encodeExpiry($expiry, $dbw ); |
392 | 402 | if( $encodedExpiry != 'infinity' ) { |
393 | 403 | $expiry_description = ' (' . wfMsgForContent( 'stabilize-expiring', |
— | — | @@ -396,7 +406,8 @@ |
397 | 407 | $reason .= "$expiry_description"; |
398 | 408 | } |
399 | 409 | } |
400 | | - |
| 410 | + # Add log entry... |
| 411 | + $log = new LogPage( 'stable' ); |
401 | 412 | if( $reset ) { |
402 | 413 | $log->addEntry( 'reset', $this->page, $reason ); |
403 | 414 | $type = "stable-logentry2"; |
— | — | @@ -404,13 +415,11 @@ |
405 | 416 | $log->addEntry( 'config', $this->page, $reason ); |
406 | 417 | $type = "stable-logentry"; |
407 | 418 | } |
| 419 | + # Build null-edit comment |
408 | 420 | $comment = $wgContLang->ucfirst( wfMsgForContent( $type, $this->page->getPrefixedText() ) ); |
409 | 421 | if( $reason ) { |
410 | 422 | $comment .= ": $reason"; |
411 | 423 | } |
412 | | - |
413 | | - $id = $this->page->getArticleId(); |
414 | | - $latest = $this->page->getLatestRevID( GAID_FOR_UPDATE ); |
415 | 424 | # Insert a null revision |
416 | 425 | $nullRevision = Revision::newNullRevision( $dbw, $id, $comment, true ); |
417 | 426 | $nullRevId = $nullRevision->insertOn( $dbw ); |
— | — | @@ -418,28 +427,40 @@ |
419 | 428 | $article = new Article( $this->page ); |
420 | 429 | $article->updateRevisionOn( $dbw, $nullRevision, $latest ); |
421 | 430 | wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, $latest) ); |
| 431 | + |
| 432 | + $invalidate = true; |
| 433 | + # Take the user to the diff if an outdated version is being |
| 434 | + # set as the default. This is really an issue with configs |
| 435 | + # that only let certain pages be reviewed. |
| 436 | + $frev = FlaggedRevision::newFromStable( $this->page, FR_MASTER ); |
| 437 | + $cfLevel = FlaggedRevs::getPrecedence( $this->select ); // desired level |
| 438 | + // Is the page out of sync? Is there no stable version? |
| 439 | + if( !$frev || $frev->getRevId() != $nullRevId || $frev->getQuality() != $cfLevel ) { |
| 440 | + $flags = FlaggedRevs::quickTags( $cfLevel ); // desired flags |
| 441 | + // Try to autoreview to this level... |
| 442 | + if( $this->reviewThis && RevisionReview::userCanSetFlags($flags) ) { |
| 443 | + $text = $nullRevision->getText(); |
| 444 | + FlaggedRevs::autoReviewEdit( $article, $wgUser, $text, $nullRevision, $flags, true ); |
| 445 | + $invalidate = false; // already done with auto-review |
| 446 | + // ...otherwise, go to diff if possible |
| 447 | + } else if( $frev ) { |
| 448 | + $query = "oldid={$frev->getRevId()}&diff=cur&diffonly=0"; |
| 449 | + } else { |
| 450 | + // can't autoreview and no diff to show... |
| 451 | + } |
| 452 | + } |
| 453 | + # Update the links tables as the stable version may now be the default page... |
| 454 | + if( $invalidate ) { |
| 455 | + FlaggedRevs::titleLinksUpdate( $this->page ); |
| 456 | + } |
422 | 457 | } |
423 | | - # Update the links tables as the stable version may now be the default page... |
424 | | - FlaggedRevs::titleLinksUpdate( $this->page ); |
425 | 458 | # Apply watchlist checkbox value |
426 | 459 | if( $this->watchThis ) { |
427 | 460 | $wgUser->addWatch( $this->page ); |
428 | 461 | } else { |
429 | 462 | $wgUser->removeWatch( $this->page ); |
430 | 463 | } |
431 | | - |
432 | | - $query = ''; |
433 | | - # Take the user to the diff to make sure an outdated version isn't |
434 | | - # being set at the default. This is really an issue with configs |
435 | | - # that only let certain pages be reviewed. |
436 | | - if( $changed && $this->select != FLAGGED_VIS_LATEST ) { |
437 | | - $frev = FlaggedRevision::newFromStable( $this->page, FR_MASTER ); |
438 | | - if( $frev && $frev->getRevId() != $nullRevId ) { |
439 | | - $query = "oldid={$frev->getRevId()}&diff=cur&diffonly=0"; // override diff-only |
440 | | - } |
441 | | - } |
442 | 464 | $wgOut->redirect( $this->page->getFullUrl( $query ) ); |
443 | | - |
444 | 465 | return true; |
445 | 466 | } |
446 | 467 | } |