Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css |
— | — | @@ -210,6 +210,9 @@ |
211 | 211 | #articleFeedbackv5-show-feedback .articleFeedbackv5-abuse-link { |
212 | 212 | margin-left: 150px; |
213 | 213 | } |
| 214 | +#articleFeedbackv5-show-feedback .articleFeedbackv5-abuse-link.abusive { |
| 215 | + color: red; |
| 216 | +} |
214 | 217 | #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot { |
215 | 218 | line-height: 22px; |
216 | 219 | float: left; |
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js |
— | — | @@ -175,8 +175,21 @@ |
176 | 176 | } ) |
177 | 177 | } ); |
178 | 178 | |
179 | | - $.each( ['unhide', 'undelete', 'oversight', 'hide', 'abuse', 'delete', 'unoversight'], function ( index, value ) { |
| 179 | + $( '.articleFeedbackv5-abuse-link' ).live( 'click', function( e ) { |
| 180 | + e.preventDefault(); |
| 181 | + var $l = $( e.target ); |
| 182 | + var id = $l.parents( '.articleFeedbackv5-feedback' ).attr( 'rel' ); |
| 183 | + var activity = $.articleFeedbackv5special.getActivity( id ); |
| 184 | + if ( activity.abuse ) { |
| 185 | + $.articleFeedbackv5special.flagFeedback( id, 'abuse', -1 ); |
| 186 | + } else { |
| 187 | + $.articleFeedbackv5special.flagFeedback( id, 'abuse', 1 ); |
| 188 | + } |
| 189 | + } ) |
| 190 | + |
| 191 | + $.each( ['unhide', 'undelete', 'oversight', 'hide', 'delete', 'unoversight'], function ( index, value ) { |
180 | 192 | $( '.articleFeedbackv5-' + value + '-link' ).live( 'click', function( e ) { |
| 193 | + e.preventDefault(); |
181 | 194 | $.articleFeedbackv5special.flagFeedback( $.articleFeedbackv5special.stripID( this, 'articleFeedbackv5-' + value + '-link-' ), value, 1 ); |
182 | 195 | } ) |
183 | 196 | } ); |
— | — | @@ -368,7 +381,6 @@ |
369 | 382 | if ( 'articlefeedbackv5-flag-feedback' in data ) { |
370 | 383 | if ( 'result' in data['articlefeedbackv5-flag-feedback'] ) { |
371 | 384 | if ( data['articlefeedbackv5-flag-feedback'].result == 'Success' ) { |
372 | | - msg = 'articlefeedbackv5-' + type + '-saved'; |
373 | 385 | if ( 'helpful' in data['articlefeedbackv5-flag-feedback'] ) { |
374 | 386 | $( '#articleFeedbackv5-helpful-votes-' + id ).text( data['articlefeedbackv5-flag-feedback'].helpful ); |
375 | 387 | } |
— | — | @@ -379,6 +391,21 @@ |
380 | 392 | } else { |
381 | 393 | $l.removeClass( 'helpful-active' ); |
382 | 394 | } |
| 395 | + } else if ( 'abuse' == type ) { |
| 396 | + var $l = $( '#articleFeedbackv5-abuse-link-' + id ); |
| 397 | + if ( dir > 0 ) { |
| 398 | + $l.text( mw.msg( 'articlefeedbackv5-abuse-saved' ) ); |
| 399 | + } else { |
| 400 | + $l.text( mw.msg( 'articlefeedbackv5-form-abuse', data['articlefeedbackv5-flag-feedback'].abuse_count ) ); |
| 401 | + } |
| 402 | + if ( data['articlefeedbackv5-flag-feedback'].abusive ) { |
| 403 | + $l.addClass( 'abusive' ); |
| 404 | + } else { |
| 405 | + $l.removeClass( 'abusive' ); |
| 406 | + } |
| 407 | + } else { |
| 408 | + msg = 'articlefeedbackv5-' + type + '-saved'; |
| 409 | + $( '#articleFeedbackv5-' + type + '-link-' + id ).text( mw.msg( msg ) ); |
383 | 410 | } |
384 | 411 | // Save activity |
385 | 412 | if ( !( id in $.articleFeedbackv5special.activity ) ) { |
— | — | @@ -391,7 +418,6 @@ |
392 | 419 | } |
393 | 420 | } |
394 | 421 | } |
395 | | - $( '#articleFeedbackv5-' + type + '-link-' + id ).text( mw.msg( msg ) ); |
396 | 422 | }, |
397 | 423 | 'error': function ( data ) { |
398 | 424 | $( '#articleFeedbackv5-' + type + '-link-' + id ).text( mw.msg( 'articlefeedbackv5-error-flagging' ) ); |
— | — | @@ -446,6 +472,10 @@ |
447 | 473 | if ( activity.unhelpful ) { |
448 | 474 | $( this ).find( '#articleFeedbackv5-unhelpful-link-' + id ).addClass( 'helpful-active' ); |
449 | 475 | } |
| 476 | + if ( activity.abuse ) { |
| 477 | + var $l = $( this ).find( '#articleFeedbackv5-abuse-link-' + id ); |
| 478 | + $l.text( mw.msg( 'articlefeedbackv5-abuse-saved' ) ); |
| 479 | + } |
450 | 480 | } |
451 | 481 | } ); |
452 | 482 | $( '#articleFeedbackv5-show-feedback' ).append( $newList ); |
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php |
— | — | @@ -152,6 +152,15 @@ |
153 | 153 | ); |
154 | 154 | |
155 | 155 | /** |
| 156 | + * Abusive threshold |
| 157 | + * |
| 158 | + * After this many users flag a comment as abusive, it is marked as such. |
| 159 | + * |
| 160 | + * @var int |
| 161 | + */ |
| 162 | +$wgArticleFeedbackv5AbusiveThreshold = 3; |
| 163 | + |
| 164 | +/** |
156 | 165 | * Temporary hack: for now, only one CTA is allowed, so set it here. |
157 | 166 | * |
158 | 167 | * Allowed values: '0' (just a confirm message), '1' (call to edit), '2' (learn |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php |
— | — | @@ -180,7 +180,9 @@ |
181 | 181 | __METHOD__ |
182 | 182 | ); |
183 | 183 | } |
184 | | - if( $record->af_abuse_count > 3 ) { |
| 184 | + global $wgArticleFeedbackv5AbusiveThreshold; |
| 185 | + $results['abuse_count'] = $record->af_abuse_count; |
| 186 | + if( $record->af_abuse_count > $wgArticleFeedbackv5AbusiveThreshold ) { |
185 | 187 | // Return a flag in the JSON, that turns the link red. |
186 | 188 | $results['abusive'] = 1; |
187 | 189 | } |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php |
— | — | @@ -294,16 +294,16 @@ |
295 | 295 | $can_delete = $wgUser->isAllowed( 'aftv5-delete-feedback' ); |
296 | 296 | |
297 | 297 | // Taken from the Moodbar extension. |
298 | | - $now = wfTimestamp( TS_UNIX ); |
299 | | - $timestamp = wfTimestamp( TS_UNIX, $record[0]->af_created ); |
| 298 | + $now = wfTimestamp( TS_UNIX ); |
| 299 | + $timestamp = wfTimestamp( TS_UNIX, $record[0]->af_created ); |
300 | 300 | $date; |
301 | 301 | |
302 | 302 | // Relative dates for 48 hours, normal timestamps later. |
303 | | - if( $timestamp > ( $now - ( 86400 * 2 ) ) ) { |
304 | | - $time = $wgLang->formatTimePeriod( |
| 303 | + if ( $timestamp > ( $now - ( 86400 * 2 ) ) ) { |
| 304 | + $time = $wgLang->formatTimePeriod( |
305 | 305 | ( $now - $timestamp ), 'avoidseconds' |
306 | | - ); |
307 | | - $date = wfMessage( 'articleFeedbackv5-comment-ago', $time )->escaped(); |
| 306 | + ); |
| 307 | + $date = wfMessage( 'articleFeedbackv5-comment-ago', $time )->escaped(); |
308 | 308 | } elseif( $timestamp ) { |
309 | 309 | $date = $wgLang->timeanddate($record[0]->af_created ); |
310 | 310 | } |
— | — | @@ -327,7 +327,7 @@ |
328 | 328 | if( $record[0]->age > 0 ) { |
329 | 329 | $details .= Linker::link( |
330 | 330 | Title::newFromText( $record[0]->page_title ), |
331 | | - wfMessage( 'articlefeedbackv5-updates-since', $record[0]->age )->escaped(), |
| 331 | + wfMessage( 'articlefeedbackv5-updates-since', $record[0]->age )->escaped(), |
332 | 332 | array(), |
333 | 333 | array( |
334 | 334 | 'action' => 'historysubmit', |
— | — | @@ -338,8 +338,7 @@ |
339 | 339 | } |
340 | 340 | |
341 | 341 | $details .= Html::closeElement( 'div' ) |
342 | | - . Html::closeElement( 'div' ); |
343 | | -; |
| 342 | + . Html::closeElement( 'div' ); |
344 | 343 | |
345 | 344 | $footer_links = Html::openElement( 'div', array( |
346 | 345 | 'class' => 'articleFeedbackv5-vote-wrapper' |
— | — | @@ -364,9 +363,14 @@ |
365 | 364 | 'id' => "articleFeedbackv5-helpful-votes-$id" |
366 | 365 | ), wfMessage( 'articlefeedbackv5-form-helpful-votes', $record[0]->af_helpful_count, $record[0]->af_unhelpful_count ) ); |
367 | 366 | if ( $can_flag ) { |
| 367 | + $aclass = 'articleFeedbackv5-abuse-link'; |
| 368 | + global $wgArticleFeedbackv5AbusiveThreshold; |
| 369 | + if ( $record[0]->af_abuse_count > $wgArticleFeedbackv5AbusiveThreshold ) { |
| 370 | + $aclass .= ' abusive'; |
| 371 | + } |
368 | 372 | $footer_links .= Html::element( 'a', array( |
369 | 373 | 'id' => "articleFeedbackv5-abuse-link-$id", |
370 | | - 'class' => 'articleFeedbackv5-abuse-link' |
| 374 | + 'class' => $aclass |
371 | 375 | ), wfMessage( 'articlefeedbackv5-form-abuse', $record[0]->af_abuse_count )->text() ); |
372 | 376 | } |
373 | 377 | $footer_links .= Html::closeElement( 'p' ) |
— | — | @@ -448,7 +452,7 @@ |
449 | 453 | . Html::closeElement( 'div' ); |
450 | 454 | } |
451 | 455 | |
452 | | - return Html::openElement( 'div', array( |
| 456 | + return Html::openElement( 'div', array( |
453 | 457 | 'class' => 'articleFeedbackv5-feedback', |
454 | 458 | 'rel' => $id |
455 | 459 | ) ) |
— | — | @@ -530,7 +534,7 @@ |
531 | 535 | 'articlefeedbackv5-form5-header', |
532 | 536 | $class, |
533 | 537 | $record[0] |
534 | | - ); |
| 538 | + ); |
535 | 539 | |
536 | 540 | return $head . $body; |
537 | 541 | } |
— | — | @@ -600,8 +604,8 @@ |
601 | 605 | ) ) |
602 | 606 | . Linker::link( Title::newFromText( $link ), $name ) |
603 | 607 | . Html::element( 'span', array( 'class' => 'icon' ) ) |
604 | | - . Html::element( 'span', |
605 | | - array( 'class' => 'result' ), |
| 608 | + . Html::element( 'span', |
| 609 | + array( 'class' => 'result' ), |
606 | 610 | wfMessage( $message, $gender, $extra )->text() |
607 | 611 | ) |
608 | 612 | . Html::closeElement( 'h3' ); |
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php |
— | — | @@ -165,6 +165,7 @@ |
166 | 166 | 'articlefeedbackv5-error-flagging', |
167 | 167 | 'articlefeedbackv5-invalid-feedback-id', |
168 | 168 | 'articlefeedbackv5-invalid-feedback-flag', |
| 169 | + 'articlefeedbackv5-form-abuse', |
169 | 170 | 'articlefeedbackv5-abuse-saved', |
170 | 171 | 'articlefeedbackv5-hide-saved', |
171 | 172 | 'articlefeedbackv5-hidden', |