vB_Library_Content_Attach
extends vB_Library_Content
in package
vB_Library_Content_Attach
Tags
Table of Contents
- ACTION_ADD = 1
- ACTION_APPROVE = 5
- ACTION_DELETE = 4
- ACTION_PUBLISH = 6
- ACTION_UPDATE = 2
- ACTION_VIEW = 3
- CACHELEVEL_CONTENT = 2
- CACHELEVEL_FULLCONTENT = 3
- CACHELEVEL_NODE = 1
- $allCanview : mixed
- $assertor : mixed
- $cacheNodes : mixed
- Whether we are caching node content
- $canBeLastContent : mixed
- $cannotDelete : mixed
- $channelTypeId : mixed
- $contenttype : mixed
- $contenttypeid : mixed
- $defaultNodeOptions : mixed
- $doFloodCheck : mixed
- $doIncompleteNodeCleanup : bool
- $extension_map : mixed
- $imageHandler : mixed
- $includeInUserPostCount : bool
- If true, then creating a node of this content type will increment the user's post count. If false, it will not. Generally, this should be true for topic starters and replies, and false for everything else.
- $index_fields : mixed
- $inheritViewPerms : mixed
- $inlist : mixed
- $instance : mixed
- $nodeApi : mixed
- $nodeLibrary : mixed
- $qryAfterAdd : mixed
- $showSignature : mixed
- $tablename : mixed
- $textCountChange : mixed
- $types : mixed
- __serialize() : mixed
- __sleep() : mixed
- __unserialize() : mixed
- __wakeup() : mixed
- add() : mixed
- Adds a new node.
- assembleContent() : array<string|int, mixed>
- Assembles the response for detailed content
- checkComplete() : bool
- This function checks to see if a node is valid, and if not it deletes or fixes it.
- checkConfigImageResizeLimitsForFile() : mixed
- clearCache() : mixed
- decrementUserPostCount() : mixed
- Decrements the number of posts for a user
- delete() : bool
- Remove an attachment
- deleteChildren() : mixed
- Delete the records without updating the parent info. It is used when deleting a whole channel and it's children need to be removed
- fetchContentType() : mixed
- fetchContentTypeId() : mixed
- fetchFromCache() : mixed
- This attempts to get the cached data for nodes
- fetchTableName() : array<string|int, mixed>
- returns the tables used by this content type.
- getAllCanView() : mixed
- Returns the fields that all users can see if they don't have canviewthreads
- getAttachmentHeaders() : array<string|int, string>
- Get array of http headers for this attachment file extension
- getAttachmentPermissions() : mixed
- getAttachmentsFromType() : mixed
- Get attachments for a content type
- getBareContent() : mixed
- Returns the node content plus the channel routeid and title, and starter route and title the as an associative array Caller MUST ensure that $nodeids are of the correct content type.
- getCanBeLastContent() : mixed
- getCanDelete() : bool
- Determines whether the current user can soft-delete or hard-delete
- getCanEdit() : bool
- Determines whether the current user can edit a node
- getCanModerate() : bool
- Determines whether the current user can moderate
- getCannotDelete() : bool
- Whether this type can be deleted. Infractions, for example, cannot be.
- getContent() : int
- Returns the node content as an associative array
- getContentApi() : mixed
- Returns a content api of the appropriate type
- getContentInstance() : mixed
- getContentLib() : mixed
- Returns a content api of the appropriate type
- getConversationParent() : array<string|int, mixed>
- Gets the conversation starter for a node. If the node is a channel it returns the channel record.
- getFullContent() : array<string|int, mixed>
- Returns the node content plus the channel routeid and title, and starter route and title the as an associative array
- getIndexableContent() : array<string|int, mixed>
- The classes that inherit this should implement this function It should return the content that should be indexed If there is a title field, the array key for that field should be 'title', the rest of the text can have any key
- getIndexableFromNode() : mixed
- See base class for information
- getInlist() : int
- Returns inlist property
- getStarter() : int
- Gets the conversation starter for a node. If the node is a channel it returns the channelid.
- getTextCountChange() : int
- Returns textCountChange property
- incrementUserPostCount() : mixed
- Increments the number of posts for a user. This function will also update user's "lastpost" field
- instance() : vB_PageCache
- Returns singleton instance of self.
- isComment() : bool
- Determines whether a specific node is a comment on a thread reply or not
- isPublished() : bool
- Is this record in a published state based on the times?
- isVisitorMessage() : bool
- determines whether a specific node is a visitor message
- mergeContentInfo() : mixed
- monitorWords() : mixed
- Checks if the text contains monitored words, and if so, sends notifications to admins and moderators if the setting is on.
- reloadOptions() : mixed
- Reload options from datastore. Currently only used by unit tests.
- removeAttachment() : mixed
- Remove an attachment
- removePrivateDataFromNode() : none
- Examines the node record returned from the node library and determines if any information needs to be removed before passing beyond the API layer.
- removeSignaturePicture() : mixed
- resetCountCalled() : mixed
- Reset the called array- this makes sure we only increment/decrement user post counts once for a given node This is only needed by the unit tests.
- saveThemeIcon() : mixed
- setDoIncompleteNodeCleanup() : mixed
- Sets the $doIncompleteNodeCleanup flag
- update() : mixed
- updates a record
- uploadAttachment() : array<string|int, mixed>
- Processes an uploaded file and saves it as an attachment
- uploadUrl() : mixed
- Upload an image based on the url
- validate() : bool
- Validates that the current can create a node with these values
- writeToCache() : void
- writes new cached data for nodes
- zapAttachmentType() : mixed
- Remove all attachments for content type
- __construct() : mixed
- afterAdd() : mixed
- Operations to be done after adding a node. Putting actions here allow child classes to minimize time keeping transaction open.
- beforeCommit() : mixed
- Called by the first child class just before the commit happens.
- changeContentType() : mixed
- checkFloodAndThrowException() : mixed
- countInUserPostCount() : bool
- Checks if the current node should be counted in the user post count for the author.
- duplicateCheck() : string|bool
- Checks accidental duplicate posting
- fetchAttachmentPath() : mixed
- fillContentTableData() : mixed
- getDuplicateHash() : string
- Calculates the CRC based on the indexable content
- getIndexableContentForAttachments() : mixed
- Get the indexable content for attachments. Separate this so that child classes can rewrite getIndexableContent entirely without having to copy as much code
- getLibraryClassNameInternal() : mixed
- getNodeClean() : bool
- Checks to see if the node has all the required data.
- getRawContent() : array<string|int, mixed>
- Prepares basic content. Used by both getBareContent and getFullContent.
- handleAttachments() : mixed
- This function needs to be implemented by sub classes that want to handle attachments. See the text library implementation for the full description.
- incompleteNodeCleanup() : bool
- This cleans up for a node that was found to be incomplete by deleting the child nodes and subsidiary table records. It is often overridden in child classes.
- needsFloodCheck() : mixed
- resizeImage() : bool
- Attempts to resize an uploaded image so that it can be saved as an attachment.
- sendModeratorNotification() : mixed
- Sends emails to moderators configured in admincp
- shouldChangeUserPostCountForChildNodes() : bool
- Checks whether or not we should adjust user post count for descendant nodes
- updateNodeOptions() : mixed
- Sets node options from individual fields.
- verifyAttachmentPath() : mixed
- verifyPostIconid() : mixed
- Verifies that the post iconid is valid
- verifyPrefixid() : mixed
- checkAndFixImageExtension() : mixed
- checkConfigImageResizeLimits() : mixed
- monitorWordsNode() : mixed
- Handles monitoring words for node creation and updates
- requiresModeration() : mixed
- saveUpload() : array<string|int, mixed>
- Saves an uploaded file into the filedata system.
- scanFileArray() : mixed
Constants
ACTION_ADD
public
mixed
ACTION_ADD
= 1
ACTION_APPROVE
public
mixed
ACTION_APPROVE
= 5
ACTION_DELETE
public
mixed
ACTION_DELETE
= 4
ACTION_PUBLISH
public
mixed
ACTION_PUBLISH
= 6
ACTION_UPDATE
public
mixed
ACTION_UPDATE
= 2
ACTION_VIEW
public
mixed
ACTION_VIEW
= 3
CACHELEVEL_CONTENT
public
mixed
CACHELEVEL_CONTENT
= 2
CACHELEVEL_FULLCONTENT
public
mixed
CACHELEVEL_FULLCONTENT
= 3
CACHELEVEL_NODE
public
mixed
CACHELEVEL_NODE
= 1
Properties
$allCanview
protected
mixed
$allCanview
= array('title' => 'title', 'channelroute' => 'channelroute', 'channeltitle' => 'channeltitle', 'channelid' => 'channelid', 'edit_reason' => 'edit_reason', 'edit_userid' => 'edit_userid', 'edit_username' => 'edit_username', 'edit_dateline' => 'edit_dateline', 'hashistory' => 'hashistory', 'starternodeoptions' => 'starternodeoptions', 'channelnodeoptions' => 'channelnodeoptions', 'contenttypeclass' => 'contenttypeclass', 'hide_title' => 'hide_title', 'hide_author' => 'hide_author', 'hide_publishdate' => 'hide_publishdate', 'display_fullincategory' => 'display_fullincategory', 'display_pageviews' => 'display_pageviews', 'channeltype' => 'channeltype', 'startertitle' => 'startertitle', 'starterauthor' => 'startertitle')
$assertor
protected
mixed
$assertor
$cacheNodes
Whether we are caching node content
protected
static mixed
$cacheNodes
$canBeLastContent
protected
mixed
$canBeLastContent
= alse
$cannotDelete
protected
mixed
$cannotDelete
= alse
$channelTypeId
protected
mixed
$channelTypeId
$contenttype
protected
mixed
$contenttype
= 'vBForum_Attach'
$contenttypeid
protected
mixed
$contenttypeid
$defaultNodeOptions
protected
static mixed
$defaultNodeOptions
= array(
'forum' => 138,
//vB_Api_Node::OPTION_AUTOAPPROVE_SUBSCRIPTION + //128
//vB_Api_Node::OPTION_AUTOAPPROVE_MEMBERSHIP + // 8
//vB_Api_Node::OPTION_ALLOW_POST //2
'blog' => 522,
//vB_Api_Node::OPTION_AUTOAPPROVE_MEMBERSHIP + // 8
//vB_Api_Node::OPTION_AUTOSUBSCRIBE_ON_JOIN // 512;
//vB_Api_Node::OPTION_ALLOW_POST //2
'article' => 138,
'group' => 10,
//vB_Api_Node::OPTION_AUTOAPPROVE_MEMBERSHIP + // 8
//vB_Api_Node::OPTION_ALLOW_POST //2
'vm' => 138,
'pm' => 138,
'album' => 138,
'report' => 138,
'infraction' => 138,
'default' => 138,
)
$doFloodCheck
protected
mixed
$doFloodCheck
= alse
$doIncompleteNodeCleanup
protected
bool
$doIncompleteNodeCleanup
= alse
$extension_map
protected
mixed
$extension_map
Tags
$imageHandler
protected
mixed
$imageHandler
$includeInUserPostCount
If true, then creating a node of this content type will increment the user's post count. If false, it will not. Generally, this should be true for topic starters and replies, and false for everything else.
protected
bool
$includeInUserPostCount
= alse
$index_fields
protected
mixed
$index_fields
= array('description')
$inheritViewPerms
protected
mixed
$inheritViewPerms
= 0
$inlist
protected
mixed
$inlist
= 0
$instance
protected
static mixed
$instance
= array()
$nodeApi
protected
mixed
$nodeApi
$nodeLibrary
protected
mixed
$nodeLibrary
$qryAfterAdd
protected
mixed
$qryAfterAdd
= array()
$showSignature
protected
mixed
$showSignature
= alse
$tablename
protected
mixed
$tablename
= 'attach'
$textCountChange
protected
mixed
$textCountChange
= 0
$types
protected
mixed
$types
Tags
Methods
__serialize()
public
__serialize() : mixed
Return values
mixed —__sleep()
public
__sleep() : mixed
Return values
mixed —__unserialize()
public
__unserialize(mixed $serialized) : mixed
Parameters
- $serialized : mixed
Return values
mixed —__wakeup()
public
__wakeup() : mixed
Return values
mixed —add()
Adds a new node.
public
add(mixed $data[, array<string|int, mixed> $options = [] ]) : mixed
This function will add a new attachment node & attach table record, increment refcount for the associated filedata table record, and set the parent node record's hasphoto to 1
Parameters
- $data : mixed
-
Array of field => value pairs which define the record. Must have all data required by vB_Library_Content::add(). At the minium, must have: int 'parentid' @see vB_Library_Content::add() int 'filedataid' Additional data may include: string 'caption' Optional. Caption for the image. If caption is set, it will overwrite the description. string 'description' Optional. If description is set but caption is not set, the caption will be set to description. @see vB_Library_Content::add() for more details It can also contain data corresponding to the attach table fields, such as: int 'visible' ??? int 'counter' ??? string 'filename' ??? int 'reportthreadid' ??? string 'settings' Serialized array of attachment settings that are used by vB5_Template_BbCode's attachReplaceCallback() to render the image with the specified settings. @see vB_Api_Content_Attach::getAvailableSettings() for a list of the avaliable settings @param array $options Array of options for the content being created. Understands skipTransaction, skipFloodCheck, floodchecktime
@return array Contains the data of the added node. Array with data-types & keys: int 'nodeid' bool 'success' string[] 'cacheEvents' array 'nodeVals' Array of field => value pairs representing the node table field values that were added to the node table. @see vB_Library_Node::getNodeFields() or the node table structure for these fields
- $options : array<string|int, mixed> = []
-
Array of options for the content being created. Understands skipTransaction, skipFloodCheck, floodchecktime, many subclasses have skipNotification.
@return mixed array with nodeid (int), success (bool), cacheEvents (array of strings), nodeVals (array of field => value).
Return values
mixed —assembleContent()
Assembles the response for detailed content
public
assembleContent(array<string|int, mixed> &$content) : array<string|int, mixed>
Parameters
- $content : array<string|int, mixed>
-
getRawContent() response array. Each element is a nodeid-keyed array. Each subarray must have the following data at minimum: nodeid, channelid, contenttypeid, starter, showopen, userid, setfor (if VM), nodeoptions
Return values
array<string|int, mixed> —Nodeid-keyed array of the $content data, plus additional data such as contenttypeclass, createpermissions, moderatorperms, channeltype, permissions, etc, @TODO: complete this list Also the expanded nodeoptions of: allow_post, moderate_comments, approve_membership, invite_only, autoparselinks, disablesmilies, disable_bbcode, hide_title, hide_author, hide_publishdate, display_fullincategory, display_pageviews, hide_comment_count
checkComplete()
This function checks to see if a node is valid, and if not it deletes or fixes it.
public
checkComplete(array<string|int, mixed> $node) : bool
Parameters
- $node : array<string|int, mixed>
-
-- node array
Return values
bool —checkConfigImageResizeLimitsForFile()
public
checkConfigImageResizeLimitsForFile(mixed $filepath) : mixed
Parameters
- $filepath : mixed
Return values
mixed —clearCache()
public
static clearCache() : mixed
Return values
mixed —decrementUserPostCount()
Decrements the number of posts for a user
public
decrementUserPostCount(array<string|int, mixed> $node[, mixed $action = '' ]) : mixed
When hard-deleting items, this is called from the content library, For all other state changes (unapprove, soft-delete, etc) it is called from the node library
Parameters
- $node : array<string|int, mixed>
- $action : mixed = ''
Return values
mixed —delete()
Remove an attachment
public
delete(mixed $nodeid) : bool
@param INT nodeid
Parameters
- $nodeid : mixed
Return values
bool —deleteChildren()
Delete the records without updating the parent info. It is used when deleting a whole channel and it's children need to be removed
public
deleteChildren(array<string|int, mixed> $childrenIds) : mixed
Parameters
- $childrenIds : array<string|int, mixed>
-
- list of node ids
Return values
mixed —fetchContentType()
public
fetchContentType() : mixed
Return values
mixed —fetchContentTypeId()
public
fetchContentTypeId() : mixed
Return values
mixed —fetchFromCache()
This attempts to get the cached data for nodes
public
static fetchFromCache(array<string|int, mixed>|int $nodeids, int $level) : mixed
Parameters
- $nodeids : array<string|int, mixed>|int
- $level : int
-
-- one of the constants for level of data
Return values
mixed —fetchTableName()
returns the tables used by this content type.
public
fetchTableName() : array<string|int, mixed>
Return values
array<string|int, mixed> —getAllCanView()
Returns the fields that all users can see if they don't have canviewthreads
public
getAllCanView() : mixed
Return values
mixed —array of strings
getAttachmentHeaders()
Get array of http headers for this attachment file extension
public
getAttachmentHeaders(string $extension) : array<string|int, string>
Parameters
- $extension : string
-
file extension, e.g. 'doc', 'gif', 'pdf', 'jpg'
Tags
Return values
array<string|int, string> —Array containing the 'content-type' http header string for $extension. If $extension is not found in attachmenttype table, the default 'Content-type: application/octet-stream' is returned in the array.
getAttachmentPermissions()
public
getAttachmentPermissions(mixed $data) : mixed
Parameters
- $data : mixed
Return values
mixed —getAttachmentsFromType()
Get attachments for a content type
public
getAttachmentsFromType(mixed $typeid) : mixed
@param INT nodeid
Parameters
- $typeid : mixed
Return values
mixed —getBareContent()
Returns the node content plus the channel routeid and title, and starter route and title the as an associative array Caller MUST ensure that $nodeids are of the correct content type.
public
getBareContent(mixed $nodeids) : mixed
Parameters
- $nodeids : mixed
Return values
mixed —getCanBeLastContent()
public
getCanBeLastContent() : mixed
Return values
mixed —getCanDelete()
Determines whether the current user can soft-delete or hard-delete
public
getCanDelete(mixed $node[, mixed $userContext = null ][, mixed $channelPerms = array() ][, mixed $hard = false ]) : bool
Parameters
- $node : mixed
- $userContext : mixed = null
- $channelPerms : mixed = array()
- $hard : mixed = false
Return values
bool —getCanEdit()
Determines whether the current user can edit a node
public
getCanEdit(mixed $node[, mixed $userContext = null ][, mixed $channelPerms = array() ]) : bool
Parameters
- $node : mixed
- $userContext : mixed = null
- $channelPerms : mixed = array()
Return values
bool —getCanModerate()
Determines whether the current user can moderate
public
getCanModerate(mixed $node[, mixed $userContext = null ][, mixed $channelPerms = array() ], mixed $nodeid) : bool
Parameters
- $node : mixed
- $userContext : mixed = null
- $channelPerms : mixed = array()
- $nodeid : mixed
Return values
bool —getCannotDelete()
Whether this type can be deleted. Infractions, for example, cannot be.
public
getCannotDelete() : bool
Return values
bool —getContent()
Returns the node content as an associative array
public
getContent(mixed $nodeids) : int
Parameters
- $nodeids : mixed
Return values
int —getContentApi()
Returns a content api of the appropriate type
public
static getContentApi(mixed $contenttypeid) : mixed
Parameters
- $contenttypeid : mixed
Return values
mixed —content api object
getContentInstance()
public
static getContentInstance(mixed $contenttypeid) : mixed
Parameters
- $contenttypeid : mixed
Return values
mixed —getContentLib()
Returns a content api of the appropriate type
public
static getContentLib(mixed $contenttypeid) : mixed
Parameters
- $contenttypeid : mixed
Return values
mixed —content api object
getConversationParent()
Gets the conversation starter for a node. If the node is a channel it returns the channel record.
public
getConversationParent(int $nodeid) : array<string|int, mixed>
Parameters
- $nodeid : int
Return values
array<string|int, mixed> —The starter node array
getFullContent()
Returns the node content plus the channel routeid and title, and starter route and title the as an associative array
public
getFullContent(mixed $nodeids) : array<string|int, mixed>
Parameters
- $nodeids : mixed
Return values
array<string|int, mixed> —Nodeid-keyed array of node content, including node.*, channel & starter id, title, route and other common data, and content-specific data. @see $this->getRawContent()
getIndexableContent()
The classes that inherit this should implement this function It should return the content that should be indexed If there is a title field, the array key for that field should be 'title', the rest of the text can have any key
public
getIndexableContent(int $nodeId[, mixed $include_attachments = true ]) : array<string|int, mixed>
Parameters
- $nodeId : int
-
- it might be the node (assiciative array)
- $include_attachments : mixed = true
Return values
array<string|int, mixed> —$indexableContent
getIndexableFromNode()
See base class for information
public
getIndexableFromNode(mixed $node[, mixed $include_attachments = true ]) : mixed
Parameters
- $node : mixed
- $include_attachments : mixed = true
Return values
mixed —getInlist()
Returns inlist property
public
getInlist() : int
Return values
int —getStarter()
Gets the conversation starter for a node. If the node is a channel it returns the channelid.
public
getStarter(int $nodeid) : int
Parameters
- $nodeid : int
Return values
int —The conversation starter's nodeid
getTextCountChange()
Returns textCountChange property
public
getTextCountChange() : int
Return values
int —incrementUserPostCount()
Increments the number of posts for a user. This function will also update user's "lastpost" field
public
incrementUserPostCount(array<string|int, mixed> $node) : mixed
When creating items, this is called from the content library, For all other state changes (approve, undelete, etc) it is called from the node library
Parameters
- $node : array<string|int, mixed>
Return values
mixed —instance()
Returns singleton instance of self.
public
static instance(mixed $class) : vB_PageCache
Parameters
- $class : mixed
Return values
vB_PageCache —- Reference to singleton instance of the cache handler
isComment()
Determines whether a specific node is a comment on a thread reply or not
public
isComment(mixed $nodeid[, array<string|int, mixed> $node = null ]) : bool
Parameters
- $nodeid : mixed
- $node : array<string|int, mixed> = null
Return values
bool —isPublished()
Is this record in a published state based on the times?
public
isPublished(mixed $data) : bool
Parameters
- $data : mixed
Return values
bool —isVisitorMessage()
determines whether a specific node is a visitor message
public
isVisitorMessage(mixed $nodeid) : bool
Parameters
- $nodeid : mixed
Return values
bool —mergeContentInfo()
public
mergeContentInfo(mixed &$result, mixed $content) : mixed
Parameters
- $result : mixed
- $content : mixed
Return values
mixed —monitorWords()
Checks if the text contains monitored words, and if so, sends notifications to admins and moderators if the setting is on.
public
monitorWords(mixed $text, mixed $type, mixed $nodeid[, mixed $userid = null ][, mixed $insertNotifications = true ], mixed $currentuserid) : mixed
Parameters
- $text : mixed
- $type : mixed
- $nodeid : mixed
- $userid : mixed = null
- $insertNotifications : mixed = true
- $currentuserid : mixed
Return values
mixed —reloadOptions()
Reload options from datastore. Currently only used by unit tests.
public
reloadOptions() : mixed
Return values
mixed —removeAttachment()
Remove an attachment
public
removeAttachment(mixed $id) : mixed
@param INT nodeid
Parameters
- $id : mixed
Return values
mixed —removePrivateDataFromNode()
Examines the node record returned from the node library and determines if any information needs to be removed before passing beyond the API layer.
public
removePrivateDataFromNode(array<string|int, mixed> &$node) : none
This is part of the library layer because its needed for a number of API classes that return node data in various forms.
Parameters
- $node : array<string|int, mixed>
-
the node array to be cleaned.
Return values
none —removeSignaturePicture()
public
removeSignaturePicture(mixed $userid) : mixed
Parameters
- $userid : mixed
Return values
mixed —resetCountCalled()
Reset the called array- this makes sure we only increment/decrement user post counts once for a given node This is only needed by the unit tests.
public
resetCountCalled() : mixed
Return values
mixed —saveThemeIcon()
public
saveThemeIcon(mixed $userid, mixed $filearray, mixed $fileContents, mixed $filesize, mixed $extension[, mixed $imageOnly = false ][, mixed $skipUploadPermissionCheck = false ]) : mixed
Parameters
- $userid : mixed
- $filearray : mixed
- $fileContents : mixed
- $filesize : mixed
- $extension : mixed
- $imageOnly : mixed = false
- $skipUploadPermissionCheck : mixed = false
Return values
mixed —setDoIncompleteNodeCleanup()
Sets the $doIncompleteNodeCleanup flag
public
setDoIncompleteNodeCleanup(mixed $value) : mixed
Parameters
- $value : mixed
Return values
mixed —update()
updates a record
public
update(mixed $nodeid, mixed $data) : mixed
Parameters
- $nodeid : mixed
- $data : mixed
-
information to update the content with
@return boolean
Return values
mixed —uploadAttachment()
Processes an uploaded file and saves it as an attachment
public
uploadAttachment(int $userid, array<string|int, mixed> $file[, bool $cheperms = true ][, bool $imageOnly = false ]) : array<string|int, mixed>
Parameters
- $userid : int
-
Userid of the user who is uploading the file
- $file : array<string|int, mixed>
-
Uploaded file data. The object or array should have the following properties or elements with data-types and names: string 'name' Filename int 'size' Filesize string 'type' Filetype string 'uploadfrom' Optional. Where the file was uploaded from. E.g. 'profile', 'sgicon', 'signature', 'newContent' or null int 'parentid' Optional. The nodeid/channelid this file should be saved under. Used for permission checks If it is an object, it should also have the following property: string 'contents' Contents of the file If it is an array, it should also have the following element: string 'tmp_name' Filepath to the temporary file created on the server
- $cheperms : bool = true
-
Optional, whether or not to check attachment permissions. Default true
- $imageOnly : bool = false
-
Optional, whether or not to only allow an image attachment. Default false
Tags
Return values
array<string|int, mixed> —Array of attachment data @see saveUpload()
uploadUrl()
Upload an image based on the url
public
uploadUrl(mixed $userid, mixed $url[, mixed $attachment = false ][, mixed $uploadfrom = '' ]) : mixed
@param int user ID
Parameters
- $userid : mixed
- $url : mixed
- $attachment : mixed = false
- $uploadfrom : mixed = ''
Return values
mixed —array of data, includes filesize, dateline, htmltype, filename, extension, and filedataid
validate()
Validates that the current can create a node with these values
public
validate(mixed $data[, mixed $action = self::ACTION_ADD ][, mixed $nodeid = false ][, mixed $nodes = false ][, mixed $userid = null ]) : bool
Parameters
- $data : mixed
-
Array of field => value pairs which define the record.
- $action : mixed = self::ACTION_ADD
-
The action const, used to be checked for permission
- $nodeid : mixed = false
- $nodes : mixed = false
-
-- $node records corresponding to the $nodeid variable. If not passed will be fetched from the DB
- $userid : mixed = null
Return values
bool —writeToCache()
writes new cached data for nodes
public
static writeToCache(mixed $nodes, mixed $level) : void
Note that this is affected by the 'cache_node_data' admin option. If that is not true then this function does nothing.
Parameters
- $nodes : mixed
- $level : mixed
Return values
void —zapAttachmentType()
Remove all attachments for content type
public
zapAttachmentType(mixed $typeid) : mixed
@param INT Content Type id
Parameters
- $typeid : mixed
Return values
mixed —__construct()
protected
__construct() : mixed
Return values
mixed —afterAdd()
Operations to be done after adding a node. Putting actions here allow child classes to minimize time keeping transaction open.
protected
afterAdd(int $nodeid, mixed $data, mixed $options, mixed $cacheEvents, mixed $nodevals) : mixed
Parameters
- $nodeid : int
- $data : mixed
-
Array of data being added
- $options : mixed
-
Array of options for the content being created- passed from add() Understands skipNotification(s), skipUpdateLastContent.
- $cacheEvents : mixed
-
Array of strings- cache events to be called
- $nodevals : mixed
-
Array of field => value pairs representing the node table field values passed to create the record. Currently most are not used but all are passed.
Return values
mixed —beforeCommit()
Called by the first child class just before the commit happens.
protected
beforeCommit(mixed $nodeid, mixed $data, mixed $options, mixed $cacheEvents, mixed $nodevals) : mixed
This is for logic that needs to be in the transaction, but relies on the child class having finished all of its processing (the flow is that content::add gets called first and then the child does it's thing, primary because the child needs the nodeid for the created node record).
Takes the same parameters as afterAdd
Parameters
- $nodeid : mixed
- $data : mixed
- $options : mixed
- $cacheEvents : mixed
- $nodevals : mixed
Return values
mixed —changeContentType()
protected
changeContentType(mixed $nodeid, mixed $oldcontentType, mixed $newcontentType) : mixed
Parameters
- $nodeid : mixed
- $oldcontentType : mixed
- $newcontentType : mixed
Return values
mixed —checkFloodAndThrowException()
protected
checkFloodAndThrowException(mixed $data) : mixed
Parameters
- $data : mixed
Return values
mixed —countInUserPostCount()
Checks if the current node should be counted in the user post count for the author.
protected
countInUserPostCount(array<string|int, mixed> $node[, mixed $action = '' ]) : bool
Parameters
- $node : array<string|int, mixed>
- $action : mixed = ''
Return values
bool —Whether or not the node should be counted in user post count.
duplicateCheck()
Checks accidental duplicate posting
protected
duplicateCheck(array<string|int, mixed> $data) : string|bool
Parameters
- $data : array<string|int, mixed>
Return values
string|bool —hash or false if check skipped
fetchAttachmentPath()
protected
fetchAttachmentPath(mixed $userid, mixed $attachmentid[, mixed $thumb = false ][, mixed $overridepath = '' ]) : mixed
Parameters
- $userid : mixed
- $attachmentid : mixed
- $thumb : mixed = false
- $overridepath : mixed = ''
Return values
mixed —fillContentTableData()
protected
fillContentTableData(mixed &$node) : mixed
Parameters
- $node : mixed
Return values
mixed —getDuplicateHash()
Calculates the CRC based on the indexable content
protected
getDuplicateHash(array<string|int, mixed> $data) : string
Parameters
- $data : array<string|int, mixed>
Return values
string —getIndexableContentForAttachments()
Get the indexable content for attachments. Separate this so that child classes can rewrite getIndexableContent entirely without having to copy as much code
protected
getIndexableContentForAttachments(mixed $nodeId) : mixed
Parameters
- $nodeId : mixed
Return values
mixed —getLibraryClassNameInternal()
protected
static getLibraryClassNameInternal(mixed $controller) : mixed
Parameters
- $controller : mixed
Return values
mixed —getNodeClean()
Checks to see if the node has all the required data.
protected
getNodeClean(mixed $node) : bool
Parameters
- $node : mixed
Return values
bool —getRawContent()
Prepares basic content. Used by both getBareContent and getFullContent.
protected
getRawContent(mixed $nodeids) : array<string|int, mixed>
Parameters
- $nodeids : mixed
Tags
Return values
array<string|int, mixed> —Nodeid-keyed array of node & content data, including node table data. Keys depend on the particular node's contenttype, but a few common ones include: node.*, channelroute, channeltitle, channelid, starterroute, startertitle, etc. See vBForum:getFullContent.
handleAttachments()
This function needs to be implemented by sub classes that want to handle attachments. See the text library implementation for the full description.
protected
handleAttachments(mixed $type, mixed $nodeid, mixed $data[, mixed $options = array() ]) : mixed
Parameters
- $type : mixed
- $nodeid : mixed
- $data : mixed
- $options : mixed = array()
Return values
mixed —incompleteNodeCleanup()
This cleans up for a node that was found to be incomplete by deleting the child nodes and subsidiary table records. It is often overridden in child classes.
protected
incompleteNodeCleanup(mixed $node) : bool
Parameters
- $node : mixed
Return values
bool —Whether the node has been cleaned up
needsFloodCheck()
protected
needsFloodCheck(mixed $data, mixed $options) : mixed
Parameters
- $data : mixed
- $options : mixed
Return values
mixed —resizeImage()
Attempts to resize an uploaded image so that it can be saved as an attachment.
protected
resizeImage(mixed $userid, mixed &$filearray, mixed &$fileContents, mixed &$filesize, mixed &$filewidth, mixed &$fileheight, mixed &$extension, array<string|int, mixed> $targets) : bool
If successful, it modifies $filearray, $fileContents, $filesize, $filewidth, $fileheight, $extension, and the temporary file as saved on disk, then returns true.
Parameters
- $userid : mixed
- $filearray : mixed
- $fileContents : mixed
- $filesize : mixed
- $filewidth : mixed
- $fileheight : mixed
- $extension : mixed
- $targets : array<string|int, mixed>
Return values
bool —Returns false if the image is not successfully resized, so the calling code can throw a size (dimensions or filesize) error
sendModeratorNotification()
Sends emails to moderators configured in admincp
protected
sendModeratorNotification(mixed $nodeid) : mixed
Parameters
- $nodeid : mixed
Return values
mixed —shouldChangeUserPostCountForChildNodes()
Checks whether or not we should adjust user post count for descendant nodes
protected
shouldChangeUserPostCountForChildNodes(mixed $node[, mixed $action = '' ]) : bool
Parameters
- $node : mixed
- $action : mixed = ''
Return values
bool —Whether or not the child nodes should be handled
updateNodeOptions()
Sets node options from individual fields.
protected
updateNodeOptions(mixed $nodeid, mixed $data) : mixed
@param int
Parameters
- $nodeid : mixed
- $data : mixed
Return values
mixed —verifyAttachmentPath()
protected
verifyAttachmentPath(mixed $userid) : mixed
Parameters
- $userid : mixed
Return values
mixed —verifyPostIconid()
Verifies that the post iconid is valid
protected
verifyPostIconid(mixed $posticonid) : mixed
Parameters
- $posticonid : mixed
Return values
mixed —verifyPrefixid()
protected
verifyPrefixid(mixed $prefixid) : mixed
Parameters
- $prefixid : mixed
Return values
mixed —checkAndFixImageExtension()
private
checkAndFixImageExtension(mixed &$extension, mixed &$filearray) : mixed
Parameters
- $extension : mixed
- $filearray : mixed
Return values
mixed —checkConfigImageResizeLimits()
private
checkConfigImageResizeLimits(mixed $filewidth, mixed $fileheight[, mixed $filesize = null ]) : mixed
Parameters
- $filewidth : mixed
- $fileheight : mixed
- $filesize : mixed = null
Return values
mixed —monitorWordsNode()
Handles monitoring words for node creation and updates
private
monitorWordsNode(mixed $nodeid, mixed $data[, mixed $insertNotifications = true ]) : mixed
Parameters
- $nodeid : mixed
- $data : mixed
- $insertNotifications : mixed = true
Return values
mixed —requiresModeration()
private
requiresModeration(mixed $userContext, mixed $parentContent, mixed $nodevals, mixed $hasAttachments) : mixed
Parameters
- $userContext : mixed
- $parentContent : mixed
- $nodevals : mixed
- $hasAttachments : mixed
Return values
mixed —saveUpload()
Saves an uploaded file into the filedata system.
private
saveUpload(int $userid, array<string|int, mixed> $filearray, string $fileContents, int $filesize, string $extension[, bool $imageOnly = false ][, bool $skipUploadPermissionCheck = false ]) : array<string|int, mixed>
Parameters
- $userid : int
-
Id of user uploading the image. This user's permissions will be checked when necessary
- $filearray : array<string|int, mixed>
-
Array of data describing the uploaded file with data-types & keys: string 'name' Filename int 'size' Filesize string 'type' Filetype string 'tmp_name' Filepath to the temporary file created on the server int 'parentid' Optional. Node/Channelid this file will be uploaded under. If provided permissions will be checked under this node. bool 'is_sigpic' Optional. If this is not empty, the saved filedata will replace the user's sigpicnew record (or inserted for the user if none exists), and the filedata record will have refcount incremented & publicview set to 1.
- $fileContents : string
-
String(?) containing file content BLOB
- $filesize : int
-
File size
- $extension : string
-
File extension
- $imageOnly : bool = false
-
If true, this function will throw an exception if the file is not an image
- $skipUploadPermissionCheck : bool = false
-
Optional boolean to skip permission checks. Only used internally when the system saves a theme icon. Do not use for normal calls to this function.
Tags
Return values
array<string|int, mixed> —Array of saved filedata info with data-types & keys: int 'filedataid' int 'filesize' int 'thumbsize' file size of the thumbnail of the saved filedata string 'extension' string 'filename' string[] 'headers' array containing the content-type http header of the saved filedata boolean 'isimage'
scanFileArray()
private
scanFileArray(mixed $file) : mixed
Parameters
- $file : mixed