Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php |
— | — | @@ -44,6 +44,11 @@ |
45 | 45 | $pageId = $params['pageid']; |
46 | 46 | $bucket = $params['bucket']; |
47 | 47 | $revisionId = $params['revid']; |
| 48 | + $email_data = array( |
| 49 | + 'ratingData' => array(), |
| 50 | + 'pageID' => $pageId, |
| 51 | + 'bucketId' => $bucket |
| 52 | + ); |
48 | 53 | |
49 | 54 | $user_answers = array(); |
50 | 55 | $fields = ApiArticleFeedbackv5Utils::getFields(); |
— | — | @@ -66,6 +71,7 @@ |
67 | 72 | $data["aa_response_$t"] = $t == $type ? $value : null; |
68 | 73 | } |
69 | 74 | $user_answers[] = $data; |
| 75 | + $email_data['ratingData'][$field->afi_name] = $value; |
70 | 76 | } else { |
71 | 77 | // TODO: ERROR |
72 | 78 | } |
— | — | @@ -75,6 +81,12 @@ |
76 | 82 | $ctaId = $this->saveUserRatings( $user_answers, $feedbackId, $bucket ); |
77 | 83 | $this->updateRollupTables( $pageId, $revisionId ); |
78 | 84 | |
| 85 | + if( $params['email'] ) { |
| 86 | + $this->captureEmail ( $params['email'], json_encode( |
| 87 | + $email_data |
| 88 | + ) ); |
| 89 | + } |
| 90 | + |
79 | 91 | $squidUpdate = new SquidUpdate( array( |
80 | 92 | wfAppendQuery( wfScript( 'api' ), array( |
81 | 93 | 'action' => 'query', |
— | — | @@ -102,6 +114,19 @@ |
103 | 115 | ); |
104 | 116 | } |
105 | 117 | |
| 118 | + protected function captureEmail( $email, $json ) { |
| 119 | + global $wgScriptPath, $wgServer; |
| 120 | + $url = "$wgServer$wgScriptPath/api.php"; |
| 121 | + $body = "email=$email&info=$json&action=emailcapture&format=json"; |
| 122 | + $c = curl_init ( $url ); |
| 123 | + curl_setopt( $c, CURLOPT_POST, true ); |
| 124 | + curl_setopt( $c, CURLOPT_POSTFIELDS, $body ); |
| 125 | + curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); |
| 126 | + |
| 127 | + $rv = curl_exec( $c ); |
| 128 | + curl_close( $c ); |
| 129 | + } |
| 130 | + |
106 | 131 | /** |
107 | 132 | * Validates a value against a field type |
108 | 133 | * |
— | — | @@ -382,6 +407,11 @@ |
383 | 408 | ApiBase::PARAM_ISMULTI => false, |
384 | 409 | ApiBase::PARAM_MIN => 0 |
385 | 410 | ), |
| 411 | + 'email' => array( |
| 412 | + ApiBase::PARAM_TYPE => 'string', |
| 413 | + ApiBase::PARAM_REQUIRED => false, |
| 414 | + ApiBase::PARAM_ISMULTI => false, |
| 415 | + ) |
386 | 416 | ); |
387 | 417 | |
388 | 418 | $fields = ApiArticleFeedbackv5Utils::getFields(); |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php |
— | — | @@ -29,11 +29,11 @@ |
30 | 30 | $params = $this->extractRequestParams(); |
31 | 31 | $html = ''; |
32 | 32 | $result = $this->getResult(); |
33 | | - $pageId = $params['pageid']; |
| 33 | + $pageId = $params['pageid']; |
34 | 34 | $length = 0; |
35 | 35 | $count = $this->fetchFeedbackCount( |
36 | 36 | $params['pageid'], $params['filter'] ); |
37 | | - $feedback = $this->fetchFeedback( |
| 37 | + $feedback = $this->fetchFeedback( |
38 | 38 | $params['pageid'], |
39 | 39 | $params['filter'], |
40 | 40 | $params['sort'], |
— | — | @@ -41,14 +41,14 @@ |
42 | 42 | $params['offset'] |
43 | 43 | ); |
44 | 44 | |
45 | | - foreach ( $feedback as $record ) { |
| 45 | + foreach ( $feedback as $record ) { |
46 | 46 | $html .= $this->renderFeedback($record); |
47 | 47 | $length++; |
48 | | - } |
| 48 | + } |
49 | 49 | |
50 | | - $result->addValue( 'data', 'length', $length ); |
51 | | - $result->addValue( 'data', 'count', $count ); |
52 | | - $result->addValue( 'data', 'feedback', $html ); |
| 50 | + $result->addValue( 'data', 'length', $length ); |
| 51 | + $result->addValue( 'data', 'count', $count ); |
| 52 | + $result->addValue( 'data', 'feedback', $html ); |
53 | 53 | } |
54 | 54 | |
55 | 55 | public function fetchOverallRating( $pageId ) { |
— | — | @@ -85,10 +85,10 @@ |
86 | 86 | $where['af_page_id'] = $pageId; |
87 | 87 | |
88 | 88 | return $dbr->selectField( |
89 | | - array( 'aft_article_feedback' ), |
90 | | - array( 'COUNT(*) AS count' ), |
| 89 | + array( 'aft_article_feedback' ), |
| 90 | + array( 'COUNT(*) AS count' ), |
91 | 91 | $where |
92 | | - ); |
| 92 | + ); |
93 | 93 | } |
94 | 94 | |
95 | 95 | public function fetchFeedback( $pageId, |
— | — | @@ -340,7 +340,7 @@ |
341 | 341 | * |
342 | 342 | * @return array the example as the first element in an array |
343 | 343 | */ |
344 | | - protected function getExamples() { |
| 344 | + public function getExamples() { |
345 | 345 | return array( |
346 | 346 | 'api.php?action=query&list=articlefeedbackv5-view-feedback&afpageid=1', |
347 | 347 | ); |