phpBB API Documentation
Class

phpbb\notification\manager

class manager

Notifications service class

Methods

manager __construct(array $notification_types, array $notification_methods, ContainerInterface $phpbb_container, user_loader $user_loader, dispatcher_interface $phpbb_dispatcher, driver_interface $db, service $cache, language $language, user $user, string $notification_types_table, string $user_notifications_table)

Notification Constructor

array load_notifications(string $method_name, array $options = array())

Load the user's notifications for a given method

mark_notifications_read(bool|string|array $notification_type_name, bool|int|array $item_id, bool|int|array $user_id, bool|int $time = false)

Mark notifications read or unread for all available methods

mark_notifications(bool|string|array $notification_type_name, bool|int|array $item_id, bool|int|array $user_id, bool|int $time = false, bool $mark_read = true)

Mark notifications read or unread for all available methods

mark_notifications_read_by_parent(string|array $notification_type_name, bool|int|array $item_parent_id, bool|int|array $user_id, bool|int $time = false)

Mark notifications read or unread from a parent identifier for all available methods

mark_notifications_by_parent(string|array $notification_type_name, bool|int|array $item_parent_id, bool|int|array $user_id, bool|int $time = false, bool $mark_read = true)

Mark notifications read or unread from a parent identifier for all available methods

mark_notifications_by_id(string $method_name, int|array $notification_id, bool|int $time = false, bool $mark_read = true)

Mark notifications read or unread for a given method

array add_notifications(string|array $notification_type_name, array $data, array $options = array())

Add a notification

add_notifications_for_users(string|array $notification_type_name, array $data, array $notify_users)

Add a notification for specific users

update_notifications(string|array $notification_type_name, array $data, array $options = array())

Update notification

update_notification(type_interface $notification, array $data, array $options = array())

Update a notification

delete_notifications(string|array $notification_type_name, int|array $item_id, mixed $parent_id = false, mixed $user_id = false)

Delete a notification

array get_subscription_types()

Get all of the subscription types

array get_subscription_methods()

Get all of the subscription methods

array get_global_subscriptions(bool|int $user_id = false)

Get global subscriptions (item_id = 0)

add_subscription(string $item_type, int $item_id, string $method = null, bool|int $user_id = false)

Add a subscription

delete_subscription(string $item_type, int $item_id, string $method = null, bool|int $user_id = false)

Delete a subscription

disable_notifications(string $notification_type_name)

Disable all notifications of a certain type

purge_notifications(string $notification_type_name)

Purge all notifications of a certain type

enable_notifications(string $notification_type_name)

Enable all notifications of a certain type

prune_notifications(int $timestamp, bool $only_read = true)

Delete all notifications older than a certain time

method_interface[] get_default_methods()

Helper to get the list of methods enabled by default

type_interface get_item_type_class(string $notification_type_name, array $data = array())

Helper to get the notifications item type class and set it up

method_interface get_method_class(string $method_name)

Helper to get the notifications method class and set it up

int get_notification_type_id(string $notification_type_name)

Get the notification type id from the name

array get_notification_type_ids(string|array $notification_type_names)

Get notification type ids (as an array)

array get_notified_users(bool|string|array $notification_type_name, array $options)

Find the users which are already notified

Details

at line 76
public manager __construct(array $notification_types, array $notification_methods, ContainerInterface $phpbb_container, user_loader $user_loader, dispatcher_interface $phpbb_dispatcher, driver_interface $db, service $cache, language $language, user $user, string $notification_types_table, string $user_notifications_table)

Notification Constructor

Parameters

array $notification_types
array $notification_methods
ContainerInterface $phpbb_container
user_loader $user_loader
dispatcher_interface $phpbb_dispatcher
driver_interface $db
service $cache
language $language
user $user
string $notification_types_table
string $user_notifications_table

Return Value

manager

at line 113
public array load_notifications(string $method_name, array $options = array())

Load the user's notifications for a given method

Parameters

string $method_name
array $options Optional options to control what notifications are loaded notificationid Notification id to load (or array of notification ids) userid User id to load notifications for (Default: $user->data['userid']) orderby Order by (Default: notificationtime) orderdir Order direction (Default: DESC) limit Number of notifications to load (Default: 5) start Notifications offset (Default: 0) allunread Load all unread notifications? If set to true, countunread is set to true (Default: false) countunread Count all unread notifications? (Default: false) counttotal Count all notifications? (Default: false)

Return Value

array Array of information based on the request with keys: 'notifications' array of notification type objects 'unreadcount' number of unread notifications the user has if countunread is true in the options 'totalcount' number of notifications the user has if counttotal is true in the options

Exceptions

exception when the method doesn't refer to a class extending \phpbb\notification\method\method_interface

at line 145
public mark_notifications_read(bool|string|array $notification_type_name, bool|int|array $item_id, bool|int|array $user_id, bool|int $time = false)

Mark notifications read or unread for all available methods

Parameters

bool|string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types). False to mark read for all item types
bool|int|array $item_id Item id or array of item ids. False to mark read for all item ids
bool|int|array $user_id User id or array of user ids. False to mark read for all user ids
bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False)

at line 159
public mark_notifications(bool|string|array $notification_type_name, bool|int|array $item_id, bool|int|array $user_id, bool|int $time = false, bool $mark_read = true)

Mark notifications read or unread for all available methods

Parameters

bool|string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types). False to mark read for all item types
bool|int|array $item_id Item id or array of item ids. False to mark read for all item ids
bool|int|array $user_id User id or array of user ids. False to mark read for all user ids
bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False)
bool $mark_read Define if the notification as to be set to True or False. (Default: True)

at line 191
public mark_notifications_read_by_parent(string|array $notification_type_name, bool|int|array $item_parent_id, bool|int|array $user_id, bool|int $time = false)

Mark notifications read or unread from a parent identifier for all available methods

Parameters

string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types)
bool|int|array $item_parent_id Item parent id or array of item parent ids. False to mark read for all item parent ids
bool|int|array $user_id User id or array of user ids. False to mark read for all user ids
bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False)

at line 205
public mark_notifications_by_parent(string|array $notification_type_name, bool|int|array $item_parent_id, bool|int|array $user_id, bool|int $time = false, bool $mark_read = true)

Mark notifications read or unread from a parent identifier for all available methods

Parameters

string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types)
bool|int|array $item_parent_id Item parent id or array of item parent ids. False to mark read for all item parent ids
bool|int|array $user_id User id or array of user ids. False to mark read for all user ids
bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False)
bool $mark_read Define if the notification as to be set to True or False. (Default: True)

at line 231
public mark_notifications_by_id(string $method_name, int|array $notification_id, bool|int $time = false, bool $mark_read = true)

Mark notifications read or unread for a given method

Parameters

string $method_name
int|array $notification_id Notification id or array of notification ids.
bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False)
bool $mark_read Define if the notification as to be set to True or False. (Default: True)

at line 252
public array add_notifications(string|array $notification_type_name, array $data, array $options = array())

Add a notification

Parameters

string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types) Note: If you send an array of types, any user who could receive multiple notifications from this single item will only receive a single notification. If they MUST receive multiple notifications, call this function multiple times instead of sending an array
array $data Data specific for this type that will be inserted
array $options Optional options to control what notifications are loaded ignore_users array of data to specify which users should not receive certain types of notifications

Return Value

array Information about what users were notified and how they were notified

at line 307
public add_notifications_for_users(string|array $notification_type_name, array $data, array $notify_users)

Add a notification for specific users

Parameters

string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types)
array $data Data specific for this type that will be inserted
array $notify_users User list to notify

at line 414
public update_notifications(string|array $notification_type_name, array $data, array $options = array())

Update notification

Parameters

string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types)
array $data Data specific for this type that will be updated
array $options

at line 436
public update_notification(type_interface $notification, array $data, array $options = array())

Update a notification

Parameters

type_interface $notification The notification
array $data Data specific for this type that will be updated
array $options

at line 458
public delete_notifications(string|array $notification_type_name, int|array $item_id, mixed $parent_id = false, mixed $user_id = false)

Delete a notification

Parameters

string|array $notification_type_name Type identifier or array of item types (only acceptable if the $item_id is identical for the specified types)
int|array $item_id Identifier within the type (or array of ids)
mixed $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified (Default: false; not checked)
mixed $user_id User id (Default: false; not checked)

at line 484
public array get_subscription_types()

Get all of the subscription types

Return Value

array Array of item types

at line 525
public array get_subscription_methods()

Get all of the subscription methods

Return Value

array Array of methods

at line 620
public array get_global_subscriptions(bool|int $user_id = false)

Get global subscriptions (item_id = 0)

Parameters

bool|int $user_id The user_id to add the subscription for (bool false for current user)

Return Value

array Subscriptions

at line 674
public add_subscription(string $item_type, int $item_id, string $method = null, bool|int $user_id = false)

Add a subscription

Parameters

string $item_type Type identifier of the subscription
int $item_id The id of the item
string $method The method of the notification e.g. 'board', 'email', or 'jabber' (if null a subscription will be added for all the defaults methods)
bool|int $user_id The user_id to add the subscription for (bool false for current user)

at line 730
public delete_subscription(string $item_type, int $item_id, string $method = null, bool|int $user_id = false)

Delete a subscription

Parameters

string $item_type Type identifier of the subscription
int $item_id The id of the item
string $method The method of the notification e.g. 'board', 'email', or 'jabber'
bool|int $user_id The user_id to add the subscription for (bool false for current user)

at line 775
public disable_notifications(string $notification_type_name)

Disable all notifications of a certain type

This should be called when an extension which has notification types is disabled so that all those notifications are hidden and do not cause errors

Parameters

string $notification_type_name Type identifier of the subscription

at line 791
public purge_notifications(string $notification_type_name)

Purge all notifications of a certain type

This should be called when an extension which has notification types is purged so that all those notifications are removed

Parameters

string $notification_type_name Type identifier of the subscription

at line 825
public enable_notifications(string $notification_type_name)

Enable all notifications of a certain type

This should be called when an extension which has notification types that was disabled is re-enabled so that all those notifications that were hidden are shown again

Parameters

string $notification_type_name Type identifier of the subscription

at line 839
public prune_notifications(int $timestamp, bool $only_read = true)

Delete all notifications older than a certain time

Parameters

int $timestamp Unix timestamp to delete all notifications that were created before
bool $only_read True (default) to only prune read notifications

at line 853
public method_interface[] get_default_methods()

Helper to get the list of methods enabled by default

Return Value

method_interface[]

at line 875
public type_interface get_item_type_class(string $notification_type_name, array $data = array())

Helper to get the notifications item type class and set it up

Parameters

string $notification_type_name
array $data

Return Value

type_interface

at line 890
public method_interface get_method_class(string $method_name)

Helper to get the notifications method class and set it up

Parameters

string $method_name

Return Value

method_interface

at line 920
public int get_notification_type_id(string $notification_type_name)

Get the notification type id from the name

Parameters

string $notification_type_name The name

Return Value

int the notificationtypeid

Exceptions

exception

at line 960
public array get_notification_type_ids(string|array $notification_type_names)

Get notification type ids (as an array)

Parameters

string|array $notification_type_names Notification type names

Return Value

array Array of integers

at line 984
public array get_notified_users(bool|string|array $notification_type_name, array $options)

Find the users which are already notified

Parameters

bool|string|array $notification_type_name Type identifier or array of item types (only acceptable if the $data is identical for the specified types). False to retrieve all item types
array $options

Return Value

array The list of the notified users