Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php |
— | — | @@ -32,12 +32,12 @@ |
33 | 33 | $params = $this->extractRequestParams(); |
34 | 34 | |
35 | 35 | // Anon token check |
36 | | - $token = ApiArticleFeedbackv5Utils::getAnonToken( $params ); |
| 36 | + $token = $this->getAnonToken( $params ); |
37 | 37 | |
38 | 38 | // Is feedback enabled on this page check? |
39 | | -# if ( !ApiArticleFeedbackv5Utils::isFeedbackEnabled( $params ) ) { |
40 | | -# $this->dieUsage( 'ArticleFeedback is not enabled on this page', 'invalidpage' ); |
41 | | -# } |
| 39 | + if ( !ApiArticleFeedbackv5Utils::isFeedbackEnabled( $params ) ) { |
| 40 | + $this->dieUsage( 'ArticleFeedback is not enabled on this page', 'invalidpage' ); |
| 41 | + } |
42 | 42 | |
43 | 43 | $feedbackId = $this->newFeedback( $params ); |
44 | 44 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -313,7 +313,7 @@ |
314 | 314 | $revId = $params['revid']; |
315 | 315 | $bucket = $params['bucket']; |
316 | 316 | $link = $params['link']; |
317 | | - $token = ApiArticleFeedbackv5Utils::getAnonToken( $params ); |
| 317 | + $token = $this->getAnonToken( $params ); |
318 | 318 | $timestamp = $dbw->timestamp(); |
319 | 319 | $ip = wfGetIP(); |
320 | 320 | |
— | — | @@ -379,6 +379,28 @@ |
380 | 380 | } |
381 | 381 | |
382 | 382 | /** |
| 383 | + * Gets the anonymous token from the params |
| 384 | + * |
| 385 | + * @param $params array the params |
| 386 | + * @return string the token, or null if the user is not anonymous |
| 387 | + */ |
| 388 | + public function getAnonToken( $params ) { |
| 389 | + global $wgUser; |
| 390 | + $token = null; |
| 391 | + if ( $wgUser->isAnon() ) { |
| 392 | + if ( !isset( $params['anontoken'] ) ) { |
| 393 | + $this->dieUsageMsg( array( 'missingparam', 'anontoken' ) ); |
| 394 | + } elseif ( strlen( $params['anontoken'] ) != 32 ) { |
| 395 | + $this->dieUsage( 'The anontoken is not 32 characters', 'invalidtoken' ); |
| 396 | + } |
| 397 | + $token = $params['anontoken']; |
| 398 | + } else { |
| 399 | + $token = ''; |
| 400 | + } |
| 401 | + return $token; |
| 402 | + } |
| 403 | + |
| 404 | + /** |
383 | 405 | * Gets the allowed parameters |
384 | 406 | * |
385 | 407 | * @return array the params info, indexed by allowed key |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php |
— | — | @@ -20,31 +20,7 @@ |
21 | 21 | * @subpackage Api |
22 | 22 | */ |
23 | 23 | class ApiArticleFeedbackv5Utils { |
24 | | - |
25 | 24 | /** |
26 | | - * Gets the anonymous token from the params |
27 | | - * |
28 | | - * @param $params array the params |
29 | | - * @return string the token, or null if the user is not anonymous |
30 | | - */ |
31 | | - public static function getAnonToken( $params ) { |
32 | | - global $wgUser; |
33 | | - $token = null; |
34 | | - if ( $wgUser->isAnon() ) { |
35 | | -# TODO: error handling |
36 | | - if ( !isset( $params['anontoken'] ) ) { |
37 | | -# $this->dieUsageMsg( array( 'missingparam', 'anontoken' ) ); |
38 | | - } elseif ( strlen( $params['anontoken'] ) != 32 ) { |
39 | | -# $this->dieUsage( 'The anontoken is not 32 characters', 'invalidtoken' ); |
40 | | - } |
41 | | - $token = $params['anontoken']; |
42 | | - } else { |
43 | | - $token = ''; |
44 | | - } |
45 | | - return $token; |
46 | | - } |
47 | | - |
48 | | - /** |
49 | 25 | * Returns whether feedback is enabled for this page |
50 | 26 | * |
51 | 27 | * @param $params array the params |
— | — | @@ -100,7 +76,9 @@ |
101 | 77 | $dbr = wfGetDB( DB_SLAVE ); |
102 | 78 | $rv = $dbr->select( |
103 | 79 | 'aft_article_field', |
104 | | - array( 'afi_name', 'afi_id', 'afi_data_type', 'afi_bucket_id' ) |
| 80 | + array( 'afi_name', 'afi_id', 'afi_data_type', 'afi_bucket_id' ), |
| 81 | + null, |
| 82 | + __METHOD__ |
105 | 83 | ); |
106 | 84 | return $rv; |
107 | 85 | } |
— | — | @@ -122,7 +100,9 @@ |
123 | 101 | $dbr = wfGetDB( DB_SLAVE ); |
124 | 102 | $rows = $dbr->select( |
125 | 103 | 'aft_article_field_option', |
126 | | - array( 'afo_option_id', 'afo_field_id', 'afo_name' ) |
| 104 | + array( 'afo_option_id', 'afo_field_id', 'afo_name' ), |
| 105 | + null, |
| 106 | + __METHOD__ |
127 | 107 | ); |
128 | 108 | $rv = array(); |
129 | 109 | foreach ( $rows as $row ) { |
— | — | @@ -130,6 +110,5 @@ |
131 | 111 | } |
132 | 112 | return $rv; |
133 | 113 | } |
134 | | - |
135 | 114 | } |
136 | 115 | |