Documentation

Post2 extends Post
in package

This class handles posting and modifying replies and new topics.

Table of Contents

Constants

INTENT_EDIT_POST  = 2
INTENT_NEW_REPLY  = 1
INTENT_NEW_TOPIC  = 0
Constants to indicate what the user intends to do with this post.

Properties

$authorIsGuest  : bool
$becomes_approved  : bool
$can_approve  : bool
$errors  : array<string|int, mixed>
$form_message  : string
$form_subject  : string
$intent  : int
$minor_errors  : array<string|int, mixed>
$subaction  : string
$subactions  : array<string|int, mixed>
$board_list  : array<string|int, mixed>
$boards  : array<string|int, mixed>
$counter  : int
$existing_msg  : Msg
$locked  : bool
$moderation_action  : bool
$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.
show()  : void
Handles showing the post screen, loading the post to be modified, and loading any post quoted.
subActionProvider()  : null|array<string|int, mixed>
Called by Subs-Compat.php BackwardCompatibility wrapper functions to provide subaction execution for existing mods
submit()  : void
Posts or saves the message composed with Post::show().
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().
checkForErrors()  : void
Checks for any errors
checkForNewReplies()  : void
Checks whether any new replies have been posted while the user was typing and warns them if so
checkVerification()  : void
Displays a visual verification control if necessary
getTopicSummary()  : void
Get the topic for display purposes.
initiateEvent()  : void
Sets up the form for creating a new event
initiateNewTopic()  : void
Sets up the form for posting a new topic
initiatePoll()  : void
Sets up the form for creating a new topic with a poll
initiateReply()  : void
Sets up various Utils::$context variables for the template when replying to a topic
loadDrafts()  : void
Handles loading drafts
loadEditor()  : void
Load a new editor instance.
loadNotifyPrefs()  : void
Get notification preferences for later use.
loadTopic()  : void
Loads the topic that is being replied to.
prepareEdit()  : void
Handles various checks when editing an existing post
prepareNewReply()  : void
Handles various checks when submitting a new reply - permissions, possible errors, etc.
prepareNewTopic()  : void
Handles various checks when submitting a new topic
setBoards()  : void
Sets the values of $this->boards and, if applicable, $this->board_list.
setLinktree()  : void
Sets up the linktree info for the template
setMessageIcons()  : void
Gets information about available message icons for the template
setPageTitle()  : void
Sets the page title based on what the user is doing
setResponsePrefix()  : void
Handles setting the response prefix
setupPostingFields()  : void
Sets up information about each of the form fields
showAttachments()  : void
Handles showing attachments and setting up information for the attachments interface
showEdit()  : void
Shows the form for editing a post
showNew()  : void
Shows the form for creating a new post
showPreview()  : void
Handles previewing a post
showVerification()  : void
Shows the verification control if necessary
submitAttachments()  : void
Handles adding/updating/deleting attachments

Constants

INTENT_EDIT_POST

public mixed INTENT_EDIT_POST = 2

INTENT_NEW_REPLY

public mixed INTENT_NEW_REPLY = 1

INTENT_NEW_TOPIC

Constants to indicate what the user intends to do with this post.

public mixed INTENT_NEW_TOPIC = 0

Properties

$authorIsGuest

public bool $authorIsGuest = true

Whether the author of this post is a guest.

This might not be the same as whether the current user is a guest, because moderators can edit other people's posts.

$becomes_approved

public bool $becomes_approved = true

Whether this post will become approved upon submission.

$can_approve

public bool $can_approve = false

Whether the current user can approve posts.

$errors

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

Errors encountered while trying to post.

$form_message

public string $form_message = ''

The message body string to show in the editor form.

$form_subject

public string $form_subject = ''

The subject string to show in the editor form.

$intent

public int $intent = self::INTENT_NEW_TOPIC

What is the user trying to do with this post?

$minor_errors

public array<string|int, mixed> $minor_errors = ['not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject', 'topic_locked', 'topic_unlocked', 'topic_stickied', 'topic_unstickied', 'cannot_post_attachment']

There are two error types: serious and minor. Serious errors actually tell the user that a real error has occurred, while minor errors are like warnings that let them know that something with their post isn't right.

$subaction

public string $subaction = 'submit'

The sub-action to call.

$subactions

public static array<string|int, mixed> $subactions = ['submit' => 'submit', 'show' => 'show']

Available sub-actions.

$board_list

protected array<string|int, mixed> $board_list = []

A list of categories and boards produced by MessageIndex::getBoardList(). Not used if a board was specified in the URL parameters.

$boards

protected array<string|int, mixed> $boards = []

The boards that this post can be submitted to.

If a board was specified in the URL parameters, this will contain the ID of that board. Otherwise, it will contain a list of boards that the user is allowed to post in.

$counter

protected int $counter = 0

Used by getTopicSummary() method to count previous posts.

$existing_msg

protected Msg $existing_msg

An instance of SMF\Msg for the existing post. Only used when editing a post.

$locked

protected bool $locked = false

Whether the current topic is locked.

$moderation_action

protected bool $moderation_action

Whether this edit is a moderation action.

$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
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.

execute()

Dispatcher to whichever sub-action method is necessary.

public execute() : void

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

Simple actions don't require the index template at all.

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

show()

Handles showing the post screen, loading the post to be modified, and loading any post quoted.

public show() : void

Additionally handles previews of posts. Uses the Post template and language file, main sub template. Requires different permissions depending on the actions, but most notably post_new, post_reply_own, and post_reply_any. Shows options for the editing and posting of calendar events and attachments, as well as the posting of polls. Accessed from ?action=post.

subActionProvider()

Called by Subs-Compat.php BackwardCompatibility wrapper functions to provide subaction execution for existing mods

public static subActionProvider([null|string $sa = null ][, bool $return_config = false ][, string|null $activity = null ]) : null|array<string|int, mixed>
Parameters
$sa : null|string = null
$return_config : bool = false
$activity : string|null = null
Return values
null|array<string|int, mixed>

submit()

Posts or saves the message composed with Post::show().

public submit() : void

Requires various permissions depending on the action. Handles attachment, post, and calendar saving. Sends off notifications, and allows for announcements and moderation. Accessed from ?action=post2.

__construct()

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

protected __construct() : mixed

checkForErrors()

Checks for any errors

protected checkForErrors() : void

checkForNewReplies()

Checks whether any new replies have been posted while the user was typing and warns them if so

protected checkForNewReplies() : void

checkVerification()

Displays a visual verification control if necessary

protected checkVerification() : void

getTopicSummary()

Get the topic for display purposes.

protected getTopicSummary() : void

Gets a summary of the most recent posts in a topic. Depends on the topicSummaryPosts setting. If you are editing a post, only shows posts previous to that post. Puts results into Utils::$context['previous_posts'].

initiateEvent()

Sets up the form for creating a new event

protected initiateEvent() : void

initiateNewTopic()

Sets up the form for posting a new topic

protected initiateNewTopic() : void

initiatePoll()

Sets up the form for creating a new topic with a poll

protected initiatePoll() : void

initiateReply()

Sets up various Utils::$context variables for the template when replying to a topic

protected initiateReply() : void

loadDrafts()

Handles loading drafts

protected loadDrafts() : void

loadEditor()

Load a new editor instance.

protected loadEditor() : void

loadNotifyPrefs()

Get notification preferences for later use.

protected loadNotifyPrefs() : void

Puts results in Utils::$context['notify'], Utils::$context['auto_notify'], and Utils::$context['notify_prefs'].

loadTopic()

Loads the topic that is being replied to.

protected loadTopic() : void

If necessary, finds the topic ID based on $_REQUEST['msg'].

prepareEdit()

Handles various checks when editing an existing post

protected prepareEdit() : void

prepareNewReply()

Handles various checks when submitting a new reply - permissions, possible errors, etc.

protected prepareNewReply() : void

prepareNewTopic()

Handles various checks when submitting a new topic

protected prepareNewTopic() : void

setBoards()

Sets the values of $this->boards and, if applicable, $this->board_list.

protected setBoards() : void

setLinktree()

Sets up the linktree info for the template

protected setLinktree() : void

setMessageIcons()

Gets information about available message icons for the template

protected setMessageIcons() : void

setPageTitle()

Sets the page title based on what the user is doing

protected setPageTitle() : void

setResponsePrefix()

Handles setting the response prefix

protected setResponsePrefix() : void

setupPostingFields()

Sets up information about each of the form fields

protected setupPostingFields() : void

showAttachments()

Handles showing attachments and setting up information for the attachments interface

protected showAttachments() : void

showEdit()

Shows the form for editing a post

protected showEdit() : void

showNew()

Shows the form for creating a new post

protected showNew() : void

showPreview()

Handles previewing a post

protected showPreview() : void

showVerification()

Shows the verification control if necessary

protected showVerification() : void

submitAttachments()

Handles adding/updating/deleting attachments

protected submitAttachments() : void

        
On this page

Search results