Documentation

Notify
in package
implements ActionInterface uses ActionSuffixRouter, ActionTrait

AbstractYes

This abstract class contains the main functionality to toggle email notification preferences for topics, boards and announcements.

It is extended by concrete classes that deal with each of those.

Mods can add support for more notification types by extending this class.

Table of Contents

Interfaces

ActionInterface
Interface for all action classes.

Constants

MODE_ALERT  = 2
MODE_BOTH  = 3
MODE_IGNORE  = 0
MODE_NO_ALERT  = -1
MODE_NO_EMAIL  = -2
MODE_NONE  = 1
PREF_ALERT  = 1
PREF_BOTH  = 3
PREF_EMAIL  = 2
PREF_NONE  = 0

Properties

$type  : string
$alert_pref  : int
$id  : int
$member_info  : array<string|int, mixed>
$mode  : int
$obj  : static
$token  : string

Methods

buildRoute()  : array<string|int, mixed>
Builds a routing path based on URL query parameters.
call()  : void
Convenience method to load() and execute() an instance of this class.
canBeLogged()  : bool
Determines whether this action can be logged in the online log.
canShowDebuggingInfo()  : bool
Determines whether debugging info should be shown.
canShowInMaintenanceMode()  : bool
Determines whether this action allows access in maintenance mode.
createUnsubscribeToken()  : string
Builds an unsubscribe token.
deleteNotifyPrefs()  : void
Deletes notification preference.
execute()  : void
Dispatcher to whichever sub-action method is necessary.
getMemberWithToken()  : array<string|int, mixed>
Verifies a member's unsubscribe token, then returns some member info.
getNotifyPrefs()  : array<string|int, mixed>
Fetches the list of preferences (or a single/subset of preferences) for notifications for one or more users.
getOutputType()  : OutputTypeInterface
Gets the output type for this action.
isAgreementAction()  : bool
Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
isRestrictedGuestAccessAllowed()  : bool
Determines whether this action allows access if guest access is restricted.
isSimpleAction()  : bool
Determines whether this is a simple action.
load()  : static
Static wrapper for constructor.
setNotifyPrefs()  : void
Sets the list of preferences for a single user.
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().
ask()  : void
Handles loading the notification settings page
askTemplateData()  : void
Sets any additional data needed for the ask template.
changeBoardTopicPref()  : void
Updates notification preferences for the board or topic.
changePref()  : void
Updates the notification preference in the database.
getSuccessMsg()  : mixed
Gets the success message to display.
prepareAjaxResponse()  : void
Adds some stuff to Utils::$context for AJAX output.
saToMode()  : void
Converts $_GET['sa'] to $_GET['mode'].
setAlertPref()  : void
Sets $this->alert_pref.
setId()  : void
For board and topic, make sure we have the necessary ID.
setMemberInfo()  : void
Sets self::$member_info with info about the member in question.
setMode()  : void
Sets $this->mode.
showConfirmation()  : void
Shows a confirmation message.

Constants

MODE_ALERT

public mixed MODE_ALERT = 2

MODE_BOTH

public mixed MODE_BOTH = 3

MODE_IGNORE

public mixed MODE_IGNORE = 0

MODE_NO_ALERT

public mixed MODE_NO_ALERT = -1

MODE_NO_EMAIL

public mixed MODE_NO_EMAIL = -2

MODE_NONE

public mixed MODE_NONE = 1

PREF_ALERT

public mixed PREF_ALERT = 1

PREF_BOTH

public mixed PREF_BOTH = 3

PREF_EMAIL

public mixed PREF_EMAIL = 2

PREF_NONE

public mixed PREF_NONE = 0

Properties

$type

public string $type

The notification type that this action handles.

$alert_pref

protected int $alert_pref

Preference value to save to the table.

$id

protected int $id

ID of the topic or board.

$member_info

protected static array<string|int, mixed> $member_info

Information about the user whose notifications preferences are changing. Will include ID number and email address.

$mode

protected int $mode

Requested notification mode.

$obj

protected static static $obj

An instance of this class. This is used by the load() method to prevent multiple instantiations.

$token

protected string $token

The unsubscribe token that the user supplied, if any.

Methods

buildRoute()

Builds a routing path based on URL query parameters.

public static buildRoute(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>

URL query parameters.

Return values
array<string|int, mixed>

Contains two elements: ['route' => [], 'params' => []]. The 'route' element contains the routing path. The 'params' element contains any $params that weren't incorporated into the route.

call()

Convenience method to load() and execute() an instance of this class.

public static call() : void

canBeLogged()

Determines whether this action can be logged in the online log.

public canBeLogged() : bool
Return values
bool

canShowDebuggingInfo()

Determines whether debugging info should be shown.

public canShowDebuggingInfo() : bool
Return values
bool

canShowInMaintenanceMode()

Determines whether this action allows access in maintenance mode.

public canShowInMaintenanceMode() : bool
Return values
bool

True if access is allowed, false otherwise.

createUnsubscribeToken()

Builds an unsubscribe token.

public static createUnsubscribeToken(int $memID, string $email[, string $type = '' ][, int $itemID = 0 ]) : string
Parameters
$memID : int

The id of the member that this token is for

$email : string

The member's email address

$type : string = ''

The type of notification the token is for (e.g. 'board', 'topic', etc.)

$itemID : int = 0

The id of the notification item, if applicable.

Return values
string

The unsubscribe token

deleteNotifyPrefs()

Deletes notification preference.

public static deleteNotifyPrefs(int $memID, array<string|int, mixed> $prefs) : void
Parameters
$memID : int

The user whose preference you're setting

$prefs : array<string|int, mixed>

The preferences to delete

execute()

Dispatcher to whichever sub-action method is necessary.

public execute() : void

getMemberWithToken()

Verifies a member's unsubscribe token, then returns some member info.

public static getMemberWithToken(string $type) : array<string|int, mixed>
Parameters
$type : string

The type of notification the token is for (e.g. 'board', 'topic', etc.)

Return values
array<string|int, mixed>

The id and email address of the specified member

getNotifyPrefs()

Fetches the list of preferences (or a single/subset of preferences) for notifications for one or more users.

public static getNotifyPrefs(int|array<string|int, mixed> $members[, string|array<string|int, mixed> $prefs = '' ][, bool $process_default = false ]) : array<string|int, mixed>
Parameters
$members : int|array<string|int, mixed>

A user id or an array of (integer) user ids to load preferences for

$prefs : string|array<string|int, mixed> = ''

An empty string to load all preferences, or a string (or array) of preference name(s) to load

$process_default : bool = false

Whether to apply the default values to the members' values or not.

Return values
array<string|int, mixed>

An array of user ids => array (pref name -> value), with user id 0 representing the defaults

isAgreementAction()

Determines whether this action can be accessed without accepting the registration agreement and privacy policy.

public isAgreementAction() : bool
Return values
bool

isRestrictedGuestAccessAllowed()

Determines whether this action allows access if guest access is restricted.

public isRestrictedGuestAccessAllowed() : bool
Return values
bool

True if access is allowed, false otherwise.

isSimpleAction()

Determines whether this is a simple action.

public isSimpleAction() : bool

Simple actions don't require the index template at all.

Return values
bool

load()

Static wrapper for constructor.

public static load() : static
Return values
static

An instance of this class.

setNotifyPrefs()

Sets the list of preferences for a single user.

public static setNotifyPrefs(int $memID[, array<string|int, mixed> $prefs = [] ]) : void
Parameters
$memID : int

The user whose preferences you are setting

$prefs : array<string|int, mixed> = []

An array key of pref -> value

__construct()

Constructor. Protected to force instantiation via self::load().

protected __construct() : mixed

ask()

Handles loading the notification settings page

protected ask() : void

askTemplateData()

Sets any additional data needed for the ask template.

protected abstract askTemplateData() : void

changeBoardTopicPref()

Updates notification preferences for the board or topic.

protected changeBoardTopicPref() : void

changePref()

Updates the notification preference in the database.

protected abstract changePref() : void

getSuccessMsg()

Gets the success message to display.

protected abstract getSuccessMsg() : mixed

prepareAjaxResponse()

Adds some stuff to Utils::$context for AJAX output.

protected prepareAjaxResponse() : void

saToMode()

Converts $_GET['sa'] to $_GET['mode'].

protected abstract saToMode() : void

sa=on/off is used for email subscribe/unsubscribe links.

setAlertPref()

Sets $this->alert_pref.

protected setAlertPref() : void

setId()

For board and topic, make sure we have the necessary ID.

protected abstract setId() : void

setMemberInfo()

Sets self::$member_info with info about the member in question.

protected setMemberInfo() : void

setMode()

Sets $this->mode.

protected setMode() : void

showConfirmation()

Shows a confirmation message.

protected showConfirmation() : void

        
On this page

Search results