public function checkForumTopicVote($user, $topic)
{
$prefix = 'forum.topic.vote.';
if ($topic->pollEnd() !== null && $topic->pollEnd()->isPast()) {
return $prefix . 'over';
}
$this->ensureLoggedIn($user, $prefix . 'user.');
$this->ensureCleanRecord($user, $prefix . 'user.');
if (!$this->doCheckUser($user, 'ForumView', $topic->forum)->can()) {
return $prefix . 'no_forum_access';
}
if (!$topic->poll_vote_change) {
$userHasVoted = $topic->pollVotes()->where('vote_user_id', $user->getKey())->exists();
if ($userHasVoted) {
return $prefix . 'voted';
}
}
return 'ok';
}