From 9150412fe7954093af3506fab1d5c7af86db98e5 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 16 Mar 2007 16:01:07 +0000 Subject: [PATCH] For now revert the rev_deleted branch merge; don't want trunk to get too far gone before changes are reviewed! Reverted: 20511, 20510, 20507, 20474, 20461, 20460, 20457, 20448, 20446 --- RELEASE-NOTES | 4 - includes/Article.php | 78 +---- includes/ChangesList.php | 304 +++++-------------- includes/DefaultSettings.php | 32 +- includes/DifferenceEngine.php | 91 ++---- includes/Export.php | 5 +- includes/ImagePage.php | 18 +- includes/Linker.php | 164 +---------- includes/LogPage.php | 32 +- includes/PageHistory.php | 44 ++- includes/RecentChange.php | 58 +--- includes/SpecialBlockip.php | 41 +-- includes/SpecialLog.php | 317 ++------------------ includes/SpecialRecentchanges.php | 9 +- includes/SpecialRevisiondelete.php | 449 ++++------------------------- includes/SpecialUndelete.php | 382 ++++-------------------- 16 files changed, 337 insertions(+), 1691 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6207714203..9e1575b259 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -270,10 +270,6 @@ lighter making things easier to read. * (bug 3984) Searching in logs by title% * (bug 9244) When calling edit page for nonexistent section, generate error inside of just discarding edits, since edit links sometimes go to the wrong place. * Private logs can now be created using $wgLogRestrictions -* (bug 3576) Revisiondelete completed (RSS feeds checked, carries over delete/undelete) -* Log events, file revisions, archived revisions can be deleted with revisiondelete -* Usernames can be hidden from block log, block list, and user list via blockip. These - blocks are instead logged privately * Show thumbnail of existing image if image exists already under this filename * (bug 5546) Watchlist reflects logged actions like move, protection, undelete * (bug 9019) No warning during upload if image description page exists, but no diff --git a/includes/Article.php b/includes/Article.php index 3debb17315..3c8d10e094 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1652,7 +1652,7 @@ class Article { * @return bool true on success */ function updateRestrictions( $limit = array(), $reason = '', $cascade = 0, $expiry = null ) { - global $wgUser, $wgRestrictionTypes, $wgContLang, $wgGroupPermissions; + global $wgUser, $wgRestrictionTypes, $wgContLang; $id = $this->mTitle->getArticleID(); if( !$wgUser->isAllowed( 'protect' ) || wfReadOnly() || $id == 0 ) { @@ -1707,11 +1707,6 @@ class Article { $nullRevision = Revision::newNullRevision( $dbw, $id, $comment, true ); $nullRevId = $nullRevision->insertOn( $dbw ); - foreach( $limit as $action => $restrictions ) { - # Check if the group level required to edit also can protect pages - # Otherwise, people who cannot normally protect can "protect" pages via transclusion - $cascade = ( $cascade && isset($wgGroupPermissions[$restrictions]['protect']) && $wgGroupPermissions[$restrictions]['protect'] ); - } # Update restrictions table foreach( $limit as $action => $restrictions ) { if ($restrictions != '' ) { @@ -1787,8 +1782,6 @@ class Article { $confirm = $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ); $reason = $wgRequest->getText( 'wpReason' ); - # Flag to hide all contents of the archived revisions - $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed('deleterevision'); # This code desperately needs to be totally rewritten @@ -1820,7 +1813,7 @@ class Article { } if( $confirm ) { - $this->doDelete( $reason, $suppress ); + $this->doDelete( $reason ); if( $wgRequest->getCheck( 'wpWatch' ) ) { $this->doWatch(); } elseif( $this->mTitle->userIsWatching() ) { @@ -1966,14 +1959,7 @@ class Article { $delcom = htmlspecialchars( wfMsg( 'deletecomment' ) ); $token = htmlspecialchars( $wgUser->editToken() ); $watch = Xml::checkLabel( wfMsg( 'watchthis' ), 'wpWatch', 'wpWatch', $wgUser->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching(), array( 'tabindex' => '2' ) ); - if ( $wgUser->isAllowed( 'deleterevision' ) ) { - $supress = " "; - $supress .= Xml::checkLabel( wfMsg( 'revdelete-suppress' ), 'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '2' ) ); - $supress .= ""; - } else { - $supress = ''; - } - + $wgOut->addHTML( "
@@ -1985,7 +1971,6 @@ class Article { - $supress @@ -2024,12 +2009,12 @@ class Article { /** * Perform a deletion and output success or failure messages */ - function doDelete( $reason, $suppress = false ) { + function doDelete( $reason ) { global $wgOut, $wgUser; wfDebug( __METHOD__."\n" ); if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason))) { - if ( $this->doDeleteArticle( $reason, $suppress ) ) { + if ( $this->doDeleteArticle( $reason ) ) { $deleted = wfEscapeWikiText( $this->mTitle->getPrefixedText() ); $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) ); @@ -2052,7 +2037,7 @@ class Article { * Deletes the article with database consistency, writes logs, purges caches * Returns success */ - function doDeleteArticle( $reason, $suppress = false ) { + function doDeleteArticle( $reason ) { global $wgUseSquid, $wgDeferredUpdateList; global $wgUseTrackbacks; @@ -2070,17 +2055,6 @@ class Article { $u = new SiteStatsUpdate( 0, 1, -(int)$this->isCountable( $this->getContent() ), -1 ); array_push( $wgDeferredUpdateList, $u ); - // Bitfields to further supress the content - if ( $suppress ) { - $bitfield = 0; - $bitfield |= Revision::DELETED_TEXT; - $bitfield |= Revision::DELETED_COMMENT; - $bitfield |= Revision::DELETED_USER; - $bitfield |= Revision::DELETED_RESTRICTED; - } else { - $bitfield = 'rev_deleted'; - } - // For now, shunt the revision data into the archive table. // Text is *not* removed from the text table; bulk storage // is left intact to avoid breaking block-compression or @@ -2104,7 +2078,7 @@ class Article { 'ar_text_id' => 'rev_text_id', 'ar_text' => '\'\'', // Be explicit to appease 'ar_flags' => '\'\'', // MySQL's "strict mode"... - 'ar_deleted' => $bitfield + 'ar_len' => 'rev_len' ), array( 'page_id' => $id, 'page_id = rev_page' @@ -2145,9 +2119,8 @@ class Article { # Clear caches Article::onArticleDelete( $this->mTitle ); - # Log the deletion, if the page was suppressed, log it at Oversight instead - $logtype = ($suppress) ? 'oversight' : 'delete'; - $log = new LogPage( $logtype ); + # Log the deletion + $log = new LogPage( 'delete' ); $log->addEntry( 'delete', $this->mTitle, $reason ); # Clear the cached article id so the interface doesn't act like we exist @@ -2253,13 +2226,8 @@ class Article { ); } - $target = Revision::newFromId( $s->rev_id ); - # Revision *must* be public and we don't well handle deleted edits on top - if ( $target->isDeleted(REVISION::DELETED_TEXT) ) { - $wgOut->setPageTitle( wfMsg('rollbackfailed') ); - $wgOut->addHTML( wfMsg( 'missingarticle' ) ); - } # Get the edit summary + $target = Revision::newFromId( $s->rev_id ); $newComment = wfMsgForContent( 'revertpage', $target->getUserText(), $from ); $newComment = $wgRequest->getText( 'summary', $newComment ); @@ -2437,30 +2405,10 @@ class Article { ? wfMsg( 'diff' ) : $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'diff' ), 'diff=next&oldid='.$oldid ); - $cdel=''; - if( $wgUser->isAllowed( 'deleterevision' ) ) { - $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); - if( $revision->isCurrent() ) { - // We don't handle top deleted edits too well - $cdel = wfMsgHtml('rev-delundel'); - } else if( !$revision->userCan( Revision::DELETED_RESTRICTED ) ) { - // If revision was hidden from sysops - $cdel = wfMsgHtml('rev-delundel'); - } else { - $cdel = $sk->makeKnownLinkObj( $revdel, - wfMsgHtml('rev-delundel'), - 'target=' . urlencode( $this->mTitle->getPrefixedDbkey() ) . - '&oldid=' . urlencode( $oldid ) ); - // Bolden oversighted content - if( $revision->isDeleted( Revision::DELETED_RESTRICTED ) ) - $cdel = "$cdel"; - } - $cdel = "($cdel)"; - } - - $userlinks = $sk->revUserTools( $revision, true ); + $userlinks = $sk->userLink( $revision->getUser(), $revision->getUserText() ) + . $sk->userToolLinks( $revision->getUser(), $revision->getUserText() ); - $r = "\n\t\t\t\t
" . "$cdel" . wfMsg( 'revision-info', $td, $userlinks ) . "
\n" . + $r = "\n\t\t\t\t
" . wfMsg( 'revision-info', $td, $userlinks ) . "
\n" . "\n\t\t\t\t
" . wfMsg( 'revision-nav', $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "
\n\t\t\t"; $wgOut->setSubtitle( $r ); } diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 3e51146759..43fd543703 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -12,11 +12,10 @@ class RCCacheEntry extends RecentChange { var $secureName, $link; - var $curlinks, $difflink, $lastlink , $usertalklink , $versionlink ; + var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ; var $userlink, $timestamp, $watched; - function newFromParent( $rc ) - { + function newFromParent( $rc ) { $rc2 = new RCCacheEntry; $rc2->mAttribs = $rc->mAttribs; $rc2->mExtra = $rc->mExtra; @@ -25,7 +24,6 @@ class RCCacheEntry extends RecentChange } ; /** - * @package MediaWiki */ class ChangesList { # Called by history lists and recent changes @@ -79,7 +77,7 @@ class ChangesList { : $nothing; $f .= $bot ? '' . $this->message['boteditletter'] . '' : $nothing; $f .= $patrolled ? '!' : $nothing; - return "$f"; + return $f; } /** @@ -105,32 +103,6 @@ class ChangesList { } } - /** - * int $field one of DELETED_* bitfield constants - * @return bool - */ - function isDeleted( $rc, $field ) { - return ($rc->mAttribs['rc_deleted'] & $field) == $field; - } - - /** - * Determine if the current user is allowed to view a particular - * field of this revision, if it's marked as deleted. - * @param int $field - * @return bool - */ - function userCan( $rc, $field ) { - if( ( $rc->mAttribs['rc_deleted'] & $field ) == $field ) { - global $wgUser; - $permission = ( $rc->mAttribs['rc_deleted'] & Revision::DELETED_RESTRICTED ) == Revision::DELETED_RESTRICTED - ? 'hiderevision' - : 'deleterevision'; - wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" ); - return $wgUser->isAllowed( $permission ); - } else { - return true; - } - } function insertMove( &$s, $rc ) { # Diff @@ -166,11 +138,10 @@ class ChangesList { $s .= '(' . $this->skin->makeKnownLinkObj($title, $logname ) . ')'; } + function insertDiffHist(&$s, &$rc, $unpatrolled) { # Diff link - if( !$this->userCan($rc,Revision::DELETED_TEXT) ) { - $diffLink = $this->message['diff']; - } else if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG) { + if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) { $diffLink = $this->message['diff']; } else { $rcidparam = $unpatrolled @@ -201,12 +172,7 @@ class ChangesList { $params = ( $unpatrolled && $rc->mAttribs['rc_type'] == RC_NEW ) ? 'rcid='.$rc->mAttribs['rc_id'] : ''; - if( $this->isDeleted($rc,Revision::DELETED_TEXT) ) { - $articlelink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params ); - $articlelink = ''.$articlelink.''; - } else { - $articlelink = ' '. $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params ); - } + $articlelink = ' '. $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params ); if($watched) $articlelink = ''.$articlelink.''; global $wgContLang; $articlelink .= $wgContLang->getDirMark(); @@ -222,37 +188,15 @@ class ChangesList { /** Insert links to user page, user talk page and eventually a blocking link */ function insertUserRelatedLinks(&$s, &$rc) { - if ( $this->isDeleted($rc,Revision::DELETED_USER) ) { - $s .= ' ' . wfMsgHtml('rev-deleted-user') . ''; - } else { - $s .= $this->skin->userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); - $s .= $this->skin->userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); - } - } - - /** insert a formatted action */ - function insertAction(&$s, &$rc) { - # Add comment - if( $rc->mAttribs['rc_type'] == RC_LOG ) { - // log action - if ( $this->isDeleted($rc,LogViewer::DELETED_ACTION) ) { - $s .= ' ' . wfMsgHtml('rev-deleted-event') . ''; - } else { - $s .= ' ' . LogPage::actionText( $rc->mAttribs['rc_log_type'], $rc->mAttribs['rc_log_action'], $rc->getTitle(), $this->skin, LogPage::extractParams($rc->mAttribs['rc_params']), true, true ); - } - } + $s .= $this->skin->userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); + $s .= $this->skin->userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); } /** insert a formatted comment */ function insertComment(&$s, &$rc) { # Add comment if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) { - // log comment - if ( $this->isDeleted($rc,Revision::DELETED_COMMENT) ) { - $s .= ' ' . wfMsgHtml('rev-deleted-comment') . ''; - } else { - $s .= $this->skin->commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() ); - } + $s .= $this->skin->commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() ); } } @@ -308,23 +252,19 @@ class OldChangesList extends ChangesList { $s .= '
  • '; - // Moved pages + // moved pages if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $this->insertMove( $s, $rc ); - // Log entries (old format) or log targets, and special pages - } elseif( $rc_namespace == NS_SPECIAL ) { + // log entries + } elseif ( $rc_namespace == NS_SPECIAL ) { list( $specialName, $specialSubpage ) = SpecialPage::resolveAliasWithSubpage( $rc_title ); if ( $specialName == 'Log' ) { $this->insertLog( $s, $rc->getTitle(), $specialSubpage ); } else { wfDebug( "Unexpected special page in recentchanges\n" ); } - // Log entries - } elseif( $rc_log_type !='' ) { - $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL ); - $this->insertLog( $s, $logtitle, $rc_log_type ); - // All other stuff - } else { + // all other stuff + } else { wfProfileIn($fname.'-page'); $this->insertDiffHist($s, $rc, $unpatrolled); @@ -345,15 +285,9 @@ class OldChangesList extends ChangesList { } $this->insertUserRelatedLinks($s,$rc); - $this->insertAction($s, $rc); $this->insertComment($s, $rc); - - # Mark revision as deleted - if ( !$rc_log_type && $this->isDeleted($rc,Revision::DELETED_TEXT) ) - $s .= ' ' . wfMsgHtml( 'deletedrev' ) . ''; - if($rc->numberofWatchingusers > 0) { - $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers)); - } + + $s .= rtrim(' ' . $this->numberofWatchingusers($rc->numberofWatchingusers)); $s .= "
  • \n"; @@ -401,14 +335,12 @@ class EnhancedChangesList extends ChangesList { $rc->unpatrolled = false; } - $showrev=true; # Make article link if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $msg = ( $rc_type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir"; $clink = wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ), $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) ); - } else if( $rc_namespace == NS_SPECIAL ) { - // Log entries (old format) and special pages + } elseif( $rc_namespace == NS_SPECIAL ) { list( $specialName, $logtype ) = SpecialPage::resolveAliasWithSubpage( $rc_title ); if ( $specialName == 'Log' ) { # Log updates, etc @@ -418,16 +350,7 @@ class EnhancedChangesList extends ChangesList { wfDebug( "Unexpected special page in recentchanges\n" ); $clink = ''; } - } elseif ( $rc_log_type !='' ) { - // Log entries - $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL ); - $logname = LogPage::logName( $rc_log_type ); - $clink = '(' . $this->skin->makeKnownLinkObj($logtitle, $logname ) . ')'; - } if ( $this->isDeleted($rc,Revision::DELETED_TEXT) ) { - $clink = '' . $this->skin->makeKnownLinkObj( $rc->getTitle(), '' ) . ''; - if ( !ChangesList::userCan($rc,Revision::DELETED_TEXT) ) - $showrev=false; - } else if( $rc->unpatrolled && $rc_type == RC_NEW ) { + } elseif( $rc->unpatrolled && $rc_type == RC_NEW ) { # Unpatrolled new page, give rc_id in query $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" ); } else { @@ -450,10 +373,7 @@ class EnhancedChangesList extends ChangesList { $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery"; $aprops = ' tabindex="'.$baseRC->counter.'"'; $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['cur'], $querycur, '' ,'', $aprops ); - if ( !$showrev ) { - $curLink = $this->message['cur']; - $diffLink = $this->message['diff']; - } else if( $rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { + if( $rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { if( $rc_type != RC_NEW ) { $curLink = $this->message['cur']; } @@ -463,27 +383,21 @@ class EnhancedChangesList extends ChangesList { } # Make "last" link - if ( !$showrev ) { - $lastLink = $this->message['last']; - } else if( $rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { + if( $rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $lastLink = $this->message['last']; } else { $lastLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['last'], - $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery ); - } - - # Make user links - if ( $this->isDeleted($rc,Revision::DELETED_USER) ) { - $rc->userlink = ' ' . wfMsgHtml('rev-deleted-user') . ''; - } else { - $rc->userlink = $this->skin->userLink( $rc_user, $rc_user_text ); - $rc->usertalklink = $this->skin->userToolLinks( $rc_user, $rc_user_text ); + $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery ); } + $rc->userlink = $this->skin->userLink( $rc_user, $rc_user_text ); + $rc->lastlink = $lastLink; $rc->curlink = $curLink; $rc->difflink = $diffLink; + $rc->usertalklink = $this->skin->userToolLinks( $rc_user, $rc_user_text ); + # Put accumulated information into the cache, for later display # Page moves go on their own line $title = $rc->getTitle(); @@ -505,11 +419,10 @@ class EnhancedChangesList extends ChangesList { */ function recentChangesBlockGroup( $block ) { global $wgLang, $wgContLang, $wgRCShowChangedSize; - $r = '
      $watch
    '; + $r = ''; # Collate list of users $isnew = false; - $namehidden = true; $unpatrolled = false; $userlinks = array(); foreach( $block as $rcObj ) { @@ -517,11 +430,6 @@ class EnhancedChangesList extends ChangesList { if( $rcObj->mAttribs['rc_new'] ) { $isnew = true; } - // if all log actions to this page were hidden, then don't - // give the name of the affected page for this block - if( !($rcObj->mAttribs['rc_deleted'] & LogViewer::DELETED_ACTION) ) { - $namehidden = false; - } $u = $rcObj->userlink; if( !isset( $userlinks[$u] ) ) { $userlinks[$u] = 0; @@ -555,25 +463,24 @@ class EnhancedChangesList extends ChangesList { $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')"; $tl = '' . $this->sideArrow() . ''; $tl .= ''; - $r .= '
    '.$tl; + $r .= $tl; # Main line - $r .= ' '.$this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot ); + $r .= ''; + $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot ); # Timestamp - $r .= ' '.$block[0]->timestamp.'  '; + $r .= ' '.$block[0]->timestamp.' '; # Article link - if ( $namehidden ) - $r .= ' ' . wfMsgHtml('rev-deleted-event') . ''; - else - $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched ); + $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched ); $r .= $wgContLang->getDirMark(); $curIdEq = 'curid=' . $block[0]->mAttribs['rc_cur_id']; $currentRevision = $block[0]->mAttribs['rc_this_oldid']; if( $block[0]->mAttribs['rc_type'] != RC_LOG ) { # Changes + $n = count($block); static $nchanges = array(); if ( !isset( $nchanges[$n] ) ) { @@ -583,95 +490,77 @@ class EnhancedChangesList extends ChangesList { $r .= ' ('; - if( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) { - $r .= $nchanges[$n]; - } else if( $isnew ) { + if( $isnew ) { $r .= $nchanges[$n]; } else { $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(), $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" ); } + $r .= ') . . '; + # Character difference $chardiff = $rcObj->getCharacterDifference( $block[ count( $block ) - 1 ]->mAttribs['rc_old_len'], $block[0]->mAttribs['rc_new_len'] ); if( $chardiff == '' ) { - $r .= '; '; + $r .= ' ('; } else { - $r .= '; ' . $chardiff . ' '; + $r .= ' ' . $chardiff. ' . . ('; } + # History - $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(), $this->message['history'], $curIdEq.'&action=history' ); - + $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(), + $this->message['history'], $curIdEq.'&action=history' ); $r .= ')'; } $r .= $users; - $r .=$this->numberofWatchingusers($block[0]->numberofWatchingusers); - - $r .= "
    \n"; + + $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers); + $r .= "
    \n"; # Sub-entries - $r .= '\n"; + $r .= "\n"; $this->rcCacheIndex++; return $r; @@ -728,23 +617,8 @@ class EnhancedChangesList extends ChangesList { * @access private */ function spacerArrow() { - //FIXME: problems with FF 1.5x return $this->arrow( '', ' ' ); } - - /** - * Generate HTML for the equivilant of a spacer image for tables - * @return string HTML tag - * @access private - */ - function spacerColumn() { - return ''; - } - - // Adds a few spaces - function spacerIndent() { - return '     '; - } /** * Enhanced RC ungrouped line. @@ -758,64 +632,46 @@ class EnhancedChangesList extends ChangesList { extract( $rcObj->mAttribs ); $curIdEq = 'curid='.$rc_cur_id; - $r = '
    '; + $r = ''; + + # Spacer image + $r .= $this->spacerArrow(); - # spacerArrow() causes issues in FF - $r .= $this->spacerColumn(); - $r .= ''; - # Flag and Timestamp + $r .= ''; + if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { - $r .= '    '; + $r .= '   '; } else { - $r .= ' '.$this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot ); + $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot ); } - $r .= ' '.$rcObj->timestamp.'  '; - + $r .= ' '.$rcObj->timestamp.' '; + # Article link - if ( $rc_log_type !='' ) { - $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL ); - $logname = LogPage::logName( $rc_log_type ); - $r .= '(' . $this->skin->makeKnownLinkObj($logtitle, $logname ) . ')'; - // All other stuff - } else { - $r .= $this->maybeWatchedLink( $rcObj->link, $rcObj->watched ); - } - if ( $rc_type != RC_LOG ) { - # Diff - $r .= ' ('. $rcObj->difflink .'; '; - # Hist - $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')'; - } - $r .= ' . . '; - + $r .= $this->maybeWatchedLink( $rcObj->link, $rcObj->watched ); + + # Diff + $r .= ' ('. $rcObj->difflink .'; '; + + # Hist + $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ') . . '; + # Character diff if( $wgRCShowChangedSize ) { $r .= ( $rcObj->getCharacterDifference() == '' ? '' : ' ' . $rcObj->getCharacterDifference() . ' . . ' ) ; } # User/talk - $r .= ' '.$rcObj->userlink . $rcObj->usertalklink; + $r .= $rcObj->userlink . $rcObj->usertalklink; # Comment if( $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) { - // log action - if ( $this->isDeleted($rcObj,LogViewer::DELETED_ACTION) ) { - $r .= ' ' . wfMsgHtml('rev-deleted-event') . ''; - } else { - $r .= ' ' . LogPage::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(), $this->skin, LogPage::extractParams($rc_params), true, true ); - } - // log comment - if ( $this->isDeleted($rcObj,LogViewer::DELETED_COMMENT) ) { - $r .= ' ' . wfMsg('rev-deleted-comment') . ''; - } else { - $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() ); - } + $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() ); } $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers); - $r .= "
    \n"; + $r .= "
    \n"; return $r; } diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 65a4d02f0b..7b8df3f001 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -169,7 +169,7 @@ $wgUploadBaseUrl = ""; * is writable to the web server but is not exposed to the internet. * * Set $wgSaveDeletedFiles to true and set up the save path in - * $wgFileStore['deleted']['directory'] + * $wgFileStore['deleted']['directory']. */ $wgSaveDeletedFiles = false; @@ -983,7 +983,6 @@ $wgGroupPermissions['bot' ]['nominornewtalk'] = true; $wgGroupPermissions['sysop']['block'] = true; $wgGroupPermissions['sysop']['createaccount'] = true; $wgGroupPermissions['sysop']['delete'] = true; -$wgGroupPermissions['sysop']['browsearchive'] = true; // can see the deleted page list $wgGroupPermissions['sysop']['deletedhistory'] = true; // can view deleted history entries, but not see or restore the text $wgGroupPermissions['sysop']['editinterface'] = true; $wgGroupPermissions['sysop']['import'] = true; @@ -1006,17 +1005,9 @@ $wgGroupPermissions['sysop']['ipblock-exempt'] = true; // Permission to change users' group assignments $wgGroupPermissions['bureaucrat']['userrights'] = true; -// Experimental permissions to enable revisiondelete: - +// Experimental permissions, not ready for production use //$wgGroupPermissions['sysop']['deleterevision'] = true; -//$wgGroupPermissions['sysop']['hideuser'] = true; -// To see hidden revs //$wgGroupPermissions['bureaucrat']['hiderevision'] = true; -// For private log access -//$wgGroupPermissions['bureaucrat']['oversight'] = true; -// Also, we may want titles to be effectively hidden -//$wgGroupPermissions['sysop']['browsearchive'] = false; -//$wgGroupPermissions['bureaucrat']['browsearchive'] = true; /** * The developer group is deprecated, but can be activated if need be @@ -2032,17 +2023,6 @@ $wgLogTypes = array( '', 'move', 'import', 'patrol', - 'oversight', -); - -/** - * This restricts log access to those who have a certain right - * Users without this will not see it in the option menu and can not view it - * Restricted logs are not added to recent changes - * Logs should remain non-transcludable - */ -$wgLogRestrictions = array( -'oversight' => 'oversight' ); /** @@ -2061,7 +2041,6 @@ $wgLogNames = array( 'move' => 'movelogpage', 'import' => 'importlogpage', 'patrol' => 'patrol-log-page', - 'oversight' => 'oversightlog', ); /** @@ -2080,7 +2059,6 @@ $wgLogHeaders = array( 'move' => 'movelogpagetext', 'import' => 'importlogpagetext', 'patrol' => 'patrol-log-header', - 'oversight' => 'overlogpagetext', ); /** @@ -2098,18 +2076,12 @@ $wgLogActions = array( 'delete/delete' => 'deletedarticle', 'delete/restore' => 'undeletedarticle', 'delete/revision' => 'revdelete-logentry', - 'delete/event' => 'logdelete-logentry', 'upload/upload' => 'uploadedimage', 'upload/revert' => 'uploadedimage', 'move/move' => '1movedto2', 'move/move_redir' => '1movedto2_redir', 'import/upload' => 'import-logentry-upload', 'import/interwiki' => 'import-logentry-interwiki', - 'oversight/revision' => 'revdelete-logentry', - 'oversight/file' => 'revdelete-logentry', - 'oversight/event' => 'logdelete-logentry', - 'oversight/delete' => 'deletedarticle', - 'oversight/block' => 'blocklogentry', ); /** diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 31fab659ea..884e82a6e0 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -174,49 +174,14 @@ CONTROL; $newminor = wfElement( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') ) . ' '; } - - $rdel = ''; $ldel = ''; - if( $wgUser->isAllowed( 'deleterevision' ) ) { - $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); - if( !$this->mOldRev->userCan( Revision::DELETED_RESTRICTED ) ) { - // If revision was hidden from sysops - $ldel = wfMsgHtml('rev-delundel'); - } else { - $ldel = $sk->makeKnownLinkObj( $revdel, - wfMsgHtml('rev-delundel'), - 'target=' . urlencode( $this->mOldRev->mTitle->getPrefixedDbkey() ) . - '&oldid=' . urlencode( $this->mOldRev->getId() ) ); - // Bolden oversighted content - if( $this->mOldRev->isDeleted( Revision::DELETED_RESTRICTED ) ) - $ldel = "$ldel"; - } - $ldel = "   ($ldel) "; - // We don't currently handle well changing the top revision's settings - if( $this->mNewRev->isCurrent() ) { - // If revision was hidden from sysops - $rdel = wfMsgHtml('rev-delundel'); - } else if( !$this->mNewRev->userCan( Revision::DELETED_RESTRICTED ) ) { - // If revision was hidden from sysops - $rdel = wfMsgHtml('rev-delundel'); - } else { - $rdel = $sk->makeKnownLinkObj( $revdel, - wfMsgHtml('rev-delundel'), - 'target=' . urlencode( $this->mNewRev->mTitle->getPrefixedDbkey() ) . - '&oldid=' . urlencode( $this->mNewRev->getId() ) ); - // Bolden oversighted content - if( $this->mNewRev->isDeleted( Revision::DELETED_RESTRICTED ) ) - $rdel = "$rdel"; - } - $rdel = "   ($rdel) "; - } $oldHeader = "{$this->mOldtitle}
    " . - $sk->revUserTools( $this->mOldRev, true ) . "
    " . - $oldminor . $sk->revComment( $this->mOldRev, !$diffOnly, true ) . "$ldel
    " . + $sk->revUserTools( $this->mOldRev ) . "
    " . + $oldminor . $sk->revComment( $this->mOldRev, !$diffOnly ) . "
    " . $prevlink; $newHeader = "{$this->mNewtitle}
    " . - $sk->revUserTools( $this->mNewRev, true ) . " $rollback
    " . - $newminor . $sk->revComment( $this->mNewRev, !$diffOnly, true ) . "$rdel
    " . + $sk->revUserTools( $this->mNewRev ) . " $rollback
    " . + $newminor . $sk->revComment( $this->mNewRev, !$diffOnly ) . "
    " . $nextlink . $patrol; $this->showDiff( $oldHeader, $newHeader ); @@ -237,10 +202,8 @@ CONTROL; $wgOut->addHTML( "

    {$this->mPagetitle}

    \n" ); #add deleted rev tag if needed - if( !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) { + if ( !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) { $wgOut->addWikiText( wfMsg( 'rev-deleted-text-permission' ) ); - } else if( $this->mNewRev->isDeleted(Revision::DELETED_TEXT) ) { - $wgOut->addWikiText( wfMsg( 'rev-deleted-text-view' ) ); } if( !$this->mNewRev->isCurrent() ) { @@ -369,25 +332,20 @@ CONTROL; } } - // Loadtext is permission safe, this just clears out the diff + #loadtext is permission safe, this just clears out the diff if ( !$this->loadText() ) { wfProfileOut( $fname ); return false; } else if ( $this->mOldRev && !$this->mOldRev->userCan(Revision::DELETED_TEXT) ) { - return ''; + return ''; } else if ( $this->mNewRev && !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) { - return ''; + return ''; } $difftext = $this->generateDiffBody( $this->mOldtext, $this->mNewtext ); // Save to cache for 7 days - // Only do this for public revs, otherwise an admin can view the diff and a non-admin can nab it! - if ( $this->mOldRev && $this->mOldRev->isDeleted(Revision::DELETED_TEXT) ) { - wfIncrStats( 'diff_uncacheable' ); - } else if ( $this->mNewRev && $this->mNewRev->isDeleted(Revision::DELETED_TEXT) ) { - wfIncrStats( 'diff_uncacheable' ); - } else if ( $key !== false && $difftext !== false ) { + if ( $key !== false && $difftext !== false ) { wfIncrStats( 'diff_cache_miss' ); $wgMemc->set( $key, $difftext, 7*86400 ); } else { @@ -521,7 +479,13 @@ CONTROL; */ function addHeader( $diff, $otitle, $ntitle, $multi = '' ) { global $wgOut; - + + if ( $this->mOldRev && $this->mOldRev->isDeleted(Revision::DELETED_TEXT) ) { + $otitle = ''.$otitle.''; + } + if ( $this->mNewRev && $this->mNewRev->isDeleted(Revision::DELETED_TEXT) ) { + $ntitle = ''.$ntitle.''; + } $header = " @@ -594,11 +558,6 @@ CONTROL; $this->mNewtitle = "{$this->mPagetitle}" . " (" . htmlspecialchars( wfMsg( 'editold' ) ) . ")"; } - if ( !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) { - $this->mNewtitle = "{$this->mPagetitle}"; - } else if ( $this->mNewRev->isDeleted(Revision::DELETED_TEXT) ) { - $this->mNewtitle = ''.$this->mNewtitle.''; - } // Load the old revision object $this->mOldRev = false; @@ -626,20 +585,11 @@ CONTROL; $t = $wgLang->timeanddate( $this->mOldRev->getTimestamp(), true ); $oldLink = $this->mOldPage->escapeLocalUrl( 'oldid=' . $this->mOldid ); $oldEdit = $this->mOldPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mOldid ); - $this->mOldPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $t ) ); - - $this->mOldtitle = "{$this->mOldPagetitle}" - . "(" . htmlspecialchars( wfMsg( 'editold' ) ) . ")"; - // Now that we considered old rev, we can make undo link (bug 8133, multi-edit undo) + $this->mOldtitle = "" . htmlspecialchars( wfMsg( 'revisionasof', $t ) ) + . " (" . htmlspecialchars( wfMsg( 'editold' ) ) . ")"; + //now that we considered old rev, we can make undo link (bug 8133, multi-edit undo) $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undoafter=' . $this->mOldid . '&undoto=' . $this->mNewid); - if ( $this->mNewRev->userCan(Revision::DELETED_TEXT) ) - $this->mNewtitle .= " (" . htmlspecialchars( wfMsg( 'editundo' ) ) . ")"; - - if ( !$this->mOldRev->userCan(Revision::DELETED_TEXT) ) { - $this->mOldtitle = "{$this->mOldPagetitle}"; - } else if ( $this->mOldRev->isDeleted(Revision::DELETED_TEXT) ) { - $this->mOldtitle = ''.$this->mOldtitle.''; - } + $this->mNewtitle .= " (" . htmlspecialchars( wfMsg( 'editundo' ) ) . ")"; } return true; @@ -660,6 +610,7 @@ CONTROL; return false; } if ( $this->mOldRev ) { + // FIXME: permission tests $this->mOldtext = $this->mOldRev->revText(); if ( $this->mOldtext === false ) { return false; diff --git a/includes/Export.php b/includes/Export.php index 3c24554064..f15c77847c 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -139,10 +139,7 @@ class WikiExporter { $fname = "do_list_authors" ; wfProfileIn( $fname ); $this->author_list = ""; - //rev_deleted - $deleted = '(rev_deleted & '.Revision::DELETED_USER.') !=1 '; - - $sql = "SELECT DISTINCT rev_user_text,rev_user FROM {$page},{$revision} WHERE page_id=rev_page AND $deleted AND " . $cond ; + $sql = "SELECT DISTINCT rev_user_text,rev_user FROM {$page},{$revision} WHERE page_id=rev_page AND " . $cond ; $result = $this->db->query( $sql, $fname ); $resultset = $this->db->resultObject( $result ); while( $row = $resultset->fetchObject() ) { diff --git a/includes/ImagePage.php b/includes/ImagePage.php index fb5bf8ed11..3ddf192017 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -508,9 +508,7 @@ END $reason = $wgRequest->getVal( 'wpReason' ); $image = $wgRequest->getVal( 'image' ); $oldimage = $wgRequest->getVal( 'oldimage' ); - # Flag to hide all contents of the archived revisions - $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed('deleterevision'); - + # Only sysops can delete images. Previously ordinary users could delete # old revisions, but this is no longer the case. if ( !$wgUser->isAllowed('delete') ) { @@ -538,7 +536,7 @@ END # Deleting old images doesn't require confirmation if ( !is_null( $oldimage ) || $confirm ) { if( $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) { - $this->doDelete( $reason, $suppress ); + $this->doDelete( $reason ); } else { $wgOut->showFatalError( wfMsg( 'sessionfailure' ) ); } @@ -559,7 +557,7 @@ END * Delete an image. * @param $reason User provided reason for deletion. */ - function doDelete( $reason, $suppress=false ) { + function doDelete( $reason ) { global $wgOut, $wgRequest; $oldimage = $wgRequest->getVal( 'oldimage' ); @@ -573,12 +571,12 @@ END $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) ); return; } - if ( !$this->doDeleteOldImage( $oldimage, $suppress ) ) { + if ( !$this->doDeleteOldImage( $oldimage ) ) { return; } $deleted = $oldimage; } else { - $ok = $this->img->delete( $reason, $suppress ); + $ok = $this->img->delete( $reason ); if( !$ok ) { # If the deletion operation actually failed, bug out: $wgOut->showFileDeleteError( $this->img->getName() ); @@ -589,7 +587,7 @@ END # Now we remove the image description page. $article = new Article( $this->mTitle ); - $article->doDeleteArticle( $reason, $suppress ); # ignore errors + $article->doDeleteArticle( $reason ); # ignore errors $deleted = $this->img->getName(); } @@ -608,11 +606,11 @@ END /** * @return success */ - function doDeleteOldImage( $oldimage, $suppress=false ) + function doDeleteOldImage( $oldimage ) { global $wgOut; - $ok = $this->img->deleteOld( $oldimage, '', $suppress ); + $ok = $this->img->deleteOld( $oldimage, '' ); if( !$ok ) { # If we actually have a file and can't delete it, throw an error. # Something went awry... diff --git a/includes/Linker.php b/includes/Linker.php index 5bd812333a..56622529e1 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -830,13 +830,10 @@ class Linker { /** * Generate a user link if the current user is allowed to view it * @param $rev Revision object. - * @param $isPublic, bool, show only if all users can see it * @return string HTML */ - function revUserLink( $rev, $isPublic = false ) { - if( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) { - $link = wfMsgHtml( 'rev-deleted-user' ); - } else if( $rev->userCan( Revision::DELETED_USER ) ) { + function revUserLink( $rev ) { + if( $rev->userCan( Revision::DELETED_USER ) ) { $link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() ); } else { $link = wfMsgHtml( 'rev-deleted-user' ); @@ -846,121 +843,26 @@ class Linker { } return $link; } - - /** - * Generate a user link if the current user is allowed to view it - * @param $event, log item. - * @param $isPublic, bool, show only if all users can see it - * @return string HTML - */ - function logUserLink( $event, $isPublic = false ) { - if( LogViewer::isDeleted( $event, LogViewer::DELETED_USER ) && $isPublic ) { - $link = wfMsgHtml( 'rev-deleted-user' ); - } else if( LogViewer::userCan( $event, LogViewer::DELETED_USER ) ) { - if ( isset($event->user_name) ) { - $link = $this->userLink( $event->log_user, $event->user_name ); - } else { - $user = $event->log_user; - $link = $this->userLink( $event->log_user, User::whoIs( $user ) ); - } - } else { - $link = wfMsgHtml( 'rev-deleted-user' ); - } - if( LogViewer::isDeleted( $event, LogViewer::DELETED_USER ) ) { - return '' . $link . ''; - } - return $link; - } - - /** - * Generate a user link if the current user is allowed to view it - * @param $file, filestore file - * @param $isPublic, bool, show only if all users can see it - * @return string HTML - */ - function fileUserLink( $file, $isPublic = false ) { - if( $file->isDeleted( Revision::DELETED_USER ) && $isPublic ) { - $link = wfMsgHtml( 'rev-deleted-user' ); - } else if( $file->userCan( Revision::DELETED_USER ) ) { - $link = $this->userLink( $file->mUser, $file->mUserText ); - } else { - $link = wfMsgHtml( 'rev-deleted-user' ); - } - if( $file->isDeleted( Revision::DELETED_USER ) ) { - return '' . $link . ''; - } - return $link; - } /** * Generate a user tool link cluster if the current user is allowed to view it * @param $rev Revision object. - * @param $isPublic, bool, show only if all users can see it * @return string HTML */ - function revUserTools( $rev, $isPublic = false ) { - if( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) { - $link = wfMsgHtml( 'rev-deleted-user' ); - } else if( $rev->userCan( Revision::DELETED_USER ) ) { + function revUserTools( $rev ) { + if( $rev->userCan( Revision::DELETED_USER ) ) { $link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() ) . - ' ' . $this->userToolLinks( $rev->getRawUser(), $rev->getRawUserText() ); + ' ' . + $this->userToolLinks( $rev->getRawUser(), $rev->getRawUserText() ); } else { $link = wfMsgHtml( 'rev-deleted-user' ); } if( $rev->isDeleted( Revision::DELETED_USER ) ) { - return ' ' . $link . ''; - } - return " $link"; - } - - /** - * Generate a user tool link cluster if the current user is allowed to view it - * @param $event, log item. - * @param $isPublic, bool, show only if all users can see it - * @return string HTML - */ - function logUserTools( $event, $isPublic = false ) { - if( LogViewer::isDeleted( $event, LogViewer::DELETED_USER ) && $isPublic ) { - $link = wfMsgHtml( 'rev-deleted-user' ); - } else if( LogViewer::userCan( $event, LogViewer::DELETED_USER ) ) { - if ( isset($event->user_name) ) { - $link = $this->userLink( $event->log_user, $event->user_name ) . - ' ' . $this->userToolLinks( $event->log_user, $event->user_name ); - } else { - $usertext = User::whoIs( $event->log_user ); - $link = $this->userLink( $event->log_user, $usertext ) . - ' ' . $this->userToolLinks( $event->log_user, $usertext ); - } - } else { - $link = wfMsgHtml( 'rev-deleted-user' ); - } - if( LogViewer::isDeleted( $event, LogViewer::DELETED_USER ) ) { - return '' . $link . ''; - } - return $link; - } - - /** - * Generate a user tool link cluster if the current user is allowed to view it - * @param $file, filestore file - * @param $isPublic, bool, show only if all users can see it - * @return string HTML - */ - function fileUserTools( $file, $isPublic = false ) { - if( $file->isDeleted( Revision::DELETED_USER ) && $isPublic ) { - $link = wfMsgHtml( 'rev-deleted-user' ); - } else if( $file->userCan( Revision::DELETED_USER ) ) { - $link = $this->userLink( $file->mUser, $file->mUserText ) . - $this->userToolLinks( $file->mUser, $file->mUserText ); - } else { - $link = wfMsgHtml( 'rev-deleted-user' ); - } - if( $file->isDeleted( Revision::DELETED_USER ) ) { return '' . $link . ''; } return $link; } - + /** * This function is called by all recent changes variants, by the page history, * and by the user contributions list. It is responsible for formatting edit @@ -1083,64 +985,20 @@ class Linker { * * @param Revision $rev * @param bool $local Whether section links should refer to local page - * @param $isPublic, show only if all users can see it * @return string HTML */ - function revComment( Revision $rev, $local = false, $isPublic = false ) { - if( $rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) { - $block = " " . wfMsgHtml( 'rev-deleted-comment' ) . ""; - } else if( $rev->userCan( Revision::DELETED_COMMENT ) ) { + function revComment( Revision $rev, $local = false ) { + if( $rev->userCan( Revision::DELETED_COMMENT ) ) { $block = $this->commentBlock( $rev->getRawComment(), $rev->getTitle(), $local ); } else { - $block = " " . wfMsgHtml( 'rev-deleted-comment' ) . ""; + $block = " " . + wfMsgHtml( 'rev-deleted-comment' ) . ""; } if( $rev->isDeleted( Revision::DELETED_COMMENT ) ) { return " $block"; } return $block; } - - /** - * Wrap and format the given event's comment block, if the current - * user is allowed to view it. - * - * @param Revision $rev - * @return string HTML - */ - function logComment( $event, $isPublic = false ) { - if( LogViewer::isDeleted( $event, LogViewer::DELETED_COMMENT ) && $isPublic ) { - $block = ' ' . wfMsgHtml( 'rev-deleted-comment' ); - } else if( LogViewer::userCan( $event, LogViewer::DELETED_COMMENT ) ) { - $block = $this->commentBlock( LogViewer::getRawComment( $event ) ); - } else { - $block = ' ' . wfMsgHtml( 'rev-deleted-comment' ); - } - if( LogViewer::isDeleted( $event, LogViewer::DELETED_COMMENT ) ) { - return "$block"; - } - return $block; - } - - /** - * Wrap and format the given file's comment block, if the current - * user is allowed to view it. - * - * @param FileStore file object $file - * @return string HTML - */ - function fileComment( $file, $isPublic = false ) { - if( $file->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) { - $block = ' ' . wfMsgHtml( 'rev-deleted-comment' ); - } else if( $file->userCan( Revision::DELETED_COMMENT ) ) { - $block = $this->commentBlock( $file->mDescription ); - } else { - $block = ' ' . wfMsgHtml( 'rev-deleted-comment' ); - } - if( $file->isDeleted( Revision::DELETED_COMMENT ) ) { - return "$block"; - } - return $block; - } /** @todo document */ function tocIndent() { diff --git a/includes/LogPage.php b/includes/LogPage.php index a1e4638330..65dbbe4042 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -50,15 +50,13 @@ class LogPage { function saveContent() { if( wfReadOnly() ) return false; - global $wgUser, $wgLogRestrictions; + global $wgUser; $fname = 'LogPage::saveContent'; $dbw = wfGetDB( DB_MASTER ); $uid = $wgUser->getID(); $this->timestamp = $now = wfTimestampNow(); - - $log_id = $dbw->nextSequenceValue( 'log_log_id_seq' ); $dbw->insert( 'logging', array( 'log_type' => $this->type, @@ -71,15 +69,20 @@ class LogPage { 'log_params' => $this->params ), $fname ); - $newId = $dbw->insertId(); # And update recentchanges if ( $this->updateRecentChanges ) { - # Don't add private logs to RC!!! - if ( !isset($wgLogRestrictions[$this->type]) || $wgLogRestrictions[$this->type]=='*' ) { - RecentChange::notifyLog( $now, $this->target, $wgUser, $this->actionText, '', - $this->type, $this->action, $this->target, $this->comment, $this->params, $newId ); + $titleObj = SpecialPage::getTitleFor( 'Log', $this->type ); + $rcComment = $this->actionText; + if( '' != $this->comment ) { + if ($rcComment == '') + $rcComment = $this->comment; + else + $rcComment .= ': ' . $this->comment; } + + RecentChange::notifyLog( $now, $titleObj, $wgUser, $rcComment, '', + $this->type, $this->action, $this->target, $this->comment, $this->params ); } return true; } @@ -119,13 +122,13 @@ class LogPage { */ function logHeader( $type ) { global $wgLogHeaders; - return wfMsgHtml( $wgLogHeaders[$type] ); + return wfMsg( $wgLogHeaders[$type] ); } /** * @static */ - function actionText( $type, $action, $title=NULL, $skin=NULL, $params = array(), $filterWikilinks=false, $translate=false, $forRC=false ) { + function actionText( $type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks=false, $translate=false ) { global $wgLang, $wgContLang, $wgLogActions; $key = "$type/$action"; @@ -182,17 +185,12 @@ class LogPage { } } else { array_unshift( $params, $titleLink ); - // Oversighted blocks show as normal - if ( $translate && ($key == 'block/block' || $key == 'oversight/block') ) { + if ( $translate && $key == 'block/block' ) { $params[1] = $wgLang->translateBlockExpiry( $params[1] ); $params[2] = isset( $params[2] ) ? self::formatBlockFlags( $params[2] ) : ''; } - if ( $forRC ) { - $params[1] = $wgLang->translateBlockExpiry( $params[1], true ); - $params[2] = isset( $params[2] ) ? str_replace( ",", ", ", self::formatBlockFlags( $params[2] ) ) : ''; - } $rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin ); } } @@ -224,7 +222,7 @@ class LogPage { $this->comment = $comment; $this->params = LogPage::makeParamBlob( $params ); - $this->actionText = LogPage::actionText( $this->type, $action, $target, NULL, $params, false, false, true ); + $this->actionText = LogPage::actionText( $this->type, $action, $target, NULL, $params ); return $this->saveContent(); } diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 1622a6e189..94b55eab47 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -38,20 +38,6 @@ class PageHistory { $this->mTitle =& $article->mTitle; $this->mNotificationTimestamp = NULL; $this->mSkin = $wgUser->getSkin(); - $this->preCacheMessages(); - } - - /** - * As we use the same small set of messages in various methods and that - * they are called often, we call them once and save them in $this->message - */ - function preCacheMessages() { - // Precache various messages - if( !isset( $this->message ) ) { - foreach( explode(' ', 'cur last rev-delundel' ) as $msg ) { - $this->message[$msg] = wfMsgExt( $msg, array( 'escape') ); - } - } } /** @@ -201,31 +187,35 @@ class PageHistory { $arbitrary = $this->diffButtons( $rev, $firstInList, $counter ); $link = $this->revLink( $rev ); + $user = $this->mSkin->userLink( $rev->getUser(), $rev->getUserText() ) + . $this->mSkin->userToolLinks( $rev->getUser(), $rev->getUserText() ); + $s .= "($curlink) ($lastlink) $arbitrary"; if( $wgUser->isAllowed( 'deleterevision' ) ) { $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); if( $firstInList ) { - // We don't currently handle well changing the top revision's settings - $del = $this->message['rev-delundel']; + // We don't currently handle well changing the top revision's settings + $del = wfMsgHtml( 'rev-delundel' ); } else if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { // If revision was hidden from sysops - $del = $this->message['rev-delundel']; + $del = wfMsgHtml( 'rev-delundel' ); } else { $del = $this->mSkin->makeKnownLinkObj( $revdel, - $this->message['rev-delundel'], + wfMsg( 'rev-delundel' ), 'target=' . urlencode( $this->mTitle->getPrefixedDbkey() ) . '&oldid=' . urlencode( $rev->getId() ) ); - // Bolden oversighted content - if( $rev->isDeleted( Revision::DELETED_RESTRICTED ) ) - $del = "$del"; } - $s .= " ($del) "; + $s .= " ($del) "; } $s .= " $link"; - $s .= $this->mSkin->revUserTools( $rev, true); - + #getUser is safe, but this avoids making the invalid untargeted contribs links + if( $row->rev_deleted & Revision::DELETED_USER ) { + $user = '' . wfMsg('rev-deleted-user') . ''; + } + $s .= " $user"; + if( $row->rev_minor_edit ) { $s .= ' ' . wfElement( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') ); } @@ -251,7 +241,7 @@ class PageHistory { } #add blurb about text having been deleted if( $row->rev_deleted & Revision::DELETED_TEXT ) { - $s .= ' ' . wfMsgHtml( 'deletedrev' ) . ''; + $s .= ' ' . wfMsgHtml( 'deletedrev' ); } if( $wgUser->isAllowed( 'rollback' ) && $latest ) { $s .= ' '.$this->mSkin->generateRollback( $rev ); @@ -279,7 +269,7 @@ class PageHistory { /** @todo document */ function curLink( $rev, $latest ) { - $cur = $this->message['cur']; + $cur = wfMsgExt( 'cur', array( 'escape') ); if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) { return $cur; } else { @@ -292,7 +282,7 @@ class PageHistory { /** @todo document */ function lastLink( $rev, $next, $counter ) { - $last = $this->message['last']; + $last = wfMsgExt( 'last', array( 'escape' ) ); if ( is_null( $next ) ) { # Probably no next row return $last; diff --git a/includes/RecentChange.php b/includes/RecentChange.php index ceb0717efa..fced434397 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -25,11 +25,6 @@ * rc_patrolled boolean whether or not someone has marked this edit as patrolled * rc_old_len integer byte length of the text before the edit * rc_new_len the same after the edit - * rc_deleted partial deletion - * rc_logid the log_id value for this log entry (or zero) - * rc_log_type the log type (or null) - * rc_log_action the log action (or null) - * rc_params log params * * mExtra: * prefixedDBkey prefixed db key, used by external app via msg queue @@ -232,7 +227,8 @@ class RecentChange # Makes an entry in the database corresponding to an edit /*static*/ function notifyEdit( $timestamp, &$title, $minor, &$user, $comment, - $oldId, $lastTimestamp, $bot="default", $ip='', $oldSize=0, $newSize=0, $newId=0) + $oldId, $lastTimestamp, $bot = "default", $ip = '', $oldSize = 0, $newSize = 0, + $newId = 0) { if ( $bot === 'default' ) { @@ -267,12 +263,7 @@ class RecentChange 'rc_patrolled' => 0, 'rc_new' => 0, # obsolete 'rc_old_len' => $oldSize, - 'rc_new_len' => $newSize, - 'rc_deleted' => 0, - 'rc_logid' => 0, - 'rc_log_type' => null, - 'rc_log_action' => '', - 'rc_params' => '' + 'rc_new_len' => $newSize ); $rc->mExtra = array( @@ -293,7 +284,7 @@ class RecentChange * @static */ public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot = "default", - $ip='', $size=0, $newId=0 ) + $ip='', $size = 0, $newId = 0 ) { if ( !$ip ) { $ip = wfGetIP(); @@ -301,7 +292,6 @@ class RecentChange $ip = ''; } } - if ( $bot == 'default' ) { $bot = $user->isAllowed( 'bot' ); } @@ -325,14 +315,9 @@ class RecentChange 'rc_moved_to_title' => '', 'rc_ip' => $ip, 'rc_patrolled' => 0, - 'rc_new' => 1, # obsolete + 'rc_new' => 1, # obsolete 'rc_old_len' => 0, - 'rc_new_len' => $size, - 'rc_deleted' => 0, - 'rc_logid' => 0, - 'rc_log_type' => null, - 'rc_log_action' => '', - 'rc_params' => '' + 'rc_new_len' => $size ); $rc->mExtra = array( @@ -354,7 +339,7 @@ class RecentChange $ip = ''; } } - + $rc = new RecentChange; $rc->mAttribs = array( 'rc_timestamp' => $timestamp, @@ -377,11 +362,6 @@ class RecentChange 'rc_patrolled' => 1, 'rc_old_len' => NULL, 'rc_new_len' => NULL, - 'rc_deleted' => 0, - 'rc_logid' => 0, # notifyMove not used anymore - 'rc_log_type' => null, - 'rc_log_action' => '', - 'rc_params' => '' ); $rc->mExtra = array( @@ -400,14 +380,18 @@ class RecentChange RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, true ); } - # A log entry is different to an edit in that previous revisions are not kept - /*static*/ function notifyLog( $timestamp, &$title, &$user, $actionText = null, $ip='', - $type, $action, $target, $logComment, $params, $newId=0 ) + # A log entry is different to an edit in that previous revisions are + # not kept + /*static*/ function notifyLog( $timestamp, &$title, &$user, $comment, $ip='', + $type, $action, $target, $logComment, $params ) { if ( !$ip ) { $ip = wfGetIP(); - if ( !$ip ) $ip = ''; + if ( !$ip ) { + $ip = ''; + } } + $rc = new RecentChange; $rc->mAttribs = array( 'rc_timestamp' => $timestamp, @@ -419,7 +403,7 @@ class RecentChange 'rc_cur_id' => $title->getArticleID(), 'rc_user' => $user->getID(), 'rc_user_text' => $user->getName(), - 'rc_comment' => $logComment, + 'rc_comment' => $comment, 'rc_this_oldid' => 0, 'rc_last_oldid' => 0, 'rc_bot' => $user->isAllowed( 'bot' ) ? 1 : 0, @@ -430,11 +414,6 @@ class RecentChange 'rc_new' => 0, # obsolete 'rc_old_len' => NULL, 'rc_new_len' => NULL, - 'rc_deleted' => 0, - 'rc_logid' => $newId, - 'rc_log_type' => $type, - 'rc_log_action' => $action, - 'rc_params' => $params ); $rc->mExtra = array( 'prefixedDBkey' => $title->getPrefixedDBkey(), @@ -481,11 +460,6 @@ class RecentChange 'rc_new' => $row->page_is_new, # obsolete 'rc_old_len' => $row->rc_old_len, 'rc_new_len' => $row->rc_new_len, - 'rc_deleted' => $row->rc_deleted, - 'rc_logid' => $row->rc_logid, - 'rc_log_type' => $row->rc_log_type, - 'rc_log_action' => $row->rc_log_action, - 'rc_params' => $row->rc_params ); $this->mExtra = array(); diff --git a/includes/SpecialBlockip.php b/includes/SpecialBlockip.php index f427519d0a..27729f2b82 100644 --- a/includes/SpecialBlockip.php +++ b/includes/SpecialBlockip.php @@ -45,7 +45,7 @@ class IPBlockForm { var $BlockAddress, $BlockExpiry, $BlockReason; function IPBlockForm( $par ) { - global $wgRequest, $wgUser; + global $wgRequest; $this->BlockAddress = $wgRequest->getVal( 'wpBlockAddress', $wgRequest->getVal( 'ip', $par ) ); $this->BlockAddress = strtr( $this->BlockAddress, '_', ' ' ); @@ -59,8 +59,6 @@ class IPBlockForm { $this->BlockAnonOnly = $wgRequest->getBool( 'wpAnonOnly', $byDefault ); $this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', $byDefault ); $this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', $byDefault ); - # Re-check user's rights to hide names, very serious, defaults to 0 - $this->BlockHideName = $wgRequest->getBool( 'wpHideName', 0 ) && $wgUser->isAllowed( 'hideuser' ); } function showForm( $err ) { @@ -133,7 +131,6 @@ class IPBlockForm { "); } - $wgOut->addHTML(" @@ -153,46 +150,31 @@ class IPBlockForm { - "); - // Allow some users to hide name from block log, blocklist and listusers - if ( $wgUser->isAllowed( 'hideuser' ) ) { - $wgOut->addHTML(" - - - - - "); - } - $wgOut->addHTML(" @@ -301,7 +283,7 @@ class IPBlockForm { $block = new Block( $this->BlockAddress, $userId, $wgUser->getID(), $this->BlockReason, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly, - $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName); + $this->BlockCreateAccount, $this->BlockEnableAutoblock ); if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) { @@ -318,9 +300,8 @@ class IPBlockForm { $logParams[] = $expirestr; $logParams[] = $this->blockLogFlags(); - # Make log entry, if the name is hidden, put it in the oversight log - $log_type = ($this->BlockHideName) ? 'oversight' : 'block'; - $log = new LogPage( $log_type ); + # Make log entry + $log = new LogPage( 'block' ); $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ), $this->BlockReason, $logParams ); diff --git a/includes/SpecialLog.php b/includes/SpecialLog.php index 3e3f007463..302b196397 100644 --- a/includes/SpecialLog.php +++ b/includes/SpecialLog.php @@ -72,70 +72,16 @@ class LogReader { list( $this->limit, $this->offset ) = $request->getLimitOffset(); } - - function newFromTitle( $title, $logid=0 ) { - $fname = 'LogReader::newFromTitle'; - - $matchId = intval( $logid ); - $dbr = wfGetDB( DB_SLAVE ); - $res = $dbr->select( 'logging', array('*'), - array('log_id' => $matchId, 'log_namespace' => $title->getNamespace(), 'log_title' => $title->getDBkey() ), - $fname ); - - if ( $res ) { - $ret = $dbr->fetchObject( $res ); - if ( $ret ) { - return $ret; - } - } - return null; - } - - function newFromId( $logid ) { - $fname = 'LogReader::newFromId'; - - $matchId = intval( $logid ); - $dbr = wfGetDB( DB_SLAVE ); - $res = $dbr->select( 'logging', array('*'), array('log_id' => $matchId ), $fname ); - - if ( $res ) { - $ret = $dbr->fetchObject( $res ); - if ( $ret ) { - return $ret; - } - } - return null; - } /** * Set the log reader to return only entries of the given type. - * Type restrictions enforced here * @param string $type A log type ('upload', 'delete', etc) * @private */ function limitType( $type ) { - global $wgLogRestrictions, $wgUser; - - // Restriction system - if ( isset($wgLogRestrictions) ) { - foreach ( $wgLogRestrictions as $logtype => $right ) { - if ( !$wgUser->isAllowed( $right ) ) { - $safetype = $this->db->strencode( $logtype ); - $this->whereClauses[] = "log_type <> '$safetype'"; - } - } - } - if( empty( $type ) ) { return false; } - // Can user see this log? - if ( isset($wgLogRestrictions[$type]) ) { - if ( !$wgUser->isAllowed( $wgLogRestrictions[$type] ) ) { - return false; - } - } - $this->type = $type; $safetype = $this->db->strencode( $type ); $this->whereClauses[] = "log_type='$safetype'"; @@ -171,7 +117,7 @@ class LogReader { * @private */ function limitTitle( $page , $pattern ) { - $title = Title::newFromURL( $page, false ); + $title = Title::newFromText( $page ); if( empty( $page ) || is_null( $title ) ) { return false; } @@ -211,7 +157,6 @@ class LogReader { $logging = $this->db->tableName( "logging" ); $sql = "SELECT /*! STRAIGHT_JOIN */ log_type, log_action, log_timestamp, log_user, user_name, - log_id, log_deleted, log_namespace, log_title, page_id, log_comment, log_params FROM $logging "; if( !empty( $this->joinClauses ) ) { @@ -272,11 +217,6 @@ class LogReader { * @addtogroup SpecialPage */ class LogViewer { - const DELETED_ACTION = 1; - const DELETED_COMMENT = 2; - const DELETED_USER = 4; - const DELETED_RESTRICTED = 8; - /** * @var LogReader $reader */ @@ -290,20 +230,6 @@ class LogViewer { global $wgUser; $this->skin = $wgUser->getSkin(); $this->reader =& $reader; - $this->preCacheMessages(); - } - - /** - * As we use the same small set of messages in various methods and that - * they are called often, we call them once and save them in $this->message - */ - function preCacheMessages() { - // Precache various messages - if( !isset( $this->message ) ) { - foreach( explode(' ', 'viewpagelogs revhistory imghistory rev-delundel' ) as $msg ) { - $this->message[$msg] = wfMsgExt( $msg, array( 'escape') ); - } - } } /** @@ -322,123 +248,6 @@ class LogViewer { $this->showError( $wgOut ); } } - - /** - * Determine if the current user is allowed to view a particular - * field of this event, if it's marked as deleted. - * @param int $field - * @return bool - */ - function userCan( $event, $field ) { - if( ( $event->log_deleted & $field ) == $field ) { - global $wgUser; - $permission = ( $event->log_deleted & Revision::DELETED_RESTRICTED ) == Revision::DELETED_RESTRICTED - ? 'hiderevision' - : 'deleterevision'; - wfDebug( "Checking for $permission due to $field match on $event->log_deleted\n" ); - return $wgUser->isAllowed( $permission ); - } else { - return true; - } - } - - /** - * int $field one of DELETED_* bitfield constants - * @return bool - */ - function isDeleted( $event, $field ) { - return ($event->log_deleted & $field) == $field; - } - - /** - * Fetch event's user id if it's available to all users - * @return int - */ - function getUser( $event ) { - if( $this->isDeleted( $event, Revision::DELETED_USER ) ) { - return 0; - } else { - return $event->log_user; - } - } - - /** - * Fetch event's user id without regard for the current user's permissions - * @return string - */ - function getRawUser( $event ) { - return $event->log_user; - } - - /** - * Fetch event's username if it's available to all users - * @return string - */ - function getUserText( $event ) { - if( $this->isDeleted( $event, Revision::DELETED_USER ) ) { - return ""; - } else { - if ( isset($event->user_name) ) { - return $event->user_name; - } else { - return User::whoIs( $event->log_user ); - } - } - } - - /** - * Fetch event's username without regard for view restrictions - * @return string - */ - function getRawUserText( $event ) { - if ( isset($event->user_name) ) { - return $event->user_name; - } else { - return User::whoIs( $event->log_user ); - } - } - - /** - * Fetch event comment if it's available to all users - * @return string - */ - function getComment( $event ) { - if( $this->isDeleted( $event, Revision::DELETED_COMMENT ) ) { - return ""; - } else { - return $event->log_comment; - } - } - - /** - * Fetch event comment without regard for the current user's permissions - * @return string - */ - function getRawComment( $event ) { - return $event->log_comment; - } - - /** - * Returns the title of the page associated with this entry. - * @return Title - */ - function getTitle( $event ) { - return Title::makeTitle( $event->log_namespace, $event->log_title ); - } - - /** - * Return the log action if it's available to all users - * default is deleted if not specified for security - * @return Title - */ - function logActionText( $log_type, $log_action, $title, $skin, $paramArray, $log_deleted = LogViewer::DELETED_ACTION ) { - if( $log_deleted & LogViewer::DELETED_ACTION ) { - return '' . wfMsgHtml('rev-deleted-event') . ''; - } else { - $action = LogPage::actionText( $log_type, $log_action, $title, $this->skin, $paramArray, true, true ); - return $action; - } - } /** * Load the data from the linked LogReader @@ -510,8 +319,7 @@ class LogViewer { * @private */ function logLine( $s ) { - global $wgLang, $wgUser; - + global $wgLang, $wgUser;; $skin = $wgUser->getSkin(); $title = Title::makeTitle( $s->log_namespace, $s->log_title ); $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $s->log_timestamp), true ); @@ -524,64 +332,12 @@ class LogViewer { } else { $linkCache->addBadLinkObj( $title ); } - // User links - $userLink = $this->skin->logUserTools( $s, true ); - // Comment - $comment = $this->skin->logComment( $s, true ); + $userLink = $this->skin->userLink( $s->log_user, $s->user_name ) . $this->skin->userToolLinksRedContribs( $s->log_user, $s->user_name ); + $comment = $this->skin->commentBlock( $s->log_comment ); $paramArray = LogPage::extractParams( $s->log_params ); - $revert = ''; $del = ''; - - // Some user can hide log items and have review links - if( $wgUser->isAllowed( 'deleterevision' ) ) { - $del = $this->showhideLinks( $s, $title ); - } - - // Show restore/unprotect/unblock - $revert = $this->showReviewLinks( $s, $title, $paramArray ); - - // Event description - $action = $this->logActionText( $s->log_type, $s->log_action, $title, $this->skin, $paramArray, $s->log_deleted ); - - $out = "
  • $del $time $userLink $action $comment $revert
  • \n"; - return $out; - } - - /** - * @param $s, row object - * @param $s, title object - * @private - */ - function showhideLinks( $s, $title ) { - $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); - if( !LogViewer::userCan( $s, Revision::DELETED_RESTRICTED ) ) { - // If event was hidden from sysops - $del = $this->message['rev-delundel']; - } else if( $s->log_type == 'oversight' ) { - // No one should be hiding from the oversight log - $del = $this->message['rev-delundel']; - } else { - $del = $this->skin->makeKnownLinkObj( $revdel, - $this->message['rev-delundel'], - 'target=' . urlencode( $title->getPrefixedDbkey() ) . '&logid=' . $s->log_id ); - // Bolden oversighted content - if( LogViewer::isDeleted( $s, Revision::DELETED_RESTRICTED ) ) - $del = "$del"; - } - return "($del)"; - } - - /** - * @param $s, row object - * @param $title, title object - * @param $s, param array - * @private - */ - function showReviewLinks( $s, $title, $paramArray ) { - global $wgUser; - - $reviewlink=''; - // Show revertmove link + $revert = ''; + // show revertmove link if ( $s->log_type == 'move' && isset( $paramArray[0] ) ) { $destTitle = Title::newFromText( $paramArray[0] ); if ( $destTitle ) { @@ -593,47 +349,26 @@ class LogViewer { '&wpMovetalk=0' ); } // show undelete link - } else if ( $s->log_action == 'delete' && $wgUser->isAllowed( 'delete' ) ) { - $reviewlink = $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Undelete' ), + } elseif ( $s->log_action == 'delete' && $wgUser->isAllowed( 'delete' ) ) { + $revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Undelete' ), wfMsg( 'undeletebtn' ) , - 'target='. urlencode( $title->getPrefixedDBkey() ) ); + 'target='. urlencode( $title->getPrefixedDBkey() ) ) . ')'; + // show unblock link } elseif ( $s->log_action == 'block' && $wgUser->isAllowed( 'block' ) ) { - $reviewlink = $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Ipblocklist' ), + $revert = '(' . $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Ipblocklist' ), wfMsg( 'unblocklink' ), - 'action=unblock&ip=' . urlencode( $s->log_title ) ); + 'action=unblock&ip=' . urlencode( $s->log_title ) ) . ')'; // show change protection link } elseif ( $s->log_action == 'protect' && $wgUser->isAllowed( 'protect' ) ) { - $reviewlink = $this->skin->makeKnownLink( $title->getPrefixedDBkey() , + $revert = '(' . $skin->makeKnownLink( $title->getPrefixedDBkey() , wfMsg( 'protect_change' ), - 'action=unprotect' ); - } - // If an edit was hidden from a page give a review link to the history - if ( $wgUser->isAllowed( 'deleterevision' ) && isset($paramArray[2]) ) { - $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); - if ( $s->log_action == 'revision' ) { - $reviewlink = $this->skin->makeKnownLinkObj( $title, $this->message['revhistory'], - wfArrayToCGI( array('action' => 'history' ) ) ) . ':'; - } else if ( $s->log_action == 'file' ) { - // Currently, only deleted file versions can be hidden - $undelete = SpecialPage::getTitleFor( 'Undelete' ); - $reviewlink = $this->skin->makeKnownLinkObj( $undelete, $this->message['imghistory'], - wfArrayToCGI( array('target' => $title->getPrefixedText() ) ) ) . ':'; - } else if ( $s->log_action == 'event' && isset($paramArray[0]) ) { - // If this event was to a log, give a review link to logs for that page only - $reviewlink = $this->skin->makeKnownLinkObj( $title, $this->message['viewpagelogs'], - wfArrayToCGI( array('page' => $paramArray[0] ) ) ) . ':'; - } - // Link to each hidden object ID - $IdType = $paramArray[1].'id'; - $Ids = explode( ',', $paramArray[2] ); - foreach ( $Ids as $id ) { - $reviewlink .= ' '.$this->skin->makeKnownLinkObj( $revdel, "#$id", - wfArrayToCGI( array('target' => $paramArray[0], $IdType => $id ) ) ); - } + 'action=unprotect' ) . ')'; } - $reviewlink = ( $reviewlink=='' ) ? "" : "   ($reviewlink) "; - return $reviewlink; + + $action = LogPage::actionText( $s->log_type, $s->log_action, $title, $this->skin, $paramArray, true, true ); + $out = "
  • $time $userLink $action $comment $revert
  • \n"; + return $out; } /** @@ -674,8 +409,6 @@ class LogViewer { * @private */ function getTypeMenu() { - global $wgLogRestrictions, $wgUser; - $out = "'; @@ -758,12 +484,5 @@ class LogViewer { } } -/** - * Aliases for backwards compatibility with 1.6 - */ -define( 'MW_LOG_DELETED_ACTION', LogViewer::DELETED_ACTION ); -define( 'MW_LOG_DELETED_USER', LogViewer::DELETED_USER ); -define( 'MW_LOG_DELETED_COMMENT', LogViewer::DELETED_COMMENT ); -define( 'MW_LOG_DELETED_RESTRICTED', LogViewer::DELETED_RESTRICTED ); ?> diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index 5d68b9272c..13d5ebf617 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -404,7 +404,7 @@ function rcDoOutputFeed( $rows, &$feed ) { rcFormatDiff( $obj ), $title->getFullURL(), $obj->rc_timestamp, - ($obj->rc_deleted & Revision::DELETED_USER) ? wfMsgHtml('rev-deleted-user') : $obj->rc_user_text, + $obj->rc_user_text, $talkpage->getFullURL() ); $feed->outItem( $item ); @@ -613,18 +613,15 @@ function rcFormatDiff( $row ) { return rcFormatDiffRow( $titleObj, $row->rc_last_oldid, $row->rc_this_oldid, $timestamp, - ($row->rc_deleted & Revision::DELETED_COMMENT) ? wfMsgHtml('rev-deleted-comment') : $row->rc_comment, - ($row->rc_deleted & Revision::DELETED_NAME) ? wfMsgHtml('rev-deleted-event') : $row->rc_actiontext ); + $row->rc_comment ); } -function rcFormatDiffRow( $title, $oldid, $newid, $timestamp, $comment, $actiontext='' ) { +function rcFormatDiffRow( $title, $oldid, $newid, $timestamp, $comment ) { global $wgFeedDiffCutoff, $wgContLang, $wgUser; $fname = 'rcFormatDiff'; wfProfileIn( $fname ); $skin = $wgUser->getSkin(); - # log enties - if( $actiontext ) $comment = "$actiontext $comment"; $completeText = '

    ' . $skin->formatComment( $comment ) . "

    \n"; if( $title->getNamespace() >= 0 && $title->userCan( 'read' ) ) { diff --git a/includes/SpecialRevisiondelete.php b/includes/SpecialRevisiondelete.php index 7ea1c67bd7..2f459d0f2e 100644 --- a/includes/SpecialRevisiondelete.php +++ b/includes/SpecialRevisiondelete.php @@ -2,41 +2,36 @@ /** * Not quite ready for production use yet; need to fix up the restricted mode, - * and provide for preservation across delete/undelete of images. + * and provide for preservation across delete/undelete of the page. + * + * To try this out, set up extra permissions something like: + * $wgGroupPermissions['sysop']['deleterevision'] = true; + * $wgGroupPermissions['bureaucrat']['hiderevision'] = true; */ function wfSpecialRevisiondelete( $par = null ) { global $wgOut, $wgRequest; - $target = $wgRequest->getText( 'target' ); - // handle our many different possible input types + $target = $wgRequest->getVal( 'target' ); $oldid = $wgRequest->getIntArray( 'oldid' ); - $logid = $wgRequest->getIntArray( 'logid' ); - $arid = $wgRequest->getIntArray( 'arid' ); - $fileid = $wgRequest->getIntArray( 'fileid' ); - - $page = Title::newFromUrl( $target, false ); + + $page = Title::newFromUrl( $target ); + if( is_null( $page ) ) { $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); return; } - - $input_types = !is_null( $oldid ) + !is_null( $logid ) + !is_null( $arid ) + !is_null( $fileid ); - if( $input_types > 1 || $input_types==0 ) { - //one target set at a time please! + + if( is_null( $oldid ) ) { $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' ); return; } - $form = new RevisionDeleteForm( $wgRequest, $oldid, $logid, $arid, $fileid ); + $form = new RevisionDeleteForm( $wgRequest ); if( $wgRequest->wasPosted() ) { $form->submit( $wgRequest ); - } else if( $oldid || $arid ) { - $form->showRevs( $wgRequest ); - } else if( $logid ) { - $form->showEvents( $wgRequest ); - } else if( $fileid ) { - $form->showImages( $wgRequest ); + } else { + $form->show( $wgRequest ); } } @@ -199,7 +194,7 @@ class RevisionDeleteForm { $bitfields = 0; $wgOut->addHtml( "'; $table .= ''; $table .= ''; - if ( $wgUser->isAllowed( 'oversight' ) ) { - $table .= '
      - " . wfCheckLabel( wfMsgHtml( 'ipbanononly' ), + " . wfCheckLabel( wfMsg( 'ipbanononly' ), 'wpAnonOnly', 'wpAnonOnly', $this->BlockAnonOnly, - array( 'tabindex' => '4' ) ) . " + array( 'tabindex' => 4 ) ) . "
      - " . wfCheckLabel( wfMsgHtml( 'ipbcreateaccount' ), + " . wfCheckLabel( wfMsg( 'ipbcreateaccount' ), 'wpCreateAccount', 'wpCreateAccount', $this->BlockCreateAccount, - array( 'tabindex' => '5' ) ) . " + array( 'tabindex' => 5 ) ) . "
      - " . wfCheckLabel( wfMsgHtml( 'ipbenableautoblock' ), + " . wfCheckLabel( wfMsg( 'ipbenableautoblock' ), 'wpEnableAutoblock', 'wpEnableAutoblock', $this->BlockEnableAutoblock, - array( 'tabindex' => '6' ) ) . " + array( 'tabindex' => 6 ) ) . "
      - " . wfCheckLabel( wfMsgHtml( 'ipbhidename' ), - 'wpHideName', 'wpHideName', $this->BlockHideName, - array( 'tabindex' => '6' ) ) . " -
      - " . Xml::submitButton( wfMsgHtml( 'ipbsubmit' ), + " . Xml::submitButton( wfMsg( 'ipbsubmit' ), array( 'name' => 'wpBlock', 'tabindex' => '7' ) ) . "
    ' . wfMsgWikiHtml( 'undeleteextrahelp' ) . '
    ' . wfMsgHtml( 'undeletecomment' ) . '' . wfInput( 'wpComment', 50, $this->mComment ) . '
     '; - $table .= Xml::checkLabel( wfMsg( 'revdelete-unsuppress' ), 'wpUnsuppress', 'wpUnsuppress', false, array( 'tabindex' => '2' ) ); - } $table .= '
     '; $table .= wfSubmitButton( wfMsg( 'undeletebtn' ), array( 'name' => 'restore' ) ); $table .= wfElement( 'input', array( 'type' => 'reset', 'value' => wfMsg( 'undeletereset' ) ) ); @@ -835,48 +761,26 @@ class UndeleteForm { $target = urlencode( $this->mTarget ); while( $row = $revisions->fetchObject() ) { $ts = wfTimestamp( TS_MW, $row->ar_timestamp ); - // We don't handle top edits with rev_deleted if ( $this->mAllowed ) { - $checkBox = wfCheck( "ts$ts", false ); - $titleObj = SpecialPage::getTitleFor( "Undelete" ); - $pageLink = $this->getPageLink( $row, $titleObj, $ts, $target ); + $checkBox = wfCheck( "ts$ts" ); + $pageLink = $sk->makeKnownLinkObj( $titleObj, + $wgLang->timeanddate( $ts, true ), + "target=$target×tamp=$ts" ); } else { $checkBox = ''; $pageLink = $wgLang->timeanddate( $ts, true ); } - $userLink = $this->getUser( $row ); + $userLink = $sk->userLink( $row->ar_user, $row->ar_user_text ) . $sk->userToolLinks( $row->ar_user, $row->ar_user_text ); $stxt = ''; if (!is_null($size = $row->ar_len)) { if ($size == 0) $stxt = wfMsgHtml('historyempty'); - else + else $stxt = wfMsgHtml('historysize', $wgLang->formatNum( $size ) ); } - $comment = $this->getComment( $row ); - $rd=''; - if( $wgUser->isAllowed( 'deleterevision' ) ) { - $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); - if( !$this->userCan( $row, Revision::DELETED_RESTRICTED ) ) { - // If revision was hidden from sysops - $del = wfMsgHtml( 'rev-delundel' ); - } else { - $del = $this->sk->makeKnownLinkObj( $revdel, - wfMsg( 'rev-delundel' ), - 'target=' . urlencode( $this->mTarget ) . - '&arid=' . urlencode( $row->ar_rev_id ) ); - // Bolden oversighted content - if( $this->isDeleted( $row, Revision::DELETED_RESTRICTED ) ) - $del = "$del"; - } - $rd = "($del)"; - } - - $dflag=''; - if( $this->isDeleted( $row, Revision::DELETED_TEXT ) ) - $dflag = ' ' . wfMsgHtml( 'deletedrev' ) . ''; - - // Do we still need checkboxes? - $wgOut->addHTML( "
  • $checkBox $rd $pageLink . . $userLink $stxt $comment$dflag
  • \n" ); + $comment = $sk->commentBlock( $row->ar_comment ); + $wgOut->addHTML( "
  • $checkBox $pageLink . . $userLink $stxt $comment
  • \n" ); + } $revisions->free(); $wgOut->addHTML(""); @@ -891,21 +795,17 @@ class UndeleteForm { while( $row = $files->fetchObject() ) { $ts = wfTimestamp( TS_MW, $row->fa_timestamp ); if ( $this->mAllowed && $row->fa_storage_key ) { - if ( !$this->userCan( $row, Revision::DELETED_RESTRICTED ) ) - // Grey out boxes to files restricted beyond this user. - // In the future, all image storage may use FileStore, allowing - // for such items to be restored and retain their fa_deleted status - $checkBox = wfCheck( "", false, array("disabled" => "disabled") ); - else - $checkBox = wfCheck( "fileid" . $row->fa_id ); + $checkBox = wfCheck( "fileid" . $row->fa_id ); $key = urlencode( $row->fa_storage_key ); $target = urlencode( $this->mTarget ); - $pageLink = $this->getFileLink( $row, $titleObj, $ts, $target, $key ); + $pageLink = $sk->makeKnownLinkObj( $titleObj, + $wgLang->timeanddate( $ts, true ), + "target=$target&file=$key" ); } else { $checkBox = ''; $pageLink = $wgLang->timeanddate( $ts, true ); } - $userLink = $this->getFileUser( $row ); + $userLink = $sk->userLink( $row->fa_user, $row->fa_user_text ) . $sk->userToolLinks( $row->fa_user, $row->fa_user_text ); $data = wfMsgHtml( 'widthheight', $wgLang->formatNum( $row->fa_width ), @@ -913,25 +813,8 @@ class UndeleteForm { ' (' . wfMsgHtml( 'nbytes', $wgLang->formatNum( $row->fa_size ) ) . ')'; - $comment = $this->getFileComment( $row ); - $rd=''; - if( $wgUser->isAllowed( 'deleterevision' ) ) { - $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); - if( !$this->userCan( $row, Image::DELETED_RESTRICTED ) ) { - // If revision was hidden from sysops - $del = wfMsgHtml( 'rev-delundel' ); - } else { - $del = $this->sk->makeKnownLinkObj( $revdel, - wfMsg( 'rev-delundel' ), - 'target=' . urlencode( $this->mTarget ) . - '&fileid=' . urlencode( $row->fa_id ) ); - // Bolden oversighted content - if( $this->isDeleted( $row, Image::DELETED_RESTRICTED ) ) - $del = "$del"; - } - $rd = "($del)"; - } - $wgOut->addHTML( "
  • $checkBox $rd $pageLink . . $userLink $data $comment
  • \n" ); + $comment = $sk->commentBlock( $row->fa_description ); + $wgOut->addHTML( "
  • $checkBox $pageLink . . $userLink $data $comment
  • \n" ); } $files->free(); $wgOut->addHTML( "" ); @@ -947,143 +830,6 @@ class UndeleteForm { return true; } - /** - * Fetch revision text link if it's available to all users - * @return string - */ - function getPageLink( $row, $titleObj, $ts, $target ) { - global $wgLang; - - if ( !$this->userCan($row, Revision::DELETED_TEXT) ) { - return '' . $wgLang->timeanddate( $ts, true ) . ''; - } else { - $link = $this->sk->makeKnownLinkObj( $titleObj, $wgLang->timeanddate( $ts, true ), "target=$target×tamp=$ts" ); - if ( $this->isDeleted($row, Revision::DELETED_TEXT) ) - $link = '' . $link . ''; - return $link; - } - } - - /** - * Fetch image view link if it's available to all users - * @return string - */ - function getFileLink( $row, $titleObj, $ts, $target, $key ) { - global $wgLang; - - if ( !$this->userCan($row, Image::DELETED_FILE) ) { - return '' . $wgLang->timeanddate( $ts, true ) . ''; - } else { - $link = $this->sk->makeKnownLinkObj( $titleObj, $wgLang->timeanddate( $ts, true ), "target=$target&file=$key" ); - if ( $this->isDeleted($row, Image::DELETED_FILE) ) - $link = '' . $link . ''; - return $link; - } - } - - /** - * Fetch revision's user id if it's available to this user - * @return string - */ - function getUser( $row ) { - if ( !$this->userCan($row, Revision::DELETED_USER) ) { - return '' . wfMsgHtml( 'rev-deleted-user' ) . ''; - } else { - $link = $this->sk->userLink( $row->ar_user, $row->ar_user_text ) . $this->sk->userToolLinks( $row->ar_user, $row->ar_user_text ); - if ( $this->isDeleted($row, Revision::DELETED_USER) ) - $link = '' . $link . ''; - return $link; - } - } - - /** - * Fetch file's user id if it's available to this user - * @return string - */ - function getFileUser( $row ) { - if ( !$this->userCan($row, Image::DELETED_USER) ) { - return '' . wfMsgHtml( 'rev-deleted-user' ) . ''; - } else { - $link = $this->sk->userLink( $row->fa_user, $row->fa_user_text ) . $this->sk->userToolLinks( $row->fa_user, $row->fa_user_text ); - if ( $this->isDeleted($row, Image::DELETED_USER) ) - $link = '' . $link . ''; - return $link; - } - } - - /** - * Fetch revision comment if it's available to this user - * @return string - */ - function getComment( $row ) { - if ( !$this->userCan($row, Revision::DELETED_COMMENT) ) { - return '' . wfMsgHtml( 'rev-deleted-comment' ) . ''; - } else { - $link = $this->sk->commentBlock( $row->ar_comment ); - if ( $this->isDeleted($row, Revision::DELETED_COMMENT) ) - $link = '' . $link . ''; - return $link; - } - } - - /** - * Fetch file upload comment if it's available to this user - * @return string - */ - function getFileComment( $row ) { - if ( !$this->userCan($row, Image::DELETED_COMMENT) ) { - return '' . wfMsgHtml( 'rev-deleted-comment' ) . ''; - } else { - $link = $this->sk->commentBlock( $row->fa_description ); - if ( $this->isDeleted($row, Image::DELETED_COMMENT) ) - $link = '' . $link . ''; - return $link; - } - } - - /** - * int $field one of DELETED_* bitfield constants - * for file or revision rows - * @return bool - */ - function isDeleted( $row, $field ) { - if ( isset($row->ar_deleted) ) - // page revisions - return ($row->ar_deleted & $field) == $field; - else if ( isset($row->fa_deleted) ) - // files - return ($row->fa_deleted & $field) == $field; - return false; - } - - /** - * Determine if the current user is allowed to view a particular - * field of this revision, if it's marked as deleted. - * @param int $field - * @return bool - */ - function userCan( $row, $field ) { - global $wgUser; - - if( isset($row->ar_deleted) && ($row->ar_deleted & $field) == $field ) { - // page revisions - $permission = ( $row->ar_deleted & Revision::DELETED_RESTRICTED ) == Revision::DELETED_RESTRICTED - ? 'hiderevision' - : 'deleterevision'; - wfDebug( "Checking for $permission due to $field match on $row->ar_deleted\n" ); - return $wgUser->isAllowed( $permission ); - } else if( isset($row->fa_deleted) && ($row->fa_deleted & $field) == $field ) { - // files - $permission = ( $row->fa_deleted & Image::DELETED_RESTRICTED ) == Image::DELETED_RESTRICTED - ? 'hiderevision' - : 'deleterevision'; - wfDebug( "Checking for $permission due to $field match on $row->fa_deleted\n" ); - return $wgUser->isAllowed( $permission ); - } else { - return true; - } - } - function undelete() { global $wgOut, $wgUser; if( !is_null( $this->mTargetObj ) ) { @@ -1092,22 +838,16 @@ class UndeleteForm { $ok = $archive->undelete( $this->mTargetTimestamp, $this->mComment, - $this->mFileVersions, - $this->mUnsuppress ); + $this->mFileVersions ); + if( $ok ) { $skin = $wgUser->getSkin(); $link = $skin->makeKnownLinkObj( $this->mTargetObj ); $wgOut->addHtml( wfMsgWikiHtml( 'undeletedpage', $link ) ); return true; } - // Give user some idea of what is going on ... - // This can happen if the top revision would end up being deleted - $wgOut->addHtml( '

    ' . wfMsgHtml( "cannotundelete" ) . '

    ' ); - $wgOut->addHtml( '

    ' . wfMsgHtml( "undeleterevdel" ) . '

    ' ); - $wgOut->returnToMain( false, $this->mTargetObj ); - return false; } - $wgOut->showFatalError( wfMsgHtml( "cannotundelete" ) ); + $wgOut->showFatalError( wfMsg( "cannotundelete" ) ); return false; } } -- 2.20.1