Documentation

Main
in package
implements ActionInterface Uses BackwardCompatibility

This is the Moderation Center.

Table of Contents

Interfaces

ActionInterface
Interface for all action classes.

Properties

$moderation_areas  : array<string|int, mixed>
$access_checked  : bool
$obj  : object
$backcompat  : array<string|int, mixed>

Methods

call()  : void
Convenience method to load() and execute() an instance of this class.
checkAccessPermissions()  : void
Figures out which parts of the moderation center can be accessed by the current user.
createMenu()  : void
Creates the moderation center menu.
execute()  : void
Dispatcher.
exportStatic()  : void
Provides a way to export a class's public static properties and methods to global namespace.
load()  : object
Static wrapper for constructor.
ModerationMain()  : void
Backward compatibility wrapper that either calls self::call() or calls self::load()->createMenu(), depending on the value of $dont_call.
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().
setModerationAreas()  : void
Sets any dynamic values in $this->moderation_areas.

Properties

$moderation_areas

public array<string|int, mixed> $moderation_areas = ['main' => ['title' => 'mc_main', 'areas' => ['index' => ['label' => 'moderation_center', 'function' => __NAMESPACE__ . '\\Home::call', 'icon' => 'administration'], 'modlogoff' => ['label' => 'mc_logoff', 'function' => __NAMESPACE__ . '\\EndSession::call', 'enabled' => true, 'icon' => 'exit'], 'notice' => ['function' => __NAMESPACE__ . '\\ShowNotice::call', 'select' => 'index']]], 'logs' => ['title' => 'mc_logs', 'areas' => ['modlog' => ['label' => 'modlog_view', 'enabled' => true, 'function' => __NAMESPACE__ . '\\Logs::call', 'icon' => 'logs'], 'warnings' => ['label' => 'mc_warnings', 'enabled' => true, 'function' => __NAMESPACE__ . '\\Warnings::call', 'icon' => 'warning', 'subsections' => ['log' => ['label' => 'mc_warning_log', 'permission' => ['view_warning_any', 'moderate_forum']], 'templates' => ['label' => 'mc_warning_templates', 'permission' => 'issue_warning']]]]], 'posts' => ['title' => 'mc_posts', 'enabled' => true, 'areas' => ['postmod' => ['label' => 'mc_unapproved_posts', 'enabled' => true, 'function' => __NAMESPACE__ . '\\Posts::call', 'icon' => 'posts', 'custom_url' => '{scripturl}?action=moderate;area=postmod', 'subsections' => ['posts' => ['label' => 'mc_unapproved_replies'], 'topics' => ['label' => 'mc_unapproved_topics']]], 'attachmod' => ['label' => 'mc_unapproved_attachments', 'enabled' => true, 'function' => __NAMESPACE__ . '\\Posts::call', 'icon' => 'post_moderation_attach', 'custom_url' => '{scripturl}?action=moderate;area=attachmod;sa=attachments'], 'reportedposts' => ['label' => 'mc_reported_posts', 'enabled' => true, 'function' => __NAMESPACE__ . '\\ReportedContent::call', 'icon' => 'reports', 'subsections' => ['show' => ['label' => 'mc_reportedp_active'], 'closed' => ['label' => 'mc_reportedp_closed']]]]], 'groups' => ['title' => 'mc_groups', 'enabled' => true, 'areas' => ['groups' => ['label' => 'mc_group_requests', 'function' => '\\SMF\\Actions\\Groups::call', 'icon' => 'members_request', 'custom_url' => '{scripturl}?action=moderate;area=groups;sa=requests'], 'viewgroups' => ['label' => 'mc_view_groups', 'function' => '\\SMF\\Actions\\Groups::call', 'icon' => 'membergroups']]], 'members' => ['title' => 'mc_members', 'enabled' => true, 'areas' => ['userwatch' => ['label' => 'mc_watched_users_title', 'enabled' => true, 'function' => __NAMESPACE__ . '\\WatchedUsers::call', 'icon' => 'members_watched', 'subsections' => ['member' => ['label' => 'mc_watched_users_member'], 'post' => ['label' => 'mc_watched_users_post']]], 'reportedmembers' => ['label' => 'mc_reported_members_title', 'enabled' => true, 'function' => __NAMESPACE__ . '\\ReportedContent::call', 'icon' => 'members_watched', 'subsections' => ['open' => ['label' => 'mc_reportedp_active'], 'closed' => ['label' => 'mc_reportedp_closed']]]]]]

Defines the menu structure for the moderation center. See Menu.php for details!

The values of all 'title' and 'label' elements are Lang::$txt keys, and will be replaced at runtime with the values of those Lang::$txt strings.

All occurrences of '{scripturl}' and '{boardurl}' in value strings will be replaced at runtime with the real values of Config::$scripturl and Config::$boardurl.

In this default definintion, all parts of the menu are set as enabled. At runtime, however, various parts may be turned on or off depending on the forum's saved settings.

MOD AUTHORS: You can use the integration_moderation_areas hook to add things to this menu. The hook can be found in SMF\Menu::_construct().

$access_checked

protected static bool $access_checked = false

Whether self::checkAccessPermissions() has been run yet.

$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' => ['checkAccessPermissions' => 'checkAccessPermissions', 'ModerationMain' => 'ModerationMain']]

BackwardCompatibility settings for this class.

Methods

call()

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

public static call() : void

checkAccessPermissions()

Figures out which parts of the moderation center can be accessed by the current user.

public static checkAccessPermissions() : void

Populates the following context variables:

  • can_moderate_boards
  • can_moderate_groups
  • can_moderate_approvals
  • can_moderate_users

createMenu()

Creates the moderation center menu.

public createMenu() : void

This is separated from execute() for the sake of SMF\Actions\Groups, which wants to be able to create the menu without calling the methods.

execute()

Dispatcher.

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:

  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.

load()

Static wrapper for constructor.

public static load() : object
Return values
object

An instance of this class.

ModerationMain()

Backward compatibility wrapper that either calls self::call() or calls self::load()->createMenu(), depending on the value of $dont_call.

public static ModerationMain([bool $dont_call = false ]) : void
Parameters
$dont_call : bool = false

If true, just creates the menu and doesn't call the function for the appropriate mod area.

__construct()

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

protected __construct() : mixed

setModerationAreas()

Sets any dynamic values in $this->moderation_areas.

protected setModerationAreas() : void

        
On this page

Search results