Logs
in package
implements
ActionInterface
Uses
BackwardCompatibility
The moderation and adminstration logs are this class's only job.
It views them, and that's about all it does.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $action : string
- $actions : array<string|int, mixed>
- $per_page : int
- $search_types : array<string|int, mixed>
- $sort_types : array<string|int, mixed>
- $subaction : string
- $subactions : array<string|int, mixed>
- $uneditable_actions : array<string|int, mixed>
- $can_delete : bool
- $encoded_search_params : string
- $log_type : int
- $obj : object
- $search_info : array<string|int, mixed>
- $search_params : array<string|int, mixed>
- $search_params_column : string
- $search_params_string : string
- $search_params_type : string
- $sort : string
- $url_start : string
- $backcompat : array<string|int, mixed>
Methods
- adminlog() : mixed
- call() : void
- Convenience method to load() and execute() an instance of this class.
- 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_getModLogEntries() : array<string|int, mixed>
- Gets the moderation log entries that match the specified parameters.
- list_getModLogEntryCount() : int
- Get the number of mod log entries.
- load() : object
- Static wrapper for constructor.
- modlog() : mixed
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- createList() : void
- deleteAll() : void
- deleteEntries() : void
- deleteEntry() : void
- setupSearch() : void
Properties
$action
public
string
$action
= 'moderate'
The requested action. This should be set by the constructor.
$actions
public
static array<string|int, mixed>
$actions
= ['moderate', 'admin']
Actions that might call this class.
$per_page
public
int
$per_page
= 30
How many log entries to show per page.
$search_types
public
static array<string|int, mixed>
$search_types
= ['action' => ['sql' => 'lm.action', 'label' => 'modlog_action'], 'member' => ['sql' => 'mem.real_name', 'label' => 'modlog_member'], 'group' => ['sql' => 'mg.group_name', 'label' => 'modlog_position'], 'ip' => ['sql' => 'lm.ip', 'label' => 'modlog_ip']]
This array houses all the valid search types.
$sort_types
public
static array<string|int, mixed>
$sort_types
= ['action' => 'lm.action', 'time' => 'lm.log_time', 'member' => 'mem.real_name', 'group' => 'mg.group_name', 'ip' => 'lm.ip']
Instructions for how to sort columns.
$subaction
public
string
$subaction
= 'modlog'
The requested sub-action. This should be set by the constructor.
$subactions
public
static array<string|int, mixed>
$subactions
= ['modlog' => 'modlog', 'adminlog' => 'adminlog']
Available sub-actions.
$uneditable_actions
public
static array<string|int, mixed>
$uneditable_actions
= ['agreement_updated', 'policy_updated']
Actions whose log entries cannot be deleted.
$can_delete
protected
bool
$can_delete
= false
Whether the current user can delete log entries.
$encoded_search_params
protected
string
$encoded_search_params
$log_type
protected
int
$log_type
= 1
The log type to show. 1 for the moderation log. 3 for the administration log.
$obj
protected
static object
$obj
An instance of this class. This is used by the load() method to prevent mulitple instantiations.
$search_info
protected
array<string|int, mixed>
$search_info
$search_params
protected
array<string|int, mixed>
$search_params
$search_params_column
protected
string
$search_params_column
$search_params_string
protected
string
$search_params_string
$search_params_type
protected
string
$search_params_type
= 'member'
$sort
protected
string
$sort
= 'time'
$url_start
protected
string
$url_start
= ''
$backcompat
private
static array<string|int, mixed>
$backcompat
= ['func_names' => ['call' => 'ViewModlog', 'list_getModLogEntryCount' => 'list_getModLogEntryCount', 'list_getModLogEntries' => 'list_getModLogEntries']]
BackwardCompatibility settings for this class.
Methods
adminlog()
public
adminlog() : mixed
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : 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.
list_getModLogEntries()
Gets the moderation log entries that match the specified parameters.
public
static list_getModLogEntries(int $start, int $items_per_page, string $sort[, string $query_string = '' ][, array<string|int, mixed> $query_params = [] ][, int $log_type = 1 ][, bool $ignore_boards = false ]) : array<string|int, mixed>
Callback for SMF\ItemList().
Parameters
- $start : int
-
The item to start with (for pagination purposes)
- $items_per_page : int
-
The number of items to show per page
- $sort : string
-
A string indicating how to sort the results
- $query_string : string = ''
-
An extra string for the WHERE clause of the query, to further filter results
- $query_params : array<string|int, mixed> = []
-
An array of parameters for the query string
- $log_type : int = 1
-
The log type - 1 for mod log or 3 for admin log
- $ignore_boards : bool = false
-
Whether to ignore board restrictions
Return values
array<string|int, mixed> —An array of info about the mod log entries
list_getModLogEntryCount()
Get the number of mod log entries.
public
static list_getModLogEntryCount([string $query_string = '' ][, array<string|int, mixed> $query_params = [] ][, int $log_type = 1 ][, bool $ignore_boards = false ]) : int
Callback for SMF\ItemList().
Parameters
- $query_string : string = ''
-
An extra string for the WHERE clause in the query to further filter results
- $query_params : array<string|int, mixed> = []
-
An array of parameters for the query_string
- $log_type : int = 1
-
The log type (1 for mod log, 3 for admin log)
- $ignore_boards : bool = false
-
Whether to ignore board restrictions
Return values
int —Total number of visible log entries.
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
modlog()
public
modlog() : mixed
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
createList()
protected
createList() : void
deleteAll()
protected
deleteAll() : void
deleteEntries()
protected
deleteEntries() : void
deleteEntry()
protected
deleteEntry() : void
setupSearch()
protected
setupSearch() : void