Index: branches/wmf/1.18wmf1/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js |
— | — | @@ -1030,7 +1030,10 @@ |
1031 | 1031 | */ |
1032 | 1032 | getFormData: function () { |
1033 | 1033 | var data = {}; |
1034 | | - data.rating = $.articleFeedbackv5.find( '.articleFeedbackv5-rating input:hidden' ).val(); |
| 1034 | + var rating = $.articleFeedbackv5.find( '.articleFeedbackv5-rating input:hidden' ).val(); |
| 1035 | + if ( '0' != rating ) { |
| 1036 | + data.rating = rating; |
| 1037 | + } |
1035 | 1038 | data.comment = $.articleFeedbackv5.find( '.articleFeedbackv5-comment textarea' ).val(); |
1036 | 1039 | if ( data.comment == mw.msg( 'articlefeedbackv5-bucket3-comment-default' ) ) { |
1037 | 1040 | data.comment = ''; |
— | — | @@ -1723,7 +1726,10 @@ |
1724 | 1727 | var info = $.articleFeedbackv5.currentBucket().ratingInfo; |
1725 | 1728 | for ( var i = 0; i < info.length; i++ ) { |
1726 | 1729 | var key = info[i]; |
1727 | | - data[key] = $.articleFeedbackv5.find( 'input[name="' + key + '"]' ).val(); |
| 1730 | + var val = $.articleFeedbackv5.find( 'input[name="' + key + '"]' ).val(); |
| 1731 | + if ( '0' != val ) { |
| 1732 | + data[key] = val; |
| 1733 | + } |
1728 | 1734 | } |
1729 | 1735 | $.articleFeedbackv5.find( '.articleFeedbackv5-expertise input:checked' ).each( function () { |
1730 | 1736 | data['expertise-' + $( this ).val()] = 1; |
— | — | @@ -2547,7 +2553,7 @@ |
2548 | 2554 | } else { |
2549 | 2555 | var msg; |
2550 | 2556 | if ( 'error' in data ) { |
2551 | | - msg = data.error; |
| 2557 | + msg = mw.msg( data.error ); |
2552 | 2558 | } else { |
2553 | 2559 | msg = { info: mw.msg( 'articlefeedbackv5-error-unknown' ) }; |
2554 | 2560 | } |
— | — | @@ -2761,12 +2767,17 @@ |
2762 | 2768 | */ |
2763 | 2769 | $.articleFeedbackv5.markFormErrors = function ( errors ) { |
2764 | 2770 | if ( '_api' in errors ) { |
2765 | | - if ( $.articleFeedbackv5.debug ) { |
2766 | | - $.articleFeedbackv5.markTopError( errors._api.info ); |
| 2771 | + if ( typeof errors._api == 'object' ) { |
| 2772 | + if ( 'info' in errors._api ) { |
| 2773 | + mw.log( mw.msg( errors._api.info ) ); |
| 2774 | + } else { |
| 2775 | + mw.log( mw.msg( 'articlefeedbackv5-error-submit' ) ); |
| 2776 | + } |
| 2777 | + $.articleFeedbackv5.markTopError( mw.msg( 'articlefeedbackv5-error-submit' ) ); |
2767 | 2778 | } else { |
2768 | | - mw.log( mw.msg( 'articlefeedbackv5-error-submit' ) ); |
| 2779 | + mw.log( mw.msg( errors._api ) ); |
| 2780 | + $.articleFeedbackv5.markTopError( errors._api ); |
2769 | 2781 | } |
2770 | | - mw.log( mw.msg( errors._api.info ) ); |
2771 | 2782 | } else { |
2772 | 2783 | mw.log( mw.msg( 'articlefeedbackv5-error-validation' ) ); |
2773 | 2784 | if ( 'nofeedback' in errors ) { |
Index: branches/wmf/1.18wmf1/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php |
— | — | @@ -41,7 +41,6 @@ |
42 | 42 | $this->dieUsage( 'ArticleFeedback is not enabled on this page', 'invalidpage' ); |
43 | 43 | } |
44 | 44 | |
45 | | - $feedbackId = $this->newFeedback( $params ); |
46 | 45 | $dbr = wfGetDB( DB_SLAVE ); |
47 | 46 | $pageId = $params['pageid']; |
48 | 47 | $bucket = $params['bucket']; |
— | — | @@ -68,7 +67,6 @@ |
69 | 68 | } |
70 | 69 | if ( $this->validateParam( $value, $type, $field['afi_id'] ) ) { |
71 | 70 | $data = array( |
72 | | - 'aa_feedback_id' => $feedbackId, |
73 | 71 | 'aa_field_id' => $field['afi_id'], |
74 | 72 | ); |
75 | 73 | foreach ( array( 'rating', 'text', 'boolean', 'option_id' ) as $t ) { |
— | — | @@ -88,8 +86,10 @@ |
89 | 87 | ); |
90 | 88 | return; |
91 | 89 | } |
| 90 | + $ratingIds = $this->saveUserRatings( $user_answers, $bucket, $params ); |
| 91 | + $ctaId = $ratingIds['cta_id']; |
| 92 | + $feedbackId = $ratingIds['feedback_id']; |
92 | 93 | |
93 | | - $ctaId = $this->saveUserRatings( $user_answers, $feedbackId, $bucket ); |
94 | 94 | $this->updateRollupTables( $pageId, $revisionId, $user_answers ); |
95 | 95 | |
96 | 96 | if ( $params['email'] ) { |
— | — | @@ -116,9 +116,9 @@ |
117 | 117 | null, |
118 | 118 | $this->getModuleName(), |
119 | 119 | array( |
120 | | - 'result' => 'Success', |
| 120 | + 'result' => 'Success', |
121 | 121 | 'feedback_id' => $feedbackId, |
122 | | - 'cta_id' => $ctaId, |
| 122 | + 'cta_id' => $ctaId, |
123 | 123 | ) |
124 | 124 | ); |
125 | 125 | } |
— | — | @@ -435,14 +435,18 @@ |
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
439 | | - * Creates a new feedback row and returns the id |
| 439 | + * Creates a new feedback record and inserts the user's rating |
| 440 | + * for a specific revision |
440 | 441 | * |
441 | | - * @param $params array the parameters |
442 | | - * @return int the feedback id |
| 442 | + * @param array $data the data |
| 443 | + * @param int $feedbackId the feedback id |
| 444 | + * @param int $bucket the bucket id |
| 445 | + * @return int the cta id |
443 | 446 | */ |
444 | | - public function newFeedback( $params ) { |
| 447 | + private function saveUserRatings( $data, $bucket, $params ) { |
445 | 448 | global $wgUser; |
446 | 449 | $dbw = wfGetDB( DB_MASTER ); |
| 450 | + $ctaId = $this->getCTAId( $data, $bucket ); |
447 | 451 | $revId = $params['revid']; |
448 | 452 | $bucket = $params['bucket']; |
449 | 453 | $link = $params['link']; |
— | — | @@ -473,6 +477,8 @@ |
474 | 478 | $revId = $title->getLatestRevID(); |
475 | 479 | } |
476 | 480 | |
| 481 | + $dbw->begin(); |
| 482 | + |
477 | 483 | $dbw->insert( 'aft_article_feedback', array( |
478 | 484 | 'af_page_id' => $params['pageid'], |
479 | 485 | 'af_revision_id' => $revId, |
— | — | @@ -484,22 +490,12 @@ |
485 | 491 | 'af_link_id' => $link, |
486 | 492 | ) ); |
487 | 493 | |
488 | | - return $dbw->insertID(); |
489 | | - } |
| 494 | + $feedbackId = $dbw->insertID(); |
490 | 495 | |
491 | | - /** |
492 | | - * Inserts the user's rating for a specific revision |
493 | | - * |
494 | | - * @param array $data the data |
495 | | - * @param int $feedbackId the feedback id |
496 | | - * @param int $bucket the bucket id |
497 | | - * @return int the cta id |
498 | | - */ |
499 | | - private function saveUserRatings( $data, $feedbackId, $bucket ) { |
500 | | - $dbw = wfGetDB( DB_MASTER ); |
501 | | - $ctaId = $this->getCTAId( $data, $bucket ); |
| 496 | + foreach($data as $key => $item) { |
| 497 | + $data[$key]['aa_feedback_id'] = $feedbackId; |
| 498 | + } |
502 | 499 | |
503 | | - $dbw->begin(); |
504 | 500 | $dbw->insert( 'aft_article_answer', $data, __METHOD__ ); |
505 | 501 | $dbw->update( |
506 | 502 | 'aft_article_feedback', |
— | — | @@ -509,7 +505,10 @@ |
510 | 506 | ); |
511 | 507 | $dbw->commit(); |
512 | 508 | |
513 | | - return $ctaId; |
| 509 | + return array( |
| 510 | + 'cta_id' => ($ctaId ? $ctaId : 0), |
| 511 | + 'feedback_id' => ($feedbackId ? $feedbackId : 0) |
| 512 | + ); |
514 | 513 | } |
515 | 514 | |
516 | 515 | /** |
Property changes on: branches/wmf/1.18wmf1/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
517 | 516 | Merged /trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php:r108239,108245,108247,108250,108269,108280 |
Property changes on: branches/wmf/1.18wmf1/extensions/ArticleFeedbackv5 |
___________________________________________________________________ |
Modified: svn:mergeinfo |
518 | 517 | Merged /trunk/extensions/ArticleFeedbackv5:r108239,108245,108247,108250,108269,108280 |