Documentation

PersonalMessage
in package
implements ActionInterface Uses BackwardCompatibility

This class is mainly meant for controlling the actions related to personal messages. It allows viewing, sending, deleting, and marking personal messages.

Table of Contents

Interfaces

ActionInterface
Interface for all action classes.

Constants

VIEW_ALL  = 0
Display mode to show all personal messages in a paginated list.
VIEW_CONV  = 2
Display mode to show personal messages in a conversation view.
VIEW_ONE  = 1
Display mode to show one personal message at a time.

Properties

$current_label  : string
$current_label_id  : int
$folder  : string
$labels_in_use  : array<string|int, mixed>
$mode  : int
$pm_areas  : array<string|int, mixed>
$replied  : array<string|int, mixed>
$sort_methods  : array<string|int, mixed>
$subaction  : string
$subactions  : array<string|int, mixed>
$unread  : array<string|int, mixed>
$current_label_redirect  : string
$obj  : object
$backcompat  : array<string|int, mixed>

Methods

applyActions()  : void
This method performs all additional stuff.
call()  : void
Convenience method to load() and execute() an instance of this class.
drafts()  : void
Allows the user to view their PM drafts.
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.
labels()  : void
Handles adding, deleting and editing labels on messages.
load()  : object
Static wrapper for constructor.
manageLabels()  : void
Backward compatibility wrapper for the manlabels sub-action.
manageRules()  : void
Backward compatibility wrapper for the manrules sub-action.
messageActionsApply()  : void
Backward compatibility wrapper for the pmactions sub-action.
messageDrafts()  : void
Backward compatibility wrapper for the showpmdrafts sub-action.
messageFolder()  : void
Backward compatibility wrapper for the show sub-action.
messageKillAll()  : void
Backward compatibility wrapper for the removeall2 sub-action.
messagePopup()  : void
Backward compatibility wrapper for the popup sub-action.
messagePost()  : void
Backward compatibility wrapper for the send sub-action.
messagePost2()  : void
Backward compatibility wrapper for the send2 sub-action.
messagePrune()  : void
Backward compatibility wrapper for the prune sub-action.
messageSearch()  : void
Backward compatibility wrapper for the search sub-action.
messageSearch2()  : void
Backward compatibility wrapper for the search2 sub-action.
messageSettings()  : void
Backward compatibility wrapper for the settings sub-action.
popup()  : void
The popup for when we ask for the popup from the user.
prune()  : void
This function allows the user to delete all messages older than so many days.
removeAll()  : void
Delete ALL the messages!
report()  : void
Allows the user to report a personal message to an administrator.
reportMessage()  : void
Backward compatibility wrapper for the report sub-action.
rules()  : void
List all rules, and allow adding/entering etc.
search()  : void
Allows searching through personal messages.
search2()  : void
Actually do the search of personal messages.
send()  : void
Send a new message?
send2()  : void
Send it!
settings()  : void
Allows to edit Personal Message Settings.
show()  : void
Shows the personal messages in a folder (i.e. "inbox" or "sent items")
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().
buildLimitBar()  : mixed
Figures out the limit for how many PMs this user can have.
createMenu()  : void
A menu to easily access different areas of the PM section

Constants

VIEW_ALL

Display mode to show all personal messages in a paginated list.

public mixed VIEW_ALL = 0

VIEW_CONV

Display mode to show personal messages in a conversation view.

public mixed VIEW_CONV = 2

VIEW_ONE

Display mode to show one personal message at a time.

public mixed VIEW_ONE = 1

Properties

$current_label

public string $current_label = ''

Name of the current label.

$current_label_id

public int $current_label_id = -1

ID number of the current label, or -1 for the main inbox folder.

$folder

public string $folder = 'inbox'

The folder being viewed. Either 'inbox' or 'sent'.

$labels_in_use

public array<string|int, mixed> $labels_in_use = []

Labels that have been applied to a collection of PMs.

Keys are the IDs of some PMs. Values are arrays of label IDs.

$mode

public int $mode = self::VIEW_CONV

The display mode we are acutally using.

$pm_areas

public array<string|int, mixed> $pm_areas = ['folders' => ['title' => 'pm_messages', 'areas' => ['inbox' => ['label' => 'inbox', 'custom_url' => '{scripturl}?action=pm', 'amt' => 0], 'send' => ['label' => 'new_message', 'custom_url' => '{scripturl}?action=pm;sa=send', 'permission' => 'pm_send', 'amt' => 0], 'sent' => ['label' => 'sent_items', 'custom_url' => '{scripturl}?action=pm;f=sent', 'amt' => 0], 'drafts' => ['label' => 'drafts_show', 'custom_url' => '{scripturl}?action=pm;sa=showpmdrafts', 'permission' => 'pm_draft', 'enabled' => true, 'amt' => 0]], 'amt' => 0], 'labels' => ['title' => 'pm_labels', 'areas' => [], 'amt' => 0], 'actions' => ['title' => 'pm_actions', 'areas' => ['search' => ['label' => 'pm_search_bar_title', 'custom_url' => '{scripturl}?action=pm;sa=search'], 'prune' => ['label' => 'pm_prune', 'custom_url' => '{scripturl}?action=pm;sa=prune']]], 'pref' => ['title' => 'pm_preferences', 'areas' => ['manlabels' => ['label' => 'pm_manage_labels', 'custom_url' => '{scripturl}?action=pm;sa=manlabels'], 'manrules' => ['label' => 'pm_manage_rules', 'custom_url' => '{scripturl}?action=pm;sa=manrules'], 'settings' => ['label' => 'pm_settings', 'custom_url' => '{scripturl}?action=pm;sa=settings']]]]

Defines the menu structure for the personal message action. 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.

$replied

public array<string|int, mixed> $replied = []

Whether the current user has replied to a collection of PMs.

Keys are the IDs of some PMs. Values are booleans.

$sort_methods

public static array<string|int, mixed> $sort_methods = ['date' => 'pm.id_pm', 'name' => 'COALESCE(mem.real_name, \'\')', 'subject' => 'pm.subject']

Instructions for sorting the personal messages.

$subaction

public string $subaction = 'show'

The requested sub-action. This should be set by the constructor.

$subactions

public static array<string|int, mixed> $subactions = ['show' => 'show', 'popup' => 'popup', 'showpmdrafts' => 'drafts', 'send' => 'send', 'send2' => 'send2', 'search' => 'search', 'search2' => 'search2', 'pmactions' => 'applyActions', 'removeall2' => 'removeAll', 'prune' => 'prune', 'report' => 'report', 'manlabels' => 'labels', 'manrules' => 'rules', 'settings' => 'settings']

Available sub-actions.

$unread

public array<string|int, mixed> $unread = []

Whether the current user has read a collection of PMs.

Keys are the IDs of some PMs. Values are booleans.

$current_label_redirect

protected string $current_label_redirect

URL to redirect to for the current label.

$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' => 'MessageMain', 'messageFolder' => 'MessageFolder', 'messagePopup' => 'MessagePopup', 'manageLabels' => 'ManageLabels', 'manageRules' => 'ManageRules', 'messageActionsApply' => 'MessageActionsApply', 'messagePrune' => 'MessagePrune', 'messageKillAll' => 'MessageKillAll', 'reportMessage' => 'ReportMessage', 'messageSearch' => 'MessageSearch', 'messageSearch2' => 'MessageSearch2', 'messagePost' => 'MessagePost', 'messagePost2' => 'MessagePost2', 'messageSettings' => 'MessageSettings', 'messageDrafts' => 'MessageDrafts']]

BackwardCompatibility settings for this class.

Methods

applyActions()

This method performs all additional stuff.

public applyActions() : void

..

call()

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

public static call() : void

drafts()

Allows the user to view their PM drafts.

public drafts() : 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:

  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.

labels()

Handles adding, deleting and editing labels on messages.

public labels() : void

load()

Static wrapper for constructor.

public static load() : object
Return values
object

An instance of this class.

manageLabels()

Backward compatibility wrapper for the manlabels sub-action.

public static manageLabels() : void

manageRules()

Backward compatibility wrapper for the manrules sub-action.

public static manageRules() : void

messageActionsApply()

Backward compatibility wrapper for the pmactions sub-action.

public static messageActionsApply() : void

messageDrafts()

Backward compatibility wrapper for the showpmdrafts sub-action.

public static messageDrafts() : void

messageFolder()

Backward compatibility wrapper for the show sub-action.

public static messageFolder() : void

messageKillAll()

Backward compatibility wrapper for the removeall2 sub-action.

public static messageKillAll() : void

messagePopup()

Backward compatibility wrapper for the popup sub-action.

public static messagePopup() : void

messagePost()

Backward compatibility wrapper for the send sub-action.

public static messagePost() : void

messagePost2()

Backward compatibility wrapper for the send2 sub-action.

public static messagePost2() : void

messagePrune()

Backward compatibility wrapper for the prune sub-action.

public static messagePrune() : void

messageSearch()

Backward compatibility wrapper for the search sub-action.

public static messageSearch() : void

messageSearch2()

Backward compatibility wrapper for the search2 sub-action.

public static messageSearch2() : void

messageSettings()

Backward compatibility wrapper for the settings sub-action.

public static messageSettings() : void

popup()

The popup for when we ask for the popup from the user.

public popup() : void

prune()

This function allows the user to delete all messages older than so many days.

public prune() : void

report()

Allows the user to report a personal message to an administrator.

public report() : void
  • In the first instance requires that the ID of the message to report is passed through $_GET.
  • It allows the user to report to either a particular administrator - or the whole admin team.
  • It will forward on a copy of the original message without allowing the reporter to make changes.
Tags
uses
template_report_message()

reportMessage()

Backward compatibility wrapper for the report sub-action.

public static reportMessage() : void

rules()

List all rules, and allow adding/entering etc.

public rules() : void

..

Allows searching through personal messages.

public search() : void

search2()

Actually do the search of personal messages.

public search2() : void

settings()

Allows to edit Personal Message Settings.

public settings() : void

Uses Actions/Profile/Main.php Uses Profile-Modify.php Uses Profile template. Uses Profile language file.

show()

Shows the personal messages in a folder (i.e. "inbox" or "sent items")

public show() : void

__construct()

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

protected __construct() : mixed

buildLimitBar()

Figures out the limit for how many PMs this user can have.

protected buildLimitBar() : mixed

createMenu()

A menu to easily access different areas of the PM section

protected createMenu(string $area) : void
Parameters
$area : string

The area we're currently in


        
On this page

Search results