Tracking
in package
implements
ActionInterface
Uses
BackwardCompatibility
Rename here and in the exportStatic call at the end of the file.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $subaction : string
- $subactions : array<string|int, mixed>
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- activity() : void
- Handles tracking a user's activity
- call() : void
- Convenience method to load() and execute() an instance of this class.
- edits() : void
- Tracks a user's profile edits.
- 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.
- groupRequests() : void
- Display the history of group requests made by the user whose profile we are viewing.
- ip() : void
- Handles tracking a particular IP address.
- list_getGroupRequests() : array<string|int, mixed>
- Loads up information about a user's group requests. Callback for the list in trackGroupReq()
- list_getGroupRequestsCount() : int
- How many edits?
- list_getLoginCount() : int
- Finds the total number of tracked logins for a particular user
- list_getLogins() : array<string|int, mixed>
- Callback for the list in trackLogins.
- list_getProfileEditCount() : int
- How many edits?
- list_getProfileEdits() : array<string|int, mixed>
- Loads up information about a user's profile edits. Callback for the list in trackEdits()
- list_getUserErrorCount() : int
- Get the number of user errors
- list_getUserErrors() : array<string|int, mixed>
- Gets all of the errors generated by a user's actions. Callback for the list in track_activity
- load() : object
- Static wrapper for constructor.
- logins() : void
- Tracks a user's logins.
- trackActivity() : void
- Backward compatibility wrapper for the activity sub-action.
- trackEdits() : void
- Backward compatibility wrapper for the edits sub-action.
- trackGroupReq() : void
- Backward compatibility wrapper for the groupreq sub-action.
- trackLogins() : void
- Backward compatibility wrapper for the logins sub-action.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
Properties
$subaction
public
string
$subaction
= 'activity'
The requested sub-action. This should be set by the constructor.
$subactions
public
static array<string|int, mixed>
$subactions
= ['activity' => ['activity', 'trackActivity', 'moderate_forum'], 'ip' => ['ip', 'trackIP', 'moderate_forum'], 'edits' => ['edits', 'trackEdits', 'moderate_forum'], 'groupreq' => ['groupRequests', 'trackGroupRequests', 'approve_group_requests'], 'logins' => ['logins', 'trackLogins', 'moderate_forum']]
Available sub-actions.
Keys are $_REQUEST['sa'] params. Values are arrays of the form:
array('method', 'txt_key_for_page_title', 'permission')
$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' => 'tracking', 'list_getUserErrors' => 'list_getUserErrors', 'list_getUserErrorCount' => 'list_getUserErrorCount', 'list_getProfileEdits' => 'list_getProfileEdits', 'list_getProfileEditCount' => 'list_getProfileEditCount', 'list_getGroupRequests' => 'list_getGroupRequests', 'list_getGroupRequestsCount' => 'list_getGroupRequestsCount', 'list_getLogins' => 'list_getLogins', 'list_getLoginCount' => 'list_getLoginCount', 'trackActivity' => 'trackActivity', 'trackEdits' => 'trackEdits', 'trackGroupReq' => 'trackGroupReq', 'trackLogins' => 'TrackLogins']]
BackwardCompatibility settings for this class.
Methods
activity()
Handles tracking a user's activity
public
activity() : void
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
edits()
Tracks a user's profile edits.
public
edits() : void
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.
groupRequests()
Display the history of group requests made by the user whose profile we are viewing.
public
groupRequests() : void
ip()
Handles tracking a particular IP address.
public
ip() : void
list_getGroupRequests()
Loads up information about a user's group requests. Callback for the list in trackGroupReq()
public
static list_getGroupRequests(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 show 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 user's group requests
list_getGroupRequestsCount()
How many edits?
public
static list_getGroupRequestsCount() : int
Return values
int —The number of profile edits
list_getLoginCount()
Finds the total number of tracked logins for a particular user
public
static list_getLoginCount(string $where[, array<string|int, mixed> $where_vars = [] ]) : int
Parameters
- $where : string
-
A query to limit which logins are counted
- $where_vars : array<string|int, mixed> = []
-
An array of parameters for $where
Return values
int —count of messages matching the IP
list_getLogins()
Callback for the list in trackLogins.
public
static list_getLogins(int $start, int $items_per_page, string $sort, string $where[, array<string|int, mixed> $where_vars = [] ]) : 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
- $where : string
-
A query to filter results (not used here)
- $where_vars : array<string|int, mixed> = []
-
An array of parameters for $where. Only 'current_member' (the ID of the member) is used here
Return values
array<string|int, mixed> —An array of information about user logins
list_getProfileEditCount()
How many edits?
public
static list_getProfileEditCount() : int
Return values
int —The number of profile edits
list_getProfileEdits()
Loads up information about a user's profile edits. Callback for the list in trackEdits()
public
static list_getProfileEdits(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 show 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 profile edits
list_getUserErrorCount()
Get the number of user errors
public
static list_getUserErrorCount(string $where[, array<string|int, mixed> $where_vars = [] ]) : int
Parameters
- $where : string
-
A query to limit which errors are counted
- $where_vars : array<string|int, mixed> = []
-
The parameters for $where
Return values
int —Number of user errors
list_getUserErrors()
Gets all of the errors generated by a user's actions. Callback for the list in track_activity
public
static list_getUserErrors(int $start, int $items_per_page, string $sort, string $where[, array<string|int, mixed> $where_vars = [] ]) : array<string|int, mixed>
Parameters
- $start : int
-
Which item to start with (for pagination purposes)
- $items_per_page : int
-
How many items to show on each page
- $sort : string
-
A string indicating how to sort the results
- $where : string
-
A query indicating how to filter the results (eg 'id_member={int:id_member}')
- $where_vars : array<string|int, mixed> = []
-
An array of parameters for $where
Return values
array<string|int, mixed> —An array of information about the error messages
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
logins()
Tracks a user's logins.
public
logins() : void
trackActivity()
Backward compatibility wrapper for the activity sub-action.
public
static trackActivity(int $memID) : void
Parameters
- $memID : int
-
The ID of the member.
trackEdits()
Backward compatibility wrapper for the edits sub-action.
public
static trackEdits(int $memID) : void
Parameters
- $memID : int
-
The ID of the member.
trackGroupReq()
Backward compatibility wrapper for the groupreq sub-action.
public
static trackGroupReq(int $memID) : void
Parameters
- $memID : int
-
The ID of the member.
trackLogins()
Backward compatibility wrapper for the logins sub-action.
public
static trackLogins(int $memID) : void
Parameters
- $memID : int
-
The ID of the member.
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed