Documentation

QuickModeration
in package
implements ActionInterface Uses BackwardCompatibility

Handles moderation from the message index.

Table of Contents

Interfaces

ActionInterface
Interface for all action classes.

Properties

$action_permissions  : array<string|int, mixed>
$known_actions  : array<string|int, mixed>
$boards_can  : array<string|int, mixed>
$obj  : object
$possible_actions  : array<string|int, mixed>
$redirect_url  : string
$should_redirect  : bool
$topic_actions  : array<string|int, mixed>
$backcompat  : array<string|int, mixed>

Methods

call()  : void
Convenience method to load() and execute() an instance of this class.
execute()  : void
Does the job.
exportStatic()  : void
Provides a way to export a class's public static properties and methods to global namespace.
getActions()  : array<string|int, mixed>
Gets the list of known quick moderation actions.
load()  : object
Static wrapper for constructor.
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().
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.
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 object $obj

An instance of this class. This is used by the load() method to prevent mulitple 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.

$backcompat

private static array<string|int, mixed> $backcompat = ['func_names' => ['call' => 'QuickModeration']]

BackwardCompatibility settings for this class.

Methods

call()

Convenience method to load() and execute() an instance of this class.

public static call() : 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:

  1. Use this trait in the class.
  2. 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.

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.

load()

Static wrapper for constructor.

public static load() : object
Return values
object

An instance of this class.

__construct()

Constructor. Protected to force instantiation via self::load().

protected __construct() : mixed

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

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

        
On this page

Search results