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
This commit is contained in:
Roan Kattouw 2015-09-28 18:19:56 -07:00
parent ce8107ec0b
commit 28fbf2bcda
2 changed files with 20 additions and 2 deletions

View file

@ -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 );
}
}

View file

@ -101,6 +101,7 @@
"VisualEditorNewAccountEnableProportion": false,
"VisualEditorEnableTocWidget": false,
"VisualEditorAutoAccountEnable": false,
"VisualEditorTransitionDefault": false,
"VisualEditorAvailableNamespaces": {
"2": true,
"_merge_strategy": "array_plus"