Index: trunk/extensions/MoodBar/include/MoodBarHTMLMailerJob.php |
— | — | @@ -25,7 +25,8 @@ |
26 | 26 | $this->title, |
27 | 27 | $this->params['timestamp'], |
28 | 28 | $this->params['feedback'], |
29 | | - $this->params['response'] |
| 29 | + $this->params['response'], |
| 30 | + $this->params['type'] |
30 | 31 | ); |
31 | 32 | return true; |
32 | 33 | } |
Index: trunk/extensions/MoodBar/include/MoodBarHTMLEmailNotification.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | class MoodBarHTMLEmailNotification { |
9 | 9 | |
10 | 10 | protected $to, $subject, $body, $replyto, $from; |
11 | | - protected $timestamp, $composed_common, $response, $feedback; |
| 11 | + protected $timestamp, $composed_common, $response, $feedback, $type; |
12 | 12 | protected $mime_boundary; |
13 | 13 | |
14 | 14 | /** |
— | — | @@ -36,8 +36,9 @@ |
37 | 37 | * @param $timestamp string Edit timestamp |
38 | 38 | * @param $response string response text |
39 | 39 | * @param $feedback integer feedback id |
| 40 | + * @param $type string moodbar type |
40 | 41 | */ |
41 | | - public function notifyOnRespond( $editor, $title, $timestamp, $feedback, $response ) { |
| 42 | + public function notifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type ) { |
42 | 43 | global $wgEnotifUseJobQ, $wgEnotifUserTalk; |
43 | 44 | |
44 | 45 | if ( $title->getNamespace() != NS_USER_TALK || !$wgEnotifUserTalk || |
— | — | @@ -51,12 +52,13 @@ |
52 | 53 | 'editorID' => $editor->getID(), |
53 | 54 | 'timestamp' => $timestamp, |
54 | 55 | 'response' => $response, |
55 | | - 'feedback' => $feedback |
| 56 | + 'feedback' => $feedback, |
| 57 | + 'type' => $type |
56 | 58 | ); |
57 | 59 | $job = new MoodBarHTMLMailerJob( $title, $params ); |
58 | 60 | $job->insert(); |
59 | 61 | } else { |
60 | | - $this->actuallyNotifyOnRespond( $editor, $title, $timestamp, $feedback, $response ); |
| 62 | + $this->actuallyNotifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type ); |
61 | 63 | } |
62 | 64 | } |
63 | 65 | |
— | — | @@ -71,8 +73,9 @@ |
72 | 74 | * @param $timestamp string Edit timestamp |
73 | 75 | * @param $response string response text |
74 | 76 | * @param $feedabck integer feedback id |
| 77 | + * @param $type string moodbar type |
75 | 78 | */ |
76 | | - public function actuallyNotifyOnRespond( $editor, $title, $timestamp, $feedback, $response ) { |
| 79 | + public function actuallyNotifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type ) { |
77 | 80 | global $wgEnotifUserTalk; |
78 | 81 | |
79 | 82 | wfProfileIn( __METHOD__ ); |
— | — | @@ -87,6 +90,7 @@ |
88 | 91 | $this->composed_common = false; |
89 | 92 | $this->response = $response; |
90 | 93 | $this->feedback = $feedback; |
| 94 | + $this->type = $type; |
91 | 95 | |
92 | 96 | if ( $wgEnotifUserTalk && $this->canSendUserTalkEmail( $editor, $title ) ) { |
93 | 97 | $this->compose( $this->targetUser ); |
— | — | @@ -147,28 +151,27 @@ |
148 | 152 | $this->subject = wfMessage( 'moodbar-enotif-subject' )->params( $pageEditor )->escaped(); |
149 | 153 | |
150 | 154 | // build the body |
151 | | - $messageCache = MessageCache::singleton(); |
152 | | - $targetUserName = $this->targetUser->getName(); |
153 | | - $FeedbackUrl = SpecialPage::getTitleFor( 'FeedbackDashboard', $this->feedback )->getPrefixedText(); |
154 | | - $editorTalkPage = $this->editor->getTalkPage()->getPrefixedText(); |
155 | | - $targetUserTalkPage = $this->targetUser->getTalkPage()->getCanonicalUrl(); |
| 155 | + $messageCache = MessageCache::singleton(); |
| 156 | + $targetUserName = $this->targetUser->getName(); |
| 157 | + $links = $this->buildEmailLink(); |
| 158 | + |
156 | 159 | //text version |
157 | 160 | $textBody = wfMessage( 'moodbar-enotif-body' )->params( $targetUserName, |
158 | | - $FeedbackUrl, |
159 | | - $editorTalkPage, |
| 161 | + $links['feedbackPageUrl'], |
| 162 | + $links['editorTalkPageUrl'], |
160 | 163 | $this->response, |
161 | | - $targetUserTalkPage, |
| 164 | + $links['targetUserTalkPageUrl'], |
162 | 165 | $pageEditor )->escaped(); |
163 | 166 | $textBody = MessageCache::singleton()->transform( $textBody, false, null, $this->title ); |
164 | 167 | |
165 | | - //html version, this ugly as we have to make wiki link clickable in emails |
| 168 | + //html version, this is a little bit ugly as we have to make wiki link clickable in emails |
166 | 169 | $action = $wgRequest->getVal( 'action' ); |
167 | 170 | $wgRequest->setVal( 'action', 'render' ); |
168 | 171 | $htmlBody = wfMsgExt( 'moodbar-enotif-body', array( 'parse' ), $targetUserName, |
169 | | - $FeedbackUrl, |
170 | | - $editorTalkPage, |
| 172 | + $links['feedbackPageUrl'], |
| 173 | + $links['editorTalkPageUrl'], |
171 | 174 | '<div style="margin-left:20px; margin-right:20px;">' .$this->response . '</div>', |
172 | | - $targetUserTalkPage, |
| 175 | + $links['targetUserTalkPageUrl'], |
173 | 176 | $pageEditor ); |
174 | 177 | $wgRequest->setVal( 'action', $action ); |
175 | 178 | |
— | — | @@ -227,7 +230,41 @@ |
228 | 231 | $to = new MailAddress( $user ); |
229 | 232 | |
230 | 233 | return UserMailer::send( $to, $this->from, $this->subject, $this->body, $this->replyto, $contentType = 'multipart/alternative; boundary=' . $this->mime_boundary ); |
231 | | - |
232 | 234 | } |
| 235 | + |
| 236 | + /** |
| 237 | + * Build the link for Email, add clickTracking if available |
| 238 | + * @return array - the links to be tracked in used in email |
| 239 | + */ |
| 240 | + protected function buildEmailLink() { |
| 241 | + $pageObject = array( 'feedbackPage' => SpecialPage::getTitleFor( 'FeedbackDashboard', $this->feedback ), |
| 242 | + 'editorTalkPage' => $this->editor->getTalkPage(), |
| 243 | + 'targetUserTalkPage' => $this->targetUser->getTalkPage() ); |
| 244 | + |
| 245 | + $links = array(); |
| 246 | + |
| 247 | + // if clickTracking is not enabled, return the full canonical url for email |
| 248 | + if ( !class_exists( 'ApiClickTracking' ) ) { |
| 249 | + foreach ( $pageObject AS $key => $value ) { |
| 250 | + $links[$key.'Url'] = $value->getCanonicalURL(); |
| 251 | + } |
| 252 | + } |
| 253 | + else { |
| 254 | + global $wgServer, $wgScriptPath, $wgMoodBarConfig; |
| 255 | + |
| 256 | + $token = wfGenerateToken(); |
| 257 | + $eventid = 'ext.feedbackDashboard@' . $wgMoodBarConfig['bucketConfig']['version'] . |
| 258 | + '-email-response_link-' . $this->type; |
| 259 | + $clickTrackingLink = $wgServer . $wgScriptPath . '/api.php?action=clicktracking&eventid=' . |
| 260 | + wfUrlencode( $eventid ) . '&token=' . wfUrlencode( $token ); |
| 261 | + |
| 262 | + foreach ( $pageObject AS $key => $value ) { |
| 263 | + $links[$key.'Url'] = $clickTrackingLink . '&redirectto=' . wfUrlencode( $value->getLinkURL() ) . |
| 264 | + '&namespacenumber=' . wfUrlencode( $value->getNamespace() ); |
| 265 | + } |
| 266 | + } |
| 267 | + |
| 268 | + return $links; |
| 269 | + } |
233 | 270 | |
234 | | -} |
| 271 | +} |
\ No newline at end of file |
Index: trunk/extensions/MoodBar/MoodBar.i18n.php |
— | — | @@ -166,7 +166,7 @@ |
167 | 167 | |
168 | 168 | 'moodbar-enotif-body' => 'Hello $1! |
169 | 169 | |
170 | | -Welcome to {{SITENAME}}, and thanks for your [[$2|feedback]]. Another {{SITENAME}} user, [[$3|$6]], wrote the following response: |
| 170 | +Welcome to {{SITENAME}}, and thanks for your [$2 feedback]. Another {{SITENAME}} user, [$3 $6], wrote the following response: |
171 | 171 | |
172 | 172 | $4 |
173 | 173 | |
Index: trunk/extensions/MoodBar/ApiFeedbackDashboardResponse.php |
— | — | @@ -67,7 +67,7 @@ |
68 | 68 | global $wgLang; |
69 | 69 | |
70 | 70 | $EMailNotif = new MoodBarHTMLEmailNotification(); |
71 | | - $EMailNotif->notifyOnRespond( $wgUser, $talkPage, wfTimestampNow(), $item->getProperty('feedback'), $wgLang->truncate( $response, 250 ) ); |
| 71 | + $EMailNotif->notifyOnRespond( $wgUser, $talkPage, wfTimestampNow(), $item->getProperty('feedback'), $wgLang->truncate( $response, 250 ), $item->getProperty('feedbackitem')->getProperty( 'type' ) ); |
72 | 72 | |
73 | 73 | } |
74 | 74 | |