jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/329456 )
Change subject: Added notifications to manually added users ...................................................................... Added notifications to manually added users Bug: T154143 Change-Id: I22160066ac2ef0430c1c5286ebba8310b448b208 --- M Newsletter.hooks.php M extension.json M i18n/en.json M i18n/qqq.json A includes/Echo/EchoNewsletterSubscribedPresentationModel.php A includes/Echo/EchoNewsletterUnsubscribedPresentationModel.php M includes/specials/SpecialNewsletter.php 7 files changed, 109 insertions(+), 1 deletion(-) Approvals: 01tonythomas: Looks good to me, approved jenkins-bot: Verified diff --git a/Newsletter.hooks.php b/Newsletter.hooks.php index 98cf4b3..742963f 100755 --- a/Newsletter.hooks.php +++ b/Newsletter.hooks.php @@ -59,6 +59,32 @@ 'flyout-message' => 'newsletter-notification-new-publisher-flyout', 'flyout-params' => array( 'newsletter-name', 'agent' ), ); + $notifications['newsletter-subscribed'] = array( + 'category' => 'newsletter', + 'primary-link' => array( + 'message' => 'newsletter-notification-subscribed', + 'destination' => 'newsletter' + ), + 'user-locators' => array( + array( 'EchoUserLocator::locateFromEventExtra', array( 'new-subscribers-id' ) ) + ), + 'presentation-model' => 'EchoNewsletterSubscribedPresentationModel', + 'title-message' => 'newsletter-notification-subscribed', + 'title-params' => array( 'newsletter-name'), + ); + $notifications['newsletter-unsubscribed'] = array( + 'category' => 'newsletter', + 'primary-link' => array( + 'message' => 'newsletter-notification-unsubscribed', + 'destination' => 'newsletter' + ), + 'user-locators' => array( + array( 'EchoUserLocator::locateFromEventExtra', array( 'removed-subscribers-id' ) ) + ), + 'presentation-model' => 'EchoNewsletterUnsubscribedPresentationModel', + 'title-message' => 'newsletter-notification-unsubscribed', + 'title-params' => array( 'newsletter-name'), + ); return true; } diff --git a/extension.json b/extension.json index e972f39..4f9b050 100644 --- a/extension.json +++ b/extension.json @@ -89,7 +89,10 @@ "EchoNewsletterUserLocator": "includes/Echo/EchoNewsletterUserLocator.php", "BaseNewsletterPresentationModel": "includes/Echo/BaseNewsletterPresentationModel.php", "EchoNewsletterPresentationModel": "includes/Echo/EchoNewsletterPresentationModel.php", - "EchoNewsletterPublisherPresentationModel": "includes/Echo/EchoNewsletterPublisherPresentationModel.php" + "EchoNewsletterPublisherPresentationModel": "includes/Echo/EchoNewsletterPublisherPresentationModel.php", + "EchoNewsletterUnsubscribedPresentationModel": "includes/Echo/EchoNewsletterUnsubscribedPresentationModel.php", + "EchoNewsletterSubscribedPresentationModel": "includes/Echo/EchoNewsletterSubscribedPresentationModel.php" + }, "DefaultUserOptions": { "echo-subscriptions-web-newsletter": true, diff --git a/i18n/en.json b/i18n/en.json index 2eefef7..254874c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -103,6 +103,8 @@ "echo-category-title-newsletter": "Newsletters", "echo-pref-tooltip-newsletter": "Notify me when any of the newsletters to which I have subscribed to announces a new issue.", "newsletter-notification-title": "[[User:$3|$3]] {{GENDER:$4|has announced}} a [[$2|new issue]] of the newsletter \"$1\".", + "newsletter-notification-subscribed": "You have been subscribed to the \"$1\" newsletter by an administrator.", + "newsletter-notification-unsubscribed": "You have been unsubscribed from the \"$1\" newsletter by an administrator.", "newsletter-notification-flyout": "$2 {{GENDER:$3|has announced}} a new issue of $1.", "newsletter-notification-link-text-new-issue": "View new issue", "newsletter-notification-link-text-view-newsletter": "View newsletter", diff --git a/i18n/qqq.json b/i18n/qqq.json index 02d2f28..da12d65 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -109,6 +109,8 @@ "newsletter-list-search-none-found": "Error message shown on [[Special:Newsletters]] if no newsletters found after user searches the table using filters", "echo-category-title-newsletter": "Title of the notification category used by Newsletter extension.\n{{Related|Echo-category-title}}\n{{Identical|Newsletter}}", "echo-pref-tooltip-newsletter": "Short description of the newsletter notification category.\n{{Related|Echo-pref-tooltip}}", + "newsletter-notification-subscribed": "Used as a Echo notification message when user is subscribed from newsletter by administrator.", + "newsletter-notification-unsubscribed": "Used as a Echo notification message when user is unsubscribed from newsletter by administrator.", "newsletter-notification-title": "Header text for a notification when a new issue of a newsletter is announced. Parameters:\n* $1 is the name of the newsletter.\n* $2 is title of the issue page.\n* $3 is the username of the user who announced the new issue, not used for GENDER\n* $4 is the username of the user who announced the issue, used for GENDER", "newsletter-notification-flyout": "Used as a Echo notification flyout message when a new issue of a newsletter is announced. \n* $1 is the name of the newsletter.\n* $2 is the username of the user who announced the new issue, not used for GENDER\n* $3 is the username of the user who announced the new issue, used for GENDER", "newsletter-notification-link-text-new-issue": "Label of the primary link of the notification-newsletter-flyout, which on clicking navigates the user to the newly announced issue of a newsletter.", diff --git a/includes/Echo/EchoNewsletterSubscribedPresentationModel.php b/includes/Echo/EchoNewsletterSubscribedPresentationModel.php new file mode 100644 index 0000000..989e5ee --- /dev/null +++ b/includes/Echo/EchoNewsletterSubscribedPresentationModel.php @@ -0,0 +1,23 @@ +<?php + +class EchoNewsletterSubscribedPresentationModel extends BaseNewsletterPresentationModel { + + public function getIconType() { + return 'site'; + } + + public function getPrimaryLink() { + return array( + 'url' => $this->getSpecialNewsletterUrl(), + 'label' => $this->msg( 'newsletter-notification-subscribed' ) + ->params( $this->getNewsletterName() ) + ); + } + + public function getHeaderMessage() { + list( $agentFormattedName, $agentGenderName ) = $this->getAgentForOutput(); + $msg = $this->msg( 'newsletter-notification-subscribed' ); + $msg->params( $this->getNewsletterName() ); + return $msg; + } +} diff --git a/includes/Echo/EchoNewsletterUnsubscribedPresentationModel.php b/includes/Echo/EchoNewsletterUnsubscribedPresentationModel.php new file mode 100644 index 0000000..092d63d --- /dev/null +++ b/includes/Echo/EchoNewsletterUnsubscribedPresentationModel.php @@ -0,0 +1,23 @@ +<?php + +class EchoNewsletterUnsubscribedPresentationModel extends BaseNewsletterPresentationModel { + + public function getIconType() { + return 'site'; + } + + public function getPrimaryLink() { + return array( + 'url' => $this->getSpecialNewsletterUrl(), + 'label' => $this->msg( 'newsletter-notification-unsubscribed' ) + ->params( $this->getNewsletterName() ) + ); + } + + public function getHeaderMessage() { + list( $agentFormattedName, $agentGenderName ) = $this->getAgentForOutput(); + $msg = $this->msg( 'newsletter-notification-unsubscribed' ); + $msg->params( $this->getNewsletterName() ); + return $msg; + } +} diff --git a/includes/specials/SpecialNewsletter.php b/includes/specials/SpecialNewsletter.php index 42fd2d2..7437662 100644 --- a/includes/specials/SpecialNewsletter.php +++ b/includes/specials/SpecialNewsletter.php @@ -483,6 +483,35 @@ $out = $this->getOutput(); // Now report to the user if ( $added || $removed ) { + if ( !class_exists( 'EchoEvent') ) { + throw new Exception( 'Echo extension is not installed.' ); + } + if ( $added ) { + EchoEvent::create( + array( + 'type' => 'newsletter-subscribed', + 'extra' => array( + 'newsletter-name' => $this->newsletter->getName(), + 'new-subscribers-id' => $added, + 'newsletter-id' => $this->newsletter->getId() + ), + 'agent' => $this->getUser() + ) + ); + } + if ( $removed ) { + EchoEvent::create( + array( + 'type' => 'newsletter-unsubscribed', + 'extra' => array( + 'newsletter-name' => $this->newsletter->getName(), + 'removed-subscribers-id' => $removed, + 'newsletter-id' => $this->newsletter->getId() + ), + 'agent' => $this->getUser() + ) + ); + } $out->addWikiMsg( 'newsletter-edit-subscribers-success' ); } else { // Submitted without any changes to the existing subscribers -- To view, visit https://gerrit.wikimedia.org/r/329456 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I22160066ac2ef0430c1c5286ebba8310b448b208 Gerrit-PatchSet: 9 Gerrit-Project: mediawiki/extensions/Newsletter Gerrit-Branch: master Gerrit-Owner: Filip <r...@protonmail.com> Gerrit-Reviewer: 01tonythomas <01tonytho...@gmail.com> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Filip <r...@protonmail.com> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits