mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 12:03:21 +01:00
Merge pull request #1882 from prototech/ticket/11959
[ticket/11959] Trim the list of users from post notifications.
This commit is contained in:
commit
20885ccb8c
@ -416,14 +416,17 @@ $lang = array_merge($lang, array(
|
||||
'NOT_WATCHING_TOPIC' => 'You are no longer subscribed to this topic.',
|
||||
'NOTIFICATIONS' => 'Notifications',
|
||||
'NOTIFICATION_BOOKMARK' => '%1$s replied to the topic "%2$s" you have bookmarked.',
|
||||
'NOTIFICATION_BOOKMARK_TRIMMED' => '%1$s and %3$d others replied to the topic “%2$s” you have bookmarked.',
|
||||
'NOTIFICATION_GROUP_REQUEST' => '%1$s is requesting to join the group %2$s.',
|
||||
'NOTIFICATION_GROUP_REQUEST_APPROVED' => 'Your request to join the group %1$s has been approved.',
|
||||
'NOTIFICATION_PM' => '%1$s sent you a Private Message "%2$s".',
|
||||
'NOTIFICATION_POST' => '%1$s replied to the topic "%2$s".',
|
||||
'NOTIFICATION_POST_TRIMMED' => '%1$s and %3$d others replied to the topic “%2$s”',
|
||||
'NOTIFICATION_POST_APPROVED' => 'Your post was approved "%2$s".',
|
||||
'NOTIFICATION_POST_DISAPPROVED' => 'Your post "%1$s" was disapproved for reason: "%2$s".',
|
||||
'NOTIFICATION_POST_IN_QUEUE' => 'A new post titled "%2$s" was posted by %1$s and needs approval.',
|
||||
'NOTIFICATION_QUOTE' => '%1$s quoted you in the post "%2$s".',
|
||||
'NOTIFICATION_QUOTE_TRIMMED' => '%1$s and %3$d others replied to the topic “%2$s”',
|
||||
'NOTIFICATION_REPORT_PM' => '%1$s reported a Private Message "%2$s" for reason: "%3$s".',
|
||||
'NOTIFICATION_REPORT_POST' => '%1$s reported a post "%2$s" for reason: "%3$s".',
|
||||
'NOTIFICATION_REPORT_CLOSED' => '%1$s closed the report you made for "%2$s".',
|
||||
|
@ -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);
|
||||
$trimmed_responders_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 ($trimmed_responders_cnt)
|
||||
{
|
||||
$lang_key .= '_TRIMMED';
|
||||
}
|
||||
|
||||
return $this->user->lang(
|
||||
$this->language_key,
|
||||
implode(', ', $usernames),
|
||||
censor_text($this->get_data('topic_title'))
|
||||
$lang_key,
|
||||
implode($this->user->lang['COMMA_SEPARATOR'], $usernames),
|
||||
censor_text($this->get_data('topic_title')),
|
||||
$trimmed_responders_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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user