01tonythomas has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/384262 )

Change subject: Add notificaiton on removing a publisher
......................................................................

Add notificaiton on removing a publisher

New shiny notificaiton which would redirect to the newsletter page
when a publisher gets removed

Bug:T174667
Change-Id: I6b8d65d5264fd906d527db6c4a58a0d7628d3c68
---
M Newsletter.hooks.php
M extension.json
M i18n/en.json
M i18n/qqq.json
R includes/Echo/EchoNewsletterPublisherAddedPresentationModel.php
A includes/Echo/EchoNewsletterPublisherRemovedPresentationModel.php
M includes/NewsletterEditPage.php
M includes/content/NewsletterDataUpdate.php
8 files changed, 79 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Newsletter 
refs/changes/62/384262/1

diff --git a/Newsletter.hooks.php b/Newsletter.hooks.php
index bd6bc32..7061434 100644
--- a/Newsletter.hooks.php
+++ b/Newsletter.hooks.php
@@ -53,12 +53,27 @@
                        'user-locators' => [
                                [ 'EchoUserLocator::locateFromEventExtra', [ 
'new-publishers-id' ] ]
                        ],
-                       'presentation-model' => 
'EchoNewsletterPublisherPresentationModel',
+                       'presentation-model' => 
'EchoNewsletterPublisherAddedPresentationModel',
                        'title-message' => 
'newsletter-notification-new-publisher-title',
                        'title-params' => [ 'newsletter-name', 'agent' ],
                        'flyout-message' => 
'newsletter-notification-new-publisher-flyout',
                        'flyout-params' => [ 'newsletter-name', 'agent' ],
                ];
+        $notifications['newsletter-delpublisher'] = [
+            'category' => 'newsletter',
+            'primary-link' => [
+                'message' => 'newsletter-notification-link-text-del-publisher',
+                'destination' => 'newsletter'
+            ],
+            'user-locators' => [
+                [ 'EchoUserLocator::locateFromEventExtra', [ 
'del-publishers-id' ] ]
+            ],
+            'presentation-model' => 
'EchoNewsletterPublisherRemovedPresentationModel',
+            'title-message' => 'newsletter-notification-del-publisher-title',
+            'title-params' => [ 'newsletter-name', 'agent' ],
+            'flyout-message' => 'newsletter-notification-del-publisher-flyout',
+            'flyout-params' => [ 'newsletter-name', 'agent' ],
+        ];
                $notifications['newsletter-subscribed'] = [
                        'category' => 'newsletter',
                        'primary-link' => [
diff --git a/extension.json b/extension.json
index c84eddb..9cc0597 100644
--- a/extension.json
+++ b/extension.json
@@ -90,7 +90,8 @@
                "EchoNewsletterUserLocator": 
"includes/Echo/EchoNewsletterUserLocator.php",
                "BaseNewsletterPresentationModel": 
"includes/Echo/BaseNewsletterPresentationModel.php",
                "EchoNewsletterPresentationModel": 
"includes/Echo/EchoNewsletterPresentationModel.php",
-               "EchoNewsletterPublisherPresentationModel": 
"includes/Echo/EchoNewsletterPublisherPresentationModel.php",
+               "EchoNewsletterPublisherAddedPresentationModel": 
"includes/Echo/EchoNewsletterPublisherAddedPresentationModel.php",
+               "EchoNewsletterPublisherRemovedPresentationModel": 
"includes/Echo/EchoNewsletterPublisherRemovedPresentationModel.php",
                "EchoNewsletterUnsubscribedPresentationModel": 
"includes/Echo/EchoNewsletterUnsubscribedPresentationModel.php",
                "EchoNewsletterSubscribedPresentationModel": 
"includes/Echo/EchoNewsletterSubscribedPresentationModel.php"
        },
diff --git a/i18n/en.json b/i18n/en.json
index 4c20de3..03e20b0 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -5,7 +5,8 @@
                        "Thomas Arrow",
                        "Glaisher",
                        "Divadsn",
-                       "Addshore"
+                       "Addshore",
+                       "Tony Thomas"
                ]
        },
        "newsletter-extension-desc": "Enables users to publish and subscribe to 
newsletters",
@@ -139,6 +140,7 @@
        "apihelp-newslettermanage-example-2": "Remove publisher with a user ID 
of 5 from newsletter with ID 2.",
        "notification-header-newsletter-announce": "$1 {{GENDER:$2|has 
announced}} a new issue of $3.",
        "notification-header-newsletter-newpublisher": "{{GENDER:$2|You}} have 
been {{GENDER:$3|added}} as a publisher of \"$1\" newsletter.",
+       "notification-header-newsletter-delpublisher": "{{GENDER:$2|You}} have 
been {{GENDER:$3|removed}} as a publisher of \"$1\" newsletter.",
        "notification-body-newsletter-announce": "$1",
        "newsletter-list-intro": "This is a list of newsletters registered to 
this wiki. Subscribe to a newsletter to receive a notification when a new issue 
is announced. You will receive notifications via web or email, according to 
your [[Special:Preferences#mw-prefsection-echo|preferences]].",
        "newsletter-list-intro-not-logged-in": "[[Special:UserLogin|Log In]] to 
subscribe to a newsletter and receive notifications when a new issue is 
announced.",
@@ -151,6 +153,9 @@
        "newsletter-notification-link-text-new-publisher": "Manage newsletter",
        "newsletter-notification-new-publisher-title": "You have been added as 
a publisher of $1 newsletter.",
        "newsletter-notification-new-publisher-flyout": "You are now a 
publisher of $1 newsletter.",
+       "newsletter-notification-link-text-del-publisher": "View newsletter",
+       "newsletter-notification-del-publisher-title": "You have been removed 
as a publisher of $1 newsletter.",
+       "newsletter-notification-del-publisher-flyout": "You are no longer a 
publisher of $1 newsletter.",
        "log-name-newsletter": "Newsletter log",
        "log-description-newsletter": "This is a log of changes made to 
newsletters.",
        "logentry-newsletter-publisher-added": "$1 {{GENDER:$2|added}} 
{{GENDER:$6|$3}} as a publisher on newsletter $4",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index acfff15..5d54766 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -146,6 +146,7 @@
        "apihelp-newslettermanage-example-2": 
"{{doc-apihelp-example|newslettermanage}}",
        "notification-header-newsletter-announce": "Header text for a 
notification when a new issue of a newsletter is announced. Parameters:\n* $1 
is that user's name (not suitable for GENDER).\n* $2 is the user's name for use 
in GENDER.\n* $3 is the title of the newsletter.",
        "notification-header-newsletter-newpublisher": "Notifications header 
message when a user is added as a newsletter publisher. Parameters:\n* $1 - 
name of the newsletter\n* $2 - name of the user viewing the notification, for 
GENDER support\n* $3 - name of the user who added the current user as a 
publisher, for GENDER support",
+       "notification-header-newsletter-delpublisher": "Notifications header 
message when a user is removed as a newsletter publisher. Parameters:\n* $1 - 
name of the newsletter\n* $2 - name of the user viewing the notification, for 
GENDER support\n* $3 - name of the user who removed the current user as a 
publisher, for GENDER support",
        "notification-body-newsletter-announce": "Body text for a notification 
when a new issue of a newsletter is announced. Parameters:\n* $1 is the summary 
of the new newsletter issue.",
        "newsletter-list-intro": "Intro message right under the header in 
[[Special:Newsletters]] if the user is logged in",
        "newsletter-list-intro-not-logged-in": "Intro message right under the 
header in [[Special:Newsletters]] if the user is not logged in",
@@ -158,6 +159,9 @@
        "newsletter-notification-link-text-new-publisher": "Label of the 
primary link of the newsletter-notification-new-publisher-flyout, which on 
clicking navigates the user to manage page of a newsletter.",
        "newsletter-notification-new-publisher-title": "Header text for a 
notification when a new publisher is added for a newsletter. Parameters:\n* $1 
is the name of the newsletter.",
        "newsletter-notification-new-publisher-flyout": "Echo notification 
flyout message when a new publisher is added for a newsletter. \n* $1 is the 
name of the newsletter",
+       "newsletter-notification-link-text-del-publisher": "Label of the 
primary link of the newsletter-notification-new-publisher-flyout, which on 
clicking navigates the user to main page of a newsletter.",
+       "newsletter-notification-del-publisher-title": "Header text for a 
notification when publisher is removed from a newsletter. Parameters:\n* $1 is 
the name of the newsletter.",
+       "newsletter-notification-del-publisher-flyout": "Echo notification 
flyout message when a new publisher is removed from a newsletter. \n* $1 is the 
name of the newsletter",
        "log-name-newsletter": "{{log-name|newsletter}}",
        "log-description-newsletter": "{{log-description|newsletter}}",
        "logentry-newsletter-publisher-added": "{{logentry}}\nAdditional 
parameters:\n* $4 - the newsletter affected by the action",
diff --git a/includes/Echo/EchoNewsletterPublisherPresentationModel.php 
b/includes/Echo/EchoNewsletterPublisherAddedPresentationModel.php
similarity index 85%
rename from includes/Echo/EchoNewsletterPublisherPresentationModel.php
rename to includes/Echo/EchoNewsletterPublisherAddedPresentationModel.php
index d1994d9..f20d5e5 100644
--- a/includes/Echo/EchoNewsletterPublisherPresentationModel.php
+++ b/includes/Echo/EchoNewsletterPublisherAddedPresentationModel.php
@@ -1,6 +1,6 @@
 <?php
 
-class EchoNewsletterPublisherPresentationModel extends 
BaseNewsletterPresentationModel {
+class EchoNewsletterPublisherAddedPresentationModel extends 
BaseNewsletterPresentationModel {
 
        public function getIconType() {
                return 'site';
diff --git a/includes/Echo/EchoNewsletterPublisherRemovedPresentationModel.php 
b/includes/Echo/EchoNewsletterPublisherRemovedPresentationModel.php
new file mode 100644
index 0000000..271eac3
--- /dev/null
+++ b/includes/Echo/EchoNewsletterPublisherRemovedPresentationModel.php
@@ -0,0 +1,24 @@
+<?php
+
+class EchoNewsletterPublisherRemovedPresentationModel extends 
BaseNewsletterPresentationModel {
+
+    public function getIconType() {
+        return 'site';
+    }
+
+    public function getPrimaryLink() {
+        return [
+            'url' => $this->getNewsletterUrl(),
+            'label' => $this->msg( 
'newsletter-notification-link-text-del-publisher' )->text()
+        ];
+    }
+
+    public function getHeaderMessage() {
+        list( $agentFormattedName, $agentGenderName ) = 
$this->getAgentForOutput();
+        $msg = $this->msg( 'notification-header-newsletter-delpublisher' );
+        $msg->params( $this->getNewsletterName() );
+        $msg->params( $this->getViewingUserForGender() );
+        $msg->params( $agentGenderName );
+        return $msg;
+    }
+}
diff --git a/includes/NewsletterEditPage.php b/includes/NewsletterEditPage.php
index 8cb8793..7ae2b80 100644
--- a/includes/NewsletterEditPage.php
+++ b/includes/NewsletterEditPage.php
@@ -428,6 +428,19 @@
                                ]
                        );
                }
+               if ( $removed ) {
+            EchoEvent::create(
+                [
+                    'type' => 'newsletter-delpublisher',
+                    'extra' => [
+                        'newsletter-name' => $this->newsletter->getName(),
+                        'del-publishers-id' => $removed,
+                        'newsletter-id' => $newsletterId
+                    ],
+                    'agent' => $user
+                ]
+            );
+        }
 
                foreach ( $removed as $ruId ) {
                        $store->removePublisher( $this->newsletter, 
User::newFromId( $ruId ) );
diff --git a/includes/content/NewsletterDataUpdate.php 
b/includes/content/NewsletterDataUpdate.php
index 945f00f..7c4e8ef 100644
--- a/includes/content/NewsletterDataUpdate.php
+++ b/includes/content/NewsletterDataUpdate.php
@@ -125,6 +125,19 @@
                                ]
                        );
                }
+        if ( $removed ) {
+            EchoEvent::create(
+                [
+                    'type' => 'newsletter-delpublisher',
+                    'extra' => [
+                        'newsletter-name' => $this->newsletter->getName(),
+                        'del-publishers-id' => $removed,
+                        'newsletter-id' => $newsletterId
+                    ],
+                    'agent' => $user
+                ]
+            );
+        }
                foreach ( $removed as $ruId ) {
                        $store->removePublisher( $newsletter, User::newFromId( 
$ruId ) );
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/384262
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6b8d65d5264fd906d527db6c4a58a0d7628d3c68
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Newsletter
Gerrit-Branch: master
Gerrit-Owner: 01tonythomas <01tonytho...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to