Documentation

ACP
in package
implements ActionInterface Uses BackwardCompatibility

This class, unpredictable as this might be, handles basic administration.

Table of Contents

Interfaces

ActionInterface
Interface for all action classes.

Properties

$admin_areas  : array<string|int, mixed>
$obj  : object
$backcompat  : array<string|int, mixed>

Methods

adminLogin()  : mixed
Question the verity of the admin by asking for his or her password.
call()  : void
Convenience method to load() and execute() an instance of this class.
emailAdmins()  : mixed
Send all the administrators a lovely email.
execute()  : void
The main admin handling function.
exportStatic()  : void
Provides a way to export a class's public static properties and methods to global namespace.
getFileVersions()  : array<string|int, mixed>
Search through source, theme, and language files to determine their version.
getServerVersions()  : array<string|int, mixed>
Get a list of versions that are currently installed on the server.
load()  : object
Static wrapper for constructor.
prepareDBSettingContext()  : void
Helper function, it sets up the context for database settings.
saveDBSettings()  : mixed
Helper function for saving database settings.
saveSettings()  : void
Helper function. Saves settings by putting them in Settings.php or saving them in the settings table.
updateAdminPreferences()  : mixed
Saves the admin's current preferences to the database.
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().
adminLogin_outputPostVars()  : string
Used by the adminLogin() method.
construct_query_string()  : string
Properly urlencodes a string to be used in a query.
setAdminAreas()  : void
Sets any dynamic values in $this->admin_areas.

Properties

$admin_areas

public array<string|int, mixed> $admin_areas = ['forum' => ['title' => 'admin_main', 'permission' => ['admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments'], 'areas' => ['index' => ['label' => 'admin_center', 'function' => __NAMESPACE__ . '\\Home::call', 'icon' => 'administration'], 'credits' => ['label' => 'support_credits_title', 'function' => __NAMESPACE__ . '\\Home::call', 'icon' => 'support'], 'news' => ['label' => 'news_title', 'function' => __NAMESPACE__ . '\\News::call', 'icon' => 'news', 'permission' => ['edit_news', 'send_mail', 'admin_forum'], 'subsections' => ['editnews' => ['label' => 'admin_edit_news', 'permission' => 'edit_news'], 'mailingmembers' => ['label' => 'admin_newsletters', 'permission' => 'send_mail'], 'settings' => ['label' => 'settings', 'permission' => 'admin_forum']]], 'packages' => ['label' => 'package', 'function' => 'SMF\\PackageManager\\PackageManager::call', 'permission' => ['admin_forum'], 'icon' => 'packages', 'subsections' => ['browse' => ['label' => 'browse_packages'], 'packageget' => ['label' => 'download_packages', 'url' => '{scripturl}?action=admin;area=packages;sa=packageget;get'], 'perms' => ['label' => 'package_file_perms'], 'options' => ['label' => 'package_settings']]], 'search' => ['function' => __NAMESPACE__ . '\\Find::call', 'permission' => ['admin_forum'], 'select' => 'index'], 'adminlogoff' => ['label' => 'admin_logoff', 'function' => __NAMESPACE__ . '\\EndSession::call', 'enabled' => true, 'icon' => 'exit']]], 'config' => ['title' => 'admin_config', 'permission' => ['admin_forum'], 'areas' => ['featuresettings' => ['label' => 'modSettings_title', 'function' => __NAMESPACE__ . '\\Features::call', 'icon' => 'features', 'subsections' => ['basic' => ['label' => 'mods_cat_features'], 'bbc' => ['label' => 'manageposts_bbc_settings'], 'layout' => ['label' => 'mods_cat_layout'], 'sig' => ['label' => 'signature_settings_short'], 'profile' => ['label' => 'custom_profile_shorttitle'], 'likes' => ['label' => 'likes'], 'mentions' => ['label' => 'mentions'], 'alerts' => ['label' => 'notifications']]], 'antispam' => ['label' => 'antispam_title', 'function' => __NAMESPACE__ . '\\AntiSpam::call', 'icon' => 'security'], 'languages' => ['label' => 'language_configuration', 'function' => __NAMESPACE__ . '\\Languages::call', 'icon' => 'languages', 'subsections' => ['edit' => ['label' => 'language_edit'], 'add' => ['label' => 'language_add'], 'settings' => ['label' => 'language_settings']]], 'current_theme' => ['label' => 'theme_current_settings', 'function' => __NAMESPACE__ . '\\Themes::call', 'custom_url' => '{scripturl}?action=admin;area=theme;sa=list;th=%1$d', 'icon' => 'current_theme'], 'theme' => ['label' => 'theme_admin', 'function' => __NAMESPACE__ . '\\Themes::call', 'custom_url' => '{scripturl}?action=admin;area=theme', 'icon' => 'themes', 'subsections' => ['admin' => ['label' => 'themeadmin_admin_title'], 'list' => ['label' => 'themeadmin_list_title'], 'reset' => ['label' => 'themeadmin_reset_title'], 'edit' => ['label' => 'themeadmin_edit_title']]], 'modsettings' => ['label' => 'admin_modifications', 'function' => __NAMESPACE__ . '\\Mods::call', 'icon' => 'modifications', 'subsections' => [ // MOD AUTHORS: If your mod has just a few simple // settings and doesn't need its own settings page, you // can use the integrate_general_mod_settings hook to // add them to the 'general' page. 'general' => ['label' => 'mods_cat_modifications_misc'], ]]]], 'layout' => ['title' => 'layout_controls', 'permission' => ['manage_boards', 'admin_forum', 'manage_smileys', 'manage_attachments', 'moderate_forum'], 'areas' => ['manageboards' => ['label' => 'admin_boards', 'function' => __NAMESPACE__ . '\\Boards::call', 'icon' => 'boards', 'permission' => ['manage_boards'], 'subsections' => ['main' => ['label' => 'boards_edit'], 'newcat' => ['label' => 'mboards_new_cat'], 'settings' => ['label' => 'settings', 'admin_forum']]], 'postsettings' => ['label' => 'manageposts', 'function' => __NAMESPACE__ . '\\Posts::call', 'permission' => ['admin_forum'], 'icon' => 'posts', 'subsections' => ['posts' => ['label' => 'manageposts_settings'], 'censor' => ['label' => 'admin_censored_words'], 'topics' => ['label' => 'manageposts_topic_settings'], 'drafts' => ['label' => 'manage_drafts']]], 'managecalendar' => ['label' => 'manage_calendar', 'function' => __NAMESPACE__ . '\\Calendar::call', 'icon' => 'calendar', 'permission' => ['admin_forum'], 'inactive' => false, 'subsections' => ['holidays' => ['label' => 'manage_holidays', 'permission' => 'admin_forum'], 'settings' => ['label' => 'calendar_settings', 'permission' => 'admin_forum']]], 'managesearch' => ['label' => 'manage_search', 'function' => __NAMESPACE__ . '\\Search::call', 'icon' => 'search', 'permission' => ['admin_forum'], 'subsections' => ['weights' => ['label' => 'search_weights'], 'method' => ['label' => 'search_method'], 'settings' => ['label' => 'settings']]], 'smileys' => ['label' => 'smileys_manage', 'function' => __NAMESPACE__ . '\\Smileys::call', 'icon' => 'smiley', 'permission' => ['manage_smileys'], 'subsections' => ['editsets' => ['label' => 'smiley_sets'], 'addsmiley' => ['label' => 'smileys_add', 'enabled' => true], 'editsmileys' => ['label' => 'smileys_edit', 'enabled' => true], 'setorder' => ['label' => 'smileys_set_order', 'enabled' => true], 'editicons' => ['label' => 'icons_edit_message_icons', 'enabled' => true], 'settings' => ['label' => 'settings']]], 'manageattachments' => ['label' => 'attachments_avatars', 'function' => __NAMESPACE__ . '\\Attachments::call', 'icon' => 'attachment', 'permission' => ['manage_attachments'], 'subsections' => ['browse' => ['label' => 'attachment_manager_browse'], 'attachments' => ['label' => 'attachment_manager_settings'], 'avatars' => ['label' => 'attachment_manager_avatar_settings'], 'attachpaths' => ['label' => 'attach_directories'], 'maintenance' => ['label' => 'attachment_manager_maintenance']]], 'sengines' => ['label' => 'search_engines', 'inactive' => false, 'function' => __NAMESPACE__ . '\\SearchEngines::call', 'icon' => 'engines', 'permission' => 'admin_forum', 'subsections' => ['stats' => ['label' => 'spider_stats'], 'logs' => ['label' => 'spider_logs'], 'spiders' => ['label' => 'spiders'], 'settings' => ['label' => 'settings']]]]], 'members' => ['title' => 'admin_manage_members', 'permission' => ['moderate_forum', 'manage_membergroups', 'manage_bans', 'manage_permissions', 'admin_forum'], 'areas' => ['viewmembers' => ['label' => 'admin_users', 'function' => __NAMESPACE__ . '\\Members::call', 'icon' => 'members', 'permission' => ['moderate_forum'], 'subsections' => ['all' => ['label' => 'view_all_members'], 'search' => ['label' => 'mlist_search']]], 'membergroups' => ['label' => 'admin_groups', 'function' => __NAMESPACE__ . '\\Membergroups::call', 'icon' => 'membergroups', 'permission' => ['manage_membergroups'], 'subsections' => ['index' => ['label' => 'membergroups_edit_groups', 'permission' => 'manage_membergroups'], 'add' => ['label' => 'membergroups_new_group', 'permission' => 'manage_membergroups'], 'settings' => ['label' => 'settings', 'permission' => 'admin_forum']]], 'permissions' => ['label' => 'edit_permissions', 'function' => __NAMESPACE__ . '\\Permissions::call', 'icon' => 'permissions', 'permission' => ['manage_permissions'], 'subsections' => ['index' => ['label' => 'permissions_groups', 'permission' => 'manage_permissions'], 'board' => ['label' => 'permissions_boards', 'permission' => 'manage_permissions'], 'profiles' => ['label' => 'permissions_profiles', 'permission' => 'manage_permissions'], 'postmod' => ['label' => 'permissions_post_moderation', 'permission' => 'manage_permissions'], 'settings' => ['label' => 'settings', 'permission' => 'admin_forum']]], 'regcenter' => ['label' => 'registration_center', 'function' => __NAMESPACE__ . '\\Registration::call', 'icon' => 'regcenter', 'permission' => ['admin_forum', 'moderate_forum'], 'subsections' => ['register' => ['label' => 'admin_browse_register_new', 'permission' => 'moderate_forum'], 'agreement' => ['label' => 'registration_agreement', 'permission' => 'admin_forum'], 'policy' => ['label' => 'privacy_policy', 'permission' => 'admin_forum'], 'reservednames' => ['label' => 'admin_reserved_set', 'permission' => 'admin_forum'], 'settings' => ['label' => 'settings', 'permission' => 'admin_forum']]], 'warnings' => ['label' => 'warnings', 'function' => __NAMESPACE__ . '\\Warnings::call', 'icon' => 'warning', 'inactive' => false, 'permission' => ['admin_forum']], 'ban' => ['label' => 'ban_title', 'function' => __NAMESPACE__ . '\\Bans::call', 'icon' => 'ban', 'permission' => 'manage_bans', 'subsections' => ['list' => ['label' => 'ban_edit_list'], 'add' => ['label' => 'ban_add_new'], 'browse' => ['label' => 'ban_trigger_browse'], 'log' => ['label' => 'ban_log']]], 'paidsubscribe' => ['label' => 'paid_subscriptions', 'inactive' => false, 'function' => __NAMESPACE__ . '\\Subscriptions::call', 'icon' => 'paid', 'permission' => 'admin_forum', 'subsections' => ['view' => ['label' => 'paid_subs_view'], 'settings' => ['label' => 'settings']]]]], 'maintenance' => ['title' => 'admin_maintenance', 'permission' => ['admin_forum'], 'areas' => ['serversettings' => ['label' => 'admin_server_settings', 'function' => __NAMESPACE__ . '\\Server::call', 'icon' => 'server', 'subsections' => ['general' => ['label' => 'general_settings'], 'database' => ['label' => 'database_settings'], 'cookie' => ['label' => 'cookies_sessions_settings'], 'security' => ['label' => 'security_settings'], 'cache' => ['label' => 'caching_settings'], 'export' => ['label' => 'export_settings'], 'loads' => ['label' => 'load_balancing_settings'], 'phpinfo' => ['label' => 'phpinfo_settings']]], 'maintain' => ['label' => 'maintain_title', 'function' => __NAMESPACE__ . '\\Maintenance::call', 'icon' => 'maintain', 'subsections' => ['routine' => ['label' => 'maintain_sub_routine', 'permission' => 'admin_forum'], 'database' => ['label' => 'maintain_sub_database', 'permission' => 'admin_forum'], 'members' => ['label' => 'maintain_sub_members', 'permission' => 'admin_forum'], 'topics' => ['label' => 'maintain_sub_topics', 'permission' => 'admin_forum'], 'hooks' => ['label' => 'hooks_title_list', 'permission' => 'admin_forum']]], 'scheduledtasks' => ['label' => 'maintain_tasks', 'function' => __NAMESPACE__ . '\\Tasks::call', 'icon' => 'scheduled', 'subsections' => ['tasks' => ['label' => 'maintain_tasks', 'permission' => 'admin_forum'], 'tasklog' => ['label' => 'scheduled_log', 'permission' => 'admin_forum'], 'settings' => ['label' => 'scheduled_tasks_settings', 'permission' => 'admin_forum']]], 'mailqueue' => ['label' => 'mailqueue_title', 'function' => __NAMESPACE__ . '\\Mail::call', 'icon' => 'mail', 'subsections' => ['browse' => ['label' => 'mailqueue_browse', 'permission' => 'admin_forum'], 'settings' => ['label' => 'mailqueue_settings', 'permission' => 'admin_forum'], 'test' => ['label' => 'mailqueue_test', 'permission' => 'admin_forum']]], 'reports' => ['label' => 'generate_reports', 'function' => __NAMESPACE__ . '\\Reports::call', 'icon' => 'reports'], 'logs' => ['label' => 'logs', 'function' => __NAMESPACE__ . '\\Logs::call', 'icon' => 'logs', 'subsections' => ['errorlog' => ['label' => 'errorlog', 'permission' => 'admin_forum', 'enabled' => true, 'url' => '{scripturl}?action=admin;area=logs;sa=errorlog;desc'], 'adminlog' => ['label' => 'admin_log', 'permission' => 'admin_forum', 'enabled' => true], 'modlog' => ['label' => 'moderation_log', 'permission' => 'admin_forum', 'enabled' => true], 'banlog' => ['label' => 'ban_log', 'permission' => 'manage_bans'], 'spiderlog' => ['label' => 'spider_logs', 'permission' => 'admin_forum', 'enabled' => true], 'tasklog' => ['label' => 'scheduled_log', 'permission' => 'admin_forum'], 'settings' => ['label' => 'log_settings', 'permission' => 'admin_forum']]], 'repairboards' => ['label' => 'admin_repair', 'function' => __NAMESPACE__ . '\\RepairBoards::call', 'select' => 'maintain', 'hidden' => true]]]]

Defines the menu structure for the admin 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: If your mod has just a few simple settings and doesn't need its own settings page, you don't need to bother adding anything to this menu. Instead, just use the integrate_general_mod_settings hook to add your settings to the general mod settings page.

Alternatively, if you want to add a custom settings page for your mod, please use the integrate_admin_areas hook to add your settings page to $admin_areas['config']['areas']['modsettings']['subsections'].

$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' => 'AdminMain', 'prepareDBSettingContext' => 'prepareDBSettingContext', 'saveSettings' => 'saveSettings', 'saveDBSettings' => 'saveDBSettings', 'getServerVersions' => 'getServerVersions', 'getFileVersions' => 'getFileVersions', 'updateAdminPreferences' => 'updateAdminPreferences', 'emailAdmins' => 'emailAdmins', 'adminLogin' => 'adminLogin']]

BackwardCompatibility settings for this class.

Methods

adminLogin()

Question the verity of the admin by asking for his or her password.

public static adminLogin([string $type = 'admin' ]) : mixed
  • loads Login.template.php and uses the admin_login sub template.
  • sends data to template so the admin is sent on to the page they wanted if their password is correct, otherwise they can try again.
Parameters
$type : string = 'admin'

What login type is this - can be 'admin' or 'moderate'

call()

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

public static call() : void

emailAdmins()

Send all the administrators a lovely email.

public static emailAdmins(string $template[, array<string|int, mixed> $replacements = [] ][, array<string|int, mixed> $additional_recipients = [] ]) : mixed
  • loads all users who are admins or have the admin forum permission.
  • uses the email template and replacements passed in the parameters.
  • sends them an email.
Parameters
$template : string

Which email template to use

$replacements : array<string|int, mixed> = []

An array of items to replace the variables in the template

$additional_recipients : array<string|int, mixed> = []

An array of arrays of info for additional recipients. Should have 'id', 'email' and 'name' for each.

execute()

The main admin handling function.

public execute() : void

It initialises all the basic context required for the admin center. It passes execution onto the relevant admin section. If the passed section is not found it shows the admin home page.

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.

getFileVersions()

Search through source, theme, and language files to determine their version.

public static getFileVersions(array<string|int, mixed> &$versionOptions) : array<string|int, mixed>

Get detailed version information about the physical SMF files on the server.

  • the input parameter allows to set whether to include SSI.php and whether the results should be sorted.
  • returns an array containing information on source files, templates, and language files found in the default theme directory (grouped by language).
Parameters
$versionOptions : array<string|int, mixed>

An array of options. Can contain one or more of 'include_root', 'include_tasks' and 'sort_results'

Return values
array<string|int, mixed>

An array of file version info.

getServerVersions()

Get a list of versions that are currently installed on the server.

public static getServerVersions(array<string|int, mixed> $checkFor) : array<string|int, mixed>
Parameters
$checkFor : array<string|int, mixed>

An array of what to check versions for - can contain one or more of 'gd', 'imagemagick', 'db_server', 'phpa', 'memcache', 'php' or 'server'

Return values
array<string|int, mixed>

An array of versions (keys are same as what was in $checkFor, values are the versions)

load()

Static wrapper for constructor.

public static load() : object
Return values
object

An instance of this class.

prepareDBSettingContext()

Helper function, it sets up the context for database settings.

public static prepareDBSettingContext(array<string|int, mixed> &$config_vars) : void
Parameters
$config_vars : array<string|int, mixed>

An array of configuration variables

Tags
todo

see rev. 10406 from 2.1-requests

saveDBSettings()

Helper function for saving database settings.

public static saveDBSettings(array<string|int, mixed> &$config_vars) : mixed
Parameters
$config_vars : array<string|int, mixed>

An array of configuration variables

Tags
todo

see rev. 10406 from 2.1-requests

saveSettings()

Helper function. Saves settings by putting them in Settings.php or saving them in the settings table.

public static saveSettings(array<string|int, mixed> &$config_vars) : void
  • Saves those settings set from ?action=admin;area=serversettings.
  • Requires the admin_forum permission.
  • Contains arrays of the types of data to save into Settings.php.
Parameters
$config_vars : array<string|int, mixed>

An array of configuration variables

updateAdminPreferences()

Saves the admin's current preferences to the database.

public static updateAdminPreferences() : mixed

__construct()

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

protected __construct() : mixed

adminLogin_outputPostVars()

Used by the adminLogin() method.

protected static adminLogin_outputPostVars(string $k, string $v) : string

If 'value' is an array, calls itself recursively.

Parameters
$k : string

The keys

$v : string

The values

Return values
string

'hidden' HTML form fields, containing key-value pairs

construct_query_string()

Properly urlencodes a string to be used in a query.

protected static construct_query_string(string $get) : string
Parameters
$get : string

A copy of $_GET.

Return values
string

Our query string.

setAdminAreas()

Sets any dynamic values in $this->admin_areas.

protected setAdminAreas() : void

        
On this page

Search results