Groups
in package
implements
ActionInterface
Uses
BackwardCompatibility
Shows group info and allows certain priviledged members to add/remove members.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $subaction : string
- $subactions : array<string|int, mixed>
- $action_url : string
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- 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.
- GroupList() : void
- Backward compatibility wrapper for index sub-action.
- GroupRequests() : void
- Backward compatibility wrapper for requests sub-action.
- index() : void
- This very simply lists the groups, nothing snazy.
- list_getGroupRequestCount() : int
- Callback function for SMF\ItemList().
- list_getGroupRequests() : array<string|int, mixed>
- Callback function for SMF\ItemList().
- list_getMembergroups() : array<string|int, mixed>
- Helper function to generate a list of membergroups for display
- listMembergroupMembers_Href() : bool
- Gets the members of a supplied membergroup.
- load() : object
- Static wrapper for constructor.
- MembergroupMembers() : void
- Backward compatibility wrapper for members sub-action.
- members() : void
- Display members of a group, and allow adding of members to a group.
- requests() : void
- Show and manage all group requests.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
Properties
$subaction
public
string
$subaction
= 'index'
The requested sub-action. This should be set by the constructor.
$subactions
public
static array<string|int, mixed>
$subactions
= ['index' => 'index', 'members' => 'members', 'requests' => 'requests']
Available sub-actions.
$action_url
protected
string
$action_url
= '?action=groups'
The action and area URL query to use in links to sub-actions.
Possible values:
- '?action=groups'
- '?action=moderate;area=groups'
- '?action=moderate;area=viewgroups'
$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' => 'Groups', 'list_getMembergroups' => 'list_getMembergroups', 'listMembergroupMembers_Href' => 'listMembergroupMembers_Href', 'list_getGroupRequestCount' => 'list_getGroupRequestCount', 'list_getGroupRequests' => 'list_getGroupRequests', 'GroupList' => 'GroupList', 'MembergroupMembers' => 'MembergroupMembers', 'GroupRequests' => 'GroupRequests']]
BackwardCompatibility settings for this class.
Methods
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
It allows moderators and users to access the group showing functions. It handles permission checks, and puts the moderation bar on as required.
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.
GroupList()
Backward compatibility wrapper for index sub-action.
public
static GroupList() : void
GroupRequests()
Backward compatibility wrapper for requests sub-action.
public
static GroupRequests() : void
index()
This very simply lists the groups, nothing snazy.
public
index() : void
list_getGroupRequestCount()
Callback function for SMF\ItemList().
public
static list_getGroupRequestCount(string $where, array<string|int, mixed> $where_parameters) : int
Parameters
- $where : string
-
The WHERE clause for the query
- $where_parameters : array<string|int, mixed>
-
The parameters for the WHERE clause
Return values
int —The number of group requests
list_getGroupRequests()
Callback function for SMF\ItemList().
public
static list_getGroupRequests(int $start, int $items_per_page, string $sort, string $where, string $where_parameters) : array<string|int, mixed>
Parameters
- $start : int
-
The result to start with.
- $items_per_page : int
-
The number of items per page.
- $sort : string
-
An SQL sort expression (column/direction).
- $where : string
-
Data for the WHERE clause.
- $where_parameters : string
-
Parameter values to be inserted into the WHERE clause.
Return values
array<string|int, mixed> —An array of group requests. Each group request has: 'id' 'member_link' 'group_link' 'reason' 'time_submitted'
list_getMembergroups()
Helper function to generate a list of membergroups for display
public
static list_getMembergroups(int $start, int $items_per_page, string $sort, string $membergroup_type) : array<string|int, mixed>
Parameters
- $start : int
-
What item to start with (not used here)
- $items_per_page : int
-
How many items to show on each page (not used here)
- $sort : string
-
An SQL query indicating how to sort the results
- $membergroup_type : string
-
Should be 'post_count' for post groups or anything else for regular groups
Return values
array<string|int, mixed> —An array of group member info for the list
listMembergroupMembers_Href()
Gets the members of a supplied membergroup.
public
static listMembergroupMembers_Href(array<string|int, mixed> &$members, int $membergroup[, int $limit = null ]) : bool
Returns them as a link for display.
Parameters
- $members : array<string|int, mixed>
-
The IDs of the members.
- $membergroup : int
-
The ID of the group.
- $limit : int = null
-
How many members to show (null for no limit).
Return values
bool —True if there are more members to display, false otherwise.
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
MembergroupMembers()
Backward compatibility wrapper for members sub-action.
public
static MembergroupMembers() : void
members()
Display members of a group, and allow adding of members to a group.
public
members() : void
It can be called from ManageMembergroups if it needs templating within the admin environment. It shows a list of members that are part of a given membergroup. It is called by ?action=moderate;area=viewgroups;sa=members;group=x It requires the manage_membergroups permission. It allows to add and remove members from the selected membergroup. It allows sorting on several columns. It redirects to itself.
Tags
requests()
Show and manage all group requests.
public
requests() : void
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed