r110434 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110433‎ | r110434 | r110435 >
Date:21:42, 31 January 2012
Author:gregchiasson
Status:ok
Tags:aft 
Comment:
AFT5: Bug fixes in flagFeeedback API - increase/decrease in place of increment/decrement, and accidental fallthrough on a couple of cases in the flagtype switch. Added functionality to special.js to allow admins to toggle delete/hide statuses that were added by other administrators - seemed logical to me to make it remove a flag if it were set, even if there was no cookie
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
@@ -204,7 +204,9 @@
205205 var $l = $( e.target );
206206 var id = $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
207207 var activity = $.articleFeedbackv5special.getActivity( id );
208 - if ( activity.hide ) {
 208+ if ( activity.hide
 209+ || $( e.target ).text() == mw.msg('articlefeedbackv5-form-unhide')
 210+ ) {
209211 $.articleFeedbackv5special.flagFeedback( id, 'hide', -1 );
210212 } else {
211213 $.articleFeedbackv5special.flagFeedback( id, 'hide', 1 );
@@ -217,7 +219,9 @@
218220 var $l = $( e.target );
219221 var id = $l.closest( '.articleFeedbackv5-feedback' ).attr( 'rel' );
220222 var activity = $.articleFeedbackv5special.getActivity( id );
221 - if ( activity.delete ) {
 223+ if ( activity.delete
 224+ || $( e.target ).text() == mw.msg('articlefeedbackv5-form-undelete')
 225+ ) {
222226 $.articleFeedbackv5special.flagFeedback( id, 'delete', -1 );
223227 } else {
224228 $.articleFeedbackv5special.flagFeedback( id, 'delete', 1 );
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php
@@ -50,12 +50,13 @@
5151 case 'oversight':
5252 $field = 'af_needs_oversight';
5353 $count = 'needsoversight';
 54+ break;
5455 case 'delete':
5556 $field = 'af_is_deleted';
5657 $count = 'deleted';
 58+ break;
5759 default: return; # return error, ideally.
5860 }
59 -
6061 if( $direction == 'increase' ) {
6162 $update[] = "$field = TRUE";
6263 } else {
@@ -63,12 +64,18 @@
6465 }
6566
6667 // Increment or decrement whichever flag is being set.
67 - $counts[$direction][] = $count;
 68+ $countDirection = $direction == 'increase' ? 'increment' : 'decrement';
 69+ $counts[$countDirection][] = $count;
6870 // If this is hiding/deleting, decrement the visible count.
6971 if( ( $count == 'hide' || $count == 'deleted' )
7072 && $direction == 'increase' ) {
71 - $counts['decrease'][] = 'visible';
 73+ $counts['decrement'][] = 'visible';
7274 }
 75+ // If this is unhiding/undeleting, increment the visible count.
 76+ if( ( $count == 'hide' || $count == 'deleted' )
 77+ && $direction == 'decrease' ) {
 78+ $counts['increment'][] = 'visible';
 79+ }
7380 } elseif ( in_array( $flag, $counters ) ) {
7481 // Probably this doesn't need validation, since the API
7582 // will handle it, but if it's getting interpolated into

Status & tagging log