* @ingroup SpecialPage
*/
-use MediaWiki\Storage\RevisionRecord;
+use MediaWiki\MediaWikiServices;
+use MediaWiki\Revision\RevisionRecord;
+use MediaWiki\Permissions\PermissionManager;
/**
* Special page allowing users with the appropriate permissions to view
/** @var string */
private $otherReason;
+ /** @var PermissionManager */
+ private $permissionManager;
+
/**
* UI labels for each type.
*/
],
];
- public function __construct() {
+ /**
+ * @inheritDoc
+ *
+ * @param PermissionManager $permissionManager
+ */
+ public function __construct( PermissionManager $permissionManager ) {
parent::__construct( 'Revisiondelete', 'deleterevision' );
+
+ $this->permissionManager = $permissionManager;
}
public function doesWrites() {
$output = $this->getOutput();
$user = $this->getUser();
- // Check blocks
- // @TODO Use PermissionManager::isBlockedFrom() instead.
- $block = $user->getBlock();
- if ( $block ) {
- throw new UserBlockedError( $block );
- }
-
$this->setHeaders();
$this->outputHeader();
$request = $this->getRequest();
return;
}
+ // Check blocks
+ if ( $this->permissionManager->isBlockedFrom( $user, $this->targetObj ) ) {
+ throw new UserBlockedError( $user->getBlock() );
+ }
+
$this->typeLabels = self::$UILabels[$this->typeName];
$list = $this->getList();
$list->reset();
- $this->mIsAllowed = $user->isAllowed( RevisionDeleter::getRestriction( $this->typeName ) );
- $canViewSuppressedOnly = $this->getUser()->isAllowed( 'viewsuppressed' ) &&
- !$this->getUser()->isAllowed( 'suppressrevision' );
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
+ $this->mIsAllowed = $permissionManager->userHasRight( $user,
+ RevisionDeleter::getRestriction( $this->typeName ) );
+ $canViewSuppressedOnly = $permissionManager->userHasRight( $user, 'viewsuppressed' ) &&
+ !$permissionManager->userHasRight( $user, 'suppressrevision' );
$pageIsSuppressed = $list->areAnySuppressed();
$this->mIsAllowed = $this->mIsAllowed && !( $canViewSuppressedOnly && $pageIsSuppressed );
[ 'revdelete-hide-comment', 'wpHideComment', RevisionRecord::DELETED_COMMENT ],
[ 'revdelete-hide-user', 'wpHideUser', RevisionRecord::DELETED_USER ]
];
- if ( $user->isAllowed( 'suppressrevision' ) ) {
+ if ( $permissionManager->userHasRight( $user, 'suppressrevision' ) ) {
$this->checks[] = [ 'revdelete-hide-restricted',
'wpHideRestricted', RevisionRecord::DELETED_RESTRICTED ];
}
$this->showForm();
}
- if ( $user->isAllowed( 'deletedhistory' ) ) {
+ if ( $permissionManager->userHasRight( $user, 'deletedhistory' ) ) {
$qc = $this->getLogQueryCond();
# Show relevant lines from the deletion log
$deleteLogPage = new LogPage( 'delete' );
);
}
# Show relevant lines from the suppression log
- if ( $user->isAllowed( 'suppressionlog' ) ) {
+ if ( $permissionManager->userHasRight( $user, 'suppressionlog' ) ) {
$suppressLogPage = new LogPage( 'suppress' );
$output->addHTML( "<h2>" . $suppressLogPage->getName()->escaped() . "</h2>\n" );
LogEventsList::showLogExtract(
[ 'action' => 'history' ]
);
# Link to deleted edits
- if ( $this->getUser()->isAllowed( 'undelete' ) ) {
+ if ( MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userHasRight( $this->getUser(), 'undelete' )
+ ) {
$undelete = SpecialPage::getTitleFor( 'Undelete' );
$links[] = $linkRenderer->makeKnownLink(
$undelete,
Xml::closeElement( 'fieldset' ) . "\n" .
Xml::closeElement( 'form' ) . "\n";
// Show link to edit the dropdown reasons
- if ( $this->getUser()->isAllowed( 'editinterface' ) ) {
+ if ( MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userHasRight( $this->getUser(), 'editinterface' )
+ ) {
$link = $this->getLinkRenderer()->makeKnownLink(
$this->msg( 'revdelete-reason-dropdown' )->inContentLanguage()->getTitle(),
$this->msg( 'revdelete-edit-reasonlist' )->text(),
'revdelete-text-others'
);
- if ( $this->getUser()->isAllowed( 'suppressrevision' ) ) {
+ if ( MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userHasRight( $this->getUser(), 'suppressrevision' )
+ ) {
$this->getOutput()->addWikiMsg( 'revdelete-suppress-text' );
}
}
# Can the user set this field?
if ( $bitParams[RevisionRecord::DELETED_RESTRICTED] == 1
- && !$this->getUser()->isAllowed( 'suppressrevision' )
+ && !MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userHasRight( $this->getUser(), 'suppressrevision' )
) {
throw new PermissionsError( 'suppressrevision' );
}
$this->getOutput()->setPageTitle( $this->msg( 'actionfailed' ) );
$this->getOutput()->wrapWikiTextAsInterface(
'errorbox',
- $status->getWikiText( $this->typeLabels['failure'] )
+ $status->getWikiText( $this->typeLabels['failure'], false, $this->getLanguage() )
);
$this->showForm();
}