Allow unregistered users to see ended poll results

This commit is contained in:
celestora 2022-10-11 21:26:08 +03:00
parent 6345a62744
commit efbb6a74e7

View file

@ -28,16 +28,21 @@ final class PollPresenter extends OpenVKPresenter
$this->template->until = $poll->endsAt();
$this->template->votes = $poll->getVoterCount();
$this->template->meta = $poll->getMetaDescription();
if(is_null($this->user) || $poll->canVote($this->user->identity)) {
$this->template->ended = $ended = $poll->hasEnded();
if((is_null($this->user) || $poll->canVote($this->user->identity)) && !$ended) {
$this->template->options = $poll->getOptions();
$this->template->_template = "Poll/Poll.xml";
return;
}
if(is_null($this->user)) {
$this->template->voted = false;
$this->template->results = $poll->getResults();
} else {
$this->template->voted = $poll->hasVoted($this->user->identity);
$this->template->ended = $poll->hasEnded();
$this->template->results = $poll->getResults($this->user->identity);
}
$this->template->_template = "Poll/PollResults.xml";
}