r110157 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110156‎ | r110157 | r110158 >
Date:19:45, 27 January 2012
Author:rsterbin
Status:ok
Tags:aft 
Comment:
Abuse count thresholds:
- ArticleFeedbackv5.php:
- New config var wgArticleFeedbackv5HideAbuseThreshold
- api/ApiFlagFeedbackArticleFeedbackv5.php:
- Updated to use $wgArticleFeedbackv5AbusiveThreshold
- Updated to test thresholds with greater than or equal to, rather than
just greater than
- api/ApiViewFeedbackArticleFeedbackv5.php:
- Updated to test $wgArticleFeedbackv5AbusiveThreshold with greater
than or equal to, rather than just greater than
- modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js:
- If flagFeedback comes back with the key 'abuse-hidden', do an
animated hide
- SpecialArticleFeedbackv5.php:
- Fixed some spacing
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.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
@@ -403,6 +403,9 @@
404404 } else {
405405 $l.removeClass( 'abusive' );
406406 }
 407+ if ( data['articlefeedbackv5-flag-feedback']['abuse-hidden'] ) {
 408+ $l.parents( '.articleFeedbackv5-feedback' ).hide( 'slow' );
 409+ }
407410 } else {
408411 msg = 'articlefeedbackv5-' + type + '-saved';
409412 $( '#articleFeedbackv5-' + type + '-link-' + id ).text( mw.msg( msg ) );
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php
@@ -161,6 +161,15 @@
162162 $wgArticleFeedbackv5AbusiveThreshold = 3;
163163
164164 /**
 165+ * Hide abuse threshold
 166+ *
 167+ * After this many users flag a comment as abusive, it is hidden.
 168+ *
 169+ * @var int
 170+ */
 171+$wgArticleFeedbackv5HideAbuseThreshold = 5;
 172+
 173+/**
165174 * Temporary hack: for now, only one CTA is allowed, so set it here.
166175 *
167176 * Allowed values: '0' (just a confirm message), '1' (call to edit), '2' (learn
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php
@@ -167,25 +167,28 @@
168168 }
169169
170170 // Conditional formatting for abuse flag
 171+ global $wgArticleFeedbackv5AbusiveThreshold,
 172+ $wgArticleFeedbackv5HideAbuseThreshold;
171173 // Re-fetch record - as above, from read/slave DB.
172174 // The record could have had it's falg increased or
173175 // decreased, so load a fresh (as fresh as the read
174176 // db is, anyway) copy of it.
175177 $record = $this->fetchRecord( $params['feedbackid'] );
176 - if( $record->af_abuse_count > 5 ) {
 178+ $results['abuse_count'] = $record->af_abuse_count;
 179+ if( $record->af_abuse_count >= $wgArticleFeedbackv5AbusiveThreshold ) {
 180+ // Return a flag in the JSON, that turns the link red.
 181+ $results['abusive'] = 1;
 182+ }
 183+ if( $record->af_abuse_count >= $wgArticleFeedbackv5HideAbuseThreshold ) {
177184 $dbw->update(
178185 'aft_article_feedback',
179186 array( 'af_hide_count = af_hide_count + 1' ),
180187 array( 'af_id' => $params['feedbackid'] ),
181188 __METHOD__
182189 );
 190+ // Return a flag in the JSON, that knows to kill the row
 191+ $results['abuse-hidden'] = 1;
183192 }
184 - global $wgArticleFeedbackv5AbusiveThreshold;
185 - $results['abuse_count'] = $record->af_abuse_count;
186 - if( $record->af_abuse_count > $wgArticleFeedbackv5AbusiveThreshold ) {
187 - // Return a flag in the JSON, that turns the link red.
188 - $results['abusive'] = 1;
189 - }
190193 }
191194
192195 if ( $error ) {
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -365,7 +365,7 @@
366366 if ( $can_flag ) {
367367 $aclass = 'articleFeedbackv5-abuse-link';
368368 global $wgArticleFeedbackv5AbusiveThreshold;
369 - if ( $record[0]->af_abuse_count > $wgArticleFeedbackv5AbusiveThreshold ) {
 369+ if ( $record[0]->af_abuse_count >= $wgArticleFeedbackv5AbusiveThreshold ) {
370370 $aclass .= ' abusive';
371371 }
372372 $footer_links .= Html::element( 'a', array(
Index: trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php
@@ -33,20 +33,20 @@
3434 global $wgUser;
3535 parent::__construct( 'ArticleFeedbackv5' );
3636
37 - // NOTE: The 'all' option actually displays different things
 37+ // NOTE: The 'all' option actually displays different things
3838 // based on the users role, which is handled in the filter:
3939 // - deleter-all is actually everything
40 - // - hidder-all is 'visible + hidden'
 40+ // - hidder-all is 'visible + hidden'
4141 // - regular non-admin all is just 'all visible'
4242
43 - if( $wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) {
 43+ if ( $wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) {
4444 array_push( $this->filters,
4545 'unhelpful', 'abusive', 'invisible'
4646 );
4747 # removing the 'needsoversight' filter, per Fabrice
4848 }
4949
50 - if( $wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) ) {
 50+ if ( $wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) ) {
5151 $this->filters[] = 'deleted';
5252 }
5353 }
@@ -62,7 +62,7 @@
6363 $title = Title::newFromText( $param );
6464
6565 // Page does not exist.
66 - if( !$title->exists() ) {
 66+ if ( !$title->exists() ) {
6767 $out->addWikiMsg( 'articlefeedbackv5-invalid-page-id' );
6868 return;
6969 }
@@ -81,7 +81,7 @@
8282 );
8383
8484 // Page exists, but feedback is disabled.
85 - if( $dbr->numRows( $t ) == 0 ) {
 85+ if ( $dbr->numRows( $t ) == 0 ) {
8686 $out->addWikiMsg( 'articlefeedbackv5-page-disabled' );
8787 return;
8888 }
@@ -138,7 +138,7 @@
139139
140140 if ( $found ) {
141141 $class = $found > 50 ? 'positive' : 'negative';
142 - $span = Html::rawElement( 'span', array(
 142+ $span = Html::rawElement( 'span', array(
143143 'class' => "stat-marker $class"
144144 ), wfMsg( 'percent', $found ) );
145145 $out->addHtml(
@@ -159,7 +159,7 @@
160160 'id' => 'articleFeedbackv5-special-add-feedback',
161161 ),
162162 $this->msg( 'articlefeedbackv5-special-add-feedback' )->text()
163 - )
 163+ )
164164 . Html::element( 'div', array( 'class' => 'float-clear' ) )
165165 . Html::closeElement( 'div' )
166166 );
@@ -191,7 +191,7 @@
192192
193193 $opts = array();
194194 $counts = $this->getFilterCounts( $pageId );
195 - foreach( $this->filters as $filter ) {
 195+ foreach ( $this->filters as $filter ) {
196196 $count = array_key_exists( $filter, $counts ) ? $counts[$filter] : 0;
197197 $key = $this->msg( 'articlefeedbackv5-special-filter-'.$filter, $count )->escaped();
198198 $opts[ (string) $key ] = $filter;
@@ -322,7 +322,7 @@
323323 __METHOD__
324324 );
325325
326 - foreach( $rows as $row ) {
 326+ foreach ( $rows as $row ) {
327327 $rv[ $row->afc_filter_name ] = $row->afc_filter_count;
328328 }
329329

Status & tagging log