mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-25 06:36:32 +00:00
Merge "Hygiene: Use PermissionsManager instead of deprecated methods"
This commit is contained in:
commit
b64585dfad
|
@ -57,7 +57,8 @@ return [
|
||||||
$skin,
|
$skin,
|
||||||
$context->getTitle(),
|
$context->getTitle(),
|
||||||
$context->getUser(),
|
$context->getUser(),
|
||||||
$context
|
$context,
|
||||||
|
$services->getPermissionManager()
|
||||||
);
|
);
|
||||||
if ( $skinOptions->get( SkinOptions::OPTION_OVERFLOW_SUBMENU ) ) {
|
if ( $skinOptions->get( SkinOptions::OPTION_OVERFLOW_SUBMENU ) ) {
|
||||||
$overflowBuilder = $userPageHelper->isUserPage() ?
|
$overflowBuilder = $userPageHelper->isUserPage() ?
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace MediaWiki\Minerva\Menu\PageActions;
|
||||||
use ExtensionRegistry;
|
use ExtensionRegistry;
|
||||||
use Hooks;
|
use Hooks;
|
||||||
use MediaWiki\Minerva\Menu\Group;
|
use MediaWiki\Minerva\Menu\Group;
|
||||||
|
use MediaWiki\Permissions\PermissionManager;
|
||||||
use MessageLocalizer;
|
use MessageLocalizer;
|
||||||
use MinervaUI;
|
use MinervaUI;
|
||||||
use MWException;
|
use MWException;
|
||||||
|
@ -53,19 +54,25 @@ class ToolbarBuilder {
|
||||||
*/
|
*/
|
||||||
private $messageLocalizer;
|
private $messageLocalizer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PermissionManager
|
||||||
|
*/
|
||||||
|
private $permissionsManager;
|
||||||
/**
|
/**
|
||||||
* Build Group containing icons for toolbar
|
* Build Group containing icons for toolbar
|
||||||
* @param SkinMinerva $skin User Skin
|
* @param SkinMinerva $skin User Skin
|
||||||
* @param Title $title Article title user is currently browsing
|
* @param Title $title Article title user is currently browsing
|
||||||
* @param User $user Currently logged in user
|
* @param User $user Currently logged in user
|
||||||
* @param MessageLocalizer $msgLocalizer Message localizer to generate localized texts
|
* @param MessageLocalizer $msgLocalizer Message localizer to generate localized texts
|
||||||
|
* @param PermissionManager $permissionManager Mediawiki Permissions Manager
|
||||||
*/
|
*/
|
||||||
public function __construct( SkinMinerva $skin, Title $title, User $user,
|
public function __construct( SkinMinerva $skin, Title $title, User $user,
|
||||||
MessageLocalizer $msgLocalizer ) {
|
MessageLocalizer $msgLocalizer, PermissionManager $permissionManager ) {
|
||||||
$this->skin = $skin;
|
$this->skin = $skin;
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->messageLocalizer = $msgLocalizer;
|
$this->messageLocalizer = $msgLocalizer;
|
||||||
|
$this->permissionsManager = $permissionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,10 +111,12 @@ class ToolbarBuilder {
|
||||||
*
|
*
|
||||||
* @return PageActionMenuEntry An edit page actions menu entry
|
* @return PageActionMenuEntry An edit page actions menu entry
|
||||||
* @throws MWException
|
* @throws MWException
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
protected function createEditPageAction() {
|
protected function createEditPageAction() {
|
||||||
$title = $this->title;
|
$title = $this->title;
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
|
$pm = $this->permissionsManager;
|
||||||
|
|
||||||
$editArgs = [ 'action' => 'edit' ];
|
$editArgs = [ 'action' => 'edit' ];
|
||||||
if ( $title->isWikitextPage() ) {
|
if ( $title->isWikitextPage() ) {
|
||||||
|
@ -115,9 +124,15 @@ class ToolbarBuilder {
|
||||||
// Full wikitext editing is hard on mobile devices.
|
// Full wikitext editing is hard on mobile devices.
|
||||||
$editArgs['section'] = SkinMinerva::LEAD_SECTION_NUMBER;
|
$editArgs['section'] = SkinMinerva::LEAD_SECTION_NUMBER;
|
||||||
}
|
}
|
||||||
$userQuickEditCheck = $title->quickUserCan( 'edit', $user )
|
|
||||||
&& ( $title->exists() || $title->quickUserCan( 'create', $user ) );
|
$userQuickEditCheck =
|
||||||
$userBlockInfo = $user->getId() == 0 ? false : $user->isBlockedFrom( $title, true );
|
$pm->userCan( 'edit', $user, $title, PermissionManager::RIGOR_QUICK ) &&
|
||||||
|
(
|
||||||
|
$title->exists() ||
|
||||||
|
$pm->userCan( 'create', $user, $title, PermissionManager::RIGOR_QUICK )
|
||||||
|
);
|
||||||
|
|
||||||
|
$userBlockInfo = $user->isAnon() ? false : $pm->isBlockedFrom( $user, $title, true );
|
||||||
$userCanEdit = $userQuickEditCheck && !$userBlockInfo;
|
$userCanEdit = $userQuickEditCheck && !$userBlockInfo;
|
||||||
|
|
||||||
$entry = new PageActionMenuEntry(
|
$entry = new PageActionMenuEntry(
|
||||||
|
|
Loading…
Reference in a new issue