Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | 'articlefeedbackv5-special-sort-label-after' => '', |
71 | 71 | 'articlefeedbackv5-special-filter-label-before' => 'Showing:', |
72 | 72 | 'articlefeedbackv5-special-filter-label-after' => '', |
73 | | - 'articlefeedbackv5-special-showing' => '$1 feedback posts on this page', // FIXME: Needs plural support on $1. |
| 73 | + 'articlefeedbackv5-special-showing' => '{{PLURAL:$1|1 feedback post|$1 feedback posts }} on this article', |
74 | 74 | 'articlefeedbackv5-comment-link' => 'Permalink', |
75 | 75 | 'articlefeedbackv5-updates-since' => '{{PLURAL:$1|1 edit|$1 edits}} since post', |
76 | 76 | 'articlefeedbackv5-special-more' => 'More', |
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/images/sort-ascending.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/images/sort-ascending.png |
___________________________________________________________________ |
Added: svn:mime-type |
77 | 77 | + image/png |
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/images/sort-descending.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/images/sort-descending.png |
___________________________________________________________________ |
Added: svn:mime-type |
78 | 78 | + image/png |
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | /** |
42 | 42 | * The name of the filter used to select feedback |
43 | 43 | */ |
44 | | - $.articleFeedbackv5special.filter = 'visible'; |
| 44 | + $.articleFeedbackv5special.filter = 'comment'; |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Some fitlers have values they need tobe passed (eg, permalinks) |
— | — | @@ -143,10 +143,10 @@ |
144 | 144 | $( '.articleFeedbackv5-sort-arrow' ).hide(); |
145 | 145 | $( '.articleFeedbackv5-sort-link' ).removeClass( 'sort-active' ); |
146 | 146 | |
147 | | - $( '#articleFeedbackv5-sort-arrow-' + id ).text( |
148 | | - mw.msg( 'articlefeedbackv5-special-sort-' + dir ) |
| 147 | + $( '#articleFeedbackv5-sort-arrow-' + id ).show(); |
| 148 | + $( '#articleFeedbackv5-sort-arrow-' + id ).attr( |
| 149 | + 'src', 'images/sort ' + dir + 'ending.png' |
149 | 150 | ); |
150 | | - $( '#articleFeedbackv5-sort-arrow-' + id ).show(); |
151 | 151 | $( '#articleFeedbackv5-special-sort-' + id).addClass( 'sort-active' ); |
152 | 152 | } |
153 | 153 | |
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php |
— | — | @@ -284,3 +284,8 @@ |
285 | 285 | // Special Page |
286 | 286 | $wgSpecialPages['ArticleFeedbackv5'] = 'SpecialArticleFeedbackv5'; |
287 | 287 | $wgSpecialPageGroups['ArticleFeedbackv5'] = 'other'; |
| 288 | + |
| 289 | +$wgAvailableRights[] = 'aftv5-hide-feedback'; |
| 290 | +$wgAvailableRights[] = 'aftv5-delete-feedback'; |
| 291 | +$wgAvailableRights[] = 'aftv5-see-deleted-feedback'; |
| 292 | +$wgAvailableRights[] = 'aftv5-see-hidden-feedback'; |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | $params = $this->extractRequestParams(); |
27 | 27 | $error = null; |
28 | 28 | $dbr = wfGetDB( DB_SLAVE ); |
29 | | - |
| 29 | + $counts = array( 'increment' => array(), 'decrement' => array() ); |
30 | 30 | # load feedback record, bail if we don't have one |
31 | 31 | $record = $dbr->selectRow( |
32 | 32 | 'aft_article_feedback', |
— | — | @@ -34,6 +34,8 @@ |
35 | 35 | ); |
36 | 36 | |
37 | 37 | $flags = array( 'abuse', 'hide', 'helpful', 'unhelpful', 'delete' ); |
| 38 | + $flag = $params['flagtype']; |
| 39 | + |
38 | 40 | if ( !$record->af_id ) { |
39 | 41 | // no-op, because this is already broken |
40 | 42 | $error = 'articlefeedbackv5-invalid-feedback-id'; |
— | — | @@ -41,19 +43,51 @@ |
42 | 44 | // Probably this doesn't need validation, since the API |
43 | 45 | // will handle it, but if it's getting interpolated into |
44 | 46 | // the SQL, I'm really wary not re-validating it. |
45 | | - $flag = 'af_'.$params['flagtype'].'_count'; |
46 | | - $update[] = "$flag = $flag + 1"; |
| 47 | + $field = 'af_'.$params['flagtype'].'_count'; |
| 48 | + $update[] = "$field = $field + 1"; |
47 | 49 | } else { |
48 | 50 | $error = 'articlefeedbackv5-invalid-feedback-flag'; |
49 | 51 | } |
50 | 52 | |
| 53 | + |
| 54 | + // Newly abusive record |
| 55 | + if( $flag == 'abuse' && $record->af_abuse_count == 0 ) { |
| 56 | + $counts['increment'][] = 'abuse'; |
| 57 | + } |
| 58 | + |
| 59 | + // Newly hidden record |
| 60 | + if( $flag == 'hide' && $record->af_hide_count == 0 ) { |
| 61 | + $counts['increment'][] = 'invisible'; |
| 62 | + $counts['decrement'][] = 'visible'; |
| 63 | + } |
| 64 | + |
| 65 | + // Newly deleted record |
| 66 | + if( $flag == 'delete' && $record->af_delete_count == 0 ) { |
| 67 | + $counts['increment'][] = 'deleted'; |
| 68 | + $counts['decrement'][] = 'visible'; |
| 69 | + } |
| 70 | + |
| 71 | + // Newly helpful record |
| 72 | + if( $flag == 'helpful' && $record->af_helpful_count == 0 ) { |
| 73 | + $counts['increment'][] = 'helpful'; |
| 74 | + } |
| 75 | + |
| 76 | + // Newly unhelpful record (IE, unhelpful has overtaken helpful) |
| 77 | + if( $flag == 'unhelpful' |
| 78 | + && ( $record->af_helpful_count - $record->af_unhelpful_count ) == 1 ) { |
| 79 | + $counts['decrement'][] = 'helpful'; |
| 80 | + } |
| 81 | + |
51 | 82 | if ( !$error ) { |
52 | 83 | $dbw = wfGetDB( DB_MASTER ); |
53 | 84 | $dbw->update( |
54 | 85 | 'aft_article_feedback', |
55 | 86 | $update, |
56 | | - array( 'af_id' => $params['feedbackid'] ) |
| 87 | + array( 'af_id' => $params['feedbackid'] ), |
| 88 | + __METHOD__ |
57 | 89 | ); |
| 90 | + |
| 91 | + $this->updateFilterCounts( $counts, $params['pageid'] ); |
58 | 92 | } |
59 | 93 | |
60 | 94 | if ( $error ) { |
— | — | @@ -74,6 +108,46 @@ |
75 | 109 | ); |
76 | 110 | } |
77 | 111 | |
| 112 | + public function updateFilterCounts( $counts, $pageId ) { |
| 113 | + $dbw = wfGetDB( DB_MASTER ); |
| 114 | + $rows = array(); |
| 115 | + |
| 116 | + foreach( array_merge( $counts['increment'], $counts['decrement'] ) as $filter ) { |
| 117 | + $rows[] = array( |
| 118 | + 'afc_page_id' => $pageId, |
| 119 | + 'afc_filter_name' => $filter, |
| 120 | + 'afc_filter_count' => 0 |
| 121 | + ); |
| 122 | + } |
| 123 | + |
| 124 | + // Make sure the rows are inserted. |
| 125 | + $dbw->insert( |
| 126 | + 'aft_article_filter_count', |
| 127 | + $rows, |
| 128 | + __METHOD__, |
| 129 | + array( 'IGNORE' ) |
| 130 | + ); |
| 131 | + |
| 132 | + // Update the filter counts |
| 133 | + foreach( $counts['increment'] as $count ) { |
| 134 | + $dbw->update( |
| 135 | + 'aft_article_filter_count', |
| 136 | + array( 'afc_filter_count = afc_filter_count + 1' ), |
| 137 | + array( 'afc_filter_name' => $count ), |
| 138 | + __METHOD__ |
| 139 | + ); |
| 140 | + } |
| 141 | + |
| 142 | + foreach( $counts['decrement'] as $count ) { |
| 143 | + $dbw->update( |
| 144 | + 'aft_article_filter_count', |
| 145 | + array( 'afc_filter_count = afc_filter_count - 1' ), |
| 146 | + array( 'afc_filter_name' => $count ), |
| 147 | + __METHOD__ |
| 148 | + ); |
| 149 | + } |
| 150 | + } |
| 151 | + |
78 | 152 | /** |
79 | 153 | * Gets the allowed parameters |
80 | 154 | * |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php |
— | — | @@ -14,13 +14,11 @@ |
15 | 15 | * @subpackage Api |
16 | 16 | */ |
17 | 17 | class ApiViewFeedbackArticleFeedbackv5 extends ApiQueryBase { |
18 | | - private $access = array(); |
19 | 18 | /** |
20 | 19 | * Constructor |
21 | 20 | */ |
22 | 21 | public function __construct( $query, $moduleName ) { |
23 | 22 | parent::__construct( $query, $moduleName, 'afvf' ); |
24 | | - $this->access = ApiArticleFeedbackv5Utils::initializeAccess(); |
25 | 23 | } |
26 | 24 | |
27 | 25 | /** |
— | — | @@ -87,22 +85,23 @@ |
88 | 86 | $continueDirection = ( $direction == 'ASC' ? '>' : '<' ); |
89 | 87 | $order; |
90 | 88 | $continue; |
| 89 | + $sortField; |
91 | 90 | |
92 | 91 | switch( $sort ) { |
93 | 92 | case 'helpful': |
94 | | - $order = "net_helpfulness $direction"; |
95 | | - $continueSql = "net_helpfulness $continueDirection"; |
| 93 | + $sortField = 'net_helpfulness'; |
96 | 94 | break; |
97 | 95 | case 'rating': |
98 | | - # For now, just fall through. Not specced out. |
| 96 | + $sortField = 'rating'; |
99 | 97 | break; |
100 | 98 | case 'age': |
101 | | - # Default sort is by age. |
| 99 | + # Default field, fall through |
102 | 100 | default: |
103 | | - $order = "af_id $direction"; |
104 | | - $continueSql = "af_id $continueDirection"; |
| 101 | + $sortField = 'af_id'; |
105 | 102 | break; |
106 | | - } |
| 103 | + } |
| 104 | + $order = "$sortField $direction"; |
| 105 | + $continueSql = "$sortField $continueDirection"; |
107 | 106 | |
108 | 107 | $where['af_page_id'] = $pageId; |
109 | 108 | # This join is needed for the comment filter. |
— | — | @@ -214,40 +213,60 @@ |
215 | 214 | } |
216 | 215 | |
217 | 216 | private function getFilterCriteria( $filter, $filterValue = null ) { |
| 217 | + global $wgUser; |
218 | 218 | $where = array(); |
219 | 219 | |
220 | 220 | // Permissions check |
221 | | - if( |
222 | | - ( $filter == 'invisible' && !$this->access[ 'rollbackers' ] ) |
223 | | - || ( $filter == 'deleted' && !$this->access[ 'oversight' ] ) |
224 | | - |
| 221 | + if( |
| 222 | + ( $filter == 'invisible' |
| 223 | + && !$wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) |
| 224 | + || |
| 225 | + ( $filter == 'deleted' |
| 226 | + && !$wgUser->isAllowed( 'aftv5-ssee-deleted-feedback' ) ) |
225 | 227 | ) { |
226 | 228 | $filter = null; |
227 | 229 | } |
228 | 230 | |
| 231 | + // Always limit this to non-hidden records, unless they |
| 232 | + // specifically ask to see them. |
| 233 | + if( $filter != 'invisible' ) { |
| 234 | + $where[ 'af_hide_count' ] = 0; |
| 235 | + } |
| 236 | + |
| 237 | + // Same, but for deleted/supressed/oversight-only records. |
| 238 | + if( $filter != 'deleted' ) { |
| 239 | + $where[ 'af_delete_count' ] = 0; |
| 240 | + } |
| 241 | + |
229 | 242 | switch( $filter ) { |
230 | 243 | case 'all': |
231 | | - $where = array(); |
| 244 | + # no op |
232 | 245 | break; |
233 | 246 | case 'invisible': |
234 | | - $where = array( 'af_hide_count > 0' ); |
| 247 | + $where[] = 'af_hide_count > 0'; |
235 | 248 | break; |
236 | 249 | case 'comment': |
237 | | - $where = array( 'aa_response_text IS NOT NULL'); |
| 250 | + $where[] = 'aa_response_text IS NOT NULL'; |
238 | 251 | break; |
239 | 252 | case 'id': |
240 | | - $where = array( 'af_id' => $filterValue ); |
| 253 | + $where[ 'af_id' ] = $filterValue; |
241 | 254 | break; |
242 | 255 | case 'visible': |
| 256 | + $where[ 'af_hide_count' ] = 0; |
| 257 | + break; |
| 258 | + case 'deleted': |
| 259 | + $where[ 'af_delete_count' ] = 0; |
| 260 | + break; |
243 | 261 | default: |
244 | | - $where = array( 'af_hide_count' => 0 ); |
245 | 262 | break; |
246 | 263 | } |
247 | 264 | return $where; |
248 | 265 | } |
249 | 266 | |
250 | 267 | protected function renderFeedback( $record ) { |
251 | | - global $wgArticlePath; |
| 268 | + global $wgArticlePath, $wgUser; |
| 269 | + $id = $record[0]->af_id; |
| 270 | + |
252 | 271 | switch( $record[0]->af_bucket_id ) { |
253 | 272 | case 1: $content .= $this->renderBucket1( $record ); break; |
254 | 273 | case 2: $content .= $this->renderBucket2( $record ); break; |
— | — | @@ -257,18 +276,13 @@ |
258 | 277 | case 6: $content .= $this->renderBucket6( $record ); break; |
259 | 278 | default: $content .= $this->renderNoBucket( $record ); break; |
260 | 279 | } |
261 | | - $can_flag = !$this->access[ 'blocked' ]; |
262 | | - $can_vote = !$this->access[ 'blocked' ]; |
263 | | - $can_hide = $this->access[ 'rollbackers' ]; |
264 | | - $can_delete = $this->access[ 'oversight' ]; |
265 | | - $id = $record[0]->af_id; |
266 | 280 | |
267 | | -# $header_links = Html::openElement( 'p', array( 'class' => 'articleFeedbackv5-comment-head' ) ) |
268 | | -# . Html::element( 'a', array( 'class' => 'articleFeedbackv5-comment-name', 'href' => 'profilepage or whatever' ), $id ) |
269 | | -# . Html::openElement( 'div', array( |
270 | | -# . Html::element( 'span', array( 'class' => 'articleFeedbackv5-comment-timestamp' ), $record[0]->af_created ) |
271 | | -# . wfMessage( 'articlefeedbackv5-form-optionid', $record[0]->af_bucket_id )->escaped() |
272 | | -# . Html::closeElement( 'p' ); |
| 281 | + // These two are the same for now, but may now always be, |
| 282 | + // so set them each separately. |
| 283 | + $can_flag = !$wgUser->isBlocked(); |
| 284 | + $can_vote = !$wgUser->isBlocked(); |
| 285 | + $can_hide = $wgUser->isAllowed( 'aftv5-hide-feedback' ); |
| 286 | + $can_delete = $wgUser->isAllowed( 'aftv5-delete-feedback' ); |
273 | 287 | |
274 | 288 | $details = Html::openElement( 'div', array( |
275 | 289 | 'class' => 'articleFeedbackv5-comment-details' |
— | — | @@ -302,7 +316,6 @@ |
303 | 317 | 'oldid' => $record[0]->af_revision_id |
304 | 318 | ) |
305 | 319 | ) |
306 | | -# ), wfMessage( 'articlefeedbackv5-updates-since', $record[0]->age ) ) |
307 | 320 | . Html::closeElement( 'div' ) |
308 | 321 | . Html::closeElement( 'div' ); |
309 | 322 | ; |
— | — | @@ -326,42 +339,41 @@ |
327 | 340 | $footer_links .= Html::element( 'span', array( |
328 | 341 | 'class' => 'articleFeedbackv5-helpful-votes' |
329 | 342 | ), wfMessage( 'articlefeedbackv5-form-helpful-votes', ( $record[0]->af_helpful_count + $record[0]->af_unhelpful_count ), $record[0]->af_helpful_count, $record[0]->af_unhelpful_count ) ) |
330 | | - . Html::closeElement( 'p' ); |
331 | | - |
332 | | - |
333 | | -# $rate = Html::openElement( 'div', array( 'class' => 'articleFeedbackv5-feedback-rate' ) ) |
334 | | -# . wfMessage( 'articlefeedbackv5-form-helpful-label' )->escaped() |
335 | | -# . Html::closeElement( 'div' ); |
336 | | - |
337 | | - |
338 | | - $tools = Html::openElement( 'div', array( |
339 | | - 'class' => 'articleFeedbackv5-feedback-tools', |
340 | | - 'id' => 'articleFeedbackv5-feedback-tools-'.$id |
341 | | - ) ) |
342 | | - . Html::element( 'h3', array( |
343 | | - 'id' => 'articleFeedbackv5-feedback-tools-header-'.$id |
344 | | - ), wfMessage( 'articlefeedbackv5-form-tools-label' )->text() ) |
345 | | - . Html::openElement( 'ul', array( |
346 | | - 'id' => 'articleFeedbackv5-feedback-tools-list-'.$id |
347 | | - ) ) |
348 | | - # TODO: unhide hidden posts |
349 | | - . ( $can_hide ? Html::rawElement( 'li', array(), Html::element( 'a', array( |
350 | | - 'id' => "articleFeedbackv5-hide-link-$id", |
351 | | - 'class' => 'articleFeedbackv5-hide-link' |
352 | | - ), wfMessage( 'articlefeedbackv5-form-hide', $record[0]->af_hide_count )->text() ) ) : '' ) |
353 | | - . ( $can_flag ? Html::rawElement( 'li', array(), Html::element( 'a', array( |
| 343 | + . ( $can_flag ? Html::rawElement( 'div', array( |
| 344 | + 'class' => 'articleFeedbackv5-abuse-link-wrap' |
| 345 | + ), Html::element( 'a', array( |
354 | 346 | 'id' => "articleFeedbackv5-abuse-link-$id", |
355 | 347 | 'class' => 'articleFeedbackv5-abuse-link' |
356 | 348 | ), wfMessage( 'articlefeedbackv5-form-abuse', $record[0]->af_abuse_count )->text() ) ) : '' ) |
357 | | - # TODO: nonoversight can mark for oversight, oversight can |
358 | | - # either delete or un-delete, based on deletion status |
359 | | - . ( $can_delete ? Html::rawElement( 'li', array(), Html::element( 'a', array( |
360 | | - 'id' => "articleFeedbackv5-delete-link-$id", |
361 | | - 'class' => 'articleFeedbackv5-delete-link' |
362 | | - ), wfMessage( 'articlefeedbackv5-form-delete' )->text() ) ) : '' ) |
363 | | - . Html::closeElement( 'ul' ) |
364 | | - . Html::closeElement( 'div' ); |
| 349 | + . Html::closeElement( 'p' ); |
365 | 350 | |
| 351 | + // Don't render the toolbox if they can't do anything with it. |
| 352 | + if( $can_hide || $can_delete ) { |
| 353 | + $tools = Html::openElement( 'div', array( |
| 354 | + 'class' => 'articleFeedbackv5-feedback-tools', |
| 355 | + 'id' => 'articleFeedbackv5-feedback-tools-'.$id |
| 356 | + ) ) |
| 357 | + . Html::element( 'h3', array( |
| 358 | + 'id' => 'articleFeedbackv5-feedback-tools-header-'.$id |
| 359 | + ), wfMessage( 'articlefeedbackv5-form-tools-label' )->text() ) |
| 360 | + . Html::openElement( 'ul', array( |
| 361 | + 'id' => 'articleFeedbackv5-feedback-tools-list-'.$id |
| 362 | + ) ) |
| 363 | + # TODO: unhide hidden posts |
| 364 | + . ( $can_hide ? Html::rawElement( 'li', array(), Html::element( 'a', array( |
| 365 | + 'id' => "articleFeedbackv5-hide-link-$id", |
| 366 | + 'class' => 'articleFeedbackv5-hide-link' |
| 367 | + ), wfMessage( 'articlefeedbackv5-form-hide', $record[0]->af_hide_count )->text() ) ) : '' ) |
| 368 | + # TODO: nonoversight can mark for oversight, oversight can |
| 369 | + # either delete or un-delete, based on deletion status |
| 370 | + . ( $can_delete ? Html::rawElement( 'li', array(), Html::element( 'a', array( |
| 371 | + 'id' => "articleFeedbackv5-delete-link-$id", |
| 372 | + 'class' => 'articleFeedbackv5-delete-link' |
| 373 | + ), wfMessage( 'articlefeedbackv5-form-delete' )->text() ) ) : '' ) |
| 374 | + . Html::closeElement( 'ul' ) |
| 375 | + . Html::closeElement( 'div' ); |
| 376 | + } |
| 377 | + |
366 | 378 | return Html::openElement( 'div', array( 'class' => 'articleFeedbackv5-feedback' ) ) |
367 | 379 | . Html::openElement( 'div', array( |
368 | 380 | 'class' => "articleFeedbackv5-comment-wrap" |
— | — | @@ -371,7 +383,6 @@ |
372 | 384 | . Html::closeElement( 'div' ) |
373 | 385 | . $details |
374 | 386 | . $tools |
375 | | - . $rate |
376 | 387 | . Html::closeElement( 'div' ); |
377 | 388 | } |
378 | 389 | |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php |
— | — | @@ -190,31 +190,4 @@ |
191 | 191 | |
192 | 192 | $dbw->commit(); |
193 | 193 | } |
194 | | - |
195 | | - public function initializeAccess() { |
196 | | - global $wgUser; |
197 | | - $permissions = array( |
198 | | - 'blocked' => $wgUser->isBlocked(), |
199 | | - 'anon' => $wgUser->isAnon(), |
200 | | - 'registered' => !$wgUser->isAnon() && !$wgUser->isBlocked(), |
201 | | - 'autoconfirmed' => in_array('autoconfirmed', $wgUser->getEffectiveGroups()), |
202 | | - 'rollbackers' => in_array('rollbacker', $wgUser->getEffectiveGroups()), |
203 | | - 'admins' => false, |
204 | | - 'oversight' => false |
205 | | - ); |
206 | | - |
207 | | - if( in_array('sysop', $wgUser->getEffectiveGroups() ) ) { |
208 | | - $permissions['admins'] = true; |
209 | | - $permissions['rollbackers'] = true; |
210 | | - } |
211 | | - |
212 | | - if( in_array('oversight ', $wgUser->getEffectiveGroups() ) ) { |
213 | | - $permissions['oversight'] = true; |
214 | | - $permissions['rollbackers'] = true; |
215 | | - $permissions['admins'] = true; |
216 | | - } |
217 | | - |
218 | | - return $permissions; |
219 | | - } |
220 | 194 | } |
221 | | - |
Index: trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php |
— | — | @@ -15,10 +15,9 @@ |
16 | 16 | * @subpackage Special |
17 | 17 | */ |
18 | 18 | class SpecialArticleFeedbackv5 extends SpecialPage { |
19 | | - private $access; |
20 | 19 | private $filters = array( |
21 | | - 'visible', |
22 | | - 'comment' |
| 20 | + 'comment', |
| 21 | + 'visible' |
23 | 22 | ); |
24 | 23 | private $sorts = array( |
25 | 24 | 'age', |
— | — | @@ -30,14 +29,15 @@ |
31 | 30 | * Constructor |
32 | 31 | */ |
33 | 32 | public function __construct() { |
| 33 | + global $wgUser; |
34 | 34 | parent::__construct( 'ArticleFeedbackv5' ); |
35 | | - $this->access = ApiArticleFeedbackv5Utils::initializeAccess(); |
36 | 35 | |
37 | | - if( $this->access[ 'rollbackers' ] ) { |
| 36 | + if( $wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) { |
38 | 37 | $this->filters[] = 'invisible'; |
39 | 38 | $this->filters[] = 'all'; |
40 | 39 | } |
41 | | - if( $this->access[ 'oversight' ] ) { |
| 40 | + |
| 41 | + if( $wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) ) { |
42 | 42 | $this->filters[] = 'deleted'; |
43 | 43 | } |
44 | 44 | } |
— | — | @@ -48,16 +48,36 @@ |
49 | 49 | * @param $param string the parameter passed in the url |
50 | 50 | */ |
51 | 51 | public function execute( $param ) { |
| 52 | + global $wgArticleFeedbackv5DashboardCategory; |
52 | 53 | $out = $this->getOutput(); |
53 | 54 | $title = Title::newFromText( $param ); |
54 | 55 | |
55 | | - if ( $title ) { |
56 | | - $pageId = $title->getArticleID(); |
57 | | - } else { |
| 56 | + // Page does not exist. |
| 57 | + if( !$title->exists() ) { |
58 | 58 | $out->addWikiMsg( 'articlefeedbackv5-invalid-page-id' ); |
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
| 62 | + $pageId = $title->getArticleID(); |
| 63 | + $dbr = wfGetDB( DB_SLAVE ); |
| 64 | + $t = $dbr->select( |
| 65 | + 'categorylinks', |
| 66 | + 'cl_from', |
| 67 | + array( |
| 68 | + 'cl_from' => $pageId, |
| 69 | + 'cl_to' => $wgArticleFeedbackv5DashboardCategory |
| 70 | + ), |
| 71 | + __METHOD__, |
| 72 | + array( 'LIMIT' => 1 ) |
| 73 | + ); |
| 74 | + |
| 75 | + // Page exists, but feedback is disabled. |
| 76 | + if( $dbr->numRows( $t ) == 0 ) { |
| 77 | + $out->addWikiMsg( 'articlefeedbackv5-page-disabled' ); |
| 78 | + return; |
| 79 | + } |
| 80 | + |
| 81 | + // Success! |
62 | 82 | $ratings = $this->fetchOverallRating( $pageId ); |
63 | 83 | $found = isset( $ratings['found'] ) ? $ratings['found'] : null; |
64 | 84 | $rating = isset( $ratings['rating'] ) ? $ratings['rating'] : null; |
— | — | @@ -141,11 +161,10 @@ |
142 | 162 | |
143 | 163 | $sortLabels = array(); |
144 | 164 | foreach ( $this->sorts as $sort ) { |
145 | | - $sortLabels[] = Html::element( 'span', |
| 165 | + $sortLabels[] = Html::element( 'img', |
146 | 166 | array( |
147 | 167 | 'id' => 'articleFeedbackv5-sort-arrow-' . $sort, |
148 | 168 | 'class' => 'articleFeedbackv5-sort-arrow' |
149 | | - |
150 | 169 | ), '' ) |
151 | 170 | . Html::element( |
152 | 171 | 'a', |