1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-01 03:54:56 +02:00

[ticket/11959] Trim the list of users from post notifications.

PHPBB3-11959
This commit is contained in:
Cesar G 2013-11-21 13:02:26 -08:00
parent 46994e8dfb
commit bcf347420e
2 changed files with 32 additions and 2 deletions

View File

@ -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".',

View File

@ -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;
}