[ticket/12742] Put duplicated code into one method in notifications base

Ticket: https://tracker.phpbb.com/browse/PHPBB3-12742