Abstract handler for content type-specific attachment behaviors.

package XenForo_Attachment

 Methods

Constructor.

__construct() 

Behavior to carry out after deleting an attachment (such as reducing an attachment count on the content).

attachmentPostDelete(array $attachment, \Zend_Db_Adapter_Abstract $db) 

This is only called when the attachment has been associated with particular content (not just uploaded unassociated).

Parameters

$attachment

array

Attachment that has been deleted

$db

\Zend_Db_Adapter_Abstract

DB object

Determines if the specified user can upload new attachments or manage existing ones.

canUploadAndManageAttachments(array $contentData, array $viewingUser) : boolean

The content data may contain different type-specific values in different situations. Eg, when posting a thread, only the node_id is known; when posting a reply, the thread_id is know; when editing a post, the post_id is known.

Parameters

$contentData

array

Type-specific params based on context

$viewingUser

arraynull

Viewing user array; null for visitor

Returns

boolean

Determines if the specified user can view the given attachment.

canViewAttachment(array $attachment, array $viewingUser) : boolean

Parameters

$attachment

array

Attachment to view

$viewingUser

arraynull

Viewing user array; null for visitor

Returns

boolean

Get attachment constraints for the current attachment content type

getAttachmentConstraints() : array

Returns

array

Returns the maximum allowed attachments for this content type.

getAttachmentCountLimit() : integer | true

Returns

integertrueIf true, there is no limit

Builds a content data array.

getContentDataFromContentId(integer $contentId) : array

By default, this only contains only the primary content ID.

Parameters

$contentId

integer

Returns

array

Gets the primary content ID from an array of content data, if provided.

getContentIdFromContentData(array $contentData) : integer

Parameters

$contentData

array

Type-specific content data

Returns

integer

Returns the phrase key of a phrase that names the content type managed by this handler.

getContentTypePhraseKey() : string

Returns

string

Standardizes the viewing user array reference.

standardizeViewingUserReference(array $viewingUser) 

Parameters

$viewingUser

arraynull

Viewing user array. Will be normalized.

Determines if the specified user can upload new attachments or manage existing ones.

_canUploadAndManageAttachments(array $contentData, array $viewingUser) : boolean

The content data may contain different type-specific values in different situations. Eg, when posting a thread, only the node_id is known; when posting a reply, the thread_id is know; when editing a post, the post_id is known.

Parameters

$contentData

array

Type-specific params based on context

$viewingUser

array

Viewing user array

Returns

boolean

Determines if the specified user can view the given attachment.

_canViewAttachment(array $attachment, array $viewingUser) : boolean

Parameters

$attachment

array

Attachment to view

$viewingUser

array

Viewing user array

Returns

boolean

 Properties

 

The key of the content ID value in the content data array.

$_contentIdKey : string

Must be overriden by children.

 

The route used to build a link to the content hosting attachment managed by this handler.

$_contentRoute : string

Example: posts use 'posts' Must be overriden by children.

 

The phrase key that names the content type for this attachment handler.

$_contentTypePhraseKey : string

Examples: 'post'; 'conversation_message' Must be overriden by children.