class manager

Notifications service class

Properties

protected array $notification_types
protected array $subscription_types
protected array $notification_methods
protected ContainerInterface $phpbb_container
protected user_loader $user_loader
protected config $config
protected dispatcher_interface $phpbb_dispatcher
protected driver_interface $db
protected service $cache
protected user $user
protected string $phpbb_root_path
protected string $php_ext
protected string $notification_types_table
protected string $notifications_table
protected string $user_notifications_table

Methods

__construct(array $notification_types, array $notification_methods, ContainerInterface $phpbb_container, user_loader $user_loader, config $config, dispatcher_interface $phpbb_dispatcher, driver_interface $db, service $cache, user $user, string $phpbb_root_path, string $php_ext, string $notification_types_table, string $notifications_table, string $user_notifications_table)

Notification Constructor

array
load_notifications(array $options = array())

Load the user's notifications

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

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 from a parent identifier

mark_notifications_read_by_id(int|array $notification_id, bool|int $time = false)

Mark notifications read

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)

Update a notification

delete_notifications(string|array $notification_type_name, int|array $item_id, mixed $parent_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_user_notifications(int $user_id)

Get user's notification data

array
get_global_subscriptions(bool|int $user_id = false)

Get global subscriptions (item_id = 0)

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

Add a subscription

delete_subscription(string $item_type, int $item_id = 0, string $method = '', 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

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

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

get_method_class($method_name)

Helper to get the notifications method class and set it up

load_object($object_name)

Helper to load objects (notification types/methods)

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)

Details

at line 88
manager __construct(array $notification_types, array $notification_methods, ContainerInterface $phpbb_container, user_loader $user_loader, config $config, dispatcher_interface $phpbb_dispatcher, driver_interface $db, service $cache, user $user, string $phpbb_root_path, string $php_ext, string $notification_types_table, string $notifications_table, string $user_notifications_table)

Notification Constructor

Parameters

array $notification_types
array $notification_methods
ContainerInterface $phpbb_container
user_loader $user_loader
config $config
dispatcher_interface $phpbb_dispatcher
driver_interface $db
service $cache
user $user
string $phpbb_root_path
string $php_ext
string $notification_types_table
string $notifications_table
string $user_notifications_table

Return Value

manager

at line 127
array load_notifications(array $options = array())

Load the user's notifications

Parameters

array $options Optional options to control what notifications are loaded notification_id Notification id to load (or array of notification ids) user_id User id to load notifications for (Default: $user->data['user_id']) order_by Order by (Default: notification_time) order_dir Order direction (Default: DESC) limit Number of notifications to load (Default: 5) start Notifications offset (Default: 0) all_unread Load all unread notifications? If set to true, count_unread is set to true (Default: false) count_unread Count all unread notifications? (Default: false) count_total Count all notifications? (Default: false)

Return Value

array Array of information based on the request with keys: 'notifications' array of notification type objects 'unread_count' number of unread notifications the user has if count_unread is true in the options 'total_count' number of notifications the user has if count_total is true in the options

at line 271
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

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 292
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 from a parent identifier

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 311
mark_notifications_read_by_id(int|array $notification_id, bool|int $time = false)

Mark notifications read

Parameters

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)

at line 333
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 390
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 485
update_notifications(string|array $notification_type_name, array $data)

Update 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)
array $data Data specific for this type that will be updated

at line 527
delete_notifications(string|array $notification_type_name, int|array $item_id, mixed $parent_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)

at line 553
array get_subscription_types()

Get all of the subscription types

Return Value

array Array of item types

at line 592
array get_subscription_methods()

Get all of the subscription methods

Return Value

array Array of methods

at line 620
protected array get_user_notifications(int $user_id)

Get user's notification data

Parameters

int $user_id The user_id of the user to get the notifications for

Return Value

array User's notification

at line 647
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 696
add_subscription(string $item_type, int $item_id = 0, string $method = '', 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. '', 'email', or 'jabber'
bool|int $user_id The user_id to add the subscription for (bool false for current user)

at line 748
delete_subscription(string $item_type, int $item_id = 0, string $method = '', 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. '', 'email', or 'jabber'
bool|int $user_id The user_id to add the subscription for (bool false for current user)

at line 803
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 819
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 856
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 870
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 883
get_item_type_class($notification_type_name, $data = array())

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

Parameters

$notification_type_name
$data

at line 895
get_method_class($method_name)

Helper to get the notifications method class and set it up

Parameters

$method_name

at line 903
protected load_object($object_name)

Helper to load objects (notification types/methods)

Parameters

$object_name

at line 922
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 notification_type_id

Exceptions

exception

at line 974
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