vBulletin v5.7.2

vB_Library_Content extends vB_Library
in package

vB_Library_Content

Tags
access

public

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
__serialize()  : array<string|int, mixed>
__sleep()  : array<string|int, mixed>
__unserialize()  : void
__wakeup()  : void
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.
clearCache()  : mixed
decrementUserPostCount()  : mixed
Decrements the number of posts for a user
delete()  : bool
Permanently deletes a node
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
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
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.
removePrivateDataFromNode()  : void
Examines the node record returned from the node library and determines if any information needs to be removed before passing beyond the API layer.
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.
setDoIncompleteNodeCleanup()  : mixed
Sets the $doIncompleteNodeCleanup flag
update()  : mixed
updates a record
validate()  : bool
Validates that the current can create a node with these values
writeToCache()  : void
writes new cached data for nodes

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

Methods

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__sleep()

public __sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unserialize()

public __unserialize(array<string|int, mixed> $serialized) : void
Parameters
$serialized : array<string|int, mixed>
Return values
void

__wakeup()

public __wakeup() : void
Return values
void

add()

Adds a new node.

public add(mixed $data[, array<string|int, mixed> $options = array() ]) : mixed
Parameters
$data : mixed

Array of field => value pairs which define the record. Data-types & key names: int 'parentid' Nodeid of the parent, i.e. node this attachment is being added under. int 'userid' Optional. Userid of the user who is adding this record. If not provided, it will use the current session's user. string 'authorname' Optional. Name of the user who is adding this record. If not provided, it will use the username of userid above. string 'ipaddress' Optional. IP of request. Will be fetched from current request if skipped. ??? 'protected' ??? int 'starter' ??? int 'routeid' ??? ??? 'prefixid' ??? ??? 'iconid' ??? int 'created' Optional. Unix timestamp of creation date. If skipped it will use the value returned by vB::getRequest()->getTimeNow() (TIMENOW). int 'publishdate' Optional. Unix timestampe of publish date. If skipped, it will use TIMENOW. If 'publish_now' is provided, publishdate will be overwritten by TIMENOW mixed 'publish_now' Optional. If not empty, publishdate will be overwritten by TIMENOW int 'viewperms' Optional, default 2. Who can view this group. 0 = subscribed only, 1 = subscribed & registered users, 2 = everyone. ??? 'featured' Optional. ???(purpose/description)??? Will only be used if the CURRENT USER has the moderatorpermissions.cansetfeatured channel permission. string 'title' ??? string 'htmltitle' ??? string 'urlident' ??? int 'setfor' Only used by visitor messages. Userid of intended visitor message recipient. ??? ??? ??? Can also contain node fields. @see vB_Library_Node::getNodeFields() or the node table structure for these fields

$options : array<string|int, mixed> = array()

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

Tags
todo

finish documenting this function

throws

vB_Exception_Api('need_parent_node') If required $data['parentid'] is empty.

throws

vB_Exception_Api('invalid_request') If parent is closed and CURRENT USER lacks the moderatorpermissions.canmoderateposts channel permission.

throws

vB_Exception_Api('invalid_request') If parent is a category channel and this is not a channel

throws

vB_Exception_Api('cannot_reply_to_redirect') If parent is a "Redirect" content type

throws

vB_Exception_Api('invalid_route_contact_vbulletin_support') If there is no parent routenew record for the ('vB5_Route_Conversation', 'vB5_Route_Article') classes.

throws

vB_Exception_Api('postfloodcheck') If CURRENT USER is not an administrator and the user failed the flood check.

throws

vB_Exception_Api('invalid_data') If not enough data was provided to add anything to the node table.

throws

vB_Exception_Api('invalid_data') If this is a visitor message and $data['setfor'] was invalid

throws

vB_Exception_Api('invalid_data') If adding a record to the node tabled failed

access

public

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

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

Permanently deletes a node

public delete(array<string|int, mixed>|int $nodeids) : bool
Parameters
$nodeids : array<string|int, mixed>|int
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

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

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

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) : void

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
void

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

setDoIncompleteNodeCleanup()

Sets the $doIncompleteNodeCleanup flag

public setDoIncompleteNodeCleanup(mixed $value) : mixed
Parameters
$value : mixed
Return values
mixed

update()

updates a record

public update(int $nodeid, array<string|int, mixed> $data) : mixed
Parameters
$nodeid : int
$data : array<string|int, mixed>

information to update the content with

@return boolean

Return values
mixed

validate()

Validates that the current can create a node with these values

public validate(array<string|int, mixed> $data[, int $action = self::ACTION_ADD ][, int $nodeid = false ][, array<string|int, mixed> $nodes = false ][, mixed $userid = null ]) : bool

Note that if an array is passed it returns true only if all nodes pass the constraint.

Parameters
$data : array<string|int, mixed>

Array of field => value pairs which define the record.

$action : int = self::ACTION_ADD

The action const, used to be checked for permission

$nodeid : int = false
$nodes : array<string|int, 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

Search results