abstract class base implements type_interface

Base notifications class

Properties

protected manager $notification_manager
protected driver_interface $db
protected language $language
protected user $user
protected auth $auth
protected string $phpbb_root_path
protected string $php_ext
protected string $user_notifications_table
static bool|array $notification_option

Notification option data (for outputting to the user)

protected int $notification_type_id

The notification_type_id, set upon creation of the class This is the notification_type_id from the notification_types table

Methods

__construct(driver_interface $db, language $language, user $user, auth $auth, string $phpbb_root_path, string $php_ext, string $user_notifications_table)

Notification Type Base Constructor

set_notification_manager(manager $notification_manager)

Set notification manager (required)

set_initial_data(array $data = array())

Set initial data from the database

mixed
__get(mixed $name)

Magic method to get data from this notification

null
__set(mixed $name, mixed $value)

Magic method to set data on this notification

mixed
__toString()

Magic method to get a string of this notification

mixed
get_data(string $name)

Get special data (only important for the classes that extend this)

mixed
set_data(string $name, mixed $value)

Set special data (only important for the classes that extend this)

create_insert_array(array $type_data, array $pre_create_data = array())

Function for preparing the data for insertion in an SQL query

array
get_insert_array()

Function for getting the data for insertion in an SQL query

array
create_update_array(array $type_data)

Function for preparing the data for update in an SQL query (The service handles insertion)

string
mark_read(bool $return = false)

Mark this item read

string
mark_unread(bool $return = false)

Mark this item unread

string
get_redirect_url()

{inheritDoc}

prepare_for_display()

Prepare to output the notification to the template

get_unsubscribe_url(string|bool $method = false)

URL to unsubscribe to this notification (fall back)

string
get_style_class()

Get the CSS style class of the notification (fall back)

string
get_avatar()

Get the user's avatar (fall back)

string
get_reference()

Get the reference of the notification (fall back)

string
get_forum()

Get the forum of the notification reference (fall back)

string
get_reason()

Get the reason for the notification (fall back)

array
get_load_special()

Get the special items to load (fall back)

load_special(array $data, array $notifications)

Load the special items (fall back)

bool
is_available()

Is available (fall back)

array
pre_create_insert_array(array $type_data, array $notify_users)

Pre create insert array function (fall back)

array
check_user_notification_options(array|bool $user_ids = false, array $options = array())

Find the users who want to receive notifications (helper)

string|null
mark(bool $unread = true, bool $return = false)

Mark this item read/unread helper

array
get_authorised_recipients(array $users, int $forum_id, array $options, bool $sort = false)

Get a list of users that are authorised to receive notifications

Details

at line 87
__construct(driver_interface $db, language $language, user $user, auth $auth, string $phpbb_root_path, string $php_ext, string $user_notifications_table)

Notification Type Base Constructor

Parameters

driver_interface $db
language $language
user $user
auth $auth
string $phpbb_root_path
string $php_ext
string $user_notifications_table

at line 105
set_notification_manager(manager $notification_manager)

Set notification manager (required)

Parameters

manager $notification_manager

at line 117
set_initial_data(array $data = array())

Set initial data from the database

Parameters

array $data

Row directly from the database

at line 130
mixed __get(mixed $name)

Magic method to get data from this notification

Parameters

mixed $name

Return Value

mixed

at line 144
null __set(mixed $name, mixed $value)

Magic method to set data on this notification

Parameters

mixed $name
mixed $value

Return Value

null

at line 157
mixed __toString()

Magic method to get a string of this notification

Primarily for testing

Return Value

mixed

at line 168
protected mixed get_data(string $name)

Get special data (only important for the classes that extend this)

Parameters

string $name

Name of the variable to get

Return Value

mixed

at line 180
protected mixed set_data(string $name, mixed $value)

Set special data (only important for the classes that extend this)

Parameters

string $name

Name of the variable to set

mixed $value

Value to set to the variable

Return Value

mixed

at line 188
create_insert_array(array $type_data, array $pre_create_data = array())

Function for preparing the data for insertion in an SQL query

Parameters

array $type_data

The type specific data

array $pre_create_data

Data from pre_create_insert_array()

at line 206
array get_insert_array()

Function for getting the data for insertion in an SQL query

Return Value

array

Array of data ready to be inserted into the database

at line 222
array create_update_array(array $type_data)

Function for preparing the data for update in an SQL query (The service handles insertion)

Parameters

array $type_data

Data unique to this notification type

Return Value

array

Array of data ready to be updated in the database

at line 244
string mark_read(bool $return = false)

Mark this item read

Parameters

bool $return

True to return a string containing the SQL code to update this item, False to execute it (Default: False)

Return Value

string

at line 255
string mark_unread(bool $return = false)

Mark this item unread

Parameters

bool $return

True to return a string containing the SQL code to update this item, False to execute it (Default: False)

Return Value

string

at line 263
string get_redirect_url()

{inheritDoc}

Return Value

string URL

at line 273
prepare_for_display()

Prepare to output the notification to the template

at line 313
get_unsubscribe_url(string|bool $method = false)

URL to unsubscribe to this notification (fall back)

Parameters

string|bool $method

Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item

at line 323
string get_style_class()

Get the CSS style class of the notification (fall back)

Return Value

string

at line 333
string get_avatar()

Get the user's avatar (fall back)

Return Value

string

at line 343
string get_reference()

Get the reference of the notification (fall back)

Return Value

string

at line 353
string get_forum()

Get the forum of the notification reference (fall back)

Return Value

string

at line 363
string get_reason()

Get the reason for the notification (fall back)

Return Value

string

at line 373
array get_load_special()

Get the special items to load (fall back)

Return Value

array

Data will be combined sent to load_special() so you can run a single query and get data required for this notification type

at line 384
load_special(array $data, array $notifications)

Load the special items (fall back)

Parameters

array $data

Data from get_load_special()

array $notifications

Array of notifications (key is notification_id, value is the notification objects)

at line 394
bool is_available()

Is available (fall back)

Return Value

bool

True/False whether or not this is available to the user

at line 406
array pre_create_insert_array(array $type_data, array $notify_users)

Pre create insert array function (fall back)

Parameters

array $type_data

The type specific data

array $notify_users

Notify users list Formatted from find_users_for_notification()

Return Value

array

Whatever you want to send to create_insert_array().

at line 423
protected array check_user_notification_options(array|bool $user_ids = false, array $options = array())

Find the users who want to receive notifications (helper)

Parameters

array|bool $user_ids

User IDs to check if they want to receive notifications (Bool False to check all users besides anonymous and bots (USER_IGNORE))

array $options

Return Value

array

at line 522
protected string|null mark(bool $unread = true, bool $return = false)

Mark this item read/unread helper

Parameters

bool $unread

Unread (True/False) (Default: False)

bool $return

True to return a string containing the SQL code to update this item, False to execute it (Default: False)

Return Value

string|null

If $return is False, nothing will be returned, else the sql code to update this item

at line 554
protected array get_authorised_recipients(array $users, int $forum_id, array $options, bool $sort = false)

Get a list of users that are authorised to receive notifications

Parameters

array $users

Array of users that have subscribed to a notification

int $forum_id

Forum ID of the forum

array $options

Array of notification options

bool $sort

Whether the users array should be sorted. Default: false

Return Value

array

Array of users that are authorised recipients