Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
91 lines (77 sloc) 2.53 KB
final class PonderAddAnswerView extends AphrontView {
private $question;
private $actionURI;
private $draft;
public function setQuestion($question) {
$this->question = $question;
return $this;
public function setActionURI($uri) {
$this->actionURI = $uri;
return $this;
public function render() {
$question = $this->question;
$viewer = $this->getViewer();
$authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
if (isset($authors[$viewer->getPHID()])) {
$view = id(new PHUIInfoView())
->setTitle(pht('Already Answered'))
'You have already answered this question. You can not answer '.
'twice, but you can edit your existing answer.'));
return phutil_tag_div('ponder-add-answer-view', $view);
$info_panel = null;
if ($question->getStatus() != PonderQuestionStatus::STATUS_OPEN) {
$info_panel = id(new PHUIInfoView())
'This question has been marked as closed,
but you can still leave a new answer.'));
$box_style = null;
$header = id(new PHUIHeaderView())
->setHeader(pht('New Answer'))
$form = new AphrontFormView();
->addHiddenInput('question_id', $question->getID())
id(new PhabricatorRemarkupControl())
id(new AphrontFormSubmitControl())
->setValue(pht('Add Answer')));
if (!$viewer->isLoggedIn()) {
$login_href = id(new PhutilURI('/auth/start/'))
->replaceQueryParam('next', '/Q'.$question->getID());
$form = id(new PHUIFormLayoutView())
id(new PHUIButtonView())
->setText(pht('Log In to Answer'))
$box = id(new PHUIObjectBoxView())
if ($info_panel) {
return array($header, $box);
You can’t perform that action at this time.