QuickModeration
in package
implements
ActionInterface, Routable
uses
ActionRouter, ActionTrait
Handles moderation from the message index.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
- Routable
- Classes implementing this interface can build routes from URL query parameters and parse routes back into URL query parameters.
Properties
- $action_permissions : array<string|int, mixed>
- $known_actions : array<string|int, mixed>
- $boards_can : array<string|int, mixed>
- $obj : static
- $possible_actions : array<string|int, mixed>
- $redirect_url : string
- $should_redirect : bool
- $topic_actions : array<string|int, mixed>
Methods
- buildRoute() : array<string|int, mixed>
- Builds a routing path based on URL query parameters.
- call() : void
- Convenience method to load() and execute() an instance of this class.
- canBeLogged() : bool
- Determines whether this action can be logged in the online log.
- canShowDebuggingInfo() : bool
- Determines whether debugging info should be shown.
- canShowInMaintenanceMode() : bool
- Determines whether this action allows access in maintenance mode.
- execute() : void
- Does the job.
- getActions() : array<string|int, mixed>
- Gets the list of known quick moderation actions.
- getOutputType() : OutputTypeInterface
- Gets the output type for this action.
- isAgreementAction() : bool
- Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
- isRestrictedGuestAccessAllowed() : bool
- Determines whether this action allows access if guest access is restricted.
- isSimpleAction() : bool
- Determines whether this is a simple action.
- load() : static
- Static wrapper for constructor.
- parseRoute() : array<string|int, mixed>
- Parses a route to get URL query parameters.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- buildActionRoute() : array<string|int, mixed>
- Builds a routing path for an action based on URL query parameters.
- doApprove() : void
- Approves a topic.
- doLock() : void
- Locks or unlocks the topics, and does some logging and notifying.
- doMarkRead() : void
- Marks the topics as read for the current user.
- doMerge() : void
- Merges topics.
- doMove() : void
- Moves topics from one board to another.
- doRemove() : void
- Removes topics, by moving them to the recycle board or deleting them.
- doRestore() : void
- Restores topics.
- doSticky() : void
- Stickies or unstickies the topics, and does some logging and notifying.
- parseActionRoute() : array<string|int, mixed>
- Parses a route for an action to get URL query parameters.
- setPossibleActions() : void
- Figures out which actions the user is allowed to perform.
- setRequestActions() : void
- Standardizes $_REQUEST input regarding action and topics.
- setTopicActions() : void
- Sets $this->topic_actions based on $_REQUEST['actions'].
Properties
$action_permissions
public
static array<string|int, mixed>
$action_permissions
= ['markread' => ['any' => 'is_not_guest'], 'sticky' => ['any' => 'make_sticky'], 'lock' => ['any' => 'lock_any', 'own' => 'lock_own'], 'approve' => ['any' => 'approve_posts'], 'remove' => ['any' => 'remove_any', 'own' => 'remove_own'], 'move' => ['any' => 'move_any', 'own' => 'move_own'], 'merge' => ['any' => 'merge_any'], 'restore' => ['any' => 'move_any', 'where' => 'recycle_board']]
Permissions need to carry out different actions.
$known_actions
public
static array<string|int, mixed>
$known_actions
= ['approve', 'remove', 'lock', 'sticky', 'move', 'merge', 'restore', 'markread']
Actions that a user might perform on topics.
Note: it is better to access this via self::getActions() in case any mods have something to add to the list.
$boards_can
protected
array<string|int, mixed>
$boards_can
= []
Boards where this user can do different actions.
$obj
protected
static static
$obj
An instance of this class. This is used by the load() method to prevent multiple instantiations.
$possible_actions
protected
array<string|int, mixed>
$possible_actions
= []
Actions that this user is allowed perform on topics.
$redirect_url
protected
string
$redirect_url
= ''
Where to send the user after the action is complete.
$should_redirect
protected
bool
$should_redirect
= true
If false, do not redirect when done. Used for actions that require showing a UI.
$topic_actions
protected
array<string|int, mixed>
$topic_actions
= ['markread' => [], 'sticky' => [], 'lock' => [], 'approve' => [], 'remove' => [], 'move' => ['topics' => [], 'to' => []], 'merge' => [], 'restore' => []]
The actions to perform on the given topics.
Keys in this array are action names.
In most cases, the values are arrays of topic IDs. The exception is 'move', where the 'topics' sub-array contains topic IDs and the 'to' sub-array contains info about the board that each topic should be moved to.
Methods
buildRoute()
Builds a routing path based on URL query parameters.
public
static buildRoute(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
-
URL query parameters.
Return values
array<string|int, mixed> —Contains two elements: ['route' => [], 'params' => []]. The 'route' element contains the routing path. The 'params' element contains any $params that weren't incorporated into the route.
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
canBeLogged()
Determines whether this action can be logged in the online log.
public
canBeLogged() : bool
Return values
boolcanShowDebuggingInfo()
Determines whether debugging info should be shown.
public
canShowDebuggingInfo() : bool
Return values
boolcanShowInMaintenanceMode()
Determines whether this action allows access in maintenance mode.
public
canShowInMaintenanceMode() : bool
Return values
bool —True if access is allowed, false otherwise.
execute()
Does the job.
public
execute() : void
getActions()
Gets the list of known quick moderation actions.
public
static getActions([bool $search = false ]) : array<string|int, mixed>
Calls the integrate_quick_mod_actions hook. Sets Utils::$context['qmod_actions'].
Parameters
- $search : bool = false
-
Whether this is being called from the search results display page.
Return values
array<string|int, mixed> —The list of known quick moderation actions.
getOutputType()
Gets the output type for this action.
public
getOutputType() : OutputTypeInterface
Return values
OutputTypeInterfaceisAgreementAction()
Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
public
isAgreementAction() : bool
Return values
boolisRestrictedGuestAccessAllowed()
Determines whether this action allows access if guest access is restricted.
public
isRestrictedGuestAccessAllowed() : bool
Return values
bool —True if access is allowed, false otherwise.
isSimpleAction()
Determines whether this is a simple action.
public
isSimpleAction() : bool
Return values
boolload()
Static wrapper for constructor.
public
static load() : static
Return values
static —An instance of this class.
parseRoute()
Parses a route to get URL query parameters.
public
static parseRoute(array<string|int, mixed> $route[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $route : array<string|int, mixed>
-
Array of routing path components.
- $params : array<string|int, mixed> = []
-
Any existing URL query parameters.
Return values
array<string|int, mixed> —URL query parameters
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
buildActionRoute()
Builds a routing path for an action based on URL query parameters.
protected
static buildActionRoute(array<string|int, mixed> &$params) : array<string|int, mixed>
The 'action', 'area', and 'sa' parameters will be mapped to route path components in that order. The 'action' parameter is required, whereas 'area' and 'sa' are optional and will be silently skipped if not set.
The parameters are passed by reference and parameters are removed from the array when recognized. This lets wrapper methods continue parsing the remainder of the parameters without worrying about duplicate elements.
Parameters
- $params : array<string|int, mixed>
-
URL query parameters.
Return values
array<string|int, mixed> —The route path elements.
doApprove()
Approves a topic.
protected
doApprove() : void
Performs some checks, passes the topic IDs to SMF\Topic::approve(), and does some logging.
doLock()
Locks or unlocks the topics, and does some logging and notifying.
protected
doLock() : void
doMarkRead()
Marks the topics as read for the current user.
protected
doMarkRead() : void
doMerge()
Merges topics.
protected
doMerge() : void
Passes the topic IDs to SMF\TopicMerge::initiate(). Sets $this->should_redirect to false.
doMove()
Moves topics from one board to another.
protected
doMove() : void
Performs some checks, passes the topic IDs to SMF\Topic::remove(), updates some stats, and then does some logging and notifying.
doRemove()
Removes topics, by moving them to the recycle board or deleting them.
protected
doRemove() : void
Performs some checks, passes the topic IDs to SMF\Topic::remove(), and does some logging and notifying.
doRestore()
Restores topics.
protected
doRestore() : void
Simply redirects to ?action=restoretopic.
doSticky()
Stickies or unstickies the topics, and does some logging and notifying.
protected
doSticky() : void
parseActionRoute()
Parses a route for an action to get URL query parameters.
protected
static parseActionRoute(array<string|int, mixed> &$route) : array<string|int, mixed>
The first element of the route path is mapped to the 'action' parameter.
For the 'admin', 'moderate', and 'profile' actions, the second element of the route is mapped to the 'area' parameter and the third element is mapped to the 'sa' parameter.
For all other actions, the second element of the route path is mapped to the 'sa' parameter.
The route passed by reference and route path elements are removed from the route when recognized. This lets wrapper methods continue parsing the remainder of the route without worrying about duplicate elements.
Parameters
- $route : array<string|int, mixed>
-
Array of routing path components.
Return values
array<string|int, mixed> —URL query parameters
setPossibleActions()
Figures out which actions the user is allowed to perform.
protected
setPossibleActions() : void
Only checks the permissions for the actions that were requested.
Sets $this->possible_actions and $this->boards_can.
setRequestActions()
Standardizes $_REQUEST input regarding action and topics.
protected
setRequestActions() : void
The requested moderation actions can be specified in one of two ways:
-
$_REQUEST['qaction'] and $_REQUEST['topics'] is used when quick moderation uses checkboxes. In this approach, there is only one action specified, but any number of topics could be specified.
-
$_REQUEST['actions'] is used when quick moderation uses icons. The keys in the $_REQUEST['actions'] array are topic IDs, and the values are the actions to perform on those topics. In theory this array could contain multiple topics to act upon, although in practice the templates only offer the ability to act on one topic per request.
When this method returns, the input will have been standardized to use the $_REQUEST['actions'] format.
setTopicActions()
Sets $this->topic_actions based on $_REQUEST['actions'].
protected
setTopicActions() : void