Who
in package
implements
ActionInterface
Uses
BackwardCompatibility
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.
Properties
- $allowedActions : array<string|int, mixed>
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- call() : void
- Convenience method to load() and execute() an instance of this class.
- determineActions() : array<string|int, mixed>
- This method determines the actions of the members passed in URLs.
- 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.
- load() : object
- Static wrapper for constructor.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
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 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' => 'Who', 'determineActions' => 'determineActions']]
BackwardCompatibility settings for this class.
Methods
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
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>
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> —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
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.
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed