r108073 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108072‎ | r108073 | r108074 >
Date:19:40, 4 January 2012
Author:bsitu
Status:resolved (Comments)
Tags:
Comment:
Adding mbfr_enotif_sent to track if a response notification email is sent
Modified paths:
  • /trunk/extensions/MoodBar/ApiFeedbackDashboardResponse.php (modified) (history)
  • /trunk/extensions/MoodBar/FeedbackResponseItem.php (modified) (history)
  • /trunk/extensions/MoodBar/MoodBar.hooks.php (modified) (history)
  • /trunk/extensions/MoodBar/include/MoodBarHTMLEmailNotification.php (modified) (history)
  • /trunk/extensions/MoodBar/include/MoodBarHTMLMailerJob.php (modified) (history)
  • /trunk/extensions/MoodBar/sql/mbfr_enotif_sent.sql (added) (history)
  • /trunk/extensions/MoodBar/sql/moodbar_feedback_response.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/include/MoodBarHTMLMailerJob.php
@@ -26,7 +26,8 @@
2727 $this->params['timestamp'],
2828 $this->params['feedback'],
2929 $this->params['response'],
30 - $this->params['type']
 30+ $this->params['type'],
 31+ $this->params['responseId']
3132 );
3233 return true;
3334 }
Index: trunk/extensions/MoodBar/include/MoodBarHTMLEmailNotification.php
@@ -37,8 +37,9 @@
3838 * @param $response string response text
3939 * @param $feedback integer feedback id
4040 * @param $type string moodbar type
 41+ * @param $responseId int response id
4142 */
42 - public function notifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type ) {
 43+ public function notifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type, $responseId ) {
4344 global $wgEnotifUseJobQ, $wgEnotifUserTalk;
4445
4546 if ( $title->getNamespace() != NS_USER_TALK || !$wgEnotifUserTalk ||
@@ -53,12 +54,13 @@
5455 'timestamp' => $timestamp,
5556 'response' => $response,
5657 'feedback' => $feedback,
57 - 'type' => $type
 58+ 'type' => $type,
 59+ 'responseId' => $responseId
5860 );
5961 $job = new MoodBarHTMLMailerJob( $title, $params );
6062 $job->insert();
6163 } else {
62 - $this->actuallyNotifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type );
 64+ $this->actuallyNotifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type, $responseId );
6365 }
6466 }
6567
@@ -74,8 +76,9 @@
7577 * @param $response string response text
7678 * @param $feedabck integer feedback id
7779 * @param $type string moodbar type
 80+ * @param $responseId int response id
7881 */
79 - public function actuallyNotifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type ) {
 82+ public function actuallyNotifyOnRespond( $editor, $title, $timestamp, $feedback, $response, $type, $responseId ) {
8083 global $wgEnotifUserTalk;
8184
8285 wfProfileIn( __METHOD__ );
@@ -94,6 +97,8 @@
9598
9699 if ( $wgEnotifUserTalk && $this->canSendUserTalkEmail( $editor, $title ) ) {
97100 $this->compose( $this->targetUser );
 101+ //update to mark the email as 'sent'
 102+ MBFeedbackResponseItem::update( $responseId, array( 'mbfr_enotif_sent' => 1 ) );
98103 }
99104
100105 wfProfileOut( __METHOD__ );
@@ -253,12 +258,14 @@
254259 $token = wfGenerateToken();
255260 $eventid = 'ext.feedbackDashboard@' . $wgMoodBarConfig['bucketConfig']['version'] .
256261 '-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() ) ) );
263270 }
264271 }
265272
Index: trunk/extensions/MoodBar/ApiFeedbackDashboardResponse.php
@@ -70,7 +70,8 @@
7171 $EMailNotif->notifyOnRespond( $wgUser, $talkPage, wfTimestampNow(),
7272 $item->getProperty('feedback'),
7373 $wgLang->truncate( $response, 250 ),
74 - $item->getProperty('feedbackitem')->getProperty( 'type' ) );
 74+ $item->getProperty('feedbackitem')->getProperty( 'type' ),
 75+ $id );
7576
7677 }
7778
Index: trunk/extensions/MoodBar/MoodBar.hooks.php
@@ -144,6 +144,7 @@
145145 "$dir/mbfr_timestamp_id_index.sql", true
146146 ) );
147147 $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" );
148149
149150 return true;
150151 }
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 @@
2020 mbfr_system_type varchar(64) binary NULL, -- Operating System
2121 mbfr_user_agent varchar(255) binary NULL, -- User-Agent header
2222 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
2425 ) /*$wgDBTableOptions*/;
2526
2627 CREATE INDEX /*i*/mbfr_mbf_id ON /*_*/moodbar_feedback_response (mbfr_mbf_id);
Index: trunk/extensions/MoodBar/FeedbackResponseItem.php
@@ -278,6 +278,25 @@
279279 }
280280 }
281281
 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+
282301 }
283302
284303 class MWFeedbackResponseItemPropertyException extends MWException {};

Follow-up revisions

RevisionCommit summaryAuthorDate
r108077followup to -r108073 - Adding Proto_canonical to wfexpandurl() and drop the u...bsitu19:58, 4 January 2012

Comments

#Comment by Catrope (talk | contribs)   19:45, 4 January 2012

Using wfExpandUrl() without setting the second parameter will default to PROTO_CURRENT, which means the URL will be HTTP or HTTPS depending on what protocol the user that submitted the response used, which may be weird for the user that receives the e-mail. Please use PROTO_CANONICAL as the second parameter to prevent this.

+		if ( empty( $values ) ) {

Don't use empty() here.

OK otherwise.

Status & tagging log