diff options
author | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-08-08 17:43:15 +0200 |
---|---|---|
committer | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-08-08 19:18:18 +0200 |
commit | 05d583bba7faaf82487305e892f7758d4161f303 (patch) | |
tree | 0aa476cb131f265abc88dfa1d5b194c348284b7c /phpBB/phpbb/notification | |
parent | ec270713d0f33531e9fd4b38ca0d5cc1f902aef3 (diff) | |
download | forums-05d583bba7faaf82487305e892f7758d4161f303.tar forums-05d583bba7faaf82487305e892f7758d4161f303.tar.gz forums-05d583bba7faaf82487305e892f7758d4161f303.tar.bz2 forums-05d583bba7faaf82487305e892f7758d4161f303.tar.xz forums-05d583bba7faaf82487305e892f7758d4161f303.zip |
[ticket/14079] Correctly mark notifications as read
PHPBB3-14079
Diffstat (limited to 'phpBB/phpbb/notification')
-rw-r--r-- | phpBB/phpbb/notification/manager.php | 21 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/base.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/notification/type/type_interface.php | 4 |
3 files changed, 17 insertions, 10 deletions
diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index eb9a93be3d..4be678ac91 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -166,6 +166,7 @@ class manager $notification_type_id = false; } + /** @var method_interface $method */ foreach ($this->get_available_subscription_methods() as $method) { $method->mark_notifications($notification_type_id, $item_id, $user_id, $time, $mark_read); @@ -597,26 +598,32 @@ class manager { foreach ($types as $id => $type) { - $subscriptions[$id] = array(); + $type_subscriptions = $default_methods; if (!empty($user_notifications[$id])) { foreach ($user_notifications[$id] as $user_notification) { + $key = array_search($user_notification['method'], $type_subscriptions, true); if (!$user_notification['notify']) { + if ($key !== false) + { + unset($type_subscriptions[$key]); + } + continue; } - - if (!isset($subscriptions[$id])) + else if ($key === false) { - $subscriptions[$id] = array(); + $type_subscriptions[] = $user_notification['method']; } - - $subscriptions[$id][] = $user_notification['method']; } } - $subscriptions[$id] = array_merge($subscriptions[$id], $default_methods); + if (!empty($type_subscriptions)) + { + $subscriptions[$id] = $type_subscriptions; + } } } diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php index 06f7f9c615..31e853d7d9 100644 --- a/phpBB/phpbb/notification/type/base.php +++ b/phpBB/phpbb/notification/type/base.php @@ -503,7 +503,7 @@ abstract class base implements \phpbb\notification\type\type_interface } else { - $this->notification_manager->mark_notifications($this->get_type(), (int) $this->item_id, (int) $this->user_id, $this->notification_read); + $this->notification_manager->mark_notifications($this->get_type(), (int) $this->item_id, (int) $this->user_id, false, $this->notification_read); } } diff --git a/phpBB/phpbb/notification/type/type_interface.php b/phpBB/phpbb/notification/type/type_interface.php index 9b4446ac47..f9f832bdda 100644 --- a/phpBB/phpbb/notification/type/type_interface.php +++ b/phpBB/phpbb/notification/type/type_interface.php @@ -206,7 +206,7 @@ interface type_interface * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) * @return string */ - public function mark_read($return); + public function mark_read($return = false); /** * Mark this item unread @@ -214,5 +214,5 @@ interface type_interface * @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False) * @return string */ - public function mark_unread($return); + public function mark_unread($return = false); } |