jenkins-bot has submitted this change and it was merged.
Change subject: disable Moodbar using user prefs
......................................................................
disable Moodbar using user prefs
Earlier Moodbar preferences were set using cookies, now this can be done
using MW's preferences.
Bug: 37947
Change-Id: I0af9f522cc679ffbc060cad4d6f6a4db57815cef
---
M MoodBar.hooks.php
M MoodBar.i18n.php
M MoodBar.php
M modules/ext.moodBar/ext.moodBar.core.js
M modules/ext.moodBar/ext.moodBar.init.js
5 files changed, 78 insertions(+), 10 deletions(-)
Approvals:
Bsitu: Looks good to me, approved
jenkins-bot: Verified
diff --git a/MoodBar.hooks.php b/MoodBar.hooks.php
index fb6559d..0533781 100644
--- a/MoodBar.hooks.php
+++ b/MoodBar.hooks.php
@@ -76,6 +76,10 @@
return false;
}
+ if ( $skin->getUser()->getOption( 'moodbar-disable' ) ) {
+ return false;
+ }
+
if ( $skin->getUser()->isAnon() ) {
return false;
}
@@ -181,4 +185,17 @@
//sort($buckets);
return $buckets;
}
+
+ /**
+ * Sets the preferences for disabling moodbar.
+ */
+ public static function onGetPreferences( $user, &$preferences ) {
+ $preferences['moodbar-disable'] = array(
+ 'type' => 'toggle',
+ 'label-message' => 'moodbar-disable',
+ 'section' => 'misc/moodbar',
+ );
+
+ return true;
+ }
}
diff --git a/MoodBar.i18n.php b/MoodBar.i18n.php
index f0b72a1..c7c760e 100644
--- a/MoodBar.i18n.php
+++ b/MoodBar.i18n.php
@@ -57,11 +57,14 @@
'moodbar-form-policy-text' => 'By submitting, $1',
'moodbar-form-policy-label' => 'our policy',
'moodbar-loading-title' => 'Sharing...',
+ 'moodbar-disabling-title' => 'Disabling...',
'moodbar-success-title' => 'Thanks!',
'moodbar-error-title' => 'Oops!',
'moodbar-loading-subtitle' => 'We are sharing your feedback…',
+ 'moodbar-disabling-subtitle' => 'We are trying to disable this feature',
'moodbar-success-subtitle' => 'Sharing your $FBD-LINK helps us improve
$1.',
'moodbar-error-subtitle' => 'Something went wrong! Please try sharing
your feedback again later.',
+ 'moodbar-disable-error-subtitle' => 'Something went wrong! Please try
again later.',
'moodbar-blocked-title' => 'Oops!',
'moodbar-blocked-subtitle' => 'You have been blocked from editing.',
'moodbar-ratelimited-title' => 'Oops!',
@@ -202,6 +205,9 @@
Thanks for being part of the community.
-- {{SITENAME}}',
+ // Preferences
+ 'moodbar-disable' => 'Disable Moodbar',
+ 'prefs-moodbar' => 'Moodbar',
);
/** Message documentation (Message documentation)
@@ -279,16 +285,19 @@
See also:
* {{msg-mw|moodbar-form-policy-text}}',
'moodbar-loading-title' => 'Title of the screen when the widget is
loading (sending feedback).',
+ 'moodbar-disabling-title' => 'Title of the screen when the widget being
disabled.',
'moodbar-success-title' => 'Title of the screen after the feedback was
successfully submitted.
{{Identical|Thanks}}',
'moodbar-error-title' => 'Title of the screen when after an error
occurred and submission aborted.
{{Identical|Oops}}',
'moodbar-loading-subtitle' => '{{notranslate}}',
+ 'moodbar-disabling-subtitle' => 'Subtitle of screen when the widget is
being disabled.',
'moodbar-success-subtitle' => '{{doc-important|Do not translate
$FBD-LINK}}
Subtitle of screen when feedback was successfully submitted.
* $FBD-LINK - replaced with link to Special:FeedbackDashboard of which
{{msg-mw|moodbar-fbd-link-title}} is the link text
* $1 - Wiki SITENAME',
'moodbar-error-subtitle' => 'Subtitle of screen when an error occurred.
$1 is the SITENAME',
+ 'moodbar-disable-error-subtitle' => 'Subtitle of screen when an error
occurred while disabling the feature.',
'moodbar-blocked-title' => 'Title of the screen after blocked user
attempts to post feedback.
{{Identical|Oops}}',
'moodbar-blocked-subtitle' => 'Subtitle of screen after blocked user
attempts to post feedback.',
@@ -414,6 +423,9 @@
*$3 is the responder talk page
*$4 is the response text
*$5 is commenter talk page',
+ // Preferences
+ 'moodbar-disable' => 'Text for checkbox to disable moodbar',
+ 'prefs-moodbar' => 'Moodbar section heading on Misc tab in Preferences',
);
/** Afrikaans (Afrikaans)
diff --git a/MoodBar.php b/MoodBar.php
index 5e76937..ac8acee 100644
--- a/MoodBar.php
+++ b/MoodBar.php
@@ -44,6 +44,7 @@
$wgHooks['MakeGlobalVariablesScript'][] =
'MoodBarHooks::makeGlobalVariablesScript';
$wgHooks['LoadExtensionSchemaUpdates'][] =
'MoodBarHooks::onLoadExtensionSchemaUpdates';
$wgHooks['onMarkItemAsHelpful'][] = 'MoodBarHooks::onMarkItemAsHelpful';
+$wgHooks['GetPreferences'][] = 'MoodBarHooks::onGetPreferences';
// Special pages
$wgAutoloadClasses['SpecialMoodBar'] = $moodBarDir . 'SpecialMoodBar.php';
@@ -160,10 +161,13 @@
'moodbar-privacy',
'moodbar-disable-link',
'moodbar-loading-title',
+ 'moodbar-disabling-title',
'moodbar-error-title',
'moodbar-success-title',
'moodbar-loading-subtitle',
+ 'moodbar-disabling-subtitle',
'moodbar-error-subtitle',
+ 'moodbar-disable-error-subtitle',
'moodbar-success-subtitle',
'moodbar-blocked-title',
'moodbar-blocked-subtitle',
diff --git a/modules/ext.moodBar/ext.moodBar.core.js
b/modules/ext.moodBar/ext.moodBar.core.js
index 9d9898a..4513042 100644
--- a/modules/ext.moodBar/ext.moodBar.core.js
+++ b/modules/ext.moodBar/ext.moodBar.core.js
@@ -75,6 +75,11 @@
<div
class="mw-moodBar-state-title"><html:msg key="moodbar-loading-title" /></div>\
<div
class="mw-moodBar-state-subtitle"><html:msg key="moodbar-loading-subtitle"
/></div>\
</div>',
+ disabling: '\
+ <div class="mw-moodBar-state
mw-moodBar-state-loading">\
+ <div
class="mw-moodBar-state-title"><html:msg key="moodbar-disabling-title" /></div>\
+ <div
class="mw-moodBar-state-subtitle"><html:msg key="moodbar-disabling-subtitle"
/></div>\
+ </div>',
updatingEmail: '\
<div class="mw-moodBar-state
mw-moodBar-state-loading">\
<div
class="mw-moodBar-state-title"><html:msg key="moodbar-updating-title" /></div>\
@@ -89,6 +94,11 @@
<div class="mw-moodBar-state
mw-moodBar-state-error">\
<div
class="mw-moodBar-state-title"><html:msg key="moodbar-error-title" /></div>\
<div
class="mw-moodBar-state-subtitle"><html:msg key="moodbar-error-subtitle"
/></div>\
+ </div>',
+ disablingError: '\
+ <div class="mw-moodBar-state
mw-moodBar-state-error">\
+ <div
class="mw-moodBar-state-title"><html:msg key="moodbar-error-title" /></div>\
+ <div
class="mw-moodBar-state-subtitle"><html:msg
key="moodbar-disable-error-subtitle" /></div>\
</div>',
blocked: '\
<div class="mw-moodBar-state
mw-moodBar-state-error">\
@@ -121,13 +131,39 @@
disable: function( e ) {
e.preventDefault();
- $.cookie(
- mb.cookiePrefix() + 'disabled',
- '1',
- { 'path': '/', 'expires': Number(
mb.conf.disableExpiration ) }
- );
- mb.ui.overlay.fadeOut( 'fast' );
- mb.ui.trigger.fadeOut( 'fast' );
+ mb.swapContent ( mb.tpl.disabling );
+
+ var tokenRequest = {
+ 'action': 'tokens',
+ 'type' : 'options'
+ };
+ var prefRequest = {
+ 'action': 'options',
+ 'change': 'moodbar-disable=1'
+ };
+
+ var api = new mw.Api(),
+ err = function () {
+ mb.swapContent (
mb.tpl.disablingError );
+ mw.log( 'Could not set user
preferences (requires MediaWiki 1.20 ).' );
+ },
+ tokenError = function () {
+ err();
+ mw.log( 'Could not get token to
set user preferences (requires MediaWiki 1.20 ).' );
+ },
+ prefSuccess = function () {
+ mb.ui.overlay.fadeOut( 'fast' );
+ mb.ui.trigger.fadeOut( 'fast' );
+ },
+ tokenSuccess = function ( data ) {
+ if ( data.tokens.optionstoken )
{
+ prefRequest.token =
data.tokens.optionstoken;
+ api.post( prefRequest
).done( prefSuccess ).fail( err );
+ } else {
+ tokenError();
+ }
+ };
+ api.post( tokenRequest ).done( tokenSuccess
).fail( tokenError );
},
emailOptOut: function( e ) {
diff --git a/modules/ext.moodBar/ext.moodBar.init.js
b/modules/ext.moodBar/ext.moodBar.init.js
index 0464114..bf2c15d 100644
--- a/modules/ext.moodBar/ext.moodBar.init.js
+++ b/modules/ext.moodBar/ext.moodBar.init.js
@@ -17,15 +17,14 @@
},
isDisabled: function() {
- var cookieDisabled = ($.cookie( mb.cookiePrefix() +
'disabled' ) === '1'),
- browserDisabled = false,
+ var browserDisabled = false,
clientInfo = $.client.profile();
if ( clientInfo.name === 'msie' &&
clientInfo.versionNumber < 7 ) {
browserDisabled = true;
}
- return cookieDisabled || browserDisabled;
+ return browserDisabled;
},
ui: {
--
To view, visit https://gerrit.wikimedia.org/r/49392
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0af9f522cc679ffbc060cad4d6f6a4db57815cef
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/MoodBar
Gerrit-Branch: master
Gerrit-Owner: Nischayn22 <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Nischayn22 <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Tychay <[email protected]>
Gerrit-Reviewer: Werdna <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits