Main
in package
implements
ActionInterface
Uses
BackwardCompatibility
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.
Properties
- $check_password : bool
- $profile_areas : array<string|int, mixed>
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- call() : void
- Convenience method to load() and execute() an instance of this class.
- execute() : void
- Dispatcher to whichever sub-action method is necessary.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- load() : object
- Static wrapper for constructor.
- modifyProfile() : void
- Backward compatibility wrapper.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- createMenu() : object
- 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' => ['file' => 'Profile-Actions.php', 'function' => 'activateAccount', '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 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.
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 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' => ['modifyProfile' => 'ModifyProfile']]
BackwardCompatibility settings for this class.
Methods
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
execute()
Dispatcher to whichever sub-action method is necessary.
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:
- Use this trait in the class.
- 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.
modifyProfile()
Backward compatibility wrapper.
public
static modifyProfile([mixed $post_errors = [] ]) : void
Parameters
- $post_errors : mixed = []
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
createMenu()
Creates the profile menu.
protected
createMenu() : object
The menu is always available as Menu::$loaded['profile'], but for convenience, this method also returns it.
Return values
object —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