mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-24 02:38:40 +00:00
Make VisualEditorDisableForAnons only hide the tabs, not disable the editor
Bug: T253941 Change-Id: Id08514b3827c4315d69651bc2313bf8317ba12fc
This commit is contained in:
parent
af719282b9
commit
f81f34f59d
|
@ -110,6 +110,7 @@
|
|||
"value": false
|
||||
},
|
||||
"VisualEditorDisableForAnons": {
|
||||
"description": "Do not change the edit tabs/links for anon users, regardless of other settings. Note that this does not actually disable the visual editor, contrary to the name, and you should probably set the user preferences so that wikitext editor is the default. (T253941)",
|
||||
"value": false
|
||||
},
|
||||
"VisualEditorTransitionDefault": {
|
||||
|
|
|
@ -243,12 +243,9 @@ class VisualEditorHooks {
|
|||
* @return bool
|
||||
*/
|
||||
private static function enabledForUser( $user ) {
|
||||
$veConfig = MediaWikiServices::getInstance()->getConfigFactory()
|
||||
->makeConfig( 'visualeditor' );
|
||||
return $user->getOption( 'visualeditor-enable' ) &&
|
||||
!$user->getOption( 'visualeditor-betatempdisable' ) &&
|
||||
!$user->getOption( 'visualeditor-autodisable' ) &&
|
||||
!( $veConfig->get( 'VisualEditorDisableForAnons' ) && $user->isAnon() );
|
||||
!$user->getOption( 'visualeditor-autodisable' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -474,7 +471,11 @@ class VisualEditorHooks {
|
|||
}
|
||||
|
||||
// Exit if the user doesn't have VE enabled
|
||||
if ( !self::enabledForUser( $user ) ) {
|
||||
if (
|
||||
!self::enabledForUser( $user ) ||
|
||||
// T253941: This option does not actually disable the editor, only leaves the tabs/links unchanged
|
||||
( $config->get( 'VisualEditorDisableForAnons' ) && $user->isAnon() )
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -643,7 +644,11 @@ class VisualEditorHooks {
|
|||
|
||||
$user = $skin->getUser();
|
||||
// Exit if the user doesn't have VE enabled
|
||||
if ( !self::enabledForUser( $user ) ) {
|
||||
if (
|
||||
!self::enabledForUser( $user ) ||
|
||||
// T253941: This option does not actually disable the editor, only leaves the tabs/links unchanged
|
||||
( $config->get( 'VisualEditorDisableForAnons' ) && $user->isAnon() )
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -298,7 +298,11 @@
|
|||
// user has expressed no choice by opening this editor. (T246259)
|
||||
// Strictly speaking the same thing should happen if visual mode is
|
||||
// available but source mode isn't, but that is never the case.
|
||||
if ( !init.isVisualAvailable ) {
|
||||
if (
|
||||
!init.isVisualAvailable ||
|
||||
// T253941: This option does not actually disable the editor, only leaves the tabs/links unchanged
|
||||
( conf.disableForAnons && mw.config.get( 'wgUserName' ) === null )
|
||||
) {
|
||||
return $.Deferred().resolve().promise();
|
||||
}
|
||||
|
||||
|
@ -627,7 +631,11 @@
|
|||
// Set up the tabs appropriately if the user has VE on
|
||||
if ( init.isAvailable ) {
|
||||
// … on two-edit-tab wikis, or single-edit-tab wikis, where the user wants both …
|
||||
if ( !init.isSingleEditTab && init.isVisualAvailable ) {
|
||||
if (
|
||||
!init.isSingleEditTab && init.isVisualAvailable &&
|
||||
// T253941: This option does not actually disable the editor, only leaves the tabs/links unchanged
|
||||
!( conf.disableForAnons && mw.config.get( 'wgUserName' ) === null )
|
||||
) {
|
||||
// … set the skin up with both tabs and both section edit links.
|
||||
init.setupMultiTabSkin();
|
||||
} else if (
|
||||
|
@ -1137,10 +1145,6 @@
|
|||
);
|
||||
|
||||
enabledForUser = (
|
||||
// Allow disabling for anonymous users separately from changing the
|
||||
// default preference (T52000)
|
||||
!( conf.disableForAnons && mw.config.get( 'wgUserName' ) === null ) &&
|
||||
|
||||
// User has 'visualeditor-enable' preference enabled (for alpha opt-in)
|
||||
// User has 'visualeditor-betatempdisable' preference disabled
|
||||
// User has 'visualeditor-autodisable' preference disabled
|
||||
|
|
Loading…
Reference in a new issue