Index: trunk/phase3/includes/diff/DifferenceEngine.php |
— | — | @@ -28,6 +28,8 @@ |
29 | 29 | var $mRevisionsLoaded = false; // Have the revisions been loaded |
30 | 30 | var $mTextLoaded = 0; // How many text blobs have been loaded, 0, 1 or 2? |
31 | 31 | var $htmldiff; |
| 32 | + |
| 33 | + protected $unhide = false; |
32 | 34 | /**#@-*/ |
33 | 35 | |
34 | 36 | /** |
— | — | @@ -38,8 +40,9 @@ |
39 | 41 | * @param $rcid Integer: ??? FIXME (default 0) |
40 | 42 | * @param $refreshCache boolean If set, refreshes the diff cache |
41 | 43 | * @param $htmldiff boolean If set, output using HTMLDiff instead of raw wikicode diff |
| 44 | + * @param $unhide boolean If set, allow viewing deleted revs |
42 | 45 | */ |
43 | | - function __construct( $titleObj = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false , $htmldiff = false) { |
| 46 | + function __construct( $titleObj = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false , $htmldiff = false, $unhide = false ) { |
44 | 47 | $this->mTitle = $titleObj; |
45 | 48 | wfDebug("DifferenceEngine old '$old' new '$new' rcid '$rcid'\n"); |
46 | 49 | |
— | — | @@ -67,6 +70,7 @@ |
68 | 71 | $this->mRcidMarkPatrolled = intval($rcid); # force it to be an integer |
69 | 72 | $this->mRefreshCache = $refreshCache; |
70 | 73 | $this->htmldiff = $htmldiff; |
| 74 | + $this->unhide = $unhide; |
71 | 75 | } |
72 | 76 | |
73 | 77 | function getTitle() { |
— | — | @@ -254,16 +258,18 @@ |
255 | 259 | } |
256 | 260 | |
257 | 261 | $oldHeader = '<div id="mw-diff-otitle1"><strong>'.$this->mOldtitle.'</strong></div>' . |
258 | | - '<div id="mw-diff-otitle2">' . $sk->revUserTools( $this->mOldRev, true ) . "</div>" . |
259 | | - '<div id="mw-diff-otitle3">' . $oldminor . $sk->revComment( $this->mOldRev, !$diffOnly, true ) . $ldel . "</div>" . |
| 262 | + '<div id="mw-diff-otitle2">' . $sk->revUserTools( $this->mOldRev, !$this->unhide ) . "</div>" . |
| 263 | + '<div id="mw-diff-otitle3">' . $oldminor . $sk->revComment( $this->mOldRev, !$diffOnly, !$this->unhide ).$ldel."</div>" . |
260 | 264 | '<div id="mw-diff-otitle4">' . $prevlink .'</div>'; |
261 | 265 | $newHeader = '<div id="mw-diff-ntitle1"><strong>'.$this->mNewtitle.'</strong></div>' . |
262 | | - '<div id="mw-diff-ntitle2">' . $sk->revUserTools( $this->mNewRev, true ) . " $rollback</div>" . |
263 | | - '<div id="mw-diff-ntitle3">' . $newminor . $sk->revComment( $this->mNewRev, !$diffOnly, true ) . $rdel . "</div>" . |
| 266 | + '<div id="mw-diff-ntitle2">' . $sk->revUserTools( $this->mNewRev, !$this->unhide ) . " $rollback</div>" . |
| 267 | + '<div id="mw-diff-ntitle3">' . $newminor . $sk->revComment( $this->mNewRev, !$diffOnly, !$this->unhide ).$rdel."</div>" . |
264 | 268 | '<div id="mw-diff-ntitle4">' . $nextlink . $patrol . '</div>'; |
265 | 269 | |
266 | | - # Output the diff |
267 | | - if( !$this->mOldRev->userCan(Revision::DELETED_TEXT) || !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) { |
| 270 | + # Output the diff if allowed |
| 271 | + $allowed = $this->mOldRev->userCan(Revision::DELETED_TEXT) && $this->mNewRev->userCan(Revision::DELETED_TEXT); |
| 272 | + $deleted = $this->mOldRev->isDeleted(Revision::DELETED_TEXT) || $this->mNewRev->isDeleted(Revision::DELETED_TEXT); |
| 273 | + if( $deleted && (!$this->unhide || !$allowed) ) { |
268 | 274 | $this->showDiffStyle(); |
269 | 275 | $multi = $this->getMultiNotice(); |
270 | 276 | $wgOut->addHTML( $this->addHeader( '', $oldHeader, $newHeader, $multi ) ); |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -780,15 +780,17 @@ |
781 | 781 | } |
782 | 782 | $wgOut->setRobotPolicy( $policy ); |
783 | 783 | |
| 784 | + # Allow admins to see deleted content if explicitly requested |
| 785 | + $delId = $diff ? $diff : $oldid; |
| 786 | + $unhide = $wgRequest->getInt('unhide') == 1 && $wgUser->matchEditToken( $wgRequest->getVal('token'), $delId ); |
784 | 787 | # If we got diff and oldid in the query, we want to see a |
785 | 788 | # diff page instead of the article. |
786 | 789 | |
787 | 790 | if( !is_null( $diff ) ) { |
788 | 791 | $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); |
789 | 792 | |
790 | | - $diff = $wgRequest->getVal( 'diff' ); |
791 | 793 | $htmldiff = $wgRequest->getVal( 'htmldiff' , false); |
792 | | - $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge, $htmldiff); |
| 794 | + $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge, $htmldiff, $unhide ); |
793 | 795 | // DifferenceEngine directly fetched the revision: |
794 | 796 | $this->mRevIdFetched = $de->mNewid; |
795 | 797 | $de->showDiffPage( $diffOnly ); |
— | — | @@ -913,8 +915,9 @@ |
914 | 916 | // FIXME: This would be a nice place to load the 'no such page' text. |
915 | 917 | } else { |
916 | 918 | $this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid ); |
| 919 | + # Allow admins to see deleted content if explicitly requested |
917 | 920 | if( $this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { |
918 | | - if( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) { |
| 921 | + if( !$unhide || !$this->mRevision->userCan(Revision::DELETED_TEXT) ) { |
919 | 922 | $wgOut->addWikiMsg( 'rev-deleted-text-permission' ); |
920 | 923 | $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); |
921 | 924 | wfProfileOut( __METHOD__ ); |
— | — | @@ -2971,7 +2974,7 @@ |
2972 | 2975 | * @param $oldid String: revision ID of this article revision |
2973 | 2976 | */ |
2974 | 2977 | public function setOldSubtitle( $oldid = 0 ) { |
2975 | | - global $wgLang, $wgOut, $wgUser; |
| 2978 | + global $wgLang, $wgOut, $wgUser, $wgRequest; |
2976 | 2979 | |
2977 | 2980 | if( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) { |
2978 | 2981 | return; |
— | — | @@ -3022,16 +3025,17 @@ |
3023 | 3026 | } |
3024 | 3027 | $cdel = "(<small>$cdel</small>) "; |
3025 | 3028 | } |
3026 | | - # Show user links if allowed to see them. Normally they |
3027 | | - # are hidden regardless, but since we can already see the text here... |
3028 | | - $userlinks = $sk->revUserTools( $revision, false ); |
| 3029 | + $unhide = $wgRequest->getInt('unhide') == 1 && $wgUser->matchEditToken( $wgRequest->getVal('token'), $oldid ); |
| 3030 | + # Show user links if allowed to see them. If hidden, then show them only if requested... |
| 3031 | + $userlinks = $sk->revUserTools( $revision, !$unhide ); |
3029 | 3032 | |
3030 | 3033 | $m = wfMsg( 'revision-info-current' ); |
3031 | 3034 | $infomsg = $current && !wfEmptyMsg( 'revision-info-current', $m ) && $m != '-' |
3032 | 3035 | ? 'revision-info-current' |
3033 | 3036 | : 'revision-info'; |
3034 | 3037 | |
3035 | | - $r = "\n\t\t\t\t<div id=\"mw-{$infomsg}\">" . wfMsgExt( $infomsg, array( 'parseinline', 'replaceafter' ), $td, $userlinks, $revision->getID() ) . "</div>\n" . |
| 3038 | + $r = "\n\t\t\t\t<div id=\"mw-{$infomsg}\">" . wfMsgExt( $infomsg, array( 'parseinline', 'replaceafter' ), |
| 3039 | + $td, $userlinks, $revision->getID() ) . "</div>\n" . |
3036 | 3040 | |
3037 | 3041 | "\n\t\t\t\t<div id=\"mw-revision-nav\">" . $cdel . wfMsgHtml( 'revision-nav', $prevdiff, |
3038 | 3042 | $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>\n\t\t\t"; |
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php |
— | — | @@ -542,15 +542,16 @@ |
543 | 543 | * @returns string |
544 | 544 | */ |
545 | 545 | private function historyLine( $rev ) { |
546 | | - global $wgLang; |
| 546 | + global $wgLang, $wgUser; |
547 | 547 | |
548 | 548 | $date = $wgLang->timeanddate( $rev->getTimestamp() ); |
549 | 549 | $difflink = $del = ''; |
550 | 550 | // Live revisions |
551 | 551 | if( $this->deleteKey=='oldid' ) { |
552 | | - $revlink = $this->skin->makeLinkObj( $this->page, $date, 'oldid=' . $rev->getId() ); |
| 552 | + $tokenParams = '&unhide=1&token='.urlencode( $wgUser->editToken( $rev->getId() ) ); |
| 553 | + $revlink = $this->skin->makeLinkObj( $this->page, $date, 'oldid='.$rev->getId() . $tokenParams ); |
553 | 554 | $difflink = '(' . $this->skin->makeKnownLinkObj( $this->page, wfMsgHtml('diff'), |
554 | | - 'diff=' . $rev->getId() . '&oldid=prev' ) . ')'; |
| 555 | + 'diff=' . $rev->getId() . '&oldid=prev' . $tokenParams ) . ')'; |
555 | 556 | // Archived revisions |
556 | 557 | } else { |
557 | 558 | $undelete = SpecialPage::getTitleFor( 'Undelete' ); |
— | — | @@ -560,7 +561,7 @@ |
561 | 562 | $difflink = '(' . $this->skin->makeKnownLinkObj( $undelete, wfMsgHtml('diff'), |
562 | 563 | "target=$target&diff=prev×tamp=" . $rev->getTimestamp() ) . ')'; |
563 | 564 | } |
564 | | - |
| 565 | + // Check permissions; items may be "suppressed" |
565 | 566 | if( $rev->isDeleted(Revision::DELETED_TEXT) ) { |
566 | 567 | $revlink = '<span class="history-deleted">'.$revlink.'</span>'; |
567 | 568 | $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>'; |
— | — | @@ -569,8 +570,10 @@ |
570 | 571 | $difflink = '(' . wfMsgHtml('diff') . ')'; |
571 | 572 | } |
572 | 573 | } |
| 574 | + $userlink = $this->skin->revUserLink( $rev ); |
| 575 | + $comment = $this->skin->revComment( $rev ); |
573 | 576 | |
574 | | - return "<li> $difflink $revlink ".$this->skin->revUserLink( $rev )." ".$this->skin->revComment( $rev )."$del</li>"; |
| 577 | + return "<li> $difflink $revlink $userlink $comment{$del}</li>"; |
575 | 578 | } |
576 | 579 | |
577 | 580 | /** |
Index: trunk/phase3/includes/PageHistory.php |
— | — | @@ -315,11 +315,11 @@ |
316 | 316 | $s .= " $link"; |
317 | 317 | $s .= " <span class='history-user'>" . $this->mSkin->revUserTools( $rev, true ) . "</span>"; |
318 | 318 | |
319 | | - if( $row->rev_minor_edit ) { |
| 319 | + if( $rev->isMinor() ) { |
320 | 320 | $s .= ' ' . Xml::element( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') ); |
321 | 321 | } |
322 | 322 | |
323 | | - if( !is_null( $size = $rev->getSize() ) && $rev->userCan( Revision::DELETED_TEXT ) ) { |
| 323 | + if( !is_null( $size = $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) { |
324 | 324 | $s .= ' ' . $this->mSkin->formatRevisionSize( $size ); |
325 | 325 | } |
326 | 326 | |
— | — | @@ -381,15 +381,11 @@ |
382 | 382 | function revLink( $rev ) { |
383 | 383 | global $wgLang; |
384 | 384 | $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true ); |
385 | | - if( $rev->userCan( Revision::DELETED_TEXT ) ) { |
386 | | - $link = $this->mSkin->makeKnownLinkObj( |
387 | | - $this->mTitle, $date, "oldid=" . $rev->getId() ); |
| 385 | + if( !$rev->isDeleted( Revision::DELETED_TEXT ) ) { |
| 386 | + $link = $this->mSkin->makeKnownLinkObj( $this->mTitle, $date, "oldid=" . $rev->getId() ); |
388 | 387 | } else { |
389 | | - $link = $date; |
| 388 | + $link = '<span class="history-deleted">' . $date . '</span>'; |
390 | 389 | } |
391 | | - if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { |
392 | | - return '<span class="history-deleted">' . $link . '</span>'; |
393 | | - } |
394 | 390 | return $link; |
395 | 391 | } |
396 | 392 | |
— | — | @@ -401,7 +397,7 @@ |
402 | 398 | */ |
403 | 399 | function curLink( $rev, $latest ) { |
404 | 400 | $cur = $this->message['cur']; |
405 | | - if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) { |
| 401 | + if( $latest || $rev->isDeleted( Revision::DELETED_TEXT ) ) { |
406 | 402 | return $cur; |
407 | 403 | } else { |
408 | 404 | return $this->mSkin->makeKnownLinkObj( $this->mTitle, $cur, |
— | — | @@ -427,7 +423,7 @@ |
428 | 424 | # Next row probably exists but is unknown, use an oldid=prev link |
429 | 425 | return $this->mSkin->makeKnownLinkObj( $this->mTitle, $last, |
430 | 426 | "diff=" . $prevRev->getId() . "&oldid=prev" ); |
431 | | - } elseif( !$prevRev->userCan(Revision::DELETED_TEXT) || !$nextRev->userCan(Revision::DELETED_TEXT) ) { |
| 427 | + } elseif( $prevRev->isDeleted(Revision::DELETED_TEXT) || $nextRev->isDeleted(Revision::DELETED_TEXT) ) { |
432 | 428 | return $last; |
433 | 429 | } else { |
434 | 430 | return $this->mSkin->makeKnownLinkObj( $this->mTitle, $last, |
— | — | @@ -454,7 +450,7 @@ |
455 | 451 | $checkmark = array( 'checked' => 'checked' ); |
456 | 452 | } else { |
457 | 453 | # Check visibility of old revisions |
458 | | - if( !$rev->userCan( Revision::DELETED_TEXT ) ) { |
| 454 | + if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { |
459 | 455 | $radio['disabled'] = 'disabled'; |
460 | 456 | $checkmark = array(); // We will check the next possible one |
461 | 457 | } else if( $counter == 2 || !$this->mOldIdChecked ) { |