Main
in package
implements
ActionInterface, Routable
uses
ActionTrait
This class has the primary job of showing and editing people's profiles.
It also allows the user to change some of their or another's preferences, and such things.
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
- $check_password : bool
- $profile_areas : array<string|int, mixed>
- $obj : static
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
- Dispatcher to whichever sub-action method is necessary.
- 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().
- createMenu() : Menu
- Creates the profile menu.
- securityChecks() : void
- Checks that the viewer can see what they are asking to see.
- setProfileAreas() : void
- Sets any dynamic values in $this->profile_areas.
Properties
$check_password
public
bool
$check_password
Whether a password check is required to save changes to the current profile area.
$profile_areas
public
array<string|int, mixed>
$profile_areas
= ['info' => ['title' => 'profileInfo', 'areas' => ['summary' => ['label' => 'summary', 'function' => __NAMESPACE__ . '\Summary::call', 'sub_template' => 'summary', 'icon' => 'administration', 'permission' => ['own' => 'is_not_guest', 'any' => 'profile_view']], 'popup' => ['function' => __NAMESPACE__ . '\Popup::call', 'sub_template' => 'profile_popup', 'permission' => ['own' => 'is_not_guest', 'any' => []], 'select' => 'summary'], 'alerts_popup' => ['function' => __NAMESPACE__ . '\AlertsPopup::call', 'sub_template' => 'alerts_popup', 'permission' => ['own' => 'is_not_guest', 'any' => []], 'select' => 'summary'], 'statistics' => ['label' => 'statPanel', 'function' => __NAMESPACE__ . '\StatPanel::call', 'sub_template' => 'statPanel', 'icon' => 'stats', 'permission' => ['own' => 'is_not_guest', 'any' => 'profile_view']], 'showposts' => ['label' => 'showPosts', 'function' => __NAMESPACE__ . '\ShowPosts::call', 'sub_template' => 'showPosts', 'icon' => 'posts', 'subsections' => ['messages' => ['label' => 'showMessages', 'permission' => ['is_not_guest', 'profile_view']], 'topics' => ['label' => 'showTopics', 'permission' => ['is_not_guest', 'profile_view']], 'unwatchedtopics' => ['label' => 'showUnwatched', 'permission' => ['is_not_guest', 'profile_view'], 'enabled' => true], 'attach' => ['label' => 'showAttachments', 'permission' => ['is_not_guest', 'profile_view']]], 'permission' => ['own' => 'is_not_guest', 'any' => 'profile_view']], 'showdrafts' => ['label' => 'drafts_show', 'function' => 'SMF\Draft::showInProfile', 'icon' => 'drafts', 'enabled' => true, 'permission' => ['own' => 'is_not_guest', 'any' => []]], 'showalerts' => ['label' => 'alerts_show', 'function' => __NAMESPACE__ . '\ShowAlerts::call', 'sub_template' => 'showAlerts', 'icon' => 'alerts', 'permission' => ['own' => 'is_not_guest', 'any' => []]], 'permissions' => ['label' => 'showPermissions', 'function' => __NAMESPACE__ . '\ShowPermissions::call', 'sub_template' => 'showPermissions', 'icon' => 'permissions', 'permission' => ['own' => 'manage_permissions', 'any' => 'manage_permissions']], 'tracking' => ['label' => 'trackUser', 'function' => __NAMESPACE__ . '\Tracking::call', 'sub_template' => 'tracking', 'icon' => 'logs', 'subsections' => ['activity' => ['label' => 'trackActivity', 'permission' => 'moderate_forum'], 'ip' => ['label' => 'trackIP', 'permission' => 'moderate_forum'], 'edits' => ['label' => 'trackEdits', 'permission' => 'moderate_forum', 'enabled' => true], 'groupreq' => ['label' => 'trackGroupRequests', 'permission' => 'approve_group_requests', 'enabled' => true], 'logins' => ['label' => 'trackLogins', 'permission' => 'moderate_forum', 'enabled' => true]], 'permission' => ['own' => ['moderate_forum', 'approve_group_requests'], 'any' => ['moderate_forum', 'approve_group_requests']]], 'viewwarning' => ['label' => 'profile_view_warnings', 'function' => __NAMESPACE__ . '\ViewWarning::call', 'sub_template' => 'viewWarning', 'icon' => 'warning', 'enabled' => true, 'permission' => ['own' => ['view_warning_own', 'view_warning_any', 'issue_warning', 'moderate_forum'], 'any' => ['view_warning_any', 'issue_warning', 'moderate_forum']]]]], 'edit_profile' => ['title' => 'forumprofile', 'areas' => ['account' => ['label' => 'account', 'function' => __NAMESPACE__ . '\Account::call', 'sub_template' => 'edit_options', 'icon' => 'maintain', 'enabled' => true, 'sc' => 'post', 'token' => 'profile-ac%u', 'password' => true, 'permission' => ['own' => ['profile_identity_any', 'profile_identity_own', 'profile_password_any', 'profile_password_own', 'manage_membergroups'], 'any' => ['profile_identity_any', 'profile_password_any', 'manage_membergroups']]], 'tfasetup' => ['label' => 'account', 'function' => __NAMESPACE__ . '\TFASetup::call', 'sub_template' => 'tfasetup', 'token' => 'profile-tfa%u', 'enabled' => true, 'hidden' => true, 'select' => 'account', 'permission' => ['own' => ['profile_password_own'], 'any' => ['profile_password_any']]], 'tfadisable' => ['label' => 'account', 'function' => __NAMESPACE__ . '\TFADisable::call', 'sub_template' => 'tfadisable', 'token' => 'profile-tfa%u', 'sc' => 'post', 'password' => true, 'enabled' => true, 'hidden' => true, 'select' => 'account', 'permission' => ['own' => ['profile_password_own'], 'any' => ['profile_password_any']]], 'forumprofile' => ['label' => 'forumprofile', 'function' => __NAMESPACE__ . '\ForumProfile::call', 'sub_template' => 'edit_options', 'icon' => 'members', 'sc' => 'post', 'token' => 'profile-fp%u', 'permission' => ['own' => ['profile_forum_any', 'profile_forum_own'], 'any' => ['profile_forum_any']]], 'theme' => ['label' => 'theme', 'function' => __NAMESPACE__ . '\ThemeOptions::call', 'sub_template' => 'edit_options', 'icon' => 'features', 'sc' => 'post', 'token' => 'profile-th%u', 'permission' => ['own' => ['profile_extra_any', 'profile_extra_own'], 'any' => ['profile_extra_any']]], 'notification' => [
'label' => 'notification',
'function' => __NAMESPACE__ . '\Notification::call',
'sub_template' => 'notification',
'icon' => 'alerts',
'sc' => 'post',
// 'token' => 'profile-nt%u', This is not checked here. We do it in the function itself - but if it was checked, this is what it'd be.
'subsections' => ['alerts' => ['label' => 'alert_prefs', 'permission' => ['is_not_guest', 'profile_extra_any']], 'topics' => ['label' => 'watched_topics', 'permission' => ['is_not_guest', 'profile_extra_any']], 'boards' => ['label' => 'watched_boards', 'permission' => ['is_not_guest', 'profile_extra_any']]],
'permission' => ['own' => ['is_not_guest'], 'any' => ['profile_extra_any']],
], 'ignoreboards' => ['label' => 'ignoreboards', 'function' => __NAMESPACE__ . '\IgnoreBoards::call', 'sub_template' => 'ignoreboards', 'icon' => 'boards', 'enabled' => true, 'sc' => 'post', 'token' => 'profile-ib%u', 'permission' => ['own' => ['profile_extra_any', 'profile_extra_own'], 'any' => ['profile_extra_any']]], 'lists' => ['label' => 'editBuddyIgnoreLists', 'function' => __NAMESPACE__ . '\BuddyIgnoreLists::call', 'sub_template' => 'editBuddyIgnoreLists', 'icon' => 'frenemy', 'enabled' => true, 'sc' => 'post', 'subsections' => ['buddies' => ['label' => 'editBuddies'], 'ignore' => ['label' => 'editIgnoreList']], 'permission' => ['own' => ['profile_extra_any', 'profile_extra_own'], 'any' => []]], 'groupmembership' => ['label' => 'groupmembership', 'function' => __NAMESPACE__ . '\GroupMembership::call', 'sub_template' => 'groupMembership', 'icon' => 'people', 'enabled' => true, 'sc' => 'request', 'token' => 'profile-gm%u', 'token_type' => 'request', 'permission' => ['own' => ['is_not_guest'], 'any' => ['manage_membergroups']]]]], 'profile_action' => ['title' => 'profileAction', 'areas' => [
'sendpm' => ['label' => 'profileSendIm', 'custom_url' => '{scripturl}?action=pm;sa=send', 'icon' => 'personal_message', 'enabled' => true, 'permission' => ['own' => [], 'any' => ['pm_send']]],
'report' => ['label' => 'report_profile', 'custom_url' => '{scripturl}?action=reporttm;{session_var}={session_id}', 'icon' => 'warning', 'enabled' => true, 'permission' => ['own' => [], 'any' => ['report_user']]],
'issuewarning' => ['label' => 'profile_issue_warning', 'function' => __NAMESPACE__ . '\IssueWarning::call', 'sub_template' => 'issueWarning', 'icon' => 'warning', 'token' => 'profile-iw%u', 'enabled' => true, 'permission' => ['own' => [], 'any' => ['issue_warning']]],
'banuser' => ['label' => 'profileBanUser', 'custom_url' => '{scripturl}?action=admin;area=ban;sa=add', 'icon' => 'ban', 'enabled' => true, 'permission' => ['own' => [], 'any' => ['manage_bans']]],
'subscriptions' => ['label' => 'subscriptions', 'function' => __NAMESPACE__ . '\PaidSubs::call', 'icon' => 'paid', 'enabled' => true, 'permission' => ['own' => ['is_not_guest'], 'any' => ['moderate_forum']]],
'getprofiledata' => [
'label' => 'export_profile_data',
'function' => __NAMESPACE__ . '\Export::call',
'sub_template' => 'export_profile_data',
'icon' => 'packages',
// 'token' => 'profile-ex%u', // This is not checked here. We do it in the function itself - but if it was checked, this is what it'd be.
'permission' => ['own' => ['profile_view_own'], 'any' => ['moderate_forum']],
],
'download' => ['label' => 'export_profile_data', 'function' => __NAMESPACE__ . '\ExportDownload::call', 'sub_template' => 'download_export_file', 'icon' => 'packages', 'hidden' => true, 'select' => 'getprofiledata', 'permission' => ['own' => ['profile_view_own'], 'any' => ['moderate_forum']]],
'dlattach' => ['label' => 'export_profile_data', 'function' => __NAMESPACE__ . '\ExportAttachment::call', 'sub_template' => 'export_attachment', 'icon' => 'packages', 'hidden' => true, 'select' => 'getprofiledata', 'permission' => ['own' => ['profile_view_own'], 'any' => []]],
'deleteaccount' => ['label' => 'deleteAccount', 'function' => __NAMESPACE__ . '\Delete::call', 'sub_template' => 'deleteAccount', 'icon' => 'members_delete', 'sc' => 'post', 'token' => 'profile-da%u', 'password' => true, 'permission' => ['own' => ['profile_remove_any', 'profile_remove_own'], 'any' => ['profile_remove_any']]],
'activateaccount' => ['function' => __NAMESPACE__ . '\Activate::call', 'icon' => 'regcenter', 'sc' => 'get', 'token' => 'profile-aa%u', 'token_type' => 'get', 'permission' => ['own' => [], 'any' => ['moderate_forum']]],
// A logout link just for the popup menu.
'logout' => ['label' => 'logout', 'custom_url' => '{scripturl}?action=logout;{session_var}={session_id}', 'icon' => 'logout', 'enabled' => true, 'permission' => ['own' => ['is_not_guest'], 'any' => []]],
]]]
Defines the menu structure for the profile area. 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.
Occurrences of '{scripturl}' and '{boardurl}' in value strings will be replaced at runtime with the values of Config::$scripturl and Config::$boardurl.
Occurrences of '{session_var}' and '{session_id}' in value strings will be replaced at runtime with the values of Utils::$context['session_var'] and Utils::$context['session_id'].
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.
We start by defining the permission required. Then SMF takes this and turns it into the relevant context ;)
Possible fields:
For Sections:
string $title: Section title.
array $areas: Array of areas within this section.
For Areas:
string $label: Text string that will be used to show the area
in the menu.
string $file: Optional text string that may contain a file
name that's needed for inclusion in order to
display the area properly.
string $custom_url: Optional href for area.
string $function: Function to execute for this section.
string $class If your function is a method, set the class
field with your class's name and SMF will create
a new instance for it.
bool $enabled: Should area be shown?
string $sc: Session check validation to do on save. Without
this save will get unset.
bool $hidden: Does this not actually appear on the menu?
bool $password: Whether to require the user's password in order
to save the data in the area.
array $subsections: Array of subsections, in order of appearance.
array $permission: Array of permissions to determine who can access
this area. Should contain arrays $own and $any.
$obj
protected
static static
$obj
An instance of this class. This is used by the load() method to prevent multiple instantiations.
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()
Dispatcher to whichever sub-action method is necessary.
public
execute() : void
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
Simple actions don't require the index template at all.
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
createMenu()
Creates the profile menu.
protected
createMenu() : Menu
The menu is always available as Menu::$loaded['profile'], but for convenience, this method also returns it.
Return values
Menu —The profile menu object.
securityChecks()
Checks that the viewer can see what they are asking to see.
protected
securityChecks() : void
setProfileAreas()
Sets any dynamic values in $this->profile_areas.
protected
setProfileAreas() : void