* Don't show links to deleted revs in history for anyone (consistency)
* Always hide deleted content from all users; it can be viewed via (show/hide) links
}
$wgOut->setRobotPolicy( $policy );
}
$wgOut->setRobotPolicy( $policy );
+ # Allow admins to see deleted content if explicitly requested
+ $delId = $diff ? $diff : $oldid;
+ $unhide = $wgRequest->getInt('unhide') == 1 && $wgUser->matchEditToken( $wgRequest->getVal('token'), $delId );
# If we got diff and oldid in the query, we want to see a
# diff page instead of the article.
if( !is_null( $diff ) ) {
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
# If we got diff and oldid in the query, we want to see a
# diff page instead of the article.
if( !is_null( $diff ) ) {
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
- $diff = $wgRequest->getVal( 'diff' );
$htmldiff = $wgRequest->getVal( 'htmldiff' , false);
$htmldiff = $wgRequest->getVal( 'htmldiff' , false);
- $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge, $htmldiff);
+ $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge, $htmldiff, $unhide );
// DifferenceEngine directly fetched the revision:
$this->mRevIdFetched = $de->mNewid;
$de->showDiffPage( $diffOnly );
// DifferenceEngine directly fetched the revision:
$this->mRevIdFetched = $de->mNewid;
$de->showDiffPage( $diffOnly );
// FIXME: This would be a nice place to load the 'no such page' text.
} else {
$this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid );
// FIXME: This would be a nice place to load the 'no such page' text.
} else {
$this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid );
+ # Allow admins to see deleted content if explicitly requested
if( $this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
if( $this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
- if( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) {
+ if( !$unhide || !$this->mRevision->userCan(Revision::DELETED_TEXT) ) {
$wgOut->addWikiMsg( 'rev-deleted-text-permission' );
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
wfProfileOut( __METHOD__ );
$wgOut->addWikiMsg( 'rev-deleted-text-permission' );
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
wfProfileOut( __METHOD__ );
* @param $oldid String: revision ID of this article revision
*/
public function setOldSubtitle( $oldid = 0 ) {
* @param $oldid String: revision ID of this article revision
*/
public function setOldSubtitle( $oldid = 0 ) {
- global $wgLang, $wgOut, $wgUser;
+ global $wgLang, $wgOut, $wgUser, $wgRequest;
if( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
return;
if( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
return;
}
$cdel = "(<small>$cdel</small>) ";
}
}
$cdel = "(<small>$cdel</small>) ";
}
- # Show user links if allowed to see them. Normally they
- # are hidden regardless, but since we can already see the text here...
- $userlinks = $sk->revUserTools( $revision, false );
+ $unhide = $wgRequest->getInt('unhide') == 1 && $wgUser->matchEditToken( $wgRequest->getVal('token'), $oldid );
+ # Show user links if allowed to see them. If hidden, then show them only if requested...
+ $userlinks = $sk->revUserTools( $revision, !$unhide );
$m = wfMsg( 'revision-info-current' );
$infomsg = $current && !wfEmptyMsg( 'revision-info-current', $m ) && $m != '-'
? 'revision-info-current'
: 'revision-info';
$m = wfMsg( 'revision-info-current' );
$infomsg = $current && !wfEmptyMsg( 'revision-info-current', $m ) && $m != '-'
? 'revision-info-current'
: 'revision-info';
- $r = "\n\t\t\t\t<div id=\"mw-{$infomsg}\">" . wfMsgExt( $infomsg, array( 'parseinline', 'replaceafter' ), $td, $userlinks, $revision->getID() ) . "</div>\n" .
+ $r = "\n\t\t\t\t<div id=\"mw-{$infomsg}\">" . wfMsgExt( $infomsg, array( 'parseinline', 'replaceafter' ),
+ $td, $userlinks, $revision->getID() ) . "</div>\n" .
"\n\t\t\t\t<div id=\"mw-revision-nav\">" . $cdel . wfMsgHtml( 'revision-nav', $prevdiff,
$prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>\n\t\t\t";
"\n\t\t\t\t<div id=\"mw-revision-nav\">" . $cdel . wfMsgHtml( 'revision-nav', $prevdiff,
$prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>\n\t\t\t";
$s .= " $link";
$s .= " <span class='history-user'>" . $this->mSkin->revUserTools( $rev, true ) . "</span>";
$s .= " $link";
$s .= " <span class='history-user'>" . $this->mSkin->revUserTools( $rev, true ) . "</span>";
- if( $row->rev_minor_edit ) {
+ if( $rev->isMinor() ) {
$s .= ' ' . Xml::element( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') );
}
$s .= ' ' . Xml::element( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') );
}
- if( !is_null( $size = $rev->getSize() ) && $rev->userCan( Revision::DELETED_TEXT ) ) {
+ if( !is_null( $size = $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
$s .= ' ' . $this->mSkin->formatRevisionSize( $size );
}
$s .= ' ' . $this->mSkin->formatRevisionSize( $size );
}
function revLink( $rev ) {
global $wgLang;
$date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true );
function revLink( $rev ) {
global $wgLang;
$date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true );
- if( $rev->userCan( Revision::DELETED_TEXT ) ) {
- $link = $this->mSkin->makeKnownLinkObj(
- $this->mTitle, $date, "oldid=" . $rev->getId() );
+ if( !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
+ $link = $this->mSkin->makeKnownLinkObj( $this->mTitle, $date, "oldid=" . $rev->getId() );
- $link = $date;
- }
- if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
- return '<span class="history-deleted">' . $link . '</span>';
+ $link = '<span class="history-deleted">' . $date . '</span>';
*/
function curLink( $rev, $latest ) {
$cur = $this->message['cur'];
*/
function curLink( $rev, $latest ) {
$cur = $this->message['cur'];
- if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) {
+ if( $latest || $rev->isDeleted( Revision::DELETED_TEXT ) ) {
return $cur;
} else {
return $this->mSkin->makeKnownLinkObj( $this->mTitle, $cur,
return $cur;
} else {
return $this->mSkin->makeKnownLinkObj( $this->mTitle, $cur,
# Next row probably exists but is unknown, use an oldid=prev link
return $this->mSkin->makeKnownLinkObj( $this->mTitle, $last,
"diff=" . $prevRev->getId() . "&oldid=prev" );
# Next row probably exists but is unknown, use an oldid=prev link
return $this->mSkin->makeKnownLinkObj( $this->mTitle, $last,
"diff=" . $prevRev->getId() . "&oldid=prev" );
- } elseif( !$prevRev->userCan(Revision::DELETED_TEXT) || !$nextRev->userCan(Revision::DELETED_TEXT) ) {
+ } elseif( $prevRev->isDeleted(Revision::DELETED_TEXT) || $nextRev->isDeleted(Revision::DELETED_TEXT) ) {
return $last;
} else {
return $this->mSkin->makeKnownLinkObj( $this->mTitle, $last,
return $last;
} else {
return $this->mSkin->makeKnownLinkObj( $this->mTitle, $last,
$checkmark = array( 'checked' => 'checked' );
} else {
# Check visibility of old revisions
$checkmark = array( 'checked' => 'checked' );
} else {
# Check visibility of old revisions
- if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
+ if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
$radio['disabled'] = 'disabled';
$checkmark = array(); // We will check the next possible one
} else if( $counter == 2 || !$this->mOldIdChecked ) {
$radio['disabled'] = 'disabled';
$checkmark = array(); // We will check the next possible one
} else if( $counter == 2 || !$this->mOldIdChecked ) {
var $mRevisionsLoaded = false; // Have the revisions been loaded
var $mTextLoaded = 0; // How many text blobs have been loaded, 0, 1 or 2?
var $htmldiff;
var $mRevisionsLoaded = false; // Have the revisions been loaded
var $mTextLoaded = 0; // How many text blobs have been loaded, 0, 1 or 2?
var $htmldiff;
+
+ protected $unhide = false;
* @param $rcid Integer: ??? FIXME (default 0)
* @param $refreshCache boolean If set, refreshes the diff cache
* @param $htmldiff boolean If set, output using HTMLDiff instead of raw wikicode diff
* @param $rcid Integer: ??? FIXME (default 0)
* @param $refreshCache boolean If set, refreshes the diff cache
* @param $htmldiff boolean If set, output using HTMLDiff instead of raw wikicode diff
+ * @param $unhide boolean If set, allow viewing deleted revs
- function __construct( $titleObj = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false , $htmldiff = false) {
+ function __construct( $titleObj = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false , $htmldiff = false, $unhide = false ) {
$this->mTitle = $titleObj;
wfDebug("DifferenceEngine old '$old' new '$new' rcid '$rcid'\n");
$this->mTitle = $titleObj;
wfDebug("DifferenceEngine old '$old' new '$new' rcid '$rcid'\n");
$this->mRcidMarkPatrolled = intval($rcid); # force it to be an integer
$this->mRefreshCache = $refreshCache;
$this->htmldiff = $htmldiff;
$this->mRcidMarkPatrolled = intval($rcid); # force it to be an integer
$this->mRefreshCache = $refreshCache;
$this->htmldiff = $htmldiff;
+ $this->unhide = $unhide;
}
$oldHeader = '<div id="mw-diff-otitle1"><strong>'.$this->mOldtitle.'</strong></div>' .
}
$oldHeader = '<div id="mw-diff-otitle1"><strong>'.$this->mOldtitle.'</strong></div>' .
- '<div id="mw-diff-otitle2">' . $sk->revUserTools( $this->mOldRev, true ) . "</div>" .
- '<div id="mw-diff-otitle3">' . $oldminor . $sk->revComment( $this->mOldRev, !$diffOnly, true ) . $ldel . "</div>" .
+ '<div id="mw-diff-otitle2">' . $sk->revUserTools( $this->mOldRev, !$this->unhide ) . "</div>" .
+ '<div id="mw-diff-otitle3">' . $oldminor . $sk->revComment( $this->mOldRev, !$diffOnly, !$this->unhide ).$ldel."</div>" .
'<div id="mw-diff-otitle4">' . $prevlink .'</div>';
$newHeader = '<div id="mw-diff-ntitle1"><strong>'.$this->mNewtitle.'</strong></div>' .
'<div id="mw-diff-otitle4">' . $prevlink .'</div>';
$newHeader = '<div id="mw-diff-ntitle1"><strong>'.$this->mNewtitle.'</strong></div>' .
- '<div id="mw-diff-ntitle2">' . $sk->revUserTools( $this->mNewRev, true ) . " $rollback</div>" .
- '<div id="mw-diff-ntitle3">' . $newminor . $sk->revComment( $this->mNewRev, !$diffOnly, true ) . $rdel . "</div>" .
+ '<div id="mw-diff-ntitle2">' . $sk->revUserTools( $this->mNewRev, !$this->unhide ) . " $rollback</div>" .
+ '<div id="mw-diff-ntitle3">' . $newminor . $sk->revComment( $this->mNewRev, !$diffOnly, !$this->unhide ).$rdel."</div>" .
'<div id="mw-diff-ntitle4">' . $nextlink . $patrol . '</div>';
'<div id="mw-diff-ntitle4">' . $nextlink . $patrol . '</div>';
- # Output the diff
- if( !$this->mOldRev->userCan(Revision::DELETED_TEXT) || !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) {
+ # Output the diff if allowed
+ $allowed = $this->mOldRev->userCan(Revision::DELETED_TEXT) && $this->mNewRev->userCan(Revision::DELETED_TEXT);
+ $deleted = $this->mOldRev->isDeleted(Revision::DELETED_TEXT) || $this->mNewRev->isDeleted(Revision::DELETED_TEXT);
+ if( $deleted && (!$this->unhide || !$allowed) ) {
$this->showDiffStyle();
$multi = $this->getMultiNotice();
$wgOut->addHTML( $this->addHeader( '', $oldHeader, $newHeader, $multi ) );
$this->showDiffStyle();
$multi = $this->getMultiNotice();
$wgOut->addHTML( $this->addHeader( '', $oldHeader, $newHeader, $multi ) );
* @returns string
*/
private function historyLine( $rev ) {
* @returns string
*/
private function historyLine( $rev ) {
+ global $wgLang, $wgUser;
$date = $wgLang->timeanddate( $rev->getTimestamp() );
$difflink = $del = '';
// Live revisions
if( $this->deleteKey=='oldid' ) {
$date = $wgLang->timeanddate( $rev->getTimestamp() );
$difflink = $del = '';
// Live revisions
if( $this->deleteKey=='oldid' ) {
- $revlink = $this->skin->makeLinkObj( $this->page, $date, 'oldid=' . $rev->getId() );
+ $tokenParams = '&unhide=1&token='.urlencode( $wgUser->editToken( $rev->getId() ) );
+ $revlink = $this->skin->makeLinkObj( $this->page, $date, 'oldid='.$rev->getId() . $tokenParams );
$difflink = '(' . $this->skin->makeKnownLinkObj( $this->page, wfMsgHtml('diff'),
$difflink = '(' . $this->skin->makeKnownLinkObj( $this->page, wfMsgHtml('diff'),
- 'diff=' . $rev->getId() . '&oldid=prev' ) . ')';
+ 'diff=' . $rev->getId() . '&oldid=prev' . $tokenParams ) . ')';
// Archived revisions
} else {
$undelete = SpecialPage::getTitleFor( 'Undelete' );
// Archived revisions
} else {
$undelete = SpecialPage::getTitleFor( 'Undelete' );
$difflink = '(' . $this->skin->makeKnownLinkObj( $undelete, wfMsgHtml('diff'),
"target=$target&diff=prev×tamp=" . $rev->getTimestamp() ) . ')';
}
$difflink = '(' . $this->skin->makeKnownLinkObj( $undelete, wfMsgHtml('diff'),
"target=$target&diff=prev×tamp=" . $rev->getTimestamp() ) . ')';
}
+ // Check permissions; items may be "suppressed"
if( $rev->isDeleted(Revision::DELETED_TEXT) ) {
$revlink = '<span class="history-deleted">'.$revlink.'</span>';
$del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
if( $rev->isDeleted(Revision::DELETED_TEXT) ) {
$revlink = '<span class="history-deleted">'.$revlink.'</span>';
$del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
$difflink = '(' . wfMsgHtml('diff') . ')';
}
}
$difflink = '(' . wfMsgHtml('diff') . ')';
}
}
+ $userlink = $this->skin->revUserLink( $rev );
+ $comment = $this->skin->revComment( $rev );
- return "<li> $difflink $revlink ".$this->skin->revUserLink( $rev )." ".$this->skin->revComment( $rev )."$del</li>";
+ return "<li> $difflink $revlink $userlink $comment{$del}</li>";