vB_Library_Reactions
extends vB_Library
in package
vB_Library
Table of Contents
Constants
- EMOJI_ENABLED_LEGACY_DS_KEY = 'vb_emoji_enabled'
- REACTIONS_ALL_BY_LABEL_DS_KEY = 'vb_reactions_bylabel'
- REACTIONS_ALL_ORDERED_DS_KEY = 'vb_reactions_byorder'
- REACTIONS_ENABLEDONLY_DS_KEY = 'vb_reactions_enabled'
- THUMBS_UP_LABEL = 'thumbs up'
- VOTE_GROUP = 'reactions.emojis'
Methods
- __serialize() : array<string|int, mixed>
- __sleep() : array<string|int, mixed>
- __unserialize() : void
- __wakeup() : void
- addReaction() : int
- clearCache() : mixed
- fetchEnabledReactionsListByOrder() : array<string|int, mixed>
- Return nodevotetype data and emoji html for enabled topic reactions
- fetchOnlyEnabledReactionsVotetypeid() : array<string|int, int>
- Fetch votetypeids for only the enabled reactions.
- getContentInstance() : mixed
- getEmojisEnabledStatus() : array<string|int, mixed>
- getNotifiableTypes() : array<string|int, mixed>
- Return sparse list of votetypeids that should generate a "vB_Notification_LikedNode" notification.
- getReactionsEmojisData() : array<string|int, mixed>
- Return reactions nodevote & emojis data. Array is keyed by $type.
- getReactionsNodevotetypes() : array<string|int, mixed>
- Return nodevotetype data for topic reactions
- getReputableTypesAndFactors() : array<string|int, mixed>
- Get the votetypeid => reputation_factor array
- getThumbsUp() : array<string|int, mixed>
- The thumbs up emoji is special, because it uniquely maps to the "Like" system from vB5.
- getUserRepCountableTypes() : array<string|int, mixed>
- Return list of votetypeids that should count towards totalreactions counts, e.g.
- instance() : static
- Returns singleton instance of self.
- loadSourceEmojisData() : array<string|int, mixed>
- monitorWords() : mixed
- Checks if the text contains monitored words, and if so, sends notifications to admins and moderators if the setting is on.
- purgeReactionCaches() : mixed
- saveReactionOptions() : void
- Save reaction options (enabled, reputable, countable).
Constants
EMOJI_ENABLED_LEGACY_DS_KEY
public
mixed
EMOJI_ENABLED_LEGACY_DS_KEY
= 'vb_emoji_enabled'
REACTIONS_ALL_BY_LABEL_DS_KEY
public
mixed
REACTIONS_ALL_BY_LABEL_DS_KEY
= 'vb_reactions_bylabel'
REACTIONS_ALL_ORDERED_DS_KEY
public
mixed
REACTIONS_ALL_ORDERED_DS_KEY
= 'vb_reactions_byorder'
REACTIONS_ENABLEDONLY_DS_KEY
public
mixed
REACTIONS_ENABLEDONLY_DS_KEY
= 'vb_reactions_enabled'
THUMBS_UP_LABEL
public
mixed
THUMBS_UP_LABEL
= 'thumbs up'
VOTE_GROUP
public
mixed
VOTE_GROUP
= 'reactions.emojis'
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
addReaction()
public
addReaction(string $label[, array<string|int, mixed> $options = [] ]) : int
Parameters
- $label : string
- $options : array<string|int, mixed> = []
Return values
intclearCache()
public
static clearCache() : mixed
fetchEnabledReactionsListByOrder()
Return nodevotetype data and emoji html for enabled topic reactions
public
fetchEnabledReactionsListByOrder() : array<string|int, mixed>
Return values
array<string|int, mixed> —each element is a subarray [ 'votetypeid' => int e.g. 12345 'label' => string e.g. "grinning face" 'emojihtml' => string e.g. and also 'votegroupid' => int e.g. 123 ]
fetchOnlyEnabledReactionsVotetypeid()
Fetch votetypeids for only the enabled reactions.
public
fetchOnlyEnabledReactionsVotetypeid() : array<string|int, int>
Return values
array<string|int, int> —votetypeids
getContentInstance()
public
static getContentInstance(mixed $contenttypeid) : mixed
Parameters
- $contenttypeid : mixed
getEmojisEnabledStatus()
public
getEmojisEnabledStatus() : array<string|int, mixed>
Return values
array<string|int, mixed>getNotifiableTypes()
Return sparse list of votetypeids that should generate a "vB_Notification_LikedNode" notification.
public
getNotifiableTypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —[ int {votetypeid} => {votetypeid}, ... ]
getReactionsEmojisData()
Return reactions nodevote & emojis data. Array is keyed by $type.
public
getReactionsEmojisData([string $type = 'ordered' ]) : array<string|int, mixed>
This function is different from loadSourceEmojisData() in that this only returns the subset of emojis that are actually inserted as nodevotetypes. If you want the emoji data for the full range provided by the source file, use loadSOurceEmojisData() instead.
Parameters
- $type : string = 'ordered'
-
'ordered'|'labeled'
Return values
array<string|int, mixed>getReactionsNodevotetypes()
Return nodevotetype data for topic reactions
public
getReactionsNodevotetypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —key {label} => value array [ 'votetypeid' => int e.g. 12345 'label' => string e.g. "grinning face" 'votegroupid' => int e.g. 123 ]
getReputableTypesAndFactors()
Get the votetypeid => reputation_factor array
public
getReputableTypesAndFactors() : array<string|int, mixed>
Return values
array<string|int, mixed> —[ int {votetypeid} => float {factor}, ... ]
getThumbsUp()
The thumbs up emoji is special, because it uniquely maps to the "Like" system from vB5.
public
getThumbsUp() : array<string|int, mixed>
So there are occassions when we will have to fetch it.
Return values
array<string|int, mixed> —[ 'order' => (int), 'label' => (string) 'thumbs up', 'emojihtml' => (string) '👍', 'votetypeid' => (int), 'votegroupid' => (int), ]
getUserRepCountableTypes()
Return list of votetypeids that should count towards totalreactions counts, e.g.
public
getUserRepCountableTypes() : array<string|int, mixed>
user
.totallikes
.
Note that node
.votes
counts ALL votetypes, not just these.
Return values
array<string|int, mixed> —[ int {votetypeid} => float {factor}, ... ]
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
loadSourceEmojisData()
public
loadSourceEmojisData([mixed $versionCutoff = '12' ]) : array<string|int, mixed>
Parameters
- $versionCutoff : mixed = '12'
Return values
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
Parameters
- $text : mixed
- $type : mixed
- $nodeid : mixed
- $userid : mixed = null
- $insertNotifications : mixed = true
- $currentuserid : mixed = 0
Tags
purgeReactionCaches()
public
purgeReactionCaches() : mixed
saveReactionOptions()
Save reaction options (enabled, reputable, countable).
public
saveReactionOptions(array<string|int, mixed> $delta) : void
Used internally by admincp/managereactions.php, & install script
Parameters
- $delta : array<string|int, mixed>
-
array of options, each element may contain int 'votetypeid' Required int 'enabled' 0|1 int 'user_rep_factor' 0|1 int 'user_like_countable' 0|1 string 'emojihtml' Relevant HTML reprsenting this reaction int 'system' 1 for system defaults. 0 for custom string 'guid' usually the emoji label int 'order' Display order