Notification
in package
implements
ActionInterface
Uses
BackwardCompatibility
Handles preferences related to notifications.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $alert_types : array<string|int, mixed>
- $group_options : array<string|int, mixed>
- $subaction : string
- $subactions : array<string|int, mixed>
- $subtemplates : array<string|int, mixed>
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- alert_configuration() : void
- Backward compatibility wrapper for the configuration sub-action.
- alert_markread() : void
- Backward compatibility wrapper for the markRead sub-action.
- alert_notifications_boards() : void
- Backward compatibility wrapper for the boards sub-action.
- alert_notifications_topics() : void
- Backward compatibility wrapper for the topics sub-action.
- boards() : mixed
- Handles preferences related to board-level notifications.
- call() : void
- Convenience method to load() and execute() an instance of this class.
- configuration() : mixed
- Handles configuration of alert preferences.
- execute() : void
- Dispatcher to whichever sub-action method is necessary.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- list_getBoardNotifications() : array<string|int, mixed>
- Gets information about all the boards the user has requested notifications for.
- list_getTopicNotificationCount() : int
- Determines how many topics the user has requested notifications for.
- list_getTopicNotifications() : array<string|int, mixed>
- Gets information about all the topics the user has requested notifications for.
- load() : object
- Static wrapper for constructor.
- makeNotificationChanges() : void
- Backward compatibility wrapper for the changeNotifications method.
- markRead() : mixed
- Marks all alerts as read for user.
- topics() : mixed
- Handles alerts related to topics and posts.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- changeNotifications() : mixed
- Make any notification changes that need to be made.
Properties
$alert_types
public
array<string|int, mixed>
$alert_types
= ['board' => ['topic_notify' => ['alert' => 'yes', 'email' => 'yes'], 'board_notify' => ['alert' => 'yes', 'email' => 'yes']], 'msg' => ['msg_mention' => ['alert' => 'yes', 'email' => 'yes'], 'msg_quote' => ['alert' => 'yes', 'email' => 'yes'], 'msg_like' => ['alert' => 'yes', 'email' => 'never'], 'unapproved_reply' => ['alert' => 'yes', 'email' => 'yes']], 'pm' => ['pm_new' => ['alert' => 'never', 'email' => 'yes', 'help' => 'alert_pm_new', 'permission' => ['name' => 'pm_read', 'is_board' => false]], 'pm_reply' => ['alert' => 'never', 'email' => 'yes', 'help' => 'alert_pm_new', 'permission' => ['name' => 'pm_send', 'is_board' => false]]], 'groupr' => ['groupr_approved' => ['alert' => 'yes', 'email' => 'yes'], 'groupr_rejected' => ['alert' => 'yes', 'email' => 'yes']], 'moderation' => ['unapproved_attachment' => ['alert' => 'yes', 'email' => 'yes', 'permission' => ['name' => 'approve_posts', 'is_board' => true]], 'unapproved_post' => ['alert' => 'yes', 'email' => 'yes', 'permission' => ['name' => 'approve_posts', 'is_board' => true]], 'msg_report' => ['alert' => 'yes', 'email' => 'yes', 'permission' => ['name' => 'moderate_board', 'is_board' => true]], 'msg_report_reply' => ['alert' => 'yes', 'email' => 'yes', 'permission' => ['name' => 'moderate_board', 'is_board' => true]], 'member_report' => ['alert' => 'yes', 'email' => 'yes', 'permission' => ['name' => 'moderate_forum', 'is_board' => false]], 'member_report_reply' => ['alert' => 'yes', 'email' => 'yes', 'permission' => ['name' => 'moderate_forum', 'is_board' => false]]], 'members' => ['member_register' => ['alert' => 'yes', 'email' => 'yes', 'permission' => ['name' => 'moderate_forum', 'is_board' => false]], 'request_group' => ['alert' => 'yes', 'email' => 'yes'], 'warn_any' => ['alert' => 'yes', 'email' => 'yes', 'permission' => ['name' => 'issue_warning', 'is_board' => false]], 'buddy_request' => ['alert' => 'yes', 'email' => 'never'], 'birthday' => ['alert' => 'yes', 'email' => 'yes']], 'calendar' => ['event_new' => ['alert' => 'yes', 'email' => 'yes', 'help' => 'alert_event_new']], 'paidsubs' => ['paidsubs_expiring' => ['alert' => 'yes', 'email' => 'yes']]]
Defines all the types of alerts and their default values.
The 'alert' and 'email' keys are required for each alert type. The 'help' and 'permission' keys are optional.
Valid values for 'alert' and 'email' keys are: 'always', 'yes', 'never'. If using 'always' or 'never' you should add a help string.
$group_options
public
array<string|int, mixed>
$group_options
= ['board' => ['msg_auto_notify' => ['check', 'msg_auto_notify', 'label' => 'after'], 'msg_receive_body' => ['check', 'msg_receive_body', 'label' => 'after'], 'msg_notify_pref' => ['select', 'msg_notify_pref', 'label' => 'before', 'opts' => [0 => 'alert_opt_msg_notify_pref_never', 1 => 'alert_opt_msg_notify_pref_instant', 2 => 'alert_opt_msg_notify_pref_first', 3 => 'alert_opt_msg_notify_pref_daily', 4 => 'alert_opt_msg_notify_pref_weekly']], 'msg_notify_type' => ['select', 'msg_notify_type', 'label' => 'before', 'opts' => [1 => 'notify_send_type_everything', 2 => 'notify_send_type_everything_own', 3 => 'notify_send_type_only_replies', 4 => 'notify_send_type_nothing']]], 'pm' => ['pm_notify' => ['select', 'pm_notify', 'label' => 'before', 'opts' => [1 => 'email_notify_all', 2 => 'email_notify_buddies']]]]
The group level options.
$subaction
public
string
$subaction
= 'alerts'
The requested sub-action. This should be set by the constructor.
$subactions
public
static array<string|int, mixed>
$subactions
= ['alerts' => 'configuration', 'markread' => 'markRead', 'topics' => 'topics', 'boards' => 'boards']
Available sub-actions.
$subtemplates
public
static array<string|int, mixed>
$subtemplates
= ['alerts' => 'alert_configuration', 'markread' => 'alert_markread', 'topics' => 'alert_notifications_topics', 'boards' => 'alert_notifications_boards']
Available sub-actions.
$obj
protected
static object
$obj
An instance of this class. This is used by the load() method to prevent mulitple instantiations.
$backcompat
private
static array<string|int, mixed>
$backcompat
= ['func_names' => ['call' => 'notification', 'list_getTopicNotificationCount' => 'list_getTopicNotificationCount', 'list_getTopicNotifications' => 'list_getTopicNotifications', 'list_getBoardNotifications' => 'list_getBoardNotifications', 'alert_configuration' => 'alert_configuration', 'alert_markread' => 'alert_markread', 'alert_notifications_topics' => 'alert_notifications_topics', 'alert_notifications_boards' => 'alert_notifications_boards', 'makeNotificationChanges' => 'makeNotificationChanges']]
BackwardCompatibility settings for this class.
Methods
alert_configuration()
Backward compatibility wrapper for the configuration sub-action.
public
static alert_configuration(int $memID[, bool $defaultSettings = false ]) : void
Parameters
- $memID : int
-
The ID of the member.
- $defaultSettings : bool = false
-
If true, we are loading default options.
alert_markread()
Backward compatibility wrapper for the markRead sub-action.
public
static alert_markread(int $memID) : void
Parameters
- $memID : int
-
The ID of the member.
alert_notifications_boards()
Backward compatibility wrapper for the boards sub-action.
public
static alert_notifications_boards(int $memID) : void
Parameters
- $memID : int
-
The ID of the member.
alert_notifications_topics()
Backward compatibility wrapper for the topics sub-action.
public
static alert_notifications_topics(int $memID) : void
Parameters
- $memID : int
-
The ID of the member.
boards()
Handles preferences related to board-level notifications.
public
boards() : mixed
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
configuration()
Handles configuration of alert preferences.
public
configuration([bool $defaultSettings = false ]) : mixed
Parameters
- $defaultSettings : bool = false
-
If true, we are loading default options.
execute()
Dispatcher to whichever sub-action method is necessary.
public
execute() : void
exportStatic()
Provides a way to export a class's public static properties and methods to global namespace.
public
static exportStatic() : void
To do so:
- Use this trait in the class.
- At the END of the class's file, call its exportStatic() method.
Although it might not seem that way at first glance, this approach conforms to section 2.3 of PSR 1, since executing this method is simply a dynamic means of declaring functions when the file is included; it has no other side effects.
Regarding the $backcompat items:
A class's static properties are not exported to global variables unless explicitly included in $backcompat['prop_names']. Likewise, a class's static methods are not exported as global functions unless explicitly included in $backcompat['func_names'].
$backcompat['prop_names'] is a simple array where the keys are the names of one or more of a class's static properties, and the values are the names of global variables. In each case, the global variable will be set to a reference to the static property. Static properties that are not named in this array will not be exported.
$backcompat['func_names'] is a simple array where the keys are the names of one or more of a class's static methods, and the values are the names that should be used for global functions that will encapsulate those methods. Methods that are not named in this array will not be exported.
Adding non-static properties or methods to the $backcompat arrays will produce runtime errors. It is the responsibility of the developer to make sure not to do this.
list_getBoardNotifications()
Gets information about all the boards the user has requested notifications for.
public
static list_getBoardNotifications(int $start, int $items_per_page, string $sort) : array<string|int, mixed>
Parameters
- $start : int
-
Which item to start with (not used here).
- $items_per_page : int
-
How many items to show on each page (not used here).
- $sort : string
-
A string indicating how to sort the results.
Return values
array<string|int, mixed> —An array of information about all the boards the user is subscribed to.
list_getTopicNotificationCount()
Determines how many topics the user has requested notifications for.
public
static list_getTopicNotificationCount() : int
Return values
int —The number of topics the user has subscribed to.
list_getTopicNotifications()
Gets information about all the topics the user has requested notifications for.
public
static list_getTopicNotifications(int $start, int $items_per_page, string $sort) : array<string|int, mixed>
Parameters
- $start : int
-
Which item to start with (for pagination purposes).
- $items_per_page : int
-
How many items to display on each page.
- $sort : string
-
A string indicating how to sort the results.
Return values
array<string|int, mixed> —An array of information about the topics the user has subscribed to.
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
makeNotificationChanges()
Backward compatibility wrapper for the changeNotifications method.
public
static makeNotificationChanges(int $memID) : void
Parameters
- $memID : int
-
The ID of the member.
markRead()
Marks all alerts as read for user.
public
markRead() : mixed
topics()
Handles alerts related to topics and posts.
public
topics() : mixed
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
changeNotifications()
Make any notification changes that need to be made.
protected
changeNotifications() : mixed