Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php |
— | — | @@ -321,6 +321,7 @@ |
322 | 322 | 'articlefeedbackv5-cta2-confirmation-title' => 'The title of the learn more CTA', |
323 | 323 | 'articlefeedbackv5-cta2-confirmation-call' => 'The explanatory text of the learn more CTA', |
324 | 324 | 'articlefeedbackv5-cta2-button-text' => 'The text for the button on the learn more CTA', |
| 325 | + 'articlefeedbackv5-error-blocked' => 'This error message will be displayed on the form if the user is blocked from submitting feedback.', |
325 | 326 | 'articlefeedbackv5-error' => 'This error message will be displayed in a grey box replacing the form if there was an unrecoverable error.', |
326 | 327 | 'articlefeedbackv5-error-abuse' => 'This error message will be displayed above the form if the comment matched the spam or abuse filters. $1 is the link to the abuse policy.', |
327 | 328 | 'articlefeedbackv5-error-abuse-linktext' => 'The text for the abuse policy link.', |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php |
— | — | @@ -26,11 +26,6 @@ |
27 | 27 | $error = null; |
28 | 28 | $dbr = wfGetDB( DB_SLAVE ); |
29 | 29 | |
30 | | - if ( !isset( $params['feedbackid'] ) |
31 | | - || !preg_match( '/^\d+$/', $params['feedbackid'] ) ) { |
32 | | - $error = 'articlefeedbackv5-invalid-feedback-id'; |
33 | | - } |
34 | | - |
35 | 30 | # load feedback record, bail if we don't have one |
36 | 31 | $record = $dbr->selectRow( |
37 | 32 | 'aft_article_feedback', |
— | — | @@ -38,20 +33,16 @@ |
39 | 34 | array( 'af_id' => $params['feedbackid'] ) |
40 | 35 | ); |
41 | 36 | |
42 | | - # TODO: |
| 37 | + $flags = array( 'abuse', 'hide', 'helpful', 'unhelpful', 'delete' ); |
43 | 38 | if ( !$record->af_id ) { |
44 | 39 | // no-op, because this is already broken |
45 | 40 | $error = 'articlefeedbackv5-invalid-feedback-id'; |
46 | | - } elseif ( $params['flagtype'] == 'abuse' ) { |
47 | | - $update['af_abuse_count'] = $record->af_abuse_count + 1; |
48 | | - } elseif ( $params['flagtype'] == 'hide' ) { |
49 | | - $update['af_hide_count'] = $record->af_hide_count + 1; |
50 | | - } elseif ( $params['flagtype'] == 'helpful' ) { |
51 | | - $update['af_helpful_count'] = $record->af_helpful_count + 1; |
52 | | - } elseif ( $params['flagtype'] == 'unhelpful' ) { |
53 | | - $update['af_unhelpful_count'] = $record->af_unhelpful_count + 1; |
54 | | - } elseif ( $params['flagtype'] == 'delete' ) { |
55 | | - $update['af_delete_count'] = $record->af_delete_count + 1; |
| 41 | + } elseif( in_array( $params['flagtype'], $flags ) ) { |
| 42 | + // Probably this doesn't need validation, since the API |
| 43 | + // will handle it, but if it's getting interpolated into |
| 44 | + // the SQL, I'm really wary not re-validating it. |
| 45 | + $flag = 'af_'.$params['flagtype'].'_count'; |
| 46 | + $update[] = "$flag = $flag + 1"; |
56 | 47 | } else { |
57 | 48 | $error = 'articlefeedbackv5-invalid-feedback-flag'; |
58 | 49 | } |