/**
  * @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;
 }
Exemple #2
0
 /**
  * Initializes the available user privileges
  */
 protected function getPrivileges()
 {
     if ($this->privileges === []) {
         $this->privileges = $this->getRules($this->getUserRoleIds($this->user->getUserId()));
     }
     return $this->privileges;
 }
Exemple #3
0
 /**
  * @param array $formData
  * @param int $pollId
  * @param string $ipAddress
  * @param string $time
  * @return bool|int
  * @throws Core\Validation\Exceptions\ValidationRuleNotFoundException
  */
 public function vote(array $formData, $pollId, $ipAddress, $time)
 {
     $answers = $formData['answer'];
     $bool = false;
     $userId = $this->userModel->isAuthenticated() ? $this->userModel->getUserId() : null;
     // Multiple Answers
     if (is_array($answers) === false) {
         $answers = [$answers];
     }
     foreach ($answers as $answer) {
         if ($this->validator->is(IntegerValidationRule::class, $answer) === true) {
             $insertValues = ['poll_id' => $pollId, 'answer_id' => $answer, 'user_id' => $userId, 'ip' => $ipAddress, 'time' => $time];
             $bool = $this->voteRepository->insert($insertValues);
         }
     }
     return $bool;
 }
 private function setSessionValues()
 {
     $this->sessionHandler->set(self::AUTH_NAME, ['id' => $this->userModel->getUserId(), 'super_user' => $this->userModel->isSuperUser(), 'language' => $this->userModel->getLanguage()]);
 }