http://www.mediawiki.org/wiki/Special:Code/MediaWiki/99633
Revision: 99633
Author: ialex
Date: 2011-10-12 15:09:04 +0000 (Wed, 12 Oct 2011)
Log Message:
-----------
* Added User paremeter to Revision::userCan(), Revision::userCanBitfield(),
LogEventsList::userCan(), LogEventsList::userCanBitfield(), File::userCan() and
its subclasses so that they can check against any user instead of always
$wgUser.
* Updated callers that have a context or may use another user than $wgUser
* Revision::getUser(), Revision::getUserText(), Revision::getComment() and
Revision::getText() also have a User as parameter, but it will be used only
when Revision::FOR_THIS_USER is passed in the first parameter
Modified Paths:
--------------
trunk/phase3/includes/ChangesList.php
trunk/phase3/includes/LogEventsList.php
trunk/phase3/includes/Revision.php
trunk/phase3/includes/RevisionList.php
trunk/phase3/includes/filerepo/ArchivedFile.php
trunk/phase3/includes/filerepo/File.php
trunk/phase3/includes/filerepo/OldLocalFile.php
trunk/phase3/includes/revisiondelete/RevisionDelete.php
trunk/phase3/includes/specials/SpecialContributions.php
trunk/phase3/includes/specials/SpecialDeletedContributions.php
trunk/phase3/includes/specials/SpecialMergeHistory.php
trunk/phase3/includes/specials/SpecialRevisiondelete.php
trunk/phase3/includes/specials/SpecialUndelete.php
Modified: trunk/phase3/includes/ChangesList.php
===================================================================
--- trunk/phase3/includes/ChangesList.php 2011-10-12 14:13:06 UTC (rev
99632)
+++ trunk/phase3/includes/ChangesList.php 2011-10-12 15:09:04 UTC (rev
99633)
@@ -262,7 +262,7 @@
# Diff link
if( $rc->mAttribs['rc_type'] == RC_NEW ||
$rc->mAttribs['rc_type'] == RC_LOG ) {
$diffLink = $this->message['diff'];
- } elseif( !self::userCan($rc,Revision::DELETED_TEXT) ) {
+ } elseif ( !self::userCan( $rc, Revision::DELETED_TEXT,
$this->getUser() ) ) {
$diffLink = $this->message['diff'];
} else {
$query = array(
@@ -422,13 +422,14 @@
* field of this revision, if it's marked as deleted.
* @param $rc RCCacheEntry
* @param $field Integer
+ * @param $user User object to check, or null to use $wgUser
* @return Boolean
*/
- public static function userCan( $rc, $field ) {
+ public static function userCan( $rc, $field, User $user = null ) {
if( $rc->mAttribs['rc_type'] == RC_LOG ) {
- return LogEventsList::userCanBitfield(
$rc->mAttribs['rc_deleted'], $field );
+ return LogEventsList::userCanBitfield(
$rc->mAttribs['rc_deleted'], $field, $user );
} else {
- return Revision::userCanBitfield(
$rc->mAttribs['rc_deleted'], $field );
+ return Revision::userCanBitfield(
$rc->mAttribs['rc_deleted'], $field, $user );
}
}
@@ -675,7 +676,7 @@
}
# Don't show unusable diff links
- if ( !ChangesList::userCan($rc,Revision::DELETED_TEXT) ) {
+ if ( !ChangesList::userCan( $rc, Revision::DELETED_TEXT,
$this->getUser() ) ) {
$showdifflinks = false;
}
@@ -883,7 +884,7 @@
$r .= ' ';
if( !$allLogs ) {
$r .= '(';
- if( !ChangesList::userCan( $rcObj,
Revision::DELETED_TEXT ) ) {
+ if( !ChangesList::userCan( $rcObj,
Revision::DELETED_TEXT, $this->getUser() ) ) {
$r .= $nchanges[$n];
} elseif( $isnew ) {
$r .= $nchanges[$n];
@@ -972,7 +973,7 @@
if( $type == RC_LOG ) {
$link = $rcObj->timestamp;
# Revision link
- } elseif(
!ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) {
+ } elseif( !ChangesList::userCan( $rcObj,
Revision::DELETED_TEXT, $this->getUser() ) ) {
$link = '<span
class="history-deleted">'.$rcObj->timestamp.'</span> ';
} else {
if ( $rcObj->unpatrolled && $type == RC_NEW) {
Modified: trunk/phase3/includes/LogEventsList.php
===================================================================
--- trunk/phase3/includes/LogEventsList.php 2011-10-12 14:13:06 UTC (rev
99632)
+++ trunk/phase3/includes/LogEventsList.php 2011-10-12 15:09:04 UTC (rev
99633)
@@ -557,10 +557,11 @@
*
* @param $row Row
* @param $field Integer
+ * @param $user User object to check, or null to use $wgUser
* @return Boolean
*/
- public static function userCan( $row, $field ) {
- return self::userCanBitfield( $row->log_deleted, $field );
+ public static function userCan( $row, $field, User $user = null ) {
+ return self::userCanBitfield( $row->log_deleted, $field, $user
);
}
/**
@@ -569,19 +570,22 @@
*
* @param $bitfield Integer (current field)
* @param $field Integer
+ * @param $user User object to check, or null to use $wgUser
* @return Boolean
*/
- public static function userCanBitfield( $bitfield, $field ) {
+ public static function userCanBitfield( $bitfield, $field, User $user =
null ) {
if( $bitfield & $field ) {
- global $wgUser;
-
if ( $bitfield & LogPage::DELETED_RESTRICTED ) {
$permission = 'suppressrevision';
} else {
$permission = 'deletedhistory';
}
wfDebug( "Checking for $permission due to $field match
on $bitfield\n" );
- return $wgUser->isAllowed( $permission );
+ if ( $user === null ) {
+ global $wgUser;
+ $user = $wgUser;
+ }
+ return $user->isAllowed( $permission );
} else {
return true;
}
Modified: trunk/phase3/includes/Revision.php
===================================================================
--- trunk/phase3/includes/Revision.php 2011-10-12 14:13:06 UTC (rev 99632)
+++ trunk/phase3/includes/Revision.php 2011-10-12 15:09:04 UTC (rev 99633)
@@ -490,14 +490,14 @@
* Revision::FOR_PUBLIC to be displayed to all users
* Revision::FOR_THIS_USER to be displayed to $wgUser
* Revision::RAW get the ID regardless of permissions
- *
- *
+ * @param $user User object to check for, only if FOR_THIS_USER is
passed
+ * to the $audience parameter
* @return Integer
*/
- public function getUser( $audience = self::FOR_PUBLIC ) {
+ public function getUser( $audience = self::FOR_PUBLIC, User $user =
null ) {
if( $audience == self::FOR_PUBLIC && $this->isDeleted(
self::DELETED_USER ) ) {
return 0;
- } elseif( $audience == self::FOR_THIS_USER && !$this->userCan(
self::DELETED_USER ) ) {
+ } elseif( $audience == self::FOR_THIS_USER && !$this->userCan(
self::DELETED_USER, $user ) ) {
return 0;
} else {
return $this->mUser;
@@ -522,13 +522,14 @@
* Revision::FOR_PUBLIC to be displayed to all users
* Revision::FOR_THIS_USER to be displayed to $wgUser
* Revision::RAW get the text regardless of
permissions
- *
+ * @param $user User object to check for, only if FOR_THIS_USER is
passed
+ * to the $audience parameter
* @return string
*/
- public function getUserText( $audience = self::FOR_PUBLIC ) {
+ public function getUserText( $audience = self::FOR_PUBLIC, User $user =
null ) {
if( $audience == self::FOR_PUBLIC && $this->isDeleted(
self::DELETED_USER ) ) {
return '';
- } elseif( $audience == self::FOR_THIS_USER && !$this->userCan(
self::DELETED_USER ) ) {
+ } elseif( $audience == self::FOR_THIS_USER && !$this->userCan(
self::DELETED_USER, $user ) ) {
return '';
} else {
return $this->mUserText;
@@ -553,13 +554,14 @@
* Revision::FOR_PUBLIC to be displayed to all users
* Revision::FOR_THIS_USER to be displayed to $wgUser
* Revision::RAW get the text regardless of
permissions
- *
+ * @param $user User object to check for, only if FOR_THIS_USER is
passed
+ * to the $audience parameter
* @return String
*/
- function getComment( $audience = self::FOR_PUBLIC ) {
+ function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
if( $audience == self::FOR_PUBLIC && $this->isDeleted(
self::DELETED_COMMENT ) ) {
return '';
- } elseif( $audience == self::FOR_THIS_USER && !$this->userCan(
self::DELETED_COMMENT ) ) {
+ } elseif( $audience == self::FOR_THIS_USER && !$this->userCan(
self::DELETED_COMMENT, $user ) ) {
return '';
} else {
return $this->mComment;
@@ -630,13 +632,14 @@
* Revision::FOR_PUBLIC to be displayed to all users
* Revision::FOR_THIS_USER to be displayed to $wgUser
* Revision::RAW get the text regardless of
permissions
- *
+ * @param $user User object to check for, only if FOR_THIS_USER is
passed
+ * to the $audience parameter
* @return String
*/
- public function getText( $audience = self::FOR_PUBLIC ) {
+ public function getText( $audience = self::FOR_PUBLIC, User $user =
null ) {
if( $audience == self::FOR_PUBLIC && $this->isDeleted(
self::DELETED_TEXT ) ) {
return '';
- } elseif( $audience == self::FOR_THIS_USER && !$this->userCan(
self::DELETED_TEXT ) ) {
+ } elseif( $audience == self::FOR_THIS_USER && !$this->userCan(
self::DELETED_TEXT, $user ) ) {
return '';
} else {
return $this->getRawText();
@@ -1023,10 +1026,11 @@
* @param $field Integer:one of self::DELETED_TEXT,
* self::DELETED_COMMENT,
* self::DELETED_USER
+ * @param $user User object to check, or null to use $wgUser
* @return Boolean
*/
- public function userCan( $field ) {
- return self::userCanBitfield( $this->mDeleted, $field );
+ public function userCan( $field, User $user = null ) {
+ return self::userCanBitfield( $this->mDeleted, $field, $user );
}
/**
@@ -1038,11 +1042,11 @@
* @param $field Integer: one of self::DELETED_TEXT =
File::DELETED_FILE,
* self::DELETED_COMMENT =
File::DELETED_COMMENT,
* self::DELETED_USER = File::DELETED_USER
+ * @param $user User object to check, or null to use $wgUser
* @return Boolean
*/
- public static function userCanBitfield( $bitfield, $field ) {
+ public static function userCanBitfield( $bitfield, $field, User $user =
null ) {
if( $bitfield & $field ) { // aspect is deleted
- global $wgUser;
if ( $bitfield & self::DELETED_RESTRICTED ) {
$permission = 'suppressrevision';
} elseif ( $field & self::DELETED_TEXT ) {
@@ -1051,7 +1055,11 @@
$permission = 'deletedhistory';
}
wfDebug( "Checking for $permission due to $field match
on $bitfield\n" );
- return $wgUser->isAllowed( $permission );
+ if ( $user === null ) {
+ global $wgUser;
+ $user = $wgUser;
+ }
+ return $user->isAllowed( $permission );
} else {
return true;
}
Modified: trunk/phase3/includes/RevisionList.php
===================================================================
--- trunk/phase3/includes/RevisionList.php 2011-10-12 14:13:06 UTC (rev
99632)
+++ trunk/phase3/includes/RevisionList.php 2011-10-12 15:09:04 UTC (rev
99633)
@@ -300,11 +300,11 @@
}
public function canView() {
- return $this->revision->userCan( Revision::DELETED_RESTRICTED );
+ return $this->revision->userCan( Revision::DELETED_RESTRICTED,
$this->context->getUser() );
}
public function canViewContent() {
- return $this->revision->userCan( Revision::DELETED_TEXT );
+ return $this->revision->userCan( Revision::DELETED_TEXT,
$this->context->getUser() );
}
public function isDeleted() {
Modified: trunk/phase3/includes/filerepo/ArchivedFile.php
===================================================================
--- trunk/phase3/includes/filerepo/ArchivedFile.php 2011-10-12 14:13:06 UTC
(rev 99632)
+++ trunk/phase3/includes/filerepo/ArchivedFile.php 2011-10-12 15:09:04 UTC
(rev 99633)
@@ -461,10 +461,11 @@
* Determine if the current user is allowed to view a particular
* field of this FileStore image file, if it's marked as deleted.
* @param $field Integer
+ * @param $user User object to check, or null to use $wgUser
* @return bool
*/
- public function userCan( $field ) {
+ public function userCan( $field, User $user = null ) {
$this->load();
- return Revision::userCanBitfield( $this->deleted, $field );
+ return Revision::userCanBitfield( $this->deleted, $field, $user
);
}
}
Modified: trunk/phase3/includes/filerepo/File.php
===================================================================
--- trunk/phase3/includes/filerepo/File.php 2011-10-12 14:13:06 UTC (rev
99632)
+++ trunk/phase3/includes/filerepo/File.php 2011-10-12 15:09:04 UTC (rev
99633)
@@ -1437,9 +1437,10 @@
* field of this file, if it's marked as deleted.
* STUB
* @param $field Integer
+ * @param $user User object to check, or null to use $wgUser
* @return Boolean
*/
- function userCan( $field ) {
+ function userCan( $field, User $user = null ) {
return true;
}
Modified: trunk/phase3/includes/filerepo/OldLocalFile.php
===================================================================
--- trunk/phase3/includes/filerepo/OldLocalFile.php 2011-10-12 14:13:06 UTC
(rev 99632)
+++ trunk/phase3/includes/filerepo/OldLocalFile.php 2011-10-12 15:09:04 UTC
(rev 99633)
@@ -205,11 +205,12 @@
* field of this image file, if it's marked as deleted.
*
* @param $field Integer
+ * @param $user User object to check, or null to use $wgUser
* @return bool
*/
- function userCan( $field ) {
+ function userCan( $field, User $user = null ) {
$this->load();
- return Revision::userCanBitfield( $this->deleted, $field );
+ return Revision::userCanBitfield( $this->deleted, $field, $user
);
}
/**
Modified: trunk/phase3/includes/revisiondelete/RevisionDelete.php
===================================================================
--- trunk/phase3/includes/revisiondelete/RevisionDelete.php 2011-10-12
14:13:06 UTC (rev 99632)
+++ trunk/phase3/includes/revisiondelete/RevisionDelete.php 2011-10-12
15:09:04 UTC (rev 99633)
@@ -132,11 +132,11 @@
}
public function canView() {
- return $this->revision->userCan( Revision::DELETED_RESTRICTED );
+ return $this->revision->userCan( Revision::DELETED_RESTRICTED,
$this->list->getUser() );
}
public function canViewContent() {
- return $this->revision->userCan( Revision::DELETED_TEXT );
+ return $this->revision->userCan( Revision::DELETED_TEXT,
$this->list->getUser() );
}
public function getBits() {
@@ -509,11 +509,11 @@
}
public function canView() {
- return $this->file->userCan( File::DELETED_RESTRICTED );
+ return $this->file->userCan( File::DELETED_RESTRICTED,
$this->list->getUser() );
}
public function canViewContent() {
- return $this->file->userCan( File::DELETED_FILE );
+ return $this->file->userCan( File::DELETED_FILE,
$this->list->getUser() );
}
public function getBits() {
@@ -596,7 +596,7 @@
* @return string HTML
*/
protected function getUserTools() {
- if( $this->file->userCan( Revision::DELETED_USER ) ) {
+ if( $this->file->userCan( Revision::DELETED_USER,
$this->list->getUser() ) ) {
$link = Linker::userLink( $this->file->user,
$this->file->user_text ) .
Linker::userToolLinks( $this->file->user,
$this->file->user_text );
} else {
@@ -615,7 +615,7 @@
* @return string HTML
*/
protected function getComment() {
- if( $this->file->userCan( File::DELETED_COMMENT ) ) {
+ if( $this->file->userCan( File::DELETED_COMMENT,
$this->list->getUser() ) ) {
$block = Linker::commentBlock( $this->file->description
);
} else {
$block = ' ' . wfMsgHtml( 'rev-deleted-comment' );
@@ -807,7 +807,7 @@
}
public function canView() {
- return LogEventsList::userCan( $this->row,
Revision::DELETED_RESTRICTED );
+ return LogEventsList::userCan( $this->row,
Revision::DELETED_RESTRICTED, $this->list->getUser() );
}
public function canViewContent() {
Modified: trunk/phase3/includes/specials/SpecialContributions.php
===================================================================
--- trunk/phase3/includes/specials/SpecialContributions.php 2011-10-12
14:13:06 UTC (rev 99632)
+++ trunk/phase3/includes/specials/SpecialContributions.php 2011-10-12
15:09:04 UTC (rev 99633)
@@ -616,8 +616,9 @@
$topmarktext .= ' '.Linker::generateRollback(
$rev );
}
}
+ $user = $this->getUser();
# Is there a visible previous revision?
- if( $rev->userCan( Revision::DELETED_TEXT ) &&
$rev->getParentId() !== 0 ) {
+ if( $rev->userCan( Revision::DELETED_TEXT, $user ) &&
$rev->getParentId() !== 0 ) {
$difftext = Linker::linkKnown(
$page,
$this->messages['diff'],
@@ -646,7 +647,7 @@
$comment = $this->getLang()->getDirMark() . Linker::revComment(
$rev, false, true );
$date = $this->getLang()->timeanddate( wfTimestamp( TS_MW,
$row->rev_timestamp ), true );
- if( $rev->userCan( Revision::DELETED_TEXT ) ) {
+ if( $rev->userCan( Revision::DELETED_TEXT, $user ) ) {
$d = Linker::linkKnown(
$page,
htmlspecialchars($date),
@@ -680,9 +681,9 @@
}
// Don't show useless link to people who cannot hide revisions
- $canHide = $this->getUser()->isAllowed( 'deleterevision' );
- if( $canHide || ($rev->getVisibility() &&
$this->getUser()->isAllowed('deletedhistory')) ) {
- if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
+ $canHide = $user->isAllowed( 'deleterevision' );
+ if( $canHide || ($rev->getVisibility() &&
$user->isAllowed('deletedhistory')) ) {
+ if( !$rev->userCan( Revision::DELETED_RESTRICTED, $user
) ) {
$del = Linker::revDeleteLinkDisabled( $canHide
); // revision was hidden from sysops
} else {
$query = array(
Modified: trunk/phase3/includes/specials/SpecialDeletedContributions.php
===================================================================
--- trunk/phase3/includes/specials/SpecialDeletedContributions.php
2011-10-12 14:13:06 UTC (rev 99632)
+++ trunk/phase3/includes/specials/SpecialDeletedContributions.php
2011-10-12 15:09:04 UTC (rev 99633)
@@ -184,7 +184,7 @@
$comment = Linker::revComment( $rev );
$date = htmlspecialchars( $this->getLang()->timeanddate(
$rev->getTimestamp(), true ) );
- if( !$user->isAllowed('undelete') ||
!$rev->userCan(Revision::DELETED_TEXT) ) {
+ if( !$user->isAllowed( 'undelete' ) || !$rev->userCan(
Revision::DELETED_TEXT, $user ) ) {
$link = $date; // unusable link
} else {
$link = Linker::linkKnown(
Modified: trunk/phase3/includes/specials/SpecialMergeHistory.php
===================================================================
--- trunk/phase3/includes/specials/SpecialMergeHistory.php 2011-10-12
14:13:06 UTC (rev 99632)
+++ trunk/phase3/includes/specials/SpecialMergeHistory.php 2011-10-12
15:09:04 UTC (rev 99633)
@@ -271,7 +271,7 @@
}
# Last link
- if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
+ if( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() )
) {
$last = $this->message['last'];
} elseif( isset( $this->prevId[$row->rev_id] ) ) {
$last = Linker::linkKnown(
Modified: trunk/phase3/includes/specials/SpecialRevisiondelete.php
===================================================================
--- trunk/phase3/includes/specials/SpecialRevisiondelete.php 2011-10-12
14:13:06 UTC (rev 99632)
+++ trunk/phase3/includes/specials/SpecialRevisiondelete.php 2011-10-12
15:09:04 UTC (rev 99633)
@@ -278,7 +278,7 @@
$this->getOutput()->addWikiMsg( 'revdelete-no-file' );
return;
}
- if( !$oimage->userCan(File::DELETED_FILE) ) {
+ if( !$oimage->userCan( File::DELETED_FILE, $this->getUser() ) )
{
if( $oimage->isDeleted( File::DELETED_RESTRICTED ) ) {
$this->getOutput()->permissionRequired(
'suppressrevision' );
} else {
Modified: trunk/phase3/includes/specials/SpecialUndelete.php
===================================================================
--- trunk/phase3/includes/specials/SpecialUndelete.php 2011-10-12 14:13:06 UTC
(rev 99632)
+++ trunk/phase3/includes/specials/SpecialUndelete.php 2011-10-12 15:09:04 UTC
(rev 99633)
@@ -634,7 +634,9 @@
function execute( $par ) {
$this->setHeaders();
- if ( !$this->userCanExecute( $this->getUser() ) ) {
+
+ $user = $this->getUser();
+ if ( !$this->userCanExecute( $user ) ) {
$this->displayRestrictionError();
return;
}
@@ -663,7 +665,7 @@
if( is_null( $this->mTargetObj ) ) {
# Not all users can just browse every deleted page from
the list
- if( $this->getUser()->isAllowed( 'browsearchive' ) ) {
+ if( $user->isAllowed( 'browsearchive' ) ) {
$this->showSearchForm();
# List undeletable articles
@@ -685,14 +687,14 @@
if ( !$file->exists() ) {
$out->addWikiMsg( 'filedelete-nofile',
$this->mFilename );
return;
- } elseif( !$file->userCan( File::DELETED_FILE ) ) {
+ } elseif( !$file->userCan( File::DELETED_FILE, $user )
) {
if( $file->isDeleted( File::DELETED_RESTRICTED
) ) {
$out->permissionRequired(
'suppressrevision' );
} else {
$out->permissionRequired( 'deletedtext'
);
}
return false;
- } elseif ( !$this->getUser()->matchEditToken(
$this->mToken, $this->mFilename ) ) {
+ } elseif ( !$user->matchEditToken( $this->mToken,
$this->mFilename ) ) {
$this->showFileConfirmationForm(
$this->mFilename );
return false;
} else {
@@ -772,8 +774,6 @@
}
private function showRevision( $timestamp ) {
- $out = $this->getOutput();
-
if( !preg_match( '/[0-9]{14}/', $timestamp ) ) {
return 0;
}
@@ -782,13 +782,16 @@
wfRunHooks( 'UndeleteForm::showRevision', array( &$archive,
$this->mTargetObj ) );
$rev = $archive->getRevision( $timestamp );
+ $out = $this->getOutput();
+ $user = $this->getUser();
+
if( !$rev ) {
$out->addWikiMsg( 'undeleterevision-missing' );
return;
}
if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
- if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
+ if( !$rev->userCan( Revision::DELETED_TEXT, $user ) ) {
$out->wrapWikiMsg( "<div class='mw-warning
plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' );
return;
} else {
@@ -804,7 +807,7 @@
$previousRev = $archive->getPreviousRevision(
$timestamp );
if( $previousRev ) {
$this->showDiff( $previousRev, $rev );
- if( $this->getUser()->getOption( 'diffonly' ) )
{
+ if( $user->getOption( 'diffonly' ) ) {
return;
} else {
$out->addHTML( '<hr />' );
@@ -824,7 +827,7 @@
$time = $this->getLang()->timeAndDate( $timestamp, true );
$d = $this->getLang()->date( $timestamp, true );
$t = $this->getLang()->time( $timestamp, true );
- $user = Linker::revUserTools( $rev );
+ $userLink = Linker::revUserTools( $rev );
if( $this->mPreview ) {
$openDiv = '<div id="mw-undelete-revision"
class="mw-warning">';
@@ -835,14 +838,14 @@
// Revision delete links
if ( !$this->mDiff ) {
- $revdel = Linker::getRevDeleteLink( $this->getUser(),
$rev, $this->mTargetObj );
+ $revdel = Linker::getRevDeleteLink( $user, $rev,
$this->mTargetObj );
if ( $revdel ) {
$out->addHTML( "$revdel " );
}
}
$out->addHTML( wfMessage( 'undelete-revision' )->rawParams(
$link )->params(
- $time )->rawParams( $user )->params( $d, $t )->parse()
. '</div>' );
+ $time )->rawParams( $userLink )->params( $d, $t
)->parse() . '</div>' );
wfRunHooks( 'UndeleteShowRevision', array( $this->mTargetObj,
$rev ) );
if( $this->mPreview ) {
@@ -850,15 +853,15 @@
$popts = $out->parserOptions();
$popts->setEditSection( false );
$out->parserOptions( $popts );
- $out->addWikiTextTitleTidy( $rev->getText(
Revision::FOR_THIS_USER ), $this->mTargetObj, true );
+ $out->addWikiTextTitleTidy( $rev->getText(
Revision::FOR_THIS_USER, $user ), $this->mTargetObj, true );
}
$out->addHTML(
Xml::element( 'textarea', array(
'readonly' => 'readonly',
- 'cols' => intval(
$this->getUser()->getOption( 'cols' ) ),
- 'rows' => intval(
$this->getUser()->getOption( 'rows' ) ) ),
- $rev->getText( Revision::FOR_THIS_USER ) . "\n"
) .
+ 'cols' => intval( $user->getOption(
'cols' ) ),
+ 'rows' => intval( $user->getOption(
'rows' ) ) ),
+ $rev->getText( Revision::FOR_THIS_USER, $user )
. "\n" ) .
Xml::openElement( 'div' ) .
Xml::openElement( 'form', array(
'method' => 'post',
@@ -874,7 +877,7 @@
Xml::element( 'input', array(
'type' => 'hidden',
'name' => 'wpEditToken',
- 'value' => $this->getUser()->editToken() ) ) .
+ 'value' => $user->editToken() ) ) .
Xml::element( 'input', array(
'type' => 'submit',
'name' => 'preview',
@@ -1189,7 +1192,7 @@
if( $this->mCanView ) {
$titleObj = $this->getTitle();
# Last link
- if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
+ if( !$rev->userCan( Revision::DELETED_TEXT,
$this->getUser() ) ) {
$pageLink = htmlspecialchars(
$this->getLang()->timeanddate( $ts, true ) );
$last = wfMsgHtml( 'diff' );
} elseif( $remaining > 0 || ( $earliestLiveTime && $ts
> $earliestLiveTime ) ) {
@@ -1250,9 +1253,10 @@
$comment = $this->getFileComment( $file );
// Add show/hide deletion links if available
- $canHide = $this->getUser()->isAllowed( 'deleterevision' );
- if( $canHide || ( $file->getVisibility() &&
$this->getUser()->isAllowed( 'deletedhistory' ) ) ) {
- if( !$file->userCan( File::DELETED_RESTRICTED ) ) {
+ $user = $this->getUser();
+ $canHide = $user->isAllowed( 'deleterevision' );
+ if( $canHide || ( $file->getVisibility() && $user->isAllowed(
'deletedhistory' ) ) ) {
+ if( !$file->userCan( File::DELETED_RESTRICTED, $user )
) {
$revdlink = Linker::revDeleteLinkDisabled(
$canHide ); // revision was hidden from sysops
} else {
$query = array(
@@ -1279,7 +1283,7 @@
function getPageLink( $rev, $titleObj, $ts ) {
$time = htmlspecialchars( $this->getLang()->timeanddate( $ts,
true ) );
- if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
+ if( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() )
) {
return '<span class="history-deleted">' . $time .
'</span>';
} else {
$link = Linker::linkKnown(
@@ -1305,7 +1309,7 @@
* @return String: HTML fragment
*/
function getFileLink( $file, $titleObj, $ts, $key ) {
- if( !$file->userCan( File::DELETED_FILE ) ) {
+ if( !$file->userCan( File::DELETED_FILE, $this->getUser() ) ) {
return '<span class="history-deleted">' .
$this->getLang()->timeanddate( $ts, true ) . '</span>';
} else {
$link = Linker::linkKnown(
@@ -1332,7 +1336,7 @@
* @return String: HTML fragment
*/
function getFileUser( $file ) {
- if( !$file->userCan( File::DELETED_USER ) ) {
+ if( !$file->userCan( File::DELETED_USER, $this->getUser() ) ) {
return '<span class="history-deleted">' . wfMsgHtml(
'rev-deleted-user' ) . '</span>';
} else {
$link = Linker::userLink( $file->getRawUser(),
$file->getRawUserText() ) .
@@ -1351,7 +1355,7 @@
* @return String: HTML fragment
*/
function getFileComment( $file ) {
- if( !$file->userCan( File::DELETED_COMMENT ) ) {
+ if( !$file->userCan( File::DELETED_COMMENT, $this->getUser() )
) {
return '<span class="history-deleted"><span
class="comment">' .
wfMsgHtml( 'rev-deleted-comment' ) .
'</span></span>';
} else {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs