class vB_Library_Content_Channel extends vB_Library_Content

vB_Library_Content_Channel

Traits

Constants

ACTION_ADD

ACTION_UPDATE

ACTION_VIEW

ACTION_DELETE

ACTION_APPROVE

ACTION_PUBLISH

CACHELEVEL_NODE

CACHELEVEL_CONTENT

CACHELEVEL_FULLCONTENT

Properties

static protected $instance from vB_Library
protected $contenttype
protected $contenttypeid from vB_Library_Content
protected $tablename
protected $index_fields from vB_Library_Content
protected $textCountChange from vB_Library_Content
protected $inheritViewPerms from vB_Library_Content
protected $inlist from vB_Library_Content
protected $showSignature from vB_Library_Content
protected $doFloodCheck from vB_Library_Content
protected $assertor from vB_Library_Content
protected $nodeApi from vB_Library_Content
protected $nodeLibrary from vB_Library_Content
static protected $cacheNodes Whether we are caching node content from vB_Library_Content
protected $channelTypeId from vB_Library_Content
protected $cannotDelete from vB_Library_Content
protected $qryAfterAdd from vB_Library_Content
protected $allCanview from vB_Library_Content
protected bool $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. from vB_Library_Content
static protected $defaultNodeOptions from vB_Library_Content
protected bool $doIncompleteNodeCleanup from vB_Library_Content

Methods

__sleep()

No description

__wakeup()

No description

__construct()

No description

static vB_PageCache
instance($class)

Returns singleton instance of self.

static 
getLibraryClassNameInternal($controller)

No description

static 
getContentInstance($contenttypeid)

No description

static 
clearCache()

No description

reloadOptions()

Reload options from datastore. Currently only used by unit tests.

fetchContentType()

No description

getAllCanView()

No description

fetchContentTypeId()

No description

int
getTextCountChange()

Returns textCountChange property

int
getInlist()

Returns inlist property

add(mixed $data, array $options = array('nodeonly' => false))

Adds a new channel.

beforeCommit($nodeid, $data, $options, $cacheEvents, $nodevals)

Called by the first child class just before the commit happens.

afterAdd(int $nodeid, mixed $data, mixed $options, mixed $cacheEvents, mixed $nodevals)

Operations to be done after adding a node. Putting actions here allow child classes to minimize time keeping transaction open.

sendModeratorNotification($nodeid)

Sends emails to moderators configured in admincp

needsFloodCheck($data, $options)

No description

checkFloodAndThrowException($data)

No description

string|boolean
duplicateCheck(array $data)

Checks accidental duplicate posting

updateNodeOptions($nodeid, $data)

Sets node options from individual fields.

incrementUserPostCount(array $node)

Increments the number of posts for a user. This function will also update user's "lastpost" field

decrementUserPostCount(array $node, (unpublish|unapprove) $action = '')

Decrements the number of posts for a user

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.

boolean
countInUserPostCount(array $node, (unpublish|unapprove) $action = '')

Checks if the current node should be counted in the user post count for the author.

boolean
shouldChangeUserPostCountForChildNodes(array $node, (unpublish|unapprove) $action = '')

Checks whether or not we should adjust user post count for descendant nodes

boolean
delete(integer $nodeid)

Permanently deletes a channel

deleteChildren(array $childrenIds)

Delete the records without updating the parent info. It is used when deleting a whole channel and it's children need to be removed

bool
isPublished(mixed $data)

Is this record in a published state based on the times?

update(int $nodeid, array $data)

updates a record

static mixed
getContentApi(int $contenttypeid)

Returns a content api of the appropriate type

static mixed
getContentLib(int $contenttypeid)

Returns a content api of the appropriate type

int
getContent($nodeids)

Returns the node content as an associative array

Array[Int]
getBareContent(integer $nodeids)

Returns the node content as an associative array. Like getFullContent but without the permissions data.

array
getFullContent($nodeids, array $permissions = false)

Returns the node content as an associative array

array
getRawContent($nodeids)

Prepares basic content. Used by both getBareContent and getFullContent.

bool
getCanEdit(int $node, int $userContext = null, mixed $channelPerms = array())

Determines whether the current user can edit a node

bool
getCanDelete(mixed $node, int $userContext = null, mixed $channelPerms = array(), bool $hard = false)

Determines whether the current user can soft-delete or hard-delete

bool
getCanModerate(mixed $node, object $userContext = null, mixed $channelPerms = array(), int $nodeid = 0)

Determines whether the current user can moderate

Array
assembleContent(Array $content, mixed $permissions = false)

Assembles the response for detailed content

getIndexableFromNode($content, $include_attachments = true)

No description

array
getIndexableContent($nodeId, $include_attachments = true)

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

int
getStarter(int $nodeid)

Gets the conversation starter for a node. If the node is a channel it returns the channelid.

array
getConversationParent(int $nodeid)

Gets the conversation starter for a node. If the node is a channel it returns the channel record.

bool
isVisitorMessage(int $nodeid)

determines whether a specific node is a visitor message

bool
isComment(int $nodeid, array $node = null)

Determines whether a specific node is a comment on a thread reply or not

getIndexableContentForAttachments($nodeId)

Get the indexable content for attachments. Separate this so that child classes can rewrite getIndexableContent entirely without having to copy as much code

Array
fetchTableName()

returns the tables used by this content type.

static array('found'
fetchFromCache(array|int $nodeids, integer $level)

This attempts to get the cached data for nodes

static void
writeToCache($nodes, $level)

writes new cached data for nodes

verifyPrefixid($prefixid)

No description

verifyPostIconid(int $posticonid)

Verifies that the post iconid is valid

changeContentType($nodeid, $oldcontentType, $newcontentType)

No description

string
getDuplicateHash(array $data)

Calculates the CRC based on the indexable content

fillContentTableData($node)

No description

none
removePrivateDataFromNode(array $node)

Examines the node record returned from the node library and determines if any information needs to be removed before passing beyond the API layer.

bool
checkComplete(array $node)

This function checks to see if a node is valid, and if not it deletes or fixes it.

boolean
getCannotDelete()

Whether this type can be deleted. Infractions, for example, cannot be.

bool
getNodeClean(integer $node)

Checks to see if the node has all the required data.

bool
incompleteNodeCleanup(mixed $node)

This function either deletes the channel if it has no children, or fixes it.

setDoIncompleteNodeCleanup(bool $value)

Sets the $doIncompleteNodeCleanup flag

handleAttachments($type, $nodeid, $data, $options = array())

This function needs to be implemented by sub classes that want to handle attachments. See the text library implementation for the full description.

mergeContentInfo($result, $content)

No description

bool
validate($data, $action = self::ACTION_ADD, $nodeid = false, $nodes = false, $userid = null)

Validates that the current can create a node with these values

buildChannelOptions($nodeid, $options)

No description

boolean
switchForumCategory(bool $makeCategory, int $nodeId, bool $force = false)

Toggles the channel between acting like a forum (can have threads in it) and acting like a category (can only have subchannels in it)

createChannelPages(int $nodeid, array $data)

Creates pagetemplate, pages and routes for a channel

deleteChannelPages(int $nodeId, bool $deleteAll = true)

Deletes pages and routes for a channel

getForumHomeChannel()

No description

getMainChannel()

No description

string
getUniqueUrlIdent(string $title)

This creates an urlident from a title, and guarantees it will not be a duplicate

array
fetchChannelByGUID(string $guid)

Returns a channel record based on its node guid

int
fetchChannelIdByGUID(string $guid)

Returns a channel id based on its node guid

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

in vB_Library_Content at line 128
protected __construct()

in vB_Library at line 35
static vB_PageCache instance($class)

Returns singleton instance of self.

Parameters

$class

Return Value

vB_PageCache
  • Reference to singleton instance of the cache handler

in vB_Library at line 52
static protected getLibraryClassNameInternal($controller)

Parameters

$controller

in vB_Library at line 91
static getContentInstance($contenttypeid)

Parameters

$contenttypeid

in vB_Library at line 99
static clearCache()

in vB_Library_Content at line 158
reloadOptions()

Reload options from datastore. Currently only used by unit tests.

in vB_Library_Content at line 163
fetchContentType()

in vB_Library_Content at line 172
getAllCanView()

in vB_Library_Content at line 177
fetchContentTypeId()

in vB_Library_Content at line 186
int getTextCountChange()

Returns textCountChange property

Return Value

int

in vB_Library_Content at line 195
int getInlist()

Returns inlist property

Return Value

int

at line 68
add(mixed $data, array $options = array('nodeonly' => false))

Adds a new channel.

Parameters

mixed $data 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 ??? 'viewperms' ??? ??? '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
array $options 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).

in vB_Library_Content at line 852
protected beforeCommit($nodeid, $data, $options, $cacheEvents, $nodevals)

Called by the first child class just before the commit happens.

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
$data
$options
$cacheEvents
$nodevals

in vB_Library_Content at line 877
protected afterAdd(int $nodeid, mixed $data, mixed $options, mixed $cacheEvents, mixed $nodevals)

Operations to be done after adding a node. Putting actions here allow child classes to minimize time keeping transaction open.

Parameters

int $nodeid
mixed $data Array of data being added
mixed $options Array of options for the content being created- passed from add() Understands skipNotification(s), skipUpdateLastContent.
mixed $cacheEvents Array of strings- cache events to be called
mixed $nodevals 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.

in vB_Library_Content at line 1132
protected sendModeratorNotification($nodeid)

Sends emails to moderators configured in admincp

Parameters

$nodeid

in vB_Library_Content at line 1322
protected needsFloodCheck($data, $options)

Parameters

$data
$options

in vB_Library_Content at line 1334
protected checkFloodAndThrowException($data)

Parameters

$data

in vB_Library_Content at line 1366
protected string|boolean duplicateCheck(array $data)

Checks accidental duplicate posting

Parameters

array $data

Return Value

string|boolean hash or false if check skipped

in vB_Library_Content at line 1399
protected updateNodeOptions($nodeid, $data)

Sets node options from individual fields.

@param int

Parameters

$nodeid
$data

in vB_Library_Content at line 1435
incrementUserPostCount(array $node)

Increments the number of posts for a user. This function will also update user's "lastpost" field

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

array $node Array of node information for the affected node

in vB_Library_Content at line 1492
decrementUserPostCount(array $node, (unpublish|unapprove) $action = '')

Decrements the number of posts for a user

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

array $node Array of node information for the affected node
(unpublish|unapprove) $action Pass one of these strings when decrementUserPostCount is called after unpublishing or unapproving a post

in vB_Library_Content at line 1541
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.

in vB_Library_Content at line 1554
protected boolean countInUserPostCount(array $node, (unpublish|unapprove) $action = '')

Checks if the current node should be counted in the user post count for the author.

Parameters

array $node The node
(unpublish|unapprove) $action The action that was just carried out on the node

Return Value

boolean Whether or not the node should be counted in user post count.

in vB_Library_Content at line 1605
protected boolean shouldChangeUserPostCountForChildNodes(array $node, (unpublish|unapprove) $action = '')

Checks whether or not we should adjust user post count for descendant nodes

Parameters

array $node The node
(unpublish|unapprove) $action The action that was just carried out on the node

Return Value

boolean Whether or not the child nodes should be handled

at line 293
boolean delete(integer $nodeid)

Permanently deletes a channel

Parameters

integer $nodeid The nodeid of the record to be deleted

Return Value

boolean

in vB_Library_Content at line 1805
deleteChildren(array $childrenIds)

Delete the records without updating the parent info. It is used when deleting a whole channel and it's children need to be removed

Parameters

array $childrenIds
  • list of node ids

in vB_Library_Content at line 1822
bool isPublished(mixed $data)

Is this record in a published state based on the times?

Parameters

mixed $data

Return Value

bool

at line 208
update(int $nodeid, array $data)

updates a record

Parameters

int $nodeid
array $data information to update the content with

@return boolean

in vB_Library_Content at line 2366
static mixed getContentApi(int $contenttypeid)

Returns a content api of the appropriate type

Parameters

int $contenttypeid the content type id

Return Value

mixed content api object

in vB_Library_Content at line 2377
static mixed getContentLib(int $contenttypeid)

Returns a content api of the appropriate type

Parameters

int $contenttypeid the content type id

Return Value

mixed content api object

in vB_Library_Content at line 2395
int getContent($nodeids)

Returns the node content as an associative array

Parameters

$nodeids

Return Value

int

at line 369
Array[Int] getBareContent(integer $nodeids)

Returns the node content as an associative array. Like getFullContent but without the permissions data.

Parameters

integer $nodeids The id in the primary table.

Return Value

Array[Int] Requested data, keyed by the nodeid.

at line 342
array getFullContent($nodeids, array $permissions = false)

Returns the node content as an associative array

Parameters

$nodeids
array $permissions of permissions request- (array group, permission)

Return Value

array Nodeid-keyed array of node content, including node.*, channel & starter id, title, route and other common data, and content-specific data. see $this->getRawContent()

in vB_Library_Content at line 2473
protected array getRawContent($nodeids)

Prepares basic content. Used by both getBareContent and getFullContent.

Parameters

$nodeids

Return Value

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

Exceptions

throw new vB_Exception_Api('incorrect_content_class_called') If any node in $nodeids is not of $this's contenttype.

in vB_Library_Content at line 2598
bool getCanEdit(int $node, int $userContext = null, mixed $channelPerms = array())

Determines whether the current user can edit a node

Parameters

int $node The nodeid
int $userContext optional usercontext
mixed $channelPerms optional array of channel permissions data, which if available prevents a userContext Call

Return Value

bool

in vB_Library_Content at line 2724
bool getCanDelete(mixed $node, int $userContext = null, mixed $channelPerms = array(), bool $hard = false)

Determines whether the current user can soft-delete or hard-delete

Parameters

mixed $node The node
int $userContext Optional usercontext
mixed $channelPerms Optional array of channel permissions data, which if available prevents a userContext Call
bool $hard Optional flag - false get can soft delete, true get can hard delete

Return Value

bool

in vB_Library_Content at line 2880
bool getCanModerate(mixed $node, object $userContext = null, mixed $channelPerms = array(), int $nodeid = 0)

Determines whether the current user can moderate

Parameters

mixed $node The node
object $userContext optional usercontext
mixed $channelPerms optional array of channel permissions data, which if available prevents a userContext Call
int $nodeid optional nodeid,

Return Value

bool

at line 958
Array assembleContent(Array $content, mixed $permissions = false)

Assembles the response for detailed content

Parameters

Array $content 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
mixed $permissions optional array of permissions

Return Value

Array 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

at line 396
getIndexableFromNode($content, $include_attachments = true)

Parameters

$content
$include_attachments

in vB_Library_Content at line 3540
array getIndexableContent($nodeId, $include_attachments = true)

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

Parameters

$nodeId
$include_attachments

Return Value

array $indexableContent

in vB_Library_Content at line 3586
int getStarter(int $nodeid)

Gets the conversation starter for a node. If the node is a channel it returns the channelid.

Parameters

int $nodeid

Return Value

int The conversation starter's nodeid

in vB_Library_Content at line 3619
array getConversationParent(int $nodeid)

Gets the conversation starter for a node. If the node is a channel it returns the channel record.

Parameters

int $nodeid

Return Value

array The starter node array

in vB_Library_Content at line 3640
bool isVisitorMessage(int $nodeid)

determines whether a specific node is a visitor message

Parameters

int $nodeid

Return Value

bool

in vB_Library_Content at line 3657
bool isComment(int $nodeid, array $node = null)

Determines whether a specific node is a comment on a thread reply or not

Parameters

int $nodeid Node ID
array $node Node information

Return Value

bool

in vB_Library_Content at line 3681
protected getIndexableContentForAttachments($nodeId)

Get the indexable content for attachments. Separate this so that child classes can rewrite getIndexableContent entirely without having to copy as much code

Parameters

$nodeId

in vB_Library_Content at line 3702
Array fetchTableName()

returns the tables used by this content type.

Return Value

Array

in vB_Library_Content at line 3719
static array('found' fetchFromCache(array|int $nodeids, integer $level)

This attempts to get the cached data for nodes

Parameters

array|int $nodeids
integer $level -- one of the constants for level of data

Return Value

array('found' => array of node values per the constant, 'notfound' => array of nodeids);

in vB_Library_Content at line 3796
static void writeToCache($nodes, $level)

writes new cached data for nodes

Note that this is affected by the 'cache_node_data' admin option. If that is not true then this function does nothing.

Parameters

$nodes
$level

Return Value

void

in vB_Library_Content at line 3816
protected verifyPrefixid($prefixid)

Parameters

$prefixid

in vB_Library_Content at line 3840
protected verifyPostIconid(int $posticonid)

Verifies that the post iconid is valid

Parameters

int $posticonid post icon ID

in vB_Library_Content at line 3854
protected changeContentType($nodeid, $oldcontentType, $newcontentType)

Parameters

$nodeid
$oldcontentType
$newcontentType

in vB_Library_Content at line 3894
protected string getDuplicateHash(array $data)

Calculates the CRC based on the indexable content

Parameters

array $data

Return Value

string

in vB_Library_Content at line 3930
protected fillContentTableData($node)

Parameters

$node

in vB_Library_Content at line 3953
none removePrivateDataFromNode(array $node)

Examines the node record returned from the node library and determines if any information needs to be removed before passing beyond the API layer.

This is part of the library layer because its needed for a number of API classes that return node data in various forms.

Parameters

array $node the node array to be cleaned.

Return Value

none

in vB_Library_Content at line 3974
bool checkComplete(array $node)

This function checks to see if a node is valid, and if not it deletes or fixes it.

Parameters

array $node -- node array

Return Value

bool

in vB_Library_Content at line 3996
boolean getCannotDelete()

Whether this type can be deleted. Infractions, for example, cannot be.

Return Value

boolean

in vB_Library_Content at line 4008
protected bool getNodeClean(integer $node)

Checks to see if the node has all the required data.

Parameters

integer $node the nodeid to be checked

Return Value

bool

at line 928
bool incompleteNodeCleanup(mixed $node)

This function either deletes the channel if it has no children, or fixes it.

Parameters

mixed $node Node record, which may have missing child table data.

Return Value

bool Whether the node has been cleaned up

in vB_Library_Content at line 4095
setDoIncompleteNodeCleanup(bool $value)

Sets the $doIncompleteNodeCleanup flag

Parameters

bool $value Flag value

in vB_Library_Content at line 4105
protected handleAttachments($type, $nodeid, $data, $options = array())

This function needs to be implemented by sub classes that want to handle attachments. See the text library implementation for the full description.

Parameters

$type
$nodeid
$data
$options

in vB_Library_Content at line 4108
mergeContentInfo($result, $content)

Parameters

$result
$content

in vB_Library_Content at line 4127
bool validate($data, $action = self::ACTION_ADD, $nodeid = false, $nodes = false, $userid = null)

Validates that the current can create a node with these values

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

Parameters

$data
$action
$nodeid
$nodes
$userid

Return Value

bool

at line 27
protected buildChannelOptions($nodeid, $options)

Parameters

$nodeid
$options

at line 416
boolean switchForumCategory(bool $makeCategory, int $nodeId, bool $force = false)

Toggles the channel between acting like a forum (can have threads in it) and acting like a category (can only have subchannels in it)

Parameters

bool $makeCategory
int $nodeId
bool $force
  • If true, it will force page recreation even if the category field matches

Return Value

boolean

Exceptions

vB_Exception_Api

at line 508
protected createChannelPages(int $nodeid, array $data)

Creates pagetemplate, pages and routes for a channel

Parameters

int $nodeid nodeid
array $data
  • Must contain the following fields:
    • templates
      • vB5_Route_Channel
      • vB5_Route_Conversation (optional)
    • parentid
    • title
    • page_parentid

at line 776
protected deleteChannelPages(int $nodeId, bool $deleteAll = true)

Deletes pages and routes for a channel

Parameters

int $nodeId
bool $deleteAll true to delete both channel and conversation pages/routes false to only delete the conversation page/route, and leave the channel page/route false is used when converting a channel to a category

at line 822
getForumHomeChannel()

at line 828
getMainChannel()

at line 840
string getUniqueUrlIdent(string $title)

This creates an urlident from a title, and guarantees it will not be a duplicate

Parameters

string $title the title

Return Value

string

at line 886
array fetchChannelByGUID(string $guid)

Returns a channel record based on its node guid

Parameters

string $guid GUID

Return Value

array Channel information

at line 917
int fetchChannelIdByGUID(string $guid)

Returns a channel id based on its node guid

Parameters

string $guid Channel GUID

Return Value

int Channel id