* @property-read integer|null $objectUserID id of the user who created the liked object or null if user has been deleted or object was created by guest
* @property-read integer $likes number of likes of the liked object
* @property-read integer $dislikes number of dislikes of the liked object
+ * @property-read integer $neutralReactions number of neutral reactions on the liked object
* @property-read integer $cumulativeLikes cumulative result of likes (counting +1) and dislikes (counting -1)
* @property-read string $cachedUsers serialized array with the ids and names of the three users who liked (+1) the object last
* @property-read string $cachedReactions serialized array with the reactionTypeIDs and the count of the reactions
if ($likeObject->likeObjectID) {
$likes = $likeObject->likes;
$dislikes = $likeObject->dislikes;
+ $neutralReactions = $likeObject->neutralReactions;
$cumulativeLikes = $likeObject->cumulativeLikes;
if ($likeObject->cachedReactions !== null) {
$dislikes--;
$cumulativeLikes++;
}
+ else {
+ $neutralReactions--;
+ }
if (isset($cachedReactions[$like->getReactionType()->reactionTypeID])) {
if (--$cachedReactions[$like->getReactionType()->reactionTypeID] == 0) {
$dislikes++;
$cumulativeLikes--;
}
+ else {
+ $neutralReactions++;
+ }
if (isset($cachedReactions[$reactionType->reactionTypeID])) {
$cachedReactions[$reactionType->reactionTypeID]++;
$updateData = [
'likes' => $likes,
'dislikes' => $dislikes,
+ 'neutralReactions' => $neutralReactions,
'cumulativeLikes' => $cumulativeLikes,
'cachedReactions' => serialize($cachedReactions)
];
'objectUserID' => $likeable->getUserID() ?: null,
'likes' => ($reactionType->isPositive()) ? 1 : 0,
'dislikes' => ($reactionType->isNegative()) ? 1 : 0,
+ 'neutralReactions' => ($reactionType->isNeutral()) ? 1 : 0,
'cumulativeLikes' => $cumulativeLikes,
'cachedReactions' => serialize($cachedReactions)
]);
$likeObjectData[$like->objectTypeID][$like->objectID] = [
'likes' => 0,
'dislikes' => 0,
+ 'neutralReactions' => 0,
'cumulativeLikes' => 0,
'objectUserID' => $like->objectUserID,
'cachedReactions' => []
];
}
- if ($like->likeValue == Like::LIKE) {
+ if ($like->isLike()) {
$likeObjectData[$like->objectTypeID][$like->objectID]['likes']++;
}
- else {
+ else if ($like->isDislike()) {
$likeObjectData[$like->objectTypeID][$like->objectID]['dislikes']++;
}
+ else {
+ $likeObjectData[$like->objectTypeID][$like->objectID]['neutralReactions']++;
+ }
$likeObjectData[$like->objectTypeID][$like->objectID]['cumulativeLikes'] += $like->likeValue;
if (!isset($likeObjectData[$like->objectTypeID][$like->objectID]['cachedReactions'][$like->getReactionType()->reactionTypeID])) {
UserActivityPointHandler::getInstance()->fireEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $itemsToUser, false);
$sql = "INSERT INTO wcf".WCF_N."_like_object
- (objectTypeID, objectID, objectUserID, likes, dislikes, cumulativeLikes, cachedReactions)
- VALUES (?, ?, ?, ?, ?, ?, ?)
+ (objectTypeID, objectID, objectUserID, likes, dislikes, neutralReactions, cumulativeLikes, cachedReactions)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE likes = likes + VALUES(likes),
dislikes = dislikes + VALUES(dislikes),
+ neutralReactions = neutralReactions + VALUES(neutralReactions),
cumulativeLikes = cumulativeLikes + VALUES(cumulativeLikes),
cachedReactions = VALUES(cachedReactions)";
$statement = WCF::getDB()->prepareStatement($sql);
$data['objectUserID'],
$data['likes'],
$data['dislikes'],
+ $data['neutralReactions'],
$data['cumulativeLikes'],
serialize($data['cachedReactions'])
]);