aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/notifications/service.php
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2012-09-14 14:55:14 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2012-09-14 14:55:14 -0500
commit44aa773ce07d81d4585f3a24a728f9b445c4c098 (patch)
tree3caa90db934634a5c5f025f3a392ca91cbf2e946 /phpBB/includes/notifications/service.php
parent207bbdf48cb05abfb611f238e4ba07131131c74d (diff)
downloadforums-44aa773ce07d81d4585f3a24a728f9b445c4c098.tar
forums-44aa773ce07d81d4585f3a24a728f9b445c4c098.tar.gz
forums-44aa773ce07d81d4585f3a24a728f9b445c4c098.tar.bz2
forums-44aa773ce07d81d4585f3a24a728f9b445c4c098.tar.xz
forums-44aa773ce07d81d4585f3a24a728f9b445c4c098.zip
[ticket/11103] Allow notification types to override update functionality
This is needed for quote editing because we need to check if the users are still all quoted or notify new quotes appropriately. PHPBB3-11103
Diffstat (limited to 'phpBB/includes/notifications/service.php')
-rw-r--r--phpBB/includes/notifications/service.php39
1 files changed, 33 insertions, 6 deletions
diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php
index 0f7752446a..10af5b349b 100644
--- a/phpBB/includes/notifications/service.php
+++ b/phpBB/includes/notifications/service.php
@@ -110,7 +110,6 @@ class phpbb_notifications_service
* Add a notification
*
* @param string $item_type Type identifier
- * @param int $item_id Identifier within the type
* @param array $data Data specific for this type that will be inserted
*/
public function add_notifications($item_type, $data)
@@ -120,20 +119,38 @@ class phpbb_notifications_service
$item_id = $item_type_class_name::get_item_id($data);
// Update any existing notifications for this item
- $this->update_notifications($item_type, $item_id, $data);
-
- $notify_users = $user_ids = array();
- $notification_objects = $notification_methods = array();
- $new_rows = array();
+ $this->update_notifications($item_type, $data);
// find out which users want to receive this type of notification
$notify_users = $item_type_class_name::find_users_for_notification($this->phpbb_container, $data);
+ $this->add_notifications_for_users($item_type, $data, $notify_users);
+ }
+
+ /**
+ * Add a notification for specific users
+ *
+ * @param string $item_type Type identifier
+ * @param array $data Data specific for this type that will be inserted
+ * @param array $notify_users User list to notify
+ */
+ public function add_notifications_for_users($item_type, $data, $notify_users)
+ {
+ $item_type_class_name = $this->get_item_type_class_name($item_type);
+
+ $item_id = $item_type_class_name::get_item_id($data);
+
+ $user_ids = array();
+ $notification_objects = $notification_methods = array();
+ $new_rows = array();
+
// Never send notifications to the anonymous user or the current user!
unset($notify_users[ANONYMOUS], $notify_users[$this->phpbb_container->get('user')->data['user_id']]);
// Make sure not to send new notifications to users who've already been notified about this item
// This may happen when an item was added, but now new users are able to see the item
+ // todo Users should not receive notifications from multiple events from the same item (ex: for a topic reply with a quote including your username)
+ // Probably should be handled within each type?
$sql = 'SELECT user_id
FROM ' . NOTIFICATIONS_TABLE . "
WHERE item_type = '" . $this->db->sql_escape($item_type) . "'
@@ -202,6 +219,16 @@ class phpbb_notifications_service
{
$item_type_class_name = $this->get_item_type_class_name($item_type);
+ // Allow the notifications class to over-ride the update_notifications functionality
+ if (method_exists($item_type_class_name, 'update_notifications'))
+ {
+ // Return False to over-ride the rest of the update
+ if ($item_type_class_name::update_notifications($this->phpbb_container, $data) === false)
+ {
+ return;
+ }
+ }
+
$item_id = $item_type_class_name::get_item_id($data);
$notification = new $item_type_class_name($this->phpbb_container);