Bsitu has uploaded a new change for review.
https://gerrit.wikimedia.org/r/52948
Change subject: Add getCategory() method to event object
......................................................................
Add getCategory() method to event object
Since every event is tied to a category, it's better for event object to have
it as a member method
Change-Id: I911415284486bb11d13d91366340c5c330317c34
---
M Notifier.php
M api/ApiEchoNotifications.php
M controller/NotificationController.php
M formatters/BasicFormatter.php
M includes/EmailBatch.php
M model/Event.php
M special/SpecialNotifications.php
7 files changed, 14 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/48/52948/1
diff --git a/Notifier.php b/Notifier.php
index 99bc76a..3e2245b 100644
--- a/Notifier.php
+++ b/Notifier.php
@@ -59,8 +59,7 @@
return false;
}
// See if the user wants to receive emails for this category of
event
- $category =
EchoNotificationController::getNotificationCategory( $event->getType() );
- if ( $user->getOption( 'echo-subscriptions-email-' . $category
) ) {
+ if ( $user->getOption( 'echo-subscriptions-email-' .
$event->getCategory() ) ) {
global $wgEchoEnableEmailBatch, $wgPasswordSender,
$wgPasswordSenderName;
// batched email notification
diff --git a/api/ApiEchoNotifications.php b/api/ApiEchoNotifications.php
index 5153bdb..512172d 100644
--- a/api/ApiEchoNotifications.php
+++ b/api/ApiEchoNotifications.php
@@ -102,7 +102,7 @@
$thisEvent = array(
'id' => $event->getId(),
'type' => $event->getType(),
- 'category' =>
EchoNotificationController::getNotificationCategory( $event->getType() ),
+ 'category' => $event->getCategory(),
'timestamp' => array(
'unix' => $timestampUnix,
'mw' => $timestampMw,
diff --git a/controller/NotificationController.php
b/controller/NotificationController.php
index eff7a80..ed26a9b 100644
--- a/controller/NotificationController.php
+++ b/controller/NotificationController.php
@@ -76,7 +76,7 @@
*/
public static function getNotificationPriority( $notificationType ) {
$category = self::getNotificationCategory( $notificationType );
- return EchoNotificationController::getCategoryPriority(
$category );
+ return self::getCategoryPriority( $category );
}
/**
diff --git a/formatters/BasicFormatter.php b/formatters/BasicFormatter.php
index 1ec0815..12a15aa 100644
--- a/formatters/BasicFormatter.php
+++ b/formatters/BasicFormatter.php
@@ -129,7 +129,7 @@
) . $output;
// Add the hidden dismiss interface if the notification is
dismissable
- $category =
EchoNotificationController::getNotificationCategory( $event->type );
+ $category = $event->getCategory();
if ( isset(
$wgEchoNotificationCategories[$category]['no-dismiss'] ) ) {
$noDismiss =
$wgEchoNotificationCategories[$category]['no-dismiss'];
} else {
diff --git a/includes/EmailBatch.php b/includes/EmailBatch.php
index 77d9280..9a52b32 100644
--- a/includes/EmailBatch.php
+++ b/includes/EmailBatch.php
@@ -146,7 +146,7 @@
*/
protected function appendContent( $event ) {
// get the category for this event
- $category =
EchoNotificationController::getNotificationCategory( $event->getType() );
+ $category = $event->getCategory();
$email = EchoNotificationController::formatNotification(
$event, $this->mUser, 'email' );
if ( !isset( $this->content[$category] ) ) {
diff --git a/model/Event.php b/model/Event.php
index ceb181a..bf17b14 100644
--- a/model/Event.php
+++ b/model/Event.php
@@ -270,4 +270,12 @@
public function getTitle() {
return $this->title;
}
+
+ /**
+ * Get the category of the event type
+ * @return string
+ */
+ public function getCategory() {
+ return EchoNotificationController::getNotificationCategory(
$this->type );
+ }
}
diff --git a/special/SpecialNotifications.php b/special/SpecialNotifications.php
index c6b4795..863b9ef 100644
--- a/special/SpecialNotifications.php
+++ b/special/SpecialNotifications.php
@@ -79,8 +79,7 @@
}
$nextTimestamp = $row['timestamp']['unix'];
$nextOffset = $row['id'];
- $dataNotificationCategory =
EchoNotificationController::getNotificationCategory( $row['type'] );
- $notices .= Html::rawElement( 'li', array( 'class' =>
$class, 'data-notification-category' => $dataNotificationCategory ), $row['*']
);
+ $notices .= Html::rawElement( 'li', array( 'class' =>
$class, 'data-notification-category' => $row['category'] ), $row['*'] );
}
$html .= Html::rawElement( 'ul', array( 'id' =>
'mw-echo-special-container' ), $notices );
--
To view, visit https://gerrit.wikimedia.org/r/52948
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I911415284486bb11d13d91366340c5c330317c34
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits