mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00: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
2 changed files with 33 additions and 3 deletions
|
@ -416,14 +416,17 @@ $lang = array_merge($lang, array(
|
||||||
'NOT_WATCHING_TOPIC' => 'You are no longer subscribed to this topic.',
|
'NOT_WATCHING_TOPIC' => 'You are no longer subscribed to this topic.',
|
||||||
'NOTIFICATIONS' => 'Notifications',
|
'NOTIFICATIONS' => 'Notifications',
|
||||||
'NOTIFICATION_BOOKMARK' => '%1$s replied to the topic "%2$s" you have bookmarked.',
|
'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' => '%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_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_PM' => '%1$s sent you a Private Message "%2$s".',
|
||||||
'NOTIFICATION_POST' => '%1$s replied to the topic "%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_APPROVED' => 'Your post was approved "%2$s".',
|
||||||
'NOTIFICATION_POST_DISAPPROVED' => 'Your post "%1$s" was disapproved for reason: "%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_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' => '%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_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_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".',
|
'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'),
|
'username' => $this->get_data('post_username'),
|
||||||
)), $responders);
|
)), $responders);
|
||||||
|
|
||||||
|
$responders_cnt = sizeof($responders);
|
||||||
|
$responders = $this->trim_user_ary($responders);
|
||||||
|
$trimmed_responders_cnt = $responders_cnt - sizeof($responders);
|
||||||
|
|
||||||
foreach ($responders as $responder)
|
foreach ($responders as $responder)
|
||||||
{
|
{
|
||||||
if ($responder['username'])
|
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');
|
$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(
|
return $this->user->lang(
|
||||||
$this->language_key,
|
$lang_key,
|
||||||
implode(', ', $usernames),
|
implode($this->user->lang['COMMA_SEPARATOR'], $usernames),
|
||||||
censor_text($this->get_data('topic_title'))
|
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;
|
return $users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue