Membergroups
in package
implements
ActionInterface
Uses
BackwardCompatibility
This class is concerned with anything in the Manage Membergroups admin screen.
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
- add() : void
- Handles adding a membergroup and setting some initial properties.
- AddMembergroup() : void
- Backward compatibility wrapper for the add sub-action.
- call() : void
- Convenience method to load() and execute() an instance of this class.
- DeleteMembergroup() : void
- Backward compatibility wrapper for the delete sub-action.
- edit() : void
- Editing a membergroup.
- EditMembergroup() : void
- Backward compatibility wrapper for the edit sub-action.
- 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.
- getConfigVars() : array<string|int, mixed>
- Gets the configuration variables for this admin area.
- index() : void
- Shows an overview of the current membergroups.
- load() : object
- Static wrapper for constructor.
- MembergroupIndex() : void
- Backward compatibility wrapper for the index sub-action.
- ModifyMembergroupsettings() : void|array<string|int, mixed>
- Backward compatibility wrapper for the settings sub-action.
- settings() : void
- Set some general membergroup settings and permissions.
- __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', 'manage_membergroups'],
'add' => ['add', 'manage_membergroups'],
'edit' => ['edit', 'manage_membergroups'],
'settings' => ['settings', 'admin_forum'],
// This subaction is handled by the Groups action.
'members' => ['SMF\\Actions\\Groups::call', 'manage_membergroups'],
]
Available sub-actions.
Format: 'sa' => array('method', 'required_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' => 'ModifyMembergroups', 'AddMembergroup' => 'AddMembergroup', 'DeleteMembergroup' => 'DeleteMembergroup', 'EditMembergroup' => 'EditMembergroup', 'MembergroupIndex' => 'MembergroupIndex', 'ModifyMembergroupsettings' => 'ModifyMembergroupsettings']]
BackwardCompatibility settings for this class.
Methods
add()
Handles adding a membergroup and setting some initial properties.
public
add() : void
Called by ?action=admin;area=membergroups;sa=add. It requires the manage_membergroups permission. Allows to use a predefined permission profile or copy one from another group. Redirects to action=admin;area=membergroups;sa=edit;group=x.
AddMembergroup()
Backward compatibility wrapper for the add sub-action.
public
static AddMembergroup() : void
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
DeleteMembergroup()
Backward compatibility wrapper for the delete sub-action.
public
static DeleteMembergroup() : void
edit()
Editing a membergroup.
public
edit() : void
Screen to edit a specific membergroup. Called by ?action=admin;area=membergroups;sa=edit;group=x. It requires the manage_membergroups permission. Also handles the delete button of the edit form. Redirects to ?action=admin;area=membergroups.
EditMembergroup()
Backward compatibility wrapper for the edit sub-action.
public
static EditMembergroup() : 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.
getConfigVars()
Gets the configuration variables for this admin area.
public
static getConfigVars() : array<string|int, mixed>
Return values
array<string|int, mixed> —$config_vars for the membergroups area.
index()
Shows an overview of the current membergroups.
public
index() : void
Called by ?action=admin;area=membergroups. Requires the manage_membergroups permission. Splits the membergroups in regular ones and post count based groups. It also counts the number of members part of each membergroup.
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
MembergroupIndex()
Backward compatibility wrapper for the index sub-action.
public
static MembergroupIndex() : void
ModifyMembergroupsettings()
Backward compatibility wrapper for the settings sub-action.
public
static ModifyMembergroupsettings([bool $return_config = false ]) : void|array<string|int, mixed>
Parameters
- $return_config : bool = false
-
Whether to return the config_vars array.
Return values
void|array<string|int, mixed> —Returns nothing or returns the config_vars array.
settings()
Set some general membergroup settings and permissions.
public
settings() : void
Called by ?action=admin;area=membergroups;sa=settings Requires the admin_forum permission (and manage_permissions for changing permissions) Redirects to itself.
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed