Who
in package
implements
ActionInterface, Routable
uses
ActionRouter, ActionTrait
Who's online, and what are they doing? This class prepares the who's online data for the Who template.
It requires the who_view permission. It is enabled with the who_enabled setting. It is accessed via ?action=who.
Uses Who template, main sub-template Uses Who language file.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
- Routable
- Classes implementing this interface can build routes from URL query parameters and parse routes back into URL query parameters.
Properties
- $allowedActions : array<string|int, mixed>
- $obj : static
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.
- determineActions() : array<string|int, mixed>|string
- This method determines the actions of the members passed in URLs.
- execute() : void
- Dispatcher to whichever sub-action method is necessary.
- 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.
- parseRoute() : array<string|int, mixed>
- Parses a route to get URL query parameters.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- buildActionRoute() : array<string|int, mixed>
- Builds a routing path for an action based on URL query parameters.
- parseActionRoute() : array<string|int, mixed>
- Parses a route for an action to get URL query parameters.
Properties
$allowedActions
public
static array<string|int, mixed>
$allowedActions
= ['admin' => ['moderate_forum', 'manage_membergroups', 'manage_bans', 'admin_forum', 'manage_permissions', 'send_mail', 'manage_attachments', 'manage_smileys', 'manage_boards', 'edit_news'], 'ban' => ['manage_bans'], 'boardrecount' => ['admin_forum'], 'calendar' => ['calendar_view'], 'corefeatures' => ['admin_forum'], 'editnews' => ['edit_news'], 'featuresettings' => ['admin_forum'], 'languages' => ['admin_forum'], 'logs' => ['admin_forum'], 'mailing' => ['send_mail'], 'mailqueue' => ['admin_forum'], 'maintain' => ['admin_forum'], 'manageattachments' => ['manage_attachments'], 'manageboards' => ['manage_boards'], 'managecalendar' => ['admin_forum'], 'managesearch' => ['admin_forum'], 'managesmileys' => ['manage_smileys'], 'membergroups' => ['manage_membergroups'], 'mlist' => ['view_mlist'], 'moderate' => ['access_mod_center', 'moderate_forum', 'manage_membergroups'], 'modsettings' => ['admin_forum'], 'news' => ['edit_news', 'send_mail', 'admin_forum'], 'optimizetables' => ['admin_forum'], 'packages' => ['admin_forum'], 'paidsubscribe' => ['admin_forum'], 'permissions' => ['manage_permissions'], 'postsettings' => ['admin_forum'], 'regcenter' => ['admin_forum', 'moderate_forum'], 'repairboards' => ['admin_forum'], 'reports' => ['admin_forum'], 'scheduledtasks' => ['admin_forum'], 'search' => ['search_posts'], 'search2' => ['search_posts'], 'securitysettings' => ['admin_forum'], 'sengines' => ['admin_forum'], 'serversettings' => ['admin_forum'], 'setcensor' => ['moderate_forum'], 'setreserve' => ['moderate_forum'], 'stats' => ['view_stats'], 'theme' => ['admin_forum'], 'viewerrorlog' => ['admin_forum'], 'viewmembers' => ['moderate_forum']]
Actions that require a specific permission level.
$obj
protected
static static
$obj
An instance of this class. This is used by the load() method to prevent multiple instantiations.
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
boolcanShowDebuggingInfo()
Determines whether debugging info should be shown.
public
canShowDebuggingInfo() : bool
Return values
boolcanShowInMaintenanceMode()
Determines whether this action allows access in maintenance mode.
public
canShowInMaintenanceMode() : bool
Return values
bool —True if access is allowed, false otherwise.
determineActions()
This method determines the actions of the members passed in URLs.
public
static determineActions(mixed $urls[, string|bool $preferred_prefix = false ]) : array<string|int, mixed>|string
Adding actions to the Who's Online list: Adding actions to this list is actually relatively easy...
- for actions anyone should be able to see, just add a string named whoall_ACTION. (where ACTION is the action used in index.php.)
- for actions that have a subaction which should be represented differently, use whoall_ACTION_SUBACTION.
- for actions that include a topic, and should be restricted, use whotopic_ACTION.
- for actions that use a message, by msg or quote, use whopost_ACTION.
- for administrator-only actions, use whoadmin_ACTION.
- for actions that should be viewable only with certain permissions, use whoallow_ACTION and add a list of possible permissions to the self::$allowedActions array, using ACTION as the key.
Parameters
- $urls : mixed
-
a single url (string) or an array of arrays, each inner array being (JSON-encoded request data, id_member)
- $preferred_prefix : string|bool = false
-
= false
Return values
array<string|int, mixed>|string —an array of descriptions if you passed an array, otherwise the string describing their current location.
execute()
Dispatcher to whichever sub-action method is necessary.
public
execute() : void
getOutputType()
Gets the output type for this action.
public
getOutputType() : OutputTypeInterface
Return values
OutputTypeInterfaceisAgreementAction()
Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
public
isAgreementAction() : bool
Return values
boolisRestrictedGuestAccessAllowed()
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
Return values
boolload()
Static wrapper for constructor.
public
static load() : static
Return values
static —An instance of this class.
parseRoute()
Parses a route to get URL query parameters.
public
static parseRoute(array<string|int, mixed> $route[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $route : array<string|int, mixed>
-
Array of routing path components.
- $params : array<string|int, mixed> = []
-
Any existing URL query parameters.
Return values
array<string|int, mixed> —URL query parameters
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
buildActionRoute()
Builds a routing path for an action based on URL query parameters.
protected
static buildActionRoute(array<string|int, mixed> &$params) : array<string|int, mixed>
The 'action', 'area', and 'sa' parameters will be mapped to route path components in that order. The 'action' parameter is required, whereas 'area' and 'sa' are optional and will be silently skipped if not set.
The parameters are passed by reference and parameters are removed from the array when recognized. This lets wrapper methods continue parsing the remainder of the parameters without worrying about duplicate elements.
Parameters
- $params : array<string|int, mixed>
-
URL query parameters.
Return values
array<string|int, mixed> —The route path elements.
parseActionRoute()
Parses a route for an action to get URL query parameters.
protected
static parseActionRoute(array<string|int, mixed> &$route) : array<string|int, mixed>
The first element of the route path is mapped to the 'action' parameter.
For the 'admin', 'moderate', and 'profile' actions, the second element of the route is mapped to the 'area' parameter and the third element is mapped to the 'sa' parameter.
For all other actions, the second element of the route path is mapped to the 'sa' parameter.
The route passed by reference and route path elements are removed from the route when recognized. This lets wrapper methods continue parsing the remainder of the route without worrying about duplicate elements.
Parameters
- $route : array<string|int, mixed>
-
Array of routing path components.
Return values
array<string|int, mixed> —URL query parameters