Memberlist
in package
implements
ActionInterface
Uses
BackwardCompatibility
This class contains the methods for displaying and searching in the members list.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $cache_step_size : int
- $sort_links : array<string|int, mixed>
- $subaction : string
- $subactions : array<string|int, mixed>
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- all() : mixed
- List all members, page by page, with sorting.
- call() : void
- Convenience method to load() and execute() an instance of this class.
- execute() : void
- Shows a listing of registered members.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- getCustFields() : array<string|int, mixed>
- Sets the label, sort and join info for every custom field column.
- load() : object
- Static wrapper for constructor.
- MLAll() : void
- Backward compatibility wrapper for the all sub-action.
- MLSearch() : void
- Backward compatibility wrapper for the search sub-action.
- printRows() : mixed
- Retrieves results of the request passed to it Puts results of request into the context for the sub template.
- search() : mixed
- Search for members, or display search results.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
Properties
$cache_step_size
public
int
$cache_step_size
= 500
The chunk size for the cached index.
$sort_links
public
array<string|int, mixed>
$sort_links
= ['all' => ['label' => 'view_all_members', 'action' => 'all', 'selected' => true], 'search' => ['label' => 'mlist_search', 'action' => 'search', 'selected' => false]]
Initial definition of the sort_links array. Labels will be replaced with the indicated $txt strings. Selected will be changed to match the current sub-action.
$subaction
public
string
$subaction
= 'all'
The requested sub-action. This should be set by the constructor.
$subactions
public
static array<string|int, mixed>
$subactions
= ['all' => 'all', 'search' => 'search']
Available sub-actions.
$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' => 'Memberlist', 'MLAll' => 'MLAll', 'MLSearch' => 'MLSearch', 'printRows' => 'printMemberListRows', 'getCustFields' => 'getCustFieldsMList']]
BackwardCompatibility settings for this class.
Methods
all()
List all members, page by page, with sorting.
public
all() : mixed
Called from MemberList(). Can be passed a sort parameter, to order the display of members. Calls printRows to retrieve the results of the query.
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
execute()
Shows a listing of registered members.
public
execute() : void
- If a subaction is not specified, lists all registered members.
- It allows searching for members with the 'search' sub action.
- It calls all() or search() depending on the sub action.
- Requires the view_mlist permission.
- Accessed via ?action=mlist.
Uses Memberlist template, main sub template.
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.
getCustFields()
Sets the label, sort and join info for every custom field column.
public
static getCustFields() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of info about the custom fields for the member list
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
MLAll()
Backward compatibility wrapper for the all sub-action.
public
static MLAll() : void
MLSearch()
Backward compatibility wrapper for the search sub-action.
public
static MLSearch() : void
printRows()
Retrieves results of the request passed to it Puts results of request into the context for the sub template.
public
static printRows(resource $request) : mixed
Parameters
- $request : resource
-
An SQL result resource
search()
Search for members, or display search results.
public
search() : mixed
- Called by MemberList().
- If variable 'search' is empty displays search dialog box, using the search sub template.
- Calls printRows to retrieve the results of the query.
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed