Documentation

ACP
in package
implements ActionInterface, Routable uses ActionRouter, ActionTrait

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

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

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

Methods

adminLogin()  : void
Question the verity of the admin by asking for his or her password.
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.
emailAdmins()  : void
Send all the administrators a lovely email.
execute()  : void
The main admin handling function.
getFileVersions()  : array<string|int, mixed>
Search through source, theme, and language files to determine their version.
getOutputType()  : OutputTypeInterface
Gets the output type for this action.
getServerVersions()  : array<string|int, mixed>
Get a list of versions that are currently installed on the server.
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.
prepareDBSettingContext()  : void
Helper function, it sets up the context for database settings.
saveDBSettings()  : void
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()  : void
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.
buildActionRoute()  : array<string|int, mixed>
Builds a routing path for an action based on URL query parameters.
construct_query_string()  : string
Properly urlencodes a string to be used in a query.
init()  : mixed
Does some initial setup.
parseActionRoute()  : array<string|int, mixed>
Parses a route for an action to get URL query parameters.
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'], 'import' => ['label' => 'calendar_import', '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'], 'settings' => ['label' => 'settings', 'permission' => 'admin_forum']]], '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 definition, 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 static $obj

An instance of this class. This is used by the load() method to prevent multiple instantiations.

Methods

adminLogin()

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

public static adminLogin([string $type = 'admin' ]) : void
  • 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'

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
bool

canShowDebuggingInfo()

Determines whether debugging info should be shown.

public canShowDebuggingInfo() : bool
Return values
bool

canShowInMaintenanceMode()

Determines whether this action allows access in maintenance mode.

public canShowInMaintenanceMode() : bool
Return values
bool

True if access is allowed, false otherwise.

emailAdmins()

Send all the administrators a lovely email.

public static emailAdmins(string $template[, array<string|int, mixed> $replacements = [] ][, array<string|int, mixed> $additional_recipients = [] ]) : void
  • 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.

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)

isAgreementAction()

Determines whether this action can be accessed without accepting the registration agreement and privacy policy.

public isAgreementAction() : bool
Return values
bool

isRestrictedGuestAccessAllowed()

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
bool

load()

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

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) : void
Parameters
$config_vars : array<string|int, mixed>

An array of configuration variables

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() : void

__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|array<string|int, mixed> $v) : string

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

Parameters
$k : string

The keys

$v : string|array<string|int, mixed>

The values

Return values
string

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

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.

construct_query_string()

Properly urlencodes a string to be used in a query.

protected static construct_query_string(array<string|int, mixed> $get) : string
Parameters
$get : array<string|int, mixed>

A copy of $_GET.

Return values
string

Our query string.

init()

Does some initial setup.

protected init() : mixed

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

setAdminAreas()

Sets any dynamic values in $this->admin_areas.

protected setAdminAreas() : void

        
On this page

Search results