Alex Monk has uploaded a new change for review.
https://gerrit.wikimedia.org/r/295312
Change subject: When logging in, if VEE cookie is set, change the user's
preference to match it
......................................................................
When logging in, if VEE cookie is set, change the user's preference to match it
Bug: T133304
Change-Id: I9660cfc7b0e980192dd063f44d32d04cf34b1d6d
---
M VisualEditor.hooks.php
M extension.json
2 files changed, 16 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/12/295312/1
diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index fe4368f..0e5e2c9 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -973,4 +973,17 @@
return true;
}
+ /**
+ * On login, if user has a VEE cookie, set their preference equal to it.
+ * @param $user User
+ * @return bool true
+ */
+ public static function onUserLoggedIn( $user ) {
+ $cookie = RequestContext::getMain()->getRequest()->getCookie(
'VEE', '' );
+ if ( $cookie === 'visualeditor' || $cookie === 'wikitext' ) {
+ $user->setOption( 'visualeditor-editor', $cookie );
+ $user->saveSettings();
+ }
+ return true;
+ }
}
diff --git a/extension.json b/extension.json
index 810cb8c..b6374cb 100644
--- a/extension.json
+++ b/extension.json
@@ -186,6 +186,9 @@
],
"CustomEditor": [
"VisualEditorHooks::onCustomEditor"
+ ],
+ "UserLoggedIn": [
+ "VisualEditorHooks::onUserLoggedIn"
]
},
"ResourceModules": {
--
To view, visit https://gerrit.wikimedia.org/r/295312
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9660cfc7b0e980192dd063f44d32d04cf34b1d6d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits