Alex Monk has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/65436


Change subject: Echo notification for new project membership
......................................................................

Echo notification for new project membership

Bug: 48766
Change-Id: Ic114d2bef0bd46d439d369ff6942d079b818d00c
---
M OpenStackManager.i18n.php
M OpenStackManager.php
M special/SpecialNovaProject.php
3 files changed, 26 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OpenStackManager 
refs/changes/36/65436/1

diff --git a/OpenStackManager.i18n.php b/OpenStackManager.i18n.php
index 1e2f14e..30e064c 100644
--- a/OpenStackManager.i18n.php
+++ b/OpenStackManager.i18n.php
@@ -423,9 +423,11 @@
        'notification-osm-instance-deleted' => '$1 deleted instance \'$3\' in 
project [[$2]]',
        'notification-osm-instance-build-completed' => '$1 built instance 
\'$3\' in project [[$2]]',
        'notification-osm-instance-reboot-completed' => '$1 rebooted instance 
\'$3\' in project [[$2]]',
+       'notification-osm-projectmember-added' => '$1 added you to project 
[[$2]]',
        'echo-category-title-osm-instance-deleted' => 'Deletes an instance from 
a project I\'m an admin on.',
        'echo-category-title-osm-instance-build-completed' => 'Builds an 
instance on a project I\'m an admin on.',
        'echo-category-title-osm-instance-reboot-completed' => 'Reboots an 
instance.',
+       'echo-category-title-osm-instance-deleted' => 'Project membership 
addition',
 
        'prefs-openstack' => 'OpenStack',
        'prefs-openstack-keys' => 'Key list',
@@ -1424,6 +1426,9 @@
 * $1 - agent
 * $2 - project
 * $3 - instance',
+       'notification-osm-projectmember-added' => 'Title for the new project 
membership notification.
+* $1 - agent
+* $2 - project',
        'echo-category-title-osm-instance-deleted' => 'Used by the Echo 
extension in the Preferences -> Notifications tab as a label to enable email 
notification for the osm-instance-deleted event.
 
 Preceded by {{msg-mw|Prefs-emailsubscriptions}}.',
@@ -1431,6 +1436,7 @@
 
 Preceded by {{msg-mw|Prefs-emailsubscriptions}}.',
        'echo-category-title-osm-instance-reboot-completed' => 'Used by the 
Echo extension in the Preferences -> Notifications tab as a label to enable 
email notification for the osm-instance-reboot-completed event.',
+       'echo-category-title-osm-instance-deleted' => 'Used by the Echo 
extension in the Preferences -> Notifications tab as a label to enable email 
notification for the osm-projectmember-add event.',
        'prefs-openstack' => 'Title for a tab in Preferences for OpenStack 
related items',
        'prefs-openstack-keys' => 'Subheading used in the Preferences -> 
OpenStack for a the public SSH key list',
 );
diff --git a/OpenStackManager.php b/OpenStackManager.php
index a4c668b..f23ac0c 100644
--- a/OpenStackManager.php
+++ b/OpenStackManager.php
@@ -250,6 +250,9 @@
                }
        } elseif ( $event->getType() == 'osm-instance-reboot-completed' ) {
                $users[$event->getAgent()->getId()] = $event->getAgent(); // 
Only notify the person who did it to say the reboot was completed.
+       } elseif ( $event->getType() == 'osm-projectmembers-add' ) {
+               $extra = $event->getExtra(); // PHP 5.3 back-compat...
+               $users[$extra['userAdded']] = User::newFromId( 
$extra['userAdded'] );
        }
        unset( $users[0] );
        return true;
@@ -296,6 +299,15 @@
 $wgDefaultUserOptions["echo-subscriptions-web-osm-instance-deleted"] = true;
 $wgDefaultUserOptions["echo-subscriptions-email-osm-instance-deleted"] = true;
 
+$wgEchoNotifications['osm-projectmembers-add'] = array(
+       'formatter-class' => 'EchoBasicFormatter',
+       'category' => 'osm-projectmembers-add',
+       'title-message' => 'notification-osm-projectmember-added',
+       'title-params' => array( 'agent', 'title' ),
+       'icon' => 'placeholder',
+       'payload' => array( 'summary' )
+);
+
 /**
  * @param $updater DatabaseUpdater
  * @return bool
diff --git a/special/SpecialNovaProject.php b/special/SpecialNovaProject.php
index b13cfe4..18be30d 100644
--- a/special/SpecialNovaProject.php
+++ b/special/SpecialNovaProject.php
@@ -654,6 +654,14 @@
                        $success = $project->addMember( $member );
                        if ( $success ) {
                                $this->getOutput()->addWikiMsg( 
'openstackmanager-addedto', $formData['member'], $formData['projectname'] );
+                               if ( class_exists( 'EchoEvent' ) ) {
+                                       EchoEvent::create( array(
+                                               'type' => 
'osm-projectmembers-add',
+                                               'title' => Title::newFromText( 
$formData['projectname'], NS_NOVA_RESOURCE ),
+                                               'agent' => $this->getUser(),
+                                               'extra' => array( 'userAdded' 
=> $user->getId() ),
+                                       ) );
+                               }
                        } else {
                                $this->getOutput()->addWikiMsg( 
'openstackmanager-failedtoadd', $formData['member'], $formData['projectname'] );
                        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic114d2bef0bd46d439d369ff6942d079b818d00c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OpenStackManager
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <kren...@gmail.com>

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

Reply via email to