Index: trunk/extensions/ArticleFeedbackv5/sql/alter.sql |
— | — | @@ -22,3 +22,5 @@ |
23 | 23 | |
24 | 24 | ALTER TABLE aft_article_feedback ADD COLUMN af_link_id integer unsigned NOT NULL DEFAULT 0; |
25 | 25 | |
| 26 | +ALTER TABLE aft_article_feedback ADD COLUMN af_abuse_count integer unsigned NOT NULL DEFAULT 0; |
| 27 | +ALTER TABLE aft_article_feedback ADD COLUMN af_hide_count integer unsigned NOT NULL DEFAULT 0; |
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js |
— | — | @@ -30,14 +30,54 @@ |
31 | 31 | $.articleFeedbackv5special.loadFeedback(); |
32 | 32 | return false; |
33 | 33 | } ); |
34 | | - // TODO: need to handle: upvote, downvote, hide, flag as abuse |
35 | | - // PROTIP use 'live' instead of 'bind' because dynamic loading. |
| 34 | + $( '.aft5-abuse-link' ).live( 'click', function(e) { |
| 35 | + var id = $( this ).attr( 'id' ).replace( 'aft5-abuse-link-', '' ); |
| 36 | + $.articleFeedbackv5special.abuseFeedback( id ); |
| 37 | + return false; |
| 38 | + } ); |
| 39 | + $( '.aft5-hide-link' ).live( 'click', function(e) { |
| 40 | + var id = $( this ).attr( 'id' ).replace( 'aft5-hide-link-', '' ); |
| 41 | + $.articleFeedbackv5special.hideFeedback( id ); |
| 42 | + return false; |
| 43 | + } ); |
36 | 44 | } |
37 | 45 | |
38 | | - $.articleFeedbackv5special.loadFeedback = function () { |
| 46 | + $.articleFeedbackv5special.hideFeedback = function ( id ) { |
| 47 | + $.articleFeedbackv5special.flagFeedback( id, 'hide' ); |
| 48 | + } |
39 | 49 | |
| 50 | + $.articleFeedbackv5special.abuseFeedback = function ( id ) { |
| 51 | + $.articleFeedbackv5special.flagFeedback( id, 'abuse' ); |
| 52 | + } |
| 53 | + |
| 54 | + // TODO: User ID? |
| 55 | + $.articleFeedbackv5special.flagFeedback = function ( id, type ) { |
40 | 56 | $.ajax( { |
41 | 57 | 'url' : $.articleFeedbackv5special.apiUrl, |
| 58 | + 'type' : 'POST', |
| 59 | +'action': 'articlefeedbackv5', |
| 60 | + 'dataType': 'json', |
| 61 | + 'data' : { |
| 62 | + 'affeedbackid': id, |
| 63 | + 'afflagtype' : type, |
| 64 | + 'format' : 'json', |
| 65 | + 'maxage' : 0, |
| 66 | + 'list' : 'articlefeedbackv5-flag-feedback', |
| 67 | + }, |
| 68 | + 'success': function ( data ) { |
| 69 | + // TODO check output and error if needed |
| 70 | + $( '#aft5-' + type + '-link-' + id ).html( |
| 71 | + type + ' flag saved !' |
| 72 | + ); |
| 73 | + } |
| 74 | + // TODO have a callback for failures. |
| 75 | + } ); |
| 76 | + return false; |
| 77 | + } |
| 78 | + |
| 79 | + $.articleFeedbackv5special.loadFeedback = function () { |
| 80 | + $.ajax( { |
| 81 | + 'url' : $.articleFeedbackv5special.apiUrl, |
42 | 82 | 'type' : 'GET', |
43 | 83 | 'dataType': 'json', |
44 | 84 | 'data' : { |
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php |
— | — | @@ -201,6 +201,7 @@ |
202 | 202 | $wgAutoloadClasses['ApiArticleFeedbackv5'] = $dir . 'api/ApiArticleFeedbackv5.php'; |
203 | 203 | $wgAutoloadClasses['ApiViewRatingsArticleFeedbackv5'] = $dir . 'api/ApiViewRatingsArticleFeedbackv5.php'; |
204 | 204 | $wgAutoloadClasses['ApiViewFeedbackArticleFeedbackv5'] = $dir . 'api/ApiViewFeedbackArticleFeedbackv5.php'; |
| 205 | +$wgAutoloadClasses['ApiFlagFeedbackArticleFeedbackv5'] = $dir . 'api/ApiFlagFeedbackArticleFeedbackv5.php'; |
205 | 206 | $wgAutoloadClasses['ArticleFeedbackv5Hooks'] = $dir . 'ArticleFeedbackv5.hooks.php'; |
206 | 207 | $wgAutoloadClasses['SpecialArticleFeedbackv5'] = $dir . 'SpecialArticleFeedbackv5.php'; |
207 | 208 | $wgExtensionMessagesFiles['ArticleFeedbackv5'] = $dir . 'ArticleFeedbackv5.i18n.php'; |
— | — | @@ -220,6 +221,7 @@ |
221 | 222 | // API Registration |
222 | 223 | $wgAPIListModules['articlefeedbackv5-view-ratings'] = 'ApiViewRatingsArticleFeedbackv5'; |
223 | 224 | $wgAPIListModules['articlefeedbackv5-view-feedback'] = 'ApiViewFeedbackArticleFeedbackv5'; |
| 225 | +$wgAPIListModules['articlefeedbackv5-flag-feedback'] = 'ApiFlagFeedbackArticleFeedbackv5'; |
224 | 226 | $wgAPIModules['articlefeedbackv5'] = 'ApiArticleFeedbackv5'; |
225 | 227 | |
226 | 228 | // Special Page |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php |
— | — | @@ -0,0 +1,114 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * ApiFlagFeedbackArticleFeedbackv5 class |
| 5 | + * |
| 6 | + * @package ArticleFeedback |
| 7 | + * @subpackage Api |
| 8 | + * @author Greg Chiasson <greg@omniti.com> |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * This class pulls the individual ratings/comments for the feedback page. |
| 13 | + * |
| 14 | + * @package ArticleFeedback |
| 15 | + * @subpackage Api |
| 16 | + */ |
| 17 | +class ApiFlagFeedbackArticleFeedbackv5 extends ApiBase { |
| 18 | + public function __construct( $query, $moduleName ) { |
| 19 | + parent::__construct( $query, $moduleName, 'af' ); |
| 20 | + } |
| 21 | + |
| 22 | + /** |
| 23 | + * Execute the API call: Pull the requested feedback |
| 24 | + */ |
| 25 | + public function execute() { |
| 26 | + $params = $this->extractRequestParams(); |
| 27 | + $this->getResult()->addValue( |
| 28 | + null, |
| 29 | + $this->getModuleName(), |
| 30 | + array( |
| 31 | + 'result' => 'Success', |
| 32 | + ) |
| 33 | + ); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * Gets the allowed parameters |
| 38 | + * |
| 39 | + * @return array the params info, indexed by allowed key |
| 40 | + */ |
| 41 | + public function getAllowedParams() { |
| 42 | + return array( |
| 43 | + 'feedbackid' => array( |
| 44 | + ApiBase::PARAM_REQUIRED => true, |
| 45 | + ApiBase::PARAM_ISMULTI => false, |
| 46 | + ApiBase::PARAM_TYPE => 'integer' |
| 47 | + ), |
| 48 | + 'type' => array( |
| 49 | + ApiBase::PARAM_REQUIRED => true, |
| 50 | + ApiBase::PARAM_ISMULTI => false, |
| 51 | + ApiBase::PARAM_TYPE => array( |
| 52 | + 'abuse', 'hide' ) |
| 53 | + ), |
| 54 | + ); |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * Gets the parameter descriptions |
| 59 | + * |
| 60 | + * @return array the descriptions, indexed by allowed key |
| 61 | + */ |
| 62 | + public function getParamDescription() { |
| 63 | + return array( |
| 64 | + 'feedbackid' => 'FeedbackID to flag', |
| 65 | + 'type' => 'Type of flag to apply - hide or abuse' |
| 66 | + ); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Gets the api descriptions |
| 71 | + * |
| 72 | + * @return array the description as the first element in an array |
| 73 | + */ |
| 74 | + public function getDescription() { |
| 75 | + return array( |
| 76 | + 'Flag a feedbackID as abusive or hidden.' |
| 77 | + ); |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * Gets any possible errors |
| 82 | + * |
| 83 | + * @return array the errors |
| 84 | + */ |
| 85 | + public function getPossibleErrors() { |
| 86 | + return array_merge( parent::getPossibleErrors(), array( |
| 87 | + array( 'missingparam', 'anontoken' ), |
| 88 | + array( 'code' => 'invalidtoken', 'info' => 'The anontoken is not 32 characters' ), |
| 89 | + ) |
| 90 | + ); |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * Gets an example |
| 95 | + * |
| 96 | + * @return array the example as the first element in an array |
| 97 | + */ |
| 98 | + protected function getExamples() { |
| 99 | + return array( |
| 100 | + 'api.php?list=articlefeedbackv5-view-feedback&affeedbackid=1&aftype=abuse', |
| 101 | + ); |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * Gets the version info |
| 106 | + * |
| 107 | + * @return string the SVN version info |
| 108 | + */ |
| 109 | + public function getVersion() { |
| 110 | + return __CLASS__ . ': $Id: ApiFlagRatingsArticleFeedbackv5.php 103439 2011-11-17 03:19:01Z gregchiasson $'; |
| 111 | + } |
| 112 | + |
| 113 | + public function isWriteMode() { return true; } |
| 114 | + public function mustBePosted() { return true; } |
| 115 | +} |
Property changes on: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 116 | + native |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php |
— | — | @@ -168,8 +168,8 @@ |
169 | 169 | } |
170 | 170 | |
171 | 171 | protected function renderFeedback( $record ) { |
172 | | - $rv = "<div class='aft5-feedback'>" |
173 | | - ."<p>Feedback #".$record[0]->af_id |
| 172 | + $id = $record[0]->af_id; |
| 173 | + $rv = "<div class='aft5-feedback'><p>Feedback #$id" |
174 | 174 | .', @'.$record[0]->af_created.'</p>'; |
175 | 175 | switch( $record[0]->af_bucket_id ) { |
176 | 176 | case 1: $rv .= $this->renderBucket1( $record ); break; |
— | — | @@ -181,10 +181,8 @@ |
182 | 182 | default: return 'Invalid bucket id'; |
183 | 183 | } |
184 | 184 | $rv .= "<p> |
185 | | -<!-- |
186 | | - <a href=''>Hide this</a> |
187 | | - <a href=''>Flag as abuse</a> |
| 185 | + <a href='#' class='aft5-hide-link' id='aft5-hide-link-$id'>Hide this</a> |
| 186 | + <a href='#' class='aft5-abuse-link' id='aft5-abuse-link-$id'>Flag as abuse</a> |
188 | 187 | </p> |
189 | 188 | </div><hr>"; |
190 | 189 | return $rv; |