Index: trunk/extensions/MoodBar/MoodBar.hooks.php |
— | — | @@ -57,12 +57,12 @@ |
58 | 58 | * ResourceLoaderGetConfigVars hook |
59 | 59 | */ |
60 | 60 | public static function resourceLoaderGetConfigVars( &$vars ) { |
61 | | - global $wgMoodBarConfig, $wgUser; |
| 61 | + global $wgMoodBarConfig, $wgUser, $wgEnableEmail; |
62 | 62 | $vars['mbConfig'] = array( |
63 | 63 | 'validTypes' => MBFeedbackItem::getValidTypes(), |
64 | 64 | 'userBuckets' => MoodBarHooks::getUserBuckets( $wgUser ), |
65 | | - 'canReceiveEmail' => $wgUser->canReceiveEmail() , |
66 | | - 'userEmail' => strlen($wgUser->getEmail()) > 0 ? true : false, |
| 65 | + 'emailEnabled' => $wgEnableEmail, |
| 66 | + 'userEmail' => strlen( $wgUser->getEmail() ) > 0 ? true : false, |
67 | 67 | 'isEmailConfirmationPending' => $wgUser->isEmailConfirmationPending() //returns false if email authentication off, and if email is confimed already |
68 | 68 | |
69 | 69 | ) + $wgMoodBarConfig; |
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.init.js |
— | — | @@ -58,36 +58,13 @@ |
59 | 59 | .appendTo( ui.pMoodbar ); |
60 | 60 | |
61 | 61 | // Inject portlet into document, when document is ready |
62 | | - // Send mb.getUserInfo as a callback to be ran after MoodBar injection |
63 | | - $( mb.inject( mb.getUserInfo ) ); |
| 62 | + $( mb.inject() ); |
64 | 63 | |
65 | 64 | }, |
66 | 65 | |
67 | | - inject: function(getUserInfo) { |
| 66 | + inject: function() { |
68 | 67 | $( '#mw-head' ).append( mb.ui.pMoodbar ); |
69 | | - getUserInfo(); //run the callback |
70 | | - }, |
71 | | - |
72 | | - getUserInfo: function() { |
73 | | - var query = { |
74 | | - action: 'query', |
75 | | - meta: 'userinfo', |
76 | | - uiprop: 'email', |
77 | | - format: 'json' |
78 | | - }; |
79 | | - $.ajax( { |
80 | | - 'url': mw.util.wikiScript( 'api' ), |
81 | | - 'data': query, |
82 | | - 'success': function (data) { |
83 | | - mb.userData = data.query.userinfo; |
84 | | - }, |
85 | | - 'error': function( jqXHR, textStatus, errorThrown ) { |
86 | | - mb.userData = null; |
87 | | - }, |
88 | | - 'dataType': 'json' |
89 | | - } ); |
90 | 68 | } |
91 | | - |
92 | 69 | }; |
93 | 70 | |
94 | 71 | if ( !mb.isDisabled() ) { |
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.js |
— | — | @@ -134,20 +134,25 @@ |
135 | 135 | callback: function( data ) { |
136 | 136 | if ( data && data.moodbar && data.moodbar.result === 'success' ) { |
137 | 137 | |
138 | | - var userData = mb.userData, |
139 | | - emailOptOut = ($.cookie( mb.cookiePrefix() + 'emailOptOut' ) == '1'); |
| 138 | + var emailFlag,emailOptOut = ($.cookie( mb.cookiePrefix() + 'emailOptOut' ) == '1'); |
140 | 139 | |
141 | | - if( emailOptOut === false) { |
142 | | - if('email' in userData && userData.email !== "") { //check for email address |
143 | | - if('emailauthenticated' in userData) { //they have confirmed |
| 140 | + // if opt out cookie not set and if email is on globally, proceed with email prompt |
| 141 | + if( emailOptOut === false && mb.conf.emailEnabled ) { |
| 142 | + |
| 143 | + if( mb.conf.userEmail ) { // if user has email |
| 144 | + |
| 145 | + if ( !mb.conf.isEmailConfirmationPending ) { // if no confirmation pending, show form. |
144 | 146 | mb.showSuccess(); |
| 147 | + |
145 | 148 | } else { //show email confirmation form |
146 | 149 | mb.swapContent ( mb.tpl.emailconfirmation ); |
147 | 150 | } |
| 151 | + |
148 | 152 | } else { //no email, show email input form |
149 | 153 | mb.swapContent( mb.tpl.emailinput ); |
150 | 154 | } |
151 | | - } else { //user has email opt-out cookie set |
| 155 | + |
| 156 | + } else { //user has email opt-out cookie set, or email is disabled |
152 | 157 | mb.showSuccess(); |
153 | 158 | } |
154 | 159 | |
— | — | @@ -173,12 +178,17 @@ |
174 | 179 | email: '', |
175 | 180 | callback: function( data ) { |
176 | 181 | mb.showSuccess(); |
| 182 | + //set email flag to true so we do not ask again on this page load. |
| 183 | + mb.conf.userEmail = true; |
| 184 | + mb.conf.isEmailConfirmationPending = true; |
177 | 185 | } |
178 | 186 | }, |
179 | 187 | |
180 | 188 | emailVerify: { |
181 | 189 | callback: function ( data ) { |
182 | 190 | mb.showSuccess(); |
| 191 | + //set conf pending flag to false so we do not ask again on this page load. |
| 192 | + mb.conf.isEmailConfirmationPending = false; |
183 | 193 | } |
184 | 194 | |
185 | 195 | }, |