diff options
author | Cesar G <prototech91@gmail.com> | 2013-11-21 13:02:26 -0800 |
---|---|---|
committer | Cesar G <prototech91@gmail.com> | 2013-11-21 13:02:26 -0800 |
commit | bcf347420e4fe400d02a6ee58e63839f18a86362 (patch) | |
tree | 6395f42716db550d1f2ddaa5208b04af1ef6066f /phpBB/phpbb/notification | |
parent | 46994e8dfbb3a50aeeb5b02cf850f8a7630b9e95 (diff) | |
download | forums-bcf347420e4fe400d02a6ee58e63839f18a86362.tar forums-bcf347420e4fe400d02a6ee58e63839f18a86362.tar.gz forums-bcf347420e4fe400d02a6ee58e63839f18a86362.tar.bz2 forums-bcf347420e4fe400d02a6ee58e63839f18a86362.tar.xz forums-bcf347420e4fe400d02a6ee58e63839f18a86362.zip |
[ticket/11959] Trim the list of users from post notifications.
PHPBB3-11959
Diffstat (limited to 'phpBB/phpbb/notification')
-rw-r--r-- | phpBB/phpbb/notification/type/post.php | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 9d5c7b0a4c..0d07df8adf 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -183,6 +183,10 @@ class post extends \phpbb\notification\type\base 'username' => $this->get_data('post_username'), )), $responders); + $responders_cnt = sizeof($responders); + $responders = $this->trim_user_ary($responders); + $extra_cnt = $responders_cnt - sizeof($responders); + foreach ($responders as $responder) { if ($responder['username']) @@ -194,11 +198,18 @@ class post extends \phpbb\notification\type\base $usernames[] = $this->user_loader->get_username($responder['poster_id'], 'no_profile'); } } + $lang_key = $this->language_key; + + if ($responders_cnt > 4) + { + $lang_key .= '_TRIMMED'; + } return $this->user->lang( - $this->language_key, + $lang_key, implode(', ', $usernames), - censor_text($this->get_data('topic_title')) + censor_text($this->get_data('topic_title')), + $extra_cnt ); } @@ -272,6 +283,22 @@ class post extends \phpbb\notification\type\base } } + return $this->trim_user_ary($users); + } + + /** + * Trim the user array passed down to 3 users if the array contains + * more than 4 users. + * + * @param array $users Array of users + * @return array Trimmed array of user_ids + */ + public function trim_user_ary($users) + { + if (sizeof($users) > 4) + { + array_splice($users, 3); + } return $users; } |