r110449 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110448‎ | r110449 | r110450 >
Date:23:31, 31 January 2012
Author:gregchiasson
Status:ok
Tags:aft 
Comment:
AFT5: Re-introduce 'all' filter, per Fabrice, with oversight and rollbacker getting different filters. Add the 'left a comment' variant of bucket1, if the user didn't hit either 'found' or 'didn't find' buttons (IE, just left a comment).
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php
@@ -54,7 +54,8 @@
5555 'articlefeedbackv5-form-helpful-no-label' => 'No',
5656 'articlefeedbackv5-form-helpful-votes' => '{{PLURAL:$1|1 yes|$1 yes}} / {{PLURAL:$2|1 no|$2 no}}',
5757 'articlefeedbackv5-special-add-feedback' => 'Add your feedback',
58 - 'articlefeedbackv5-special-filter-all' => 'All ($1)',
 58+ 'articlefeedbackv5-special-filter-all' => 'All (oversight) ($1)',
 59+ 'articlefeedbackv5-special-filter-notdeleted' => 'All ($1)',
5960 'articlefeedbackv5-special-filter-comment' => 'Comments only ($1)',
6061 'articlefeedbackv5-special-filter-abusive' => 'Flagged as abuse ($1)',
6162 'articlefeedbackv5-special-filter-helpful' => 'Helpful ($1)',
@@ -91,7 +92,7 @@
9293 'articlefeedbackv5-form-header' => 'Feedback #$1, at $2',
9394 'articlefeedbackv5-form1-header-found' => '{{GENDER:$1|$1}} found what they were looking for',
9495 'articlefeedbackv5-form1-header-not-found' => '{{GENDER:$1|$1}} did not find what they were looking for',
95 - 'articlefeedbackv5-form1-header-left-comment' => '{{GENDER:$1|$1}} left a comment',
 96+ 'articlefeedbackv5-form1-header-left-comment' => '{{GENDER:$1|$1}} posted this comment',
9697 'articlefeedbackv5-form2-header-praise' => '{{GENDER:$1|$1}} had a praise:',
9798 'articlefeedbackv5-form2-header-problem' => '{{GENDER:$1|$1}} had a problem:',
9899 'articlefeedbackv5-form2-header-question' => '{{GENDER:$1|$1}} had a question:',
@@ -320,7 +321,8 @@
321322 'articlefeedbackv5-form-tools-label' => '{{Identical|Tools}}',
322323 'articlefeedbackv5-form-helpful-yes-label' => '{{Identical|Yes}}',
323324 'articlefeedbackv5-form-helpful-no-label' => '{{Identical|No}}',
324 - 'articlefeedbackv5-special-filter-all' => '{{Identical|All}}',
 325+ 'articlefeedbackv5-special-filter-all' => 'Shows all records, including ones that have been deleted or flagged for oversight.',
 326+ 'articlefeedbackv5-special-filter-notdeleted' => '{{Identical|All}}',
325327 'articlefeedbackv5-special-filter-comment' => 'Feedback with text comments',
326328 'articlefeedbackv5-special-filter-abusive' => '{{Identical|Abusive}}',
327329 'articlefeedbackv5-special-filter-helpful' => 'Feedback that has been marked as helpful',
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -231,38 +231,22 @@
232232
233233 private function getFilterCriteria( $filter, $filterValue = null ) {
234234 global $wgUser;
235 - $where = array();
 235+ $where = array();
 236+ $hiddenFilters = array( 'invisible', 'notdeleted', 'all', 'deleted' );
 237+ $deletedFilters = array( 'all', 'deleted' );
236238
237 - // Permissions check: these filters are for admins only.
238 - if (
239 - ( $filter == 'invisible'
240 - && !$wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) )
241 - ||
242 - ( $filter == 'deleted'
243 - && !$wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) )
244 - ) {
245 - $filter = null;
246 - }
247 -
248 - // Don't let non-allowed users see these.
249 - if ( !$wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) {
250 - $where[] = 'af_is_hidden IS FALSE';
251 - }
252 -
253 - // Don't let non-allowed users see these.
254 - if ( !$wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) ) {
 239+ // Never show hidden or deleted posts unless specifically requested
 240+ // and user has access.
 241+ if( !in_array( $filter, $deletedFilters )
 242+ || !$wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) ) {
255243 $where[] = 'af_is_deleted IS FALSE';
256244 }
257245
258 - // Never show hidden or deleted posts unless specifically requested.
259 - if( $filter != 'invisible' && $filter != 'deleted' ) {
 246+ if( !in_array( $filter, $hiddenFilters )
 247+ || !$wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) {
260248 $where[] = 'af_is_hidden IS FALSE';
261249 }
262250
263 - if( $filter != 'deleted' ) {
264 - $where[] = 'af_is_deleted IS FALSE';
265 - }
266 -
267251 switch ( $filter ) {
268252 case 'needsoversight':
269253 $where[] = 'af_needs_oversight IS TRUE';
@@ -503,19 +487,21 @@
504488 }
505489
506490 private function renderBucket1( $record ) {
507 - if ( $record['found']->aa_response_boolean ) {
 491+ if ( $record['found']->aa_response_boolean == 1 ) {
508492 $msg = 'articlefeedbackv5-form1-header-found';
509493 $class = 'positive';
510 - } else {
 494+ } elseif( $record['found']->aa_response_boolean !== null ) {
511495 $msg = 'articlefeedbackv5-form1-header-not-found';
512496 $class = 'negative';
 497+ } else {
 498+ $msg = 'articlefeedbackv5-form1-header-left-comment';
 499+ $class = '';
513500 }
514501
515502 return $this->feedbackHead( $msg, $class, $record[0] )
516503 . $this->renderComment( $record['comment']->aa_response_text, $record[0]->af_id );
517504 }
518505
519 -
520506 private function renderBucket2( $record ) {
521507 $type = htmlspecialchars( $record['tag']->afo_name );
522508 $class = $type == 'problem' ? 'negative' : 'positive';
@@ -679,7 +665,7 @@
680666 ApiBase::PARAM_REQUIRED => false,
681667 ApiBase::PARAM_ISMULTI => false,
682668 ApiBase::PARAM_TYPE => array(
683 - 'all', 'invisible', 'visible', 'comment', 'id', 'helpful', 'unhelpful', 'abusive', 'deleted', 'needsoversight' )
 669+ 'all', 'notdeleted', 'invisible', 'visible', 'comment', 'id', 'helpful', 'unhelpful', 'abusive', 'deleted', 'needsoversight' )
684670 ),
685671 'filtervalue' => array(
686672 ApiBase::PARAM_REQUIRED => false,
Index: trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php
@@ -33,22 +33,34 @@
3434 global $wgUser;
3535 parent::__construct( 'ArticleFeedbackv5' );
3636
37 - // NOTE: The 'all' option actually displays different things
38 - // based on the users role, which is handled in the filter:
39 - // - deleter-all is actually everything
40 - // - hidder-all is 'visible + hidden'
41 - // - regular non-admin all is just 'all visible'
 37+ $showHidden = $wgUser->isAllowed( 'aftv5-see-hidden-feedback' );
 38+ $showDeleted = $wgUser->isAllowed( 'aftv5-see-deleted-feedback' );
4239
43 - if ( $wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) {
 40+ if ( $showHidden ) {
4441 array_push( $this->filters,
4542 'unhelpful', 'abusive', 'invisible'
4643 );
4744 # removing the 'needsoversight' filter, per Fabrice
4845 }
4946
50 - if ( $wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) ) {
 47+ if ( $showDeleted ) {
5148 $this->filters[] = 'deleted';
5249 }
 50+
 51+ // NOTE: The 'all' option actually displays different things
 52+ // based on the users role, which is handled in the filter:
 53+ // - deleter's all is actually everything
 54+ // - hidder's all is 'visible + hidden'
 55+ // - regular non-admin only has 'all visible' not 'all'
 56+
 57+ // The all option, if any, is only added once, at the end of the list,
 58+ // which is why it's down here instead.
 59+ if ( $showDeleted ) {
 60+ $this->filters[] = 'all';
 61+ } elseif( $showHidden ) {
 62+ $this->filters[] = 'notdeleted';
 63+ }
 64+ $this->filters[] = 'notdeleted';
5365 }
5466
5567 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r110451Remove extra debug line that I left in in r110449gregchiasson00:03, 1 February 2012

Status & tagging log