From 28fbf2bcdac170a7cb0ff6bfdab5cb063ad85718 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 28 Sep 2015 18:19:56 -0700 Subject: [PATCH] Update autodisable logic * Make betatempdisable appear checked if autodisable is true * Set autodisable=false only if betatempdisable is also false * On wikis where $wgVisualEditorTransitionDefault=true, set autodisable=true when the user disables VE Change-Id: I3415af4a735afb10cf246f4b22b9d84ef98c882f --- VisualEditor.hooks.php | 21 +++++++++++++++++++-- extension.json | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php index 9bc3f87542..565aed323f 100644 --- a/VisualEditor.hooks.php +++ b/VisualEditor.hooks.php @@ -338,7 +338,9 @@ class VisualEditorHooks { $preferences['visualeditor-betatempdisable'] = array( 'type' => 'toggle', 'label-message' => 'visualeditor-preference-betatempdisable', - 'section' => 'editing/editor' + 'section' => 'editing/editor', + 'default' => $user->getOption( 'visualeditor-betatempdisable' ) || + $user->getOption( 'visualeditor-autodisable' ) ); $preferences['visualeditor-autodisable'] = array( 'type' => 'api' @@ -387,11 +389,26 @@ class VisualEditorHooks { * @param bool &$result Success or failure */ public static function onPreferencesFormPreSave( $data, $form, $user, &$result ) { + $veConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' ); + // On a wiki where enable is hidden and set to 1, if user sets betatempdisable=0 + // then set autodisable=0 + // On a wiki where betatempdisable is hidden and set to 0, if user sets enable=1 + // then set autodisable=0 if ( $user->getOption( 'visualeditor-autodisable' ) && - $user->getOption( 'visualeditor-enable' ) + $user->getOption( 'visualeditor-enable' ) && + !$user->getOption( 'visualeditor-betatempdisable' ) ) { $user->setOption( 'visualeditor-autodisable', false ); + } elseif ( + // On a wiki where betatempdisable is hidden and set to 0, if user sets enable=0, + // then set autodisable=1 + $veConfig->get( 'VisualEditorTransitionDefault' ) && + !$user->getOption( 'visualeditor-betatempdisable' ) && + !$user->getOption( 'visualeditor-enable' ) && + !$user->getOption( 'visualeditor-autodisable' ) + ) { + $user->setOption( 'visualeditor-autodisable', true ); } } diff --git a/extension.json b/extension.json index e62da7c797..1dad20716b 100644 --- a/extension.json +++ b/extension.json @@ -101,6 +101,7 @@ "VisualEditorNewAccountEnableProportion": false, "VisualEditorEnableTocWidget": false, "VisualEditorAutoAccountEnable": false, + "VisualEditorTransitionDefault": false, "VisualEditorAvailableNamespaces": { "2": true, "_merge_strategy": "array_plus"