From 25769935641aabee4e11141faf45a0040cb93fb7 Mon Sep 17 00:00:00 2001 From: Mark Shaw Date: Wed, 25 May 2016 14:30:04 -0400 Subject: [PATCH 1/2] [ticket/14648] Fix bug where default notifications stop working if another setting is set. When a new user signs up, they have an email preference set but no board notification preference set. The default board preference should work. Also when a user checks the email box for any notification preference, the default board preference should still work. PHPBB3-14648 --- phpBB/phpbb/notification/type/base.php | 39 ++++++++++++++++++++------ 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php index 4aacb1c99e..8f05cfc80b 100644 --- a/phpBB/phpbb/notification/type/base.php +++ b/phpBB/phpbb/notification/type/base.php @@ -449,7 +449,7 @@ abstract class base implements \phpbb\notification\type\type_interface return array(); } - $rowset = $resulting_user_ids = array(); + $rowset = $output = array(); $sql = 'SELECT user_id, method, notify FROM ' . $this->user_notifications_table . ' @@ -460,9 +460,7 @@ abstract class base implements \phpbb\notification\type\type_interface while ($row = $this->db->sql_fetchrow($result)) { - $resulting_user_ids[] = $row['user_id']; - - if (!$row['notify'] || (isset($options['ignore_users'][$row['user_id']]) && in_array($row['method'], $options['ignore_users'][$row['user_id']]))) + if (isset($options['ignore_users'][$row['user_id']]) && in_array($row['method'], $options['ignore_users'][$row['user_id']])) { continue; } @@ -471,22 +469,47 @@ abstract class base implements \phpbb\notification\type\type_interface { $rowset[$row['user_id']] = array(); } + $rowset[$row['user_id']][$row['method']] = $row['notify']; - $rowset[$row['user_id']][] = $row['method']; + if (!isset($output[$row['user_id']])) + { + $output[$row['user_id']] = array(); + } + if ($row['notify']) + { + $output[$row['user_id']][] = $row['method']; + } } $this->db->sql_freeresult($result); + $default_methods = $this->notification_manager->get_default_methods(); + foreach ($user_ids as $user_id) { - if (!in_array($user_id, $resulting_user_ids) && !isset($options['ignore_users'][$user_id])) + if (isset($options['ignore_users'][$user_id])) + { + continue; + } + if (!array_key_exists($user_id, $rowset)) { // No rows at all for this user, use the default methods - $rowset[$user_id] = $this->notification_manager->get_default_methods(); + $output[$user_id] = $default_methods; + } + else + { + foreach ($default_methods as $default_method) + { + if (!array_key_exists($default_method, $rowset[$user_id])) + { + // No user preference for this type recorded, but it should be enabled by default. + $output[$user_id][] = $default_method; + } + } } } - return $rowset; + return $output; } /** From 548357e14c1b8e05759609d130f02acfd0647539 Mon Sep 17 00:00:00 2001 From: Mark Shaw Date: Wed, 25 May 2016 18:28:07 -0400 Subject: [PATCH 2/2] [ticket/14648] Remove whitespace at the end of a line PHPBB3-14648 --- phpBB/phpbb/notification/type/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php index 8f05cfc80b..77ed7f2b09 100644 --- a/phpBB/phpbb/notification/type/base.php +++ b/phpBB/phpbb/notification/type/base.php @@ -487,7 +487,7 @@ abstract class base implements \phpbb\notification\type\type_interface foreach ($user_ids as $user_id) { - if (isset($options['ignore_users'][$user_id])) + if (isset($options['ignore_users'][$user_id])) { continue; }