/** * @param int $pollId * @return int */ protected function hasAlreadyVoted($pollId) { // Check, whether the logged user has already voted if ($this->user->isAuthenticated() === true) { $votes = $this->voteRepository->getVotesByUserId($pollId, $this->user->getUserId(), $this->request->getSymfonyRequest()->getClientIp()); } else { // For guest users check against the ip address $votes = $this->voteRepository->getVotesByIpAddress($pollId, $this->request->getSymfonyRequest()->getClientIp()); } return $votes > 0; }
/** * @param int $pollId * @param string $ipAddress * @return mixed */ protected function getVotes($pollId, $ipAddress) { // Check, whether the logged user has already voted if ($this->userModel->isAuthenticated() === true) { $votes = $this->voteRepository->getVotesByUserId($pollId, $this->userModel->getUserId(), $ipAddress); } else { // For guest users check against the ip address $votes = $this->voteRepository->getVotesByIpAddress($pollId, $ipAddress); } return $votes; }