diff options
author | Mark Shaw <mark.shaw@mail.utoronto.ca> | 2016-05-25 14:30:04 -0400 |
---|---|---|
committer | Mark Shaw <mark.shaw@mail.utoronto.ca> | 2016-05-25 14:30:04 -0400 |
commit | 25769935641aabee4e11141faf45a0040cb93fb7 (patch) | |
tree | 758bce4b8b0be045fd6e63344b4f1918d661dfdb /phpBB/phpbb/notification | |
parent | 3e88ea9c061c5f416077f54fa8f2675643a3219a (diff) | |
download | forums-25769935641aabee4e11141faf45a0040cb93fb7.tar forums-25769935641aabee4e11141faf45a0040cb93fb7.tar.gz forums-25769935641aabee4e11141faf45a0040cb93fb7.tar.bz2 forums-25769935641aabee4e11141faf45a0040cb93fb7.tar.xz forums-25769935641aabee4e11141faf45a0040cb93fb7.zip |
[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
Diffstat (limited to 'phpBB/phpbb/notification')
-rw-r--r-- | phpBB/phpbb/notification/type/base.php | 39 |
1 files 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; } /** |