EBernhardson (WMF) has submitted this change and it was merged.
Change subject: Add primary/secondary link, email, bundling to post reply
......................................................................
Add primary/secondary link, email, bundling to post reply
Change-Id: If0e0a8dcf56b11d408f914d63869d6666f7701ba
---
M Flow.i18n.php
M Flow.php
M Hooks.php
M includes/NotificationFormatter.php
4 files changed, 125 insertions(+), 5 deletions(-)
Approvals:
Siebrand: Looks good to me, but someone else must approve
Matthias Mullie: Looks good to me, but someone else must approve
EBernhardson (WMF): Looks good to me, approved
jenkins-bot: Verified
diff --git a/Flow.i18n.php b/Flow.i18n.php
index 991c589..76babc4 100644
--- a/Flow.i18n.php
+++ b/Flow.i18n.php
@@ -81,10 +81,25 @@
'flow-paging-fwd' => 'Older topics',
'flow-last-modified' => 'Last modified about $1',
- 'flow-notification-reply' => '$1 {{GENDER:$1|replied}} to your [$5
post] in $2 on [[$3|$4]].',
+ // Notification message
+ 'flow-notification-reply' => '$1 {{GENDER:$1|replied}} to your [$5
post] in $2 on "$4".',
+ 'flow-notification-reply-bundle' => '$1 and $5
{{PLURAL:$6|other|others}} {{GENDER:$1|replied}} to your [$4 post] in $2 on
"$3".',
'flow-notification-edit' => '$1 {{GENDER:$1|edited}} your [$5 post] in
$2 on [[$3|$4]].',
'flow-notification-newtopic' => '$1 {{GENDER:$1|created}} a [$5 new
topic] on [[$2|$3]]: $4.',
- 'flow-notification-rename' => '$1 {{GENDER:$1|changed}} the title of
[$2 $3] to "$4" on [[$5|$6]].'
+ 'flow-notification-rename' => '$1 {{GENDER:$1|changed}} the title of
[$2 $3] to "$4" on [[$5|$6]].',
+
+ // Notification primary links and secondary links
+ 'flow-notification-link-text-view-post' => 'View post',
+ 'flow-notification-link-text-view-board' => 'View board',
+
+ // Notification Email messages
+ 'flow-notification-reply-email-subject' => '$1 {{GENDER:$1|replied}} to
your post',
+ 'flow-notification-reply-email-batch-body' => '$1 {{GENDER:$1|replied}}
to your post in $2 on "$3"',
+ 'flow-notification-reply-email-batch-bundle-body' => '$1 and $4
{{PLURAL:$5|other|others}} {{GENDER:$1|replied}} to your post in $2 on "$3"',
+
+ // Notification preference
+ 'echo-category-title-flow-discussion' =>
'{{PLURAL:$1|Discussion|Discussions}}',
+ 'echo-pref-tooltip-flow-discussion' => 'Notify me when actions related
to me occur in the disucssion board.',
);
/** Message documentation (Message documentation)
@@ -239,10 +254,17 @@
'flow-notification-reply' => 'Notification text for when a user
receives a reply. Parameters:
* $1 - Username of the person who replied
* $2 - Title of the topic
-* $3 - Title for the Flow board
+* $3 - Title for the Flow board, this parameter is not used for the message at
this moment
* $4 - Title for the page that the Flow board is attached to
* $5 - Permanent URL for the post
{{Related|Flow-notification}}',
+ 'flow-notification-reply-bundle' => 'Notification text for when a user
receives replies from multiple users on the same post/topic. Params:
+* $1 - Username of the person who replied
+* $2 - Title of the topic
+* $3 - Title for the page that the Flow board is attached to
+* $4 - Permantent URL for the post
+* $5 - the count of other action performers, could be number or
{{msg-mw|Echo-notification-count}}. e.g. 7 others or 99+ others
+* $6 - a number used for plural support',
'flow-notification-edit' => "Notification text for when a user's post
is edited. Parameters:
* $1 - Username of the person who edited the post
* $2 - Title of the topic
@@ -265,6 +287,24 @@
* $5 - title for the Flow board
* $6 - title for the page that the Flow board is attached to
{{Related|Flow-notification}}',
+ 'flow-notification-link-text-view-post' => 'Label for button that links
to a flow post.',
+ 'flow-notification-link-text-view-board' => 'Label for button that
links to a flow discussion board.',
+ 'flow-notification-reply-email-subject' => 'Email notification subject
when a user receives a reply. Parameters:
+* $1 - Username of the person who replied',
+ 'flow-notification-reply-email-batch-body' => 'Email notification body
when a user receives a reply, this message is used in both single email and
email digest. Parameters:
+* $1 - Username of the person who replied
+* $2 - Title of the topic
+* $3 - Title for the page that the Flow board is attached to',
+ 'flow-notification-reply-email-batch-bundle-body' => 'Email
notification body when a user receives reply from multiple users, this message
is used in both single email and email digest. Parameters:
+* $1 - Username of the person who replied
+* $2 - Title of the topic
+* $3 - Title for the page that the Flow board is attached to
+* $4 - the count of other action performers, could be number or
{{msg-mw|Echo-notification-count}}. e.g. 7 others or 99+ others
+* $5 - a number used for plural support',
+ 'echo-category-title-flow-discussion' => 'This is a short title for
notification category. Parameters:
+* $1 - number of mentions, for PLURAL support
+{{Related|Echo-category-title}}',
+ 'echo-pref-tooltip-flow-discussion' => 'This is a short description of
the flow-discussion notification category.',
);
/** Asturian (asturianu)
diff --git a/Flow.php b/Flow.php
index 4a750a4..6bbad0c 100755
--- a/Flow.php
+++ b/Flow.php
@@ -184,3 +184,7 @@
$wgFlowDefaultWorkflow = 'discussion';
$wgFlowDefaultLimit = 5;
$wgFlowMaxLimit = 50;
+
+// Echo notification subscription preference
+$wgDefaultUserOptions['echo-subscriptions-web-flow-discussion'] = true;
+$wgDefaultUserOptions['echo-subscriptions-email-flow-discussion'] = true;
diff --git a/Hooks.php b/Hooks.php
index 24faa41..11927af 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -8,10 +8,11 @@
* from $wgExtensionFunctions
*/
public static function initFlowExtension() {
- global $wgEchoNotifications, $wgHooks, $wgEchoNotificationIcons;
+ global $wgEchoNotifications, $wgHooks,
$wgEchoNotificationIcons, $wgEchoNotificationCategories;
if ( isset( $wgEchoNotifications ) ) {
$wgHooks['EchoGetDefaultNotifiedUsers'][] =
'FlowHooks::getDefaultNotifiedUsers';
+ $wgHooks['EchoGetBundleRules'][] =
'FlowHooks::onEchoGetBundleRules';
$notificationTemplate = array(
'category' => 'flow-discussion',
@@ -27,8 +28,19 @@
) + $notificationTemplate;
$wgEchoNotifications['flow-post-reply'] = array(
+ 'primary-link' => array( 'message' =>
'flow-notification-link-text-view-post', 'destination' => 'flow-post' ),
+ 'secondary-link' => array( 'message' =>
'flow-notification-link-text-view-board', 'destination' => 'flow-board' ),
'title-message' => 'flow-notification-reply',
'title-params' => array( 'agent', 'subject',
'flow-title', 'title', 'post-permalink' ),
+ 'bundle' => array( 'web' => true, 'email' =>
false ),
+ 'bundle-message' =>
'flow-notification-reply-bundle',
+ 'bundle-params' => array( 'agent', 'subject',
'title', 'post-permalink', 'agent-other-display', 'agent-other-count' ),
+ 'email-subject-message' =>
'flow-notification-reply-email-subject',
+ 'email-subject-params' => array( 'agent' ),
+ 'email-body-batch-message' =>
'flow-notification-reply-email-batch-body',
+ 'email-body-batch-params' => array( 'agent',
'subject', 'title' ),
+ 'email-body-batch-bundle-message' =>
'flow-notification-reply-email-batch-bundle-body',
+ 'email-body-batch-bundle-params' => array(
'agent', 'subject', 'title', 'agent-other-display', 'agent-other-count' ),
'payload' => array( 'comment-text' ),
) + $notificationTemplate;
@@ -53,7 +65,8 @@
);
$wgEchoNotificationCategories['flow-discussion'] =
array(
- // 'echo-pref'
+ 'priority' => 3,
+ 'tooltip' =>
'echo-pref-tooltip-flow-discussion',
);
}
}
@@ -164,6 +177,32 @@
}
/**
+ * Handler for EchoGetBundleRule hook, which defines the bundle rule
for each notification
+ * @param $event EchoEvent
+ * @param $bundleString string Determines how the notification should
be bundled
+ */
+ public static function onEchoGetBundleRules( $event, &$bundleString ) {
+ switch ( $event->getType() ) {
+ case 'flow-post-reply':
+ $extra = $event->getExtra();
+
+ if ( isset( $extra['reply-to'] ) ) {
+ $postId = $extra['reply-to'];
+ } elseif ( isset( $extra['post-id'] ) ) {
+ $postId = $extra['post-id'];
+ } else {
+ $postId = null;
+ }
+
+ if ( $postId ) {
+ $bundleString = 'flow-post-reply-' .
$postId->getHex();
+ }
+ break;
+ }
+ return true;
+ }
+
+ /**
* Add token type "flow", to generate edit tokens for Flow via
* api.php?action=tokens&type=flow
*
diff --git a/includes/NotificationFormatter.php
b/includes/NotificationFormatter.php
index 5fb5074..8a375eb 100644
--- a/includes/NotificationFormatter.php
+++ b/includes/NotificationFormatter.php
@@ -64,4 +64,41 @@
parent::processParam( $event, $param, $message, $user );
}
}
+
+ /**
+ * Helper function for getLink()
+ *
+ * @param EchoEvent $event
+ * @param User $user The user receiving the notification
+ * @param String $destination The destination type for the link
+ * @return Array including target and query parameters
+ */
+ protected function getLinkParams( $event, $user, $destination ) {
+ $target = null;
+ $query = array();
+ $title = $event->getTitle();
+ // Set up link parameters based on the destination (or pass to
parent)
+ switch ( $destination ) {
+ case 'flow-post':
+ $post = $event->getExtraParam( 'post-id' );
+ $flow = $event->getExtraParam(
'topic-workflow' );
+ if ( $post && $flow && $title ) {
+ $target = SpecialPage::getTitleFor(
'Flow', $title );
+ $query = array(
+ 'topic[postId]' =>
$post->getHex(),
+ 'workflow' => $flow->getHex(),
+ 'action' => 'view'
+ );
+ }
+ break;
+ case 'flow-board':
+ if ( $title ) {
+ $target = SpecialPage::getTitleFor(
'Flow', $title );
+ }
+ break;
+ default:
+ return parent::getLinkParams( $event, $user,
$destination );
+ }
+ return array( $target, $query );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/86064
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If0e0a8dcf56b11d408f914d63869d6666f7701ba
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: EBernhardson (WMF) <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits