Index: trunk/extensions/MoodBar/include/MoodBarHTMLMailerJob.php |
— | — | @@ -26,7 +26,8 @@ |
27 | 27 | $this->params['timestamp'], |
28 | 28 | $this->params['feedback'], |
29 | 29 | $this->params['response'], |
30 | | - $this->params['type'] |
| 30 | + $this->params['type'], |
| 31 | + $this->params['responseId'] |
31 | 32 | ); |
32 | 33 | return true; |
33 | 34 | } |
Index: trunk/extensions/MoodBar/include/MoodBarHTMLEmailNotification.php |
— | — | @@ -37,8 +37,9 @@ |
38 | 38 | * @param $response string response text |
39 | 39 | * @param $feedback integer feedback id |
40 | 40 | * @param $type string moodbar type |
| 41 | + * @param $responseId int response id |
41 | 42 | */ |
42 | | - public function notifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type ) { |
| 43 | + public function notifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type, $responseId ) { |
43 | 44 | global $wgEnotifUseJobQ, $wgEnotifUserTalk; |
44 | 45 | |
45 | 46 | if ( $title->getNamespace() != NS_USER_TALK || !$wgEnotifUserTalk || |
— | — | @@ -53,12 +54,13 @@ |
54 | 55 | 'timestamp' => $timestamp, |
55 | 56 | 'response' => $response, |
56 | 57 | 'feedback' => $feedback, |
57 | | - 'type' => $type |
| 58 | + 'type' => $type, |
| 59 | + 'responseId' => $responseId |
58 | 60 | ); |
59 | 61 | $job = new MoodBarHTMLMailerJob( $title, $params ); |
60 | 62 | $job->insert(); |
61 | 63 | } else { |
62 | | - $this->actuallyNotifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type ); |
| 64 | + $this->actuallyNotifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type, $responseId ); |
63 | 65 | } |
64 | 66 | } |
65 | 67 | |
— | — | @@ -74,8 +76,9 @@ |
75 | 77 | * @param $response string response text |
76 | 78 | * @param $feedabck integer feedback id |
77 | 79 | * @param $type string moodbar type |
| 80 | + * @param $responseId int response id |
78 | 81 | */ |
79 | | - public function actuallyNotifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type ) { |
| 82 | + public function actuallyNotifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type, $responseId ) { |
80 | 83 | global $wgEnotifUserTalk; |
81 | 84 | |
82 | 85 | wfProfileIn( __METHOD__ ); |
— | — | @@ -94,6 +97,8 @@ |
95 | 98 | |
96 | 99 | if ( $wgEnotifUserTalk && $this->canSendUserTalkEmail( $editor, $title ) ) { |
97 | 100 | $this->compose( $this->targetUser ); |
| 101 | + //update to mark the email as 'sent' |
| 102 | + MBFeedbackResponseItem::update( $responseId, array( 'mbfr_enotif_sent' => 1 ) ); |
98 | 103 | } |
99 | 104 | |
100 | 105 | wfProfileOut( __METHOD__ ); |
— | — | @@ -253,12 +258,14 @@ |
254 | 259 | $token = wfGenerateToken(); |
255 | 260 | $eventid = 'ext.feedbackDashboard@' . $wgMoodBarConfig['bucketConfig']['version'] . |
256 | 261 | '-email-response_link-' . $this->type; |
257 | | - $clickTrackingLink = $wgServer . $wgScriptPath . '/api.php?action=clicktracking&eventid=' . |
258 | | - wfUrlencode( $eventid ) . '&token=' . wfUrlencode( $token ); |
259 | | - |
260 | | - foreach ( $pageObject as $key => $value ) { |
261 | | - $links[$key.'Url'] = $clickTrackingLink . '&redirectto=' . wfUrlencode( $value->getLinkURL() ) . |
262 | | - '&namespacenumber=' . wfUrlencode( $value->getNamespace() ); |
| 262 | + |
| 263 | + $clickTrackingLink = wfAppendQuery( wfScript( 'api' ), |
| 264 | + array( 'action' => 'clicktracking', 'eventid' => $eventid, 'token' => $token ) ); |
| 265 | + |
| 266 | + foreach ( $pageObject as $key => $value ) { |
| 267 | + $links[$key.'Url'] = wfExpandUrl( wfAppendQuery( $clickTrackingLink, |
| 268 | + array( 'redirectto' => $value->getLinkURL(), |
| 269 | + 'namespacenumber' => $value->getNamespace() ) ) ); |
263 | 270 | } |
264 | 271 | } |
265 | 272 | |
Index: trunk/extensions/MoodBar/ApiFeedbackDashboardResponse.php |
— | — | @@ -70,7 +70,8 @@ |
71 | 71 | $EMailNotif->notifyOnRespond( $wgUser, $talkPage, wfTimestampNow(), |
72 | 72 | $item->getProperty('feedback'), |
73 | 73 | $wgLang->truncate( $response, 250 ), |
74 | | - $item->getProperty('feedbackitem')->getProperty( 'type' ) ); |
| 74 | + $item->getProperty('feedbackitem')->getProperty( 'type' ), |
| 75 | + $id ); |
75 | 76 | |
76 | 77 | } |
77 | 78 | |
Index: trunk/extensions/MoodBar/MoodBar.hooks.php |
— | — | @@ -144,6 +144,7 @@ |
145 | 145 | "$dir/mbfr_timestamp_id_index.sql", true |
146 | 146 | ) ); |
147 | 147 | $updater->addExtensionIndex( 'moodbar_feedback_response', 'mbfr_mbf_mbfr_id', "$dir/mbfr_mbf_mbfr_id_index.sql" ); |
| 148 | + $updater->addExtensionField( 'moodbar_feedback_response', 'mbfr_enotif_sent', "$dir/mbfr_enotif_sent.sql" ); |
148 | 149 | |
149 | 150 | return true; |
150 | 151 | } |
Index: trunk/extensions/MoodBar/sql/mbfr_enotif_sent.sql |
— | — | @@ -0,0 +1,2 @@ |
| 2 | +-- Adds mbfr_enotif_sent |
| 3 | +ALTER TABLE /*_*/moodbar_feedback_response ADD COLUMN mbfr_enotif_sent tinyint unsigned not null default 0; |
Index: trunk/extensions/MoodBar/sql/moodbar_feedback_response.sql |
— | — | @@ -19,7 +19,8 @@ |
20 | 20 | mbfr_system_type varchar(64) binary NULL, -- Operating System |
21 | 21 | mbfr_user_agent varchar(255) binary NULL, -- User-Agent header |
22 | 22 | mbfr_locale varchar(32) binary NULL, -- The locale of the user's browser |
23 | | - mbfr_editing tinyint unsigned NOT NULL -- Whether or not the user was editing |
| 23 | + mbfr_editing tinyint unsigned NOT NULL, -- Whether or not the user was editing |
| 24 | + mbfr_enotif_sent tinyint unsigned not null default 0 -- Whether or not a notification email was sent |
24 | 25 | ) /*$wgDBTableOptions*/; |
25 | 26 | |
26 | 27 | CREATE INDEX /*i*/mbfr_mbf_id ON /*_*/moodbar_feedback_response (mbfr_mbf_id); |
Index: trunk/extensions/MoodBar/FeedbackResponseItem.php |
— | — | @@ -278,6 +278,25 @@ |
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
| 282 | + /** |
| 283 | + * Update response item based on the primary key $mbfr_id |
| 284 | + * @param $mbfr_id int - id representing a unique response item |
| 285 | + * @param $values array - key -> database field, value -> the new value |
| 286 | + */ |
| 287 | + public static function update( $mbfr_id, $values ) { |
| 288 | + |
| 289 | + if ( empty( $values ) ) { |
| 290 | + return; |
| 291 | + } |
| 292 | + |
| 293 | + $dbw = wfGetDB( DB_MASTER ); |
| 294 | + |
| 295 | + $dbw->update( 'moodbar_feedback_response', |
| 296 | + $values, |
| 297 | + array( 'mbfr_id' => $mbfr_id ), |
| 298 | + __METHOD__ ); |
| 299 | + } |
| 300 | + |
282 | 301 | } |
283 | 302 | |
284 | 303 | class MWFeedbackResponseItemPropertyException extends MWException {}; |