record_vote($type, $id, $value)) { // Handle type-specific actions if ($type == 'comment') { if ($user) { $commentslib = TikiLib::lib('comments'); $commentslib->vote_comment($id, $user, $value); } } $tikilib = TikiLib::lib('tiki'); if ($type == 'comment') { $forum_id = $commentslib->get_comment_forum_id($id); $forum_info = $commentslib->get_forum($forum_id); $thread_info = $commentslib->get_comment($id, null, $forum_info); $item_user = $thread_info['userName']; } elseif ($type == 'article') { $artlib = TikiLib::lib('art'); $res = $artlib->get_article($id); $item_user = $res['author']; } if ($value == '1') { TikiLib::events()->trigger( 'tiki.social.rating.add', [ 'type' => $type, 'object' => $id, 'author' => $item_user, 'user' => $user, ] ); } elseif ($value == '2') { TikiLib::events()->trigger( 'tiki.social.rating.remove', [ 'type' => $type, 'object' => $id, 'author' => $item_user, 'user' => $user, ] ); } } elseif ($value != $prev) { return tra('An error occurred.'); } } $vote = $ratinglib->get_vote($type, $id); $options = $ratinglib->get_options($type, $id, false, $hasLabels); if ($prefs['rating_smileys'] == 'y') { $smiles = $ratinglib->get_options_smiles($type, $id); $smarty->assign('rating_smiles', $smiles); } $smarty->assign('rating_type', $type); $smarty->assign('rating_id', $id); $smarty->assign('rating_options', $options); $smarty->assign('current_rating', $vote); $smarty->assign('rating_has_labels', $hasLabels); return $smarty->fetch('rating.tpl'); }