Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js |
— | — | @@ -173,6 +173,10 @@ |
174 | 174 | }, |
175 | 175 | 'submit': function() { |
176 | 176 | var context = this; |
| 177 | + // For anon users, keep a cookie around so we know they've rated before |
| 178 | + if ( mw.user.anonymous() ) { |
| 179 | + $.cookie( prefix( 'rated' ), 'true', { 'expires': 365, 'path': '/' } ); |
| 180 | + } |
177 | 181 | $.articleFeedback.fn.enableSubmission.call( context, false ); |
178 | 182 | context.$ui.find( '.articleFeedback-lock' ).show(); |
179 | 183 | // Build data from form values for 'action=articlefeedback' |
— | — | @@ -306,19 +310,20 @@ |
307 | 311 | }, |
308 | 312 | 'load': function() { |
309 | 313 | var context = this; |
| 314 | + var userrating = !mw.user.anonymous() || $.cookie( prefix( 'rated' ) ) === 'true'; |
310 | 315 | $.ajax( { |
311 | 316 | 'url': mw.config.get( 'wgScriptPath' ) + '/api.php', |
312 | 317 | 'type': 'GET', |
313 | 318 | 'dataType': 'json', |
314 | 319 | 'context': context, |
315 | | - 'cache': false, |
| 320 | + 'cache': userrating, |
316 | 321 | 'data': { |
317 | 322 | 'action': 'query', |
318 | 323 | 'format': 'json', |
319 | 324 | 'list': 'articlefeedback', |
320 | 325 | 'afpageid': mw.config.get( 'wgArticleId' ), |
321 | | - 'afanontoken': mw.user.id(), |
322 | | - 'afuserrating': 1 |
| 326 | + 'afanontoken': userrating ? mw.user.id() : '', |
| 327 | + 'afuserrating': Number( userrating ) |
323 | 328 | }, |
324 | 329 | 'success': function( data ) { |
325 | 330 | var context = this; |
— | — | @@ -508,7 +513,9 @@ |
509 | 514 | // Remember that the users rejected this, set a cookie to not |
510 | 515 | // show this for 3 days |
511 | 516 | $.cookie( |
512 | | - prefix( 'pitch-' + key ), 'hide', { 'expires': 3 } |
| 517 | + prefix( 'pitch-' + key ), |
| 518 | + 'hide', |
| 519 | + { 'expires': 3, 'path': '/' } |
513 | 520 | ); |
514 | 521 | // Track that a pitch was dismissed |
515 | 522 | if ( tracked && typeof $.trackAction == 'function' ) { |
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | * @param durration Integer: Number of days to mute the pitch for |
38 | 38 | */ |
39 | 39 | function mutePitch( pitch, duration ) { |
40 | | - $.cookie( prefix( 'pitches-' + pitch ), 'hide', { 'expires': duration } ); |
| 40 | + $.cookie( prefix( 'pitches-' + pitch ), 'hide', { 'expires': duration, 'path': '/' } ); |
41 | 41 | } |
42 | 42 | |
43 | 43 | function trackClick( id ) { |
Index: trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php |
— | — | @@ -142,9 +142,8 @@ |
143 | 143 | |
144 | 144 | protected function getAnonToken( $params ) { |
145 | 145 | global $wgUser; |
146 | | - |
147 | 146 | $token = ''; |
148 | | - if ( $wgUser->isAnon() ) { |
| 147 | + if ( $wgUser->isAnon() && $params['userrating'] ) { |
149 | 148 | if ( !isset( $params['anontoken'] ) ) { |
150 | 149 | $this->dieUsageMsg( array( 'missingparam', 'anontoken' ) ); |
151 | 150 | } elseif ( strlen( $params['anontoken'] ) != 32 ) { |
— | — | @@ -249,7 +248,7 @@ |
250 | 249 | ApiBase::PARAM_ISMULTI => false, |
251 | 250 | ApiBase::PARAM_TYPE => 'integer', |
252 | 251 | ), |
253 | | - 'userrating' => false, |
| 252 | + 'userrating' => 0, |
254 | 253 | 'anontoken' => null, |
255 | 254 | ); |
256 | 255 | } |
— | — | @@ -280,7 +279,7 @@ |
281 | 280 | return array( |
282 | 281 | 'api.php?action=query&list=articlefeedback', |
283 | 282 | 'api.php?action=query&list=articlefeedback&afpageid=1', |
284 | | - 'api.php?action=query&list=articlefeedback&afpageid=1&afuserrating', |
| 283 | + 'api.php?action=query&list=articlefeedback&afpageid=1&afuserrating=1', |
285 | 284 | ); |
286 | 285 | } |
287 | 286 | |