Documentation

AttachmentUpload
in package
implements ActionInterface, Routable uses ActionRouter, ActionTrait

This class handles adding/deleting attachments

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

$_attachments  : array<string|int, mixed>
$_attachmentUploadDir  : string|bool
$_attachResults  : array<string|int, mixed>
$_attachSuccess  : array<string|int, mixed>
$_attchDir  : string
$_board  : int|null
$_canPostAttachment  : bool
$_currentAttachmentUploadDir  : int
$_generalErrors  : array<string|int, mixed>
$_initialError  : mixed
$_msg  : int
$_response  : array<string|int, mixed>
$_sa  : string|bool
$_subActions  : array<string|int, mixed>
$obj  : static

Methods

add()  : void
Handles adding an attachment
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.
delete()  : void
Handles deleting the attachment
execute()  : void
Handles calling the appropriate function based on the sub-action
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
Attachments constructor.
buildActionRoute()  : array<string|int, mixed>
Builds a routing path for an action based on URL query parameters.
createAttach()  : void
Actually attaches the file
parseActionRoute()  : array<string|int, mixed>
Parses a route for an action to get URL query parameters.
processAttachments()  : void
Moves an attachment to the proper directory and set the relevant data into $_SESSION['temp_attachments']
sendResponse()  : void
Sends the response data
setResponse()  : void
Sets up the response information

Properties

$_attachments

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

Not used?

$_attachmentUploadDir

protected string|bool $_attachmentUploadDir = false

An array of info about attachment upload directories or false

$_attachResults

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

An array of information about the results of each file

$_attachSuccess

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

An array of information about successful attachments

$_attchDir

protected string $_attchDir = ''

The path to the current attachment directory

$_board

protected int|null $_board = null

The ID of the board this attachment's post is in or null if it's not set

$_canPostAttachment

protected bool $_canPostAttachment

Whether or not an attachment can be posted

$_currentAttachmentUploadDir

protected int $_currentAttachmentUploadDir

ID of the current attachment directory

$_generalErrors

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

An array of information about any errors that occurred

$_msg

protected int $_msg = 0

The ID of the message this attachment is associated with

$_response

protected array<string|int, mixed> $_response = ['error' => true, 'data' => [], 'extra' => '']

An array of response information. @used-by \sendResponse() when adding attachments

$_sa

protected string|bool $_sa = false

The current sub-action, or false if there isn't one

$_subActions

protected array<string|int, mixed> $_subActions = ['add', 'delete']

An array of all valid sub-actions

$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()

Handles calling the appropriate function based on the sub-action

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

__construct()

Attachments constructor.

protected __construct() : mixed

Sets up some initial information - the message ID, board, current attachment upload dir, etc. Protected to force instantiation via load().

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.

createAttach()

Actually attaches the file

protected createAttach() : void

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

processAttachments()

Moves an attachment to the proper directory and set the relevant data into $_SESSION['temp_attachments']

protected processAttachments() : void

setResponse()

Sets up the response information

protected setResponse([array<string|int, mixed> $data = [] ]) : void
Parameters
$data : array<string|int, mixed> = []

Data for the response if we're not adding an attachment


        
On this page

Search results