Adding the first step in order to enable the visualization of the Article Reminder feature.

Includes feature flag, presentation model.
Temporarly hooks to new user creation.

Bug: T165755
Bug: T165754
Change-Id: Ic0a2ca07b0cd1597e5534bb1f3b748beb215ddfc
This commit is contained in:
Ela 2017-06-01 15:08:51 +03:00
parent 4cf17a6712
commit a4974ef1e1
5 changed files with 79 additions and 1 deletions

View file

@ -37,7 +37,7 @@ class EchoHooks {
*/
public static function initEchoExtension() {
global $wgEchoNotifications, $wgEchoNotificationCategories, $wgEchoNotificationIcons,
$wgEchoEventLoggingSchemas, $wgEchoMentionStatusNotifications;
$wgEchoEventLoggingSchemas, $wgEchoMentionStatusNotifications, $wgAllowArticleReminderNotification;
// allow extensions to define their own event
Hooks::run( 'BeforeCreateEchoEvent', [ &$wgEchoNotifications, &$wgEchoNotificationCategories, &$wgEchoNotificationIcons ] );
@ -48,6 +48,11 @@ class EchoHooks {
unset( $wgEchoNotificationCategories['mention-success'] );
}
// Only allow article reminder notifications when enabled
if ( !$wgAllowArticleReminderNotification ) {
unset( $wgEchoNotificationCategories['article-reminder'] );
}
// turn schema off if eventLogging is not enabled
if ( !class_exists( 'EventLogging' ) ) {
foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) {
@ -657,6 +662,8 @@ class EchoHooks {
* @return bool
*/
public static function onLocalUserCreated( $user, $autocreated ) {
global $wgAllowArticleReminderNotification;
if ( !$autocreated ) {
$overrides = self::getNewUserPreferenceOverrides();
foreach ( $overrides as $prefKey => $value ) {
@ -665,6 +672,18 @@ class EchoHooks {
$user->saveSettings();
// Temporarily here, just for the POC
if ( $wgAllowArticleReminderNotification ) {
EchoEvent::create( [
'type' => 'article-reminder',
'agent' => $user,
'title' => Title::newMainPage(),
'extra' => [
'notifyAgent' => true
]
] );
}
EchoEvent::create( [
'type' => 'welcome',
'agent' => $user,

View file

@ -606,6 +606,10 @@
"emailuser": {
"priority": 9,
"tooltip": "echo-pref-tooltip-emailuser"
},
"article-reminder": {
"priority": 1,
"tooltip": "echo-pref-tooltip-article-reminder"
}
},
"merge_strategy": "array_plus_2d"
@ -665,6 +669,9 @@
},
"site": {
"url": false
},
"article-reminder": {
"path": "Echo/modules/icons/global.svg"
}
},
"merge_strategy": "array_plus_2d"
@ -848,6 +855,15 @@
"group": "positive",
"presentation-model": "EchoEditThresholdPresentationModel",
"section": "message"
},
"article-reminder": {
"user-locators": [
"EchoUserLocator::locateEventAgent"
],
"category": "article-reminder",
"group": "positive",
"presentation-model": "EchoArticleReminderPresentationModel",
"section": "message"
}
},
"merge_strategy": "array_plus_2d"
@ -877,6 +893,10 @@
}
},
"merge_strategy": "array_plus_2d"
},
"AllowArticleReminderNotification": {
"value": false,
"description": "This is a feature flag to the Article Reminder notification"
}
},
"manifest_version": 2,
@ -915,6 +935,7 @@
"EchoDiscussionParserTest": "tests/phpunit/DiscussionParserTest.php",
"EchoEditThresholdPresentationModel": "includes/formatters/EditThresholdPresentationModel.php",
"EchoEditUserTalkPresentationModel": "includes/formatters/EditUserTalkPresentationModel.php",
"EchoArticleReminderPresentationModel": "includes/formatters/ArticleReminderPresentationModel.php",
"EchoEmailFormat": "includes/EmailFormat.php",
"EchoEmailFrequency": "includes/EmailFrequency.php",
"EchoEmailUserPresentationModel": "includes/formatters/EmailUserPresentationModel.php",

View file

@ -72,6 +72,7 @@
"echo-category-title-system": "{{PLURAL:$1|System}}",
"echo-category-title-user-rights": "{{PLURAL:$1|User rights change|User rights changes}}",
"echo-category-title-emailuser": "{{PLURAL:$1|Email from other user|Emails from other users}}",
"echo-category-title-article-reminder": "Page {{PLURAL:$1|article-reminder|article-reminders}}",
"echo-pref-tooltip-edit-user-talk": "Notify me when someone posts a message or replies on my talk page.",
"echo-pref-tooltip-article-linked": "Notify me when someone links to a page I created from an article page.",
"echo-pref-tooltip-reverted": "Notify me when someone reverts an edit I made, by using the undo or rollback tool.",
@ -80,6 +81,7 @@
"echo-pref-tooltip-mention-success": "Notify me when I send out a mention to someone.",
"echo-pref-tooltip-user-rights": "Notify me when someone changes my user rights.",
"echo-pref-tooltip-emailuser": "Notify me when someone sends me an email.",
"echo-pref-tooltip-article-reminder": "Notify me about this article when I asked.",
"echo-error-no-formatter": "No formatting defined for notification.",
"notifications": "Notifications",
"tooltip-pt-notifications-alert": "{{GENDER:|Your}} alerts",
@ -145,6 +147,7 @@
"notification-header-page-linked": "A link was made from <strong>$4</strong> to <strong>$3</strong>.",
"notification-compact-header-page-linked": "Linked from <strong>$1</strong>.",
"notification-bundle-header-page-linked": "Links were made from {{PLURAL:$5||$5 pages|100=99+ pages}} to <strong>$3</strong>.",
"notification-header-article-reminder": "An article {{GENDER:$2|you}} have requested to be reminded about is at <strong>$3</strong>",
"notification-link-text-what-links-here": "All links to this page",
"notification-body-mention": "$1",
"notification-header-mention-other": "$1 {{GENDER:$2|mentioned}} {{GENDER:$3|you}} on <strong>$4</strong> in \"<strong>$5</strong>\".",
@ -182,6 +185,7 @@
"notification-header-thank-you-1000000-edit": "{{GENDER:$2|You}} just made {{GENDER:$2|your}} millionth edit; thank {{GENDER:$2|you}} for an astonishing contribution!",
"notification-link-thank-you-edit": "{{GENDER:$1|Your}} edit",
"notification-link-text-view-edit": "View edit",
"notification-link-article-reminder": "View article",
"notification-header-reverted": "Your {{PLURAL:$4|edit on <strong>$3</strong> was|edits on <strong>$3</strong> were}} {{GENDER:$2|reverted}}.",
"notification-body-reverted": "$1",
"notification-header-emailuser": "$1 {{GENDER:$2|sent}} you an email.",

View file

@ -66,6 +66,7 @@
"echo-category-title-system": "This is a short title for notification category.\n\nUsed in a list of options under the heading {{msg-mw|Prefs-echosubscriptions}} in Special:Preferences. As far as I can see this always needs to be a plural for an unspecified number.\n\nIt used to be used as <code>$1</code> in {{msg-mw|Echo-dismiss-message}}, but this message is no longer used, apparently.\n\nParameters:\n* $1 - number of messages, for PLURAL support\n{{Related|Echo-category-title}}\n{{Identical|System}}",
"echo-category-title-user-rights": "This is a short title for notification category.\n\nUsed in a list of options under the heading {{msg-mw|Prefs-echosubscriptions}} in Special:Preferences. As far as I can see this always needs to be a plural for an unspecified number.\n\nIt used to be used as <code>$1</code> in {{msg-mw|Echo-dismiss-message}}, but this message is no longer used, apparently.\n\nParameters:\n* $1 - number of messages, for PLURAL support\n{{Related|Echo-category-title}}",
"echo-category-title-emailuser": "This is a short title for notification category.\n\nUsed in a list of options under the heading {{msg-mw|Prefs-echosubscriptions}} in Special:Preferences. As far as I can see this always needs to be a plural for an unspecified number.\n\nIt used to be used as <code>$1</code> in {{msg-mw|Echo-dismiss-message}}, but this message is no longer used, apparently.\n\nParameters:\n* $1 - number of messages, for PLURAL support\n{{Related|Echo-category-title}}",
"echo-category-title-article-reminder": "This is a short title for notification category.\n\nUsed in a list of options under the heading {{msg-mw|Prefs-echosubscriptions}} in Special:Preferences. As far as I can see this always needs to be a plural for an unspecified number.\n\nIt used to be used as <code>$1</code> in {{msg-mw|Echo-dismiss-message}}, but this message is no longer used, apparently.\n\nParameters:\n* $1 - number of messages, for PLURAL support\n{{Related|Echo-category-title}}",
"echo-pref-tooltip-edit-user-talk": "This is a short description of the edit-user-talk notification category.\n{{Related|Echo-pref-tooltip}}",
"echo-pref-tooltip-article-linked": "This is a short description of the article-linked notification category.\n{{Related|Echo-pref-tooltip}}",
"echo-pref-tooltip-reverted": "This is a short description of the tooltip-reverted notification category.\n{{Related|Echo-pref-tooltip}}",
@ -74,6 +75,7 @@
"echo-pref-tooltip-mention-success": "This is a short description of the mention success notification category.\n{{Related|Echo-pref-tooltip}}",
"echo-pref-tooltip-user-rights": "This is a short description of the user rights changes notification category\n{{Related|Echo-pref-tooltip}}",
"echo-pref-tooltip-emailuser": "This is a short description of the user email notification category\n{{Related|Echo-pref-tooltip}}",
"echo-pref-tooltip-article-reminder": "This is a short description of the article reminder user notification category\n{{Related|Echo-pref-tooltip}}",
"echo-error-no-formatter": "Error message displayed when no formatting has been defined for a notification. In other words, the extension doesn't know how to properly display the notification.",
"notifications": "{{doc-special|Notifications}}\n{{Identical|Notification}}",
"tooltip-pt-notifications-alert": "This is used for the title (mouseover text) of the alert notifications user tool.",
@ -139,6 +141,7 @@
"notification-header-page-linked": "Notification header message for articles being linked.\n\nParameters:\n* $1 - the formatted username of the person who linked the page. \n* $2 - the username for GENDER\n* $3 - the page being linked\n* $4 - the page linked from\nSee also:\n* {{msg-mw|Notification-page-linked-email-subject}}",
"notification-compact-header-page-linked": "Notification compact header message for articles being linked.\n\nParameters:\n* $1 - the page linked from.\nSee also:\n* {{msg-mw|Notification-page-linked-email-subject}}",
"notification-bundle-header-page-linked": "Bundled message for page-linked notification. Parameters:\n* $1 - the formatted username of the person who linked the page. \n* $2 - the username for GENDER\n* $3 - the page title\n* $4 - the page linked from\n* $5 - The number of other pages that link to this page, except that if the count is greater than 99, this value will be 100; uses standard number formatting and used for PLURAL\n* $6 - Unused\nSee also:\n* {{msg-mw|Notification-page-linked-email-subject}}\n{{Related|Notification-bundle}}",
"notification-header-article-reminder": "Message for article-reminder notification. Parameters:\n* $1 - the formatted username of the user who requested the reminder. \n* $2 - the username for GENDER\n* $3 - the formatted article title of the article the user requested.",
"notification-link-text-what-links-here": "Label for link to the WhatLinksHere special page for the page being linked in this notification.",
"notification-body-mention": "{{notranslate}}",
"notification-header-mention-other": "Header text for a notification when you are mentioned by another user in a section on a page that is not an article talk page or a user talk page.\n* $1 - user's name (not suitable for GENDER).\n* $2 - user's name for use in GENDER.\n* $3 - name of the user viewing the notification, can be used for GENDER\n* $4 - name of the page they were mentioned in (with namespace).\n* $5 - name of the section they were mentioned in",
@ -176,6 +179,7 @@
"notification-header-thank-you-1000000-edit": "Text of the editor welcome notification for their millionth edit.\nParameters:\n* $1 - the formatted username of the new user\n* $2 - the username for gender purposes",
"notification-link-thank-you-edit": "Label for the link to the user's edit which triggered a threshold congratulations message.\nParameters:\n* $1 - the username for gender purposes",
"notification-link-text-view-edit": "Label for button that links to a \"diff\" view showing an edit made to a page. This is an alternative to the wording in {{msg-mw|notification-link-text-view-changes}}, which serves essentially the same function.",
"notification-link-article-reminder": "Label for the link to the article the user requested to be reminded about",
"notification-header-reverted": "Notification header of a user's edit being reverted.\n\nParameters:\n* $2 - the username for GENDER\n* $3 - the page that was reverted, formatted\n* $4 - the number of edits that were reverted. NOTE: This will only be set to 1 or 2, with 2 actually meaning \"an unknown number greater than 0\".\n{{Related|Notification-reverted}}",
"notification-body-reverted": "{{notranslate}}",
"notification-header-emailuser": "Flyout-specific format for displaying notifications of user has sent an email to another user.\n\nParameters:\n* $1 - the formatted username of the person who sent the email.\n* $2 - the username for GENDER.",

View file

@ -0,0 +1,30 @@
<?php
/**
* Presenter for 'article-reminder' notification
*
* @author Ela Opper
*
* @license MIT
*/
class EchoArticleReminderPresentationModel extends EchoEventPresentationModel {
public function canRender() {
return (bool)$this->event->getTitle();
}
public function getIconType() {
return 'article-reminder';
}
public function getHeaderMessage() {
$msg = $this->getMessageWithAgent( 'notification-header-article-reminder' );
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) );
return $msg;
}
public function getPrimaryLink() {
return [
'url' => $this->event->getTitle()->getLocalURL(),
'label' => $this->msg( 'notification-link-article-reminder' )->text(),
];
}
}