vB_Library_Content_Infraction
extends vB_Library_Content_Text
in package
vB_Library_Content_Infraction
Tags
Table of Contents
Constants
- 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
Methods
- __serialize() : array<string|int, mixed>
- __sleep() : array<string|int, mixed>
- __unserialize() : void
- __wakeup() : void
- add() : array<string|int, mixed>
- Adds a new infraction node
- assembleContent() : mixed
- Assembles the response for detailed content
- autoPopulatePreviewImage() : mixed
- DEPRECATED: This needs to remain until the corresponding API function is removed
- buildInfractionGroupIds() : mixed
- Builds infraction groups for users. Also called from the cron script
- canInfractNode() : bool
- Determines if the logged-in user can infract the (author of) the given node
- canInfractUser() : bool
- Determines if the logged-in user can infract the given user
- canViewNodeInfraction() : bool
- Determines if the logged-in user can view any infractions on the given node
- checkComplete() : bool
- This function checks to see if a node is valid, and if not it deletes or fixes it.
- clearCache() : mixed
- clearInfractionGroupCache() : mixed
- cloneArrayRecords() : void
- decrementUserPostCount() : mixed
- Decrements the number of posts for a user
- delete() : void
- Deletes an infraction. Currently the only UI for this is in the Admin CP
- 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
- fetchInfractionGroups() : array<string|int, mixed>
- Get the infraction group information for a user.
- 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
- getAutomaticBanList() : array<string|int, mixed>
- Returns a list of automatic bans or an empty array if there are none.
- getAutoparseLinks() : mixed
- Get the actual auto parse links values based on the request and context
- 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() : vB_Api_Content
- 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 as an associative array with fullcontent
- 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
- getInfraction() : array<string|int, mixed>|false
- Returns an infraction node based on its nodeid
- getInfractionGroups() : array<string|int, mixed>
- gets the infraction groups
- getInfractionLevels() : array<string|int, mixed>
- Returns an array of information for the infraction levels that are currently set up
- getInfractionsByType() : mixed
- returns a certain type of infractions
- getInlist() : int
- Returns inlist property
- getNodeDescription() : mixed
- getNodeInfraction() : array<string|int, mixed>|false
- Returns the infraction node for the given node (if it has an infraction)
- getParticipants() : array<string|int, mixed>
- Returns the displaynames of users that participated in an infraction conversation.
- getQuotes() : array<string|int, mixed>|string
- This returns a string with quoted strings in bbcode format.
- getQuotesFromNodes() : mixed
- Helper function to allow getQuotes in the API and Library classes to generate the node list independantly (so that the API can check perms without loading the nodes twice).
- getStarter() : int
- Gets the conversation starter for a node. If the node is a channel it returns the channelid.
- getTextCountChange() : int
- Returns textCountChange property
- getUserInfractions() : array<string|int, mixed>|false
- Returns the infraction nodes for infractions that the given user has received.
- incrementUserPostCount() : mixed
- Increments the number of posts for a user. This function will also update user's "lastpost" field
- instance() : static
- Returns singleton instance of self.
- isPublished() : bool
- Is this record in a published state based on the times?
- isVisitorMessage() : bool
- determines whether a specific node is a visitor message
- mergeContent() : type
- Performs the merge of content and updates the node.
- mergeContentInfo() : mixed
- Adds content info to $result so that merged content can be edited.
- monitorWords() : mixed
- Checks if the text contains monitored words, and if so, sends notifications to admins and moderators if the setting is on.
- parseAndStrip() : mixed
- postBbcodeParseCleanRawtext() : mixed
- Cleans the input in the $data array, specifically *after* any html/wysiwyg -> bbcode parsing.
- 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.
- reverseInfraction() : mixed
- Reverse an infraction
- setDoIncompleteNodeCleanup() : mixed
- Sets the $doIncompleteNodeCleanup flag
- update() : void
- Cannot update an infraction (you can only reverse them)
- 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>
__wakeup()
public
__wakeup() : void
add()
Adds a new infraction node
public
add(array<string|int, mixed> $data[, array<string|int, mixed> $options = [] ][, mixed $convertWysiwygTextToBbcode = true ]) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
-
-- Array of field => value pairs which define the record.
- $options : array<string|int, mixed> = []
-
-- Array of options for the content being created -- skipTransaction, --skipFloodCheck, -- floodchecktime, -- skipDupCheck, -- skipNotification, -- nl2br: if TRUE, all \n will be converted to
so that it's not removed by the html parser (e.g. comments). -- autoparselinks. - $convertWysiwygTextToBbcode : mixed = true
Return values
array<string|int, mixed> —-- nodeid (int), -- success (bool), -- cacheEvents (array of strings), -- nodeVals (array of field => value), -- attachments (array of attachment records).
assembleContent()
Assembles the response for detailed content
public
assembleContent(mixed &$content[, mixed $permissions = false ]) : mixed
Parameters
- $content : 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
- $permissions : mixed = false
Return values
mixed —formatted data
autoPopulatePreviewImage()
DEPRECATED: This needs to remain until the corresponding API function is removed
public
autoPopulatePreviewImage(mixed $nodeId[, array<string|int, mixed> $node = null ]) : mixed
Superceded by getPreviewImage
Populates the previewimage field for this node. To be called after the node is saved and the attachments added.
Finds the first image in the post text that can be used as a previewimage (uploaded here), or uses the first image attachment.
Parameters
- $nodeId : mixed
- $node : array<string|int, mixed> = null
-
(optional) Node content array returned by getFullContent
buildInfractionGroupIds()
Builds infraction groups for users. Also called from the cron script
public
buildInfractionGroupIds(array<string|int, mixed> $userids) : mixed
Parameters
- $userids : array<string|int, mixed>
canInfractNode()
Determines if the logged-in user can infract the (author of) the given node
public
canInfractNode(mixed $nodeid[, array<string|int, mixed>|null $node = null ]) : bool
Parameters
- $nodeid : mixed
- $node : array<string|int, mixed>|null = null
Return values
bool —The node (user) can be infracted by current user (or not)
canInfractUser()
Determines if the logged-in user can infract the given user
public
canInfractUser(mixed $userid) : bool
Parameters
- $userid : mixed
Return values
bool —The user can be infracted by current user (or not)
canViewNodeInfraction()
Determines if the logged-in user can view any infractions on the given node
public
canViewNodeInfraction(mixed $nodeid[, array<string|int, mixed>|null $node = null ]) : bool
Parameters
- $nodeid : mixed
- $node : array<string|int, mixed>|null = null
Return values
bool —The current user can view any infractions on this node (or not)
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
boolclearCache()
public
static clearCache() : mixed
clearInfractionGroupCache()
public
clearInfractionGroupCache() : mixed
cloneArrayRecords()
public
cloneArrayRecords(int $oldnodeid, int $newnodeid) : void
Parameters
- $oldnodeid : int
- $newnodeid : int
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 = ''
delete()
Deletes an infraction. Currently the only UI for this is in the Admin CP
public
delete(mixed $nodeid) : void
Parameters
- $nodeid : mixed
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
fetchContentType()
public
fetchContentType() : mixed
fetchContentTypeId()
public
fetchContentTypeId() : 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
Tags
fetchInfractionGroups()
Get the infraction group information for a user.
public
fetchInfractionGroups(mixed $ipoints, mixed $usergroupid) : array<string|int, mixed>
Parameters
- $ipoints : mixed
- $usergroupid : mixed
Return values
array<string|int, mixed> —User's final infraction groups
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
getAutomaticBanList()
Returns a list of automatic bans or an empty array if there are none.
public
getAutomaticBanList() : array<string|int, mixed>
Return values
array<string|int, mixed> —Array of automatic bans
getAutoparseLinks()
Get the actual auto parse links values based on the request and context
public
getAutoparseLinks(mixed $parents, mixed $autoparselinks) : mixed
For the moment we assume that we us autoparse if
- It is requested by the caller AND
- It is allowed by channel context
There is currently no "force" auto parse. Currently the channel option is not hierarchical, we'll check the containing channel at the lowest level and allow autoparse if that channel allows it regardless of if the parents allow it or not (currently we only have an on/off flag and would need on/off/default to handle hierachy in a reasonable way since we might want to allow it for a child while prohibiting it at the parent level or vice versa.
Parameters
- $parents : mixed
-
-- the parents array the first element should be either the node itself (for updates) or the node's parent (for adds). It will work either way.
- $autoparselinks : mixed
-
-- the requested autoparse value
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 —Requested data, keyed by the nodeid.
getCanBeLastContent()
public
getCanBeLastContent() : mixed
getCanDelete()
Determines whether the current user can soft-delete or hard-delete
public
getCanDelete(mixed $node[, mixed $userContext = null ][, mixed $channelPerms = [] ][, mixed $hard = false ]) : bool
Parameters
- $node : mixed
- $userContext : mixed = null
- $channelPerms : mixed = []
- $hard : mixed = false
Return values
boolgetCanEdit()
Determines whether the current user can edit a node
public
getCanEdit(mixed $node[, mixed $userContext = null ][, mixed $channelPerms = [] ]) : bool
Parameters
- $node : mixed
- $userContext : mixed = null
- $channelPerms : mixed = []
Return values
boolgetCanModerate()
Determines whether the current user can moderate
public
getCanModerate(mixed $node[, mixed $userContext = null ][, mixed $channelPerms = [] ][, mixed $nodeid = 0 ]) : bool
Parameters
- $node : mixed
- $userContext : mixed = null
- $channelPerms : mixed = []
- $nodeid : mixed = 0
Return values
boolgetCannotDelete()
Whether this type can be deleted. Infractions, for example, cannot be.
public
getCannotDelete() : bool
Return values
boolgetContent()
Returns the node content as an associative array
public
getContent(mixed $nodeids) : int
Parameters
- $nodeids : mixed
Return values
intgetContentApi()
Returns a content api of the appropriate type
public
static getContentApi(mixed $contenttypeid) : vB_Api_Content
Parameters
- $contenttypeid : mixed
Return values
vB_Api_Content —content api object
getContentInstance()
public
static getContentInstance(mixed $contenttypeid) : mixed
Parameters
- $contenttypeid : 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 as an associative array with fullcontent
public
getFullContent(int|array<string|int, mixed> $nodes) : array<string|int, mixed>
Parameters
- $nodes : int|array<string|int, mixed>
-
-- node id(s) to get content for
Return values
array<string|int, mixed>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 $content[, mixed $include_attachments = true ]) : mixed
Parameters
- $content : mixed
- $include_attachments : mixed = true
getInfraction()
Returns an infraction node based on its nodeid
public
getInfraction(mixed $nodeid) : array<string|int, mixed>|false
Parameters
- $nodeid : mixed
Return values
array<string|int, mixed>|false —Array of infraction info, or false
getInfractionGroups()
gets the infraction groups
public
getInfractionGroups() : array<string|int, mixed>
Return values
array<string|int, mixed> —infraction groups with infractiongroupid as key >
getInfractionLevels()
Returns an array of information for the infraction levels that are currently set up
public
getInfractionLevels() : array<string|int, mixed>
Return values
array<string|int, mixed> —Infraction levels
getInfractionsByType()
returns a certain type of infractions
public
getInfractionsByType([string $type = '' ][, bool $replied_by_me = false ]) : mixed
Parameters
- $type : string = ''
- $replied_by_me : bool = false
-
- if true, only infractions that the user commented on type = 'user' => infractions given to a user type = 'post' => infractions given to a post by a user
getInlist()
Returns inlist property
public
getInlist() : int
Return values
intgetNodeDescription()
public
getNodeDescription(mixed $data, mixed $convertWysiwygTextToBbcode) : mixed
Parameters
- $data : mixed
- $convertWysiwygTextToBbcode : mixed
getNodeInfraction()
Returns the infraction node for the given node (if it has an infraction)
public
getNodeInfraction(mixed $nodeid) : array<string|int, mixed>|false
Parameters
- $nodeid : mixed
Return values
array<string|int, mixed>|false —Array of infraction info, or false if there is no infraction
getParticipants()
Returns the displaynames of users that participated in an infraction conversation.
public
getParticipants(mixed $nodeids) : array<string|int, mixed>
Parameters
- $nodeids : mixed
Return values
array<string|int, mixed> —displaynames first level key is the nodeid, second level key is the userid
getQuotes()
This returns a string with quoted strings in bbcode format.
public
getQuotes(array<string|int, mixed>|int $nodeids) : array<string|int, mixed>|string
Parameters
- $nodeids : array<string|int, mixed>|int
Return values
array<string|int, mixed>|string —either the quote for the node or an array of $nodeid => $quotes for the array of nodes
getQuotesFromNodes()
Helper function to allow getQuotes in the API and Library classes to generate the node list independantly (so that the API can check perms without loading the nodes twice).
public
getQuotesFromNodes(array<string|int, mixed> $nodes) : mixed
Parameters
- $nodes : array<string|int, mixed>
-
-- array of nodes arrays from getContent (API or Library version) does not accept a single node array
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
intgetUserInfractions()
Returns the infraction nodes for infractions that the given user has received.
public
getUserInfractions(mixed $userid[, mixed $offset = 0 ][, mixed $limit = 20 ]) : array<string|int, mixed>|false
Parameters
- $userid : mixed
- $offset : mixed = 0
- $limit : mixed = 20
Return values
array<string|int, mixed>|false —Array of infraction info, or false if there are no infractions
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>
instance()
Returns singleton instance of self.
public
static instance(mixed $class) : static
Parameters
- $class : mixed
Return values
static —- Reference to singleton instance of the requested library class
isPublished()
Is this record in a published state based on the times?
public
isPublished(mixed $data) : bool
Parameters
- $data : mixed
Return values
boolisVisitorMessage()
determines whether a specific node is a visitor message
public
isVisitorMessage(mixed $nodeid) : bool
Parameters
- $nodeid : mixed
Return values
boolmergeContent()
Performs the merge of content and updates the node.
public
mergeContent(type $data) : type
Parameters
- $data : type
Return values
typemergeContentInfo()
Adds content info to $result so that merged content can be edited.
public
mergeContentInfo(array<string|int, mixed> &$result, array<string|int, mixed> $content) : mixed
Parameters
- $result : array<string|int, mixed>
- $content : array<string|int, 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 = 0 ]) : mixed
use the functions from the notification library directly.
Parameters
- $text : mixed
- $type : mixed
- $nodeid : mixed
- $userid : mixed = null
- $insertNotifications : mixed = true
- $currentuserid : mixed = 0
parseAndStrip()
public
parseAndStrip(mixed $text[, mixed $wysiwyg = true ]) : mixed
Parameters
- $text : mixed
- $wysiwyg : mixed = true
postBbcodeParseCleanRawtext()
Cleans the input in the $data array, specifically *after* any html/wysiwyg -> bbcode parsing.
public
postBbcodeParseCleanRawtext(array<string|int, mixed> &$data) : mixed
Parameters
- $data : array<string|int, mixed>
-
Array of fieldname => data pairs, passed by reference.
reloadOptions()
Reload options from datastore. Currently only used by unit tests.
public
reloadOptions() : 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.
reverseInfraction()
Reverse an infraction
public
reverseInfraction(mixed $nodeid, mixed $reason) : mixed
Parameters
- $nodeid : mixed
- $reason : mixed
setDoIncompleteNodeCleanup()
Sets the $doIncompleteNodeCleanup flag
public
setDoIncompleteNodeCleanup(mixed $value) : mixed
Parameters
- $value : mixed
update()
Cannot update an infraction (you can only reverse them)
public
update(mixed $nodeid, mixed $data[, mixed $convertWysiwygTextToBbcode = true ]) : void
Parameters
- $nodeid : mixed
- $data : mixed
- $convertWysiwygTextToBbcode : mixed = true
Tags
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
boolwriteToCache()
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