2012-08-10 19:44:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PonderAnswerPreviewController
|
|
|
|
extends PonderController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
2013-07-29 00:38:47 +02:00
|
|
|
$viewer = $request->getUser();
|
2012-08-10 19:44:04 +02:00
|
|
|
$question_id = $request->getInt('question_id');
|
|
|
|
|
2013-07-29 00:38:47 +02:00
|
|
|
$question = id(new PonderQuestionQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($question_id))
|
|
|
|
->executeOne();
|
2012-08-10 19:44:04 +02:00
|
|
|
if (!$question) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2013-07-29 00:38:47 +02:00
|
|
|
$author_phid = $viewer->getPHID();
|
2012-08-10 19:44:04 +02:00
|
|
|
$object_phids = array($author_phid);
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($object_phids);
|
2012-08-10 19:44:04 +02:00
|
|
|
|
|
|
|
$answer = new PonderAnswer();
|
|
|
|
$answer->setContent($request->getStr('content'));
|
|
|
|
$answer->setAuthorPHID($author_phid);
|
|
|
|
|
adding comments to ponder
Summary: This is pretty spartan, but it does the job.
Test Plan:
Patch, update storage, add some comment
to your favorite question or answer.
Reviewers: nh, vrana, epriestley
Reviewed By: epriestley
CC: aran, Korvin, starruler, syrneus, me.here, victorzarate7
Maniphest Tasks: T1645
Differential Revision: https://secure.phabricator.com/D3471
2012-09-11 21:13:20 +02:00
|
|
|
$view = new PonderPostBodyView();
|
2012-08-10 19:44:04 +02:00
|
|
|
$view
|
|
|
|
->setQuestion($question)
|
|
|
|
->setTarget($answer)
|
|
|
|
->setPreview(true)
|
2013-07-29 00:38:47 +02:00
|
|
|
->setUser($viewer)
|
2012-08-10 19:44:04 +02:00
|
|
|
->setHandles($handles)
|
2013-07-28 03:37:17 +02:00
|
|
|
->setAction(PonderLiterals::LITERAL_ANSWERED);
|
2012-08-10 19:44:04 +02:00
|
|
|
|
|
|
|
return id(new AphrontAjaxResponse())
|
|
|
|
->setContent($view->render());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|