Changeset View
Changeset View
Standalone View
Standalone View
src/applications/slowvote/view/SlowvoteEmbedView.php
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | public function render() { | ||||
$header = array( | $header = array( | ||||
$header, | $header, | ||||
$description, | $description, | ||||
); | ); | ||||
$vis = $poll->getResponseVisibility(); | $vis = $poll->getResponseVisibility(); | ||||
if ($this->areResultsVisible()) { | if ($this->areResultsVisible()) { | ||||
if ($vis == PhabricatorSlowvotePoll::RESPONSES_OWNER) { | if ($vis == SlowvotePollResponseVisibility::RESPONSES_OWNER) { | ||||
$quip = pht('Only you can see the results.'); | $quip = pht('Only you can see the results.'); | ||||
} else { | } else { | ||||
$quip = pht('Voting improves cardiovascular endurance.'); | $quip = pht('Voting improves cardiovascular endurance.'); | ||||
} | } | ||||
} else if ($vis == PhabricatorSlowvotePoll::RESPONSES_VOTERS) { | } else if ($vis == SlowvotePollResponseVisibility::RESPONSES_VOTERS) { | ||||
$quip = pht('You must vote to see the results.'); | $quip = pht('You must vote to see the results.'); | ||||
} else if ($vis == PhabricatorSlowvotePoll::RESPONSES_OWNER) { | } else if ($vis == SlowvotePollResponseVisibility::RESPONSES_OWNER) { | ||||
$quip = pht('Only the author can see the results.'); | $quip = pht('Only the author can see the results.'); | ||||
} | } | ||||
$hint = phutil_tag( | $hint = phutil_tag( | ||||
'span', | 'span', | ||||
array( | array( | ||||
'class' => 'slowvote-hint', | 'class' => 'slowvote-hint', | ||||
), | ), | ||||
▲ Show 20 Lines • Show All 220 Lines • ▼ Show 20 Lines | return phutil_tag( | ||||
'class' => 'slowvote-status', | 'class' => 'slowvote-status', | ||||
), | ), | ||||
$status); | $status); | ||||
} | } | ||||
private function areResultsVisible() { | private function areResultsVisible() { | ||||
$poll = $this->getPoll(); | $poll = $this->getPoll(); | ||||
$vis = $poll->getResponseVisibility(); | $visibility = $poll->getResponseVisibility(); | ||||
if ($vis == PhabricatorSlowvotePoll::RESPONSES_VISIBLE) { | if ($visibility == SlowvotePollResponseVisibility::RESPONSES_VISIBLE) { | ||||
return true; | return true; | ||||
} else if ($vis == PhabricatorSlowvotePoll::RESPONSES_OWNER) { | |||||
return ($poll->getAuthorPHID() == $this->getUser()->getPHID()); | |||||
} else { | |||||
$choices = mgroup($poll->getChoices(), 'getAuthorPHID'); | |||||
return (bool)idx($choices, $this->getUser()->getPHID()); | |||||
} | } | ||||
$viewer = $this->getViewer(); | |||||
if ($visibility == SlowvotePollResponseVisibility::RESPONSES_OWNER) { | |||||
return ($poll->getAuthorPHID() === $viewer->getPHID()); | |||||
} | |||||
$choices = mgroup($poll->getChoices(), 'getAuthorPHID'); | |||||
return (bool)idx($choices, $viewer->getPHID()); | |||||
} | } | ||||
} | } |