2013-07-29 02:40:11 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PonderAnswerCommentController extends PonderController {
|
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = $data['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$viewer = $request->getUser();
|
|
|
|
|
|
|
|
if (!$request->isFormPost()) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$answer = id(new PonderAnswerQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($this->id))
|
|
|
|
->executeOne();
|
|
|
|
if (!$answer) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$is_preview = $request->isPreviewRequest();
|
|
|
|
// $draft = PhabricatorDraft::buildFromRequest($request);
|
|
|
|
|
|
|
|
$qid = $answer->getQuestion()->getID();
|
|
|
|
$aid = $answer->getID();
|
Transactions - deploy buildTransactionTimeline to remaining applications
Summary:
Ref T4712. Specifically...
- Differential
- needed getApplicationTransactionViewObject() implemented
- Audit
- needed getApplicationTransactionViewObject() implemented
- Repository
- one object needed PhabricatorApplicationTransactionInterface implemented
- setShouldTerminate(true)
- Ponder
- BONUS BUG FIX - leaving a comment on an answer had a bad redirect URI
- both PonderQuestion and PonderAnswer needed PhabricatorApplicationTransactionInterface implemented
- setShouldTerminate(true) on both "history" controllers
- left a "TODO" on buildAnswers on the question view controller, which is non-standard and should be re-written eventually
- Phortune
- BONUS BUG FIX - fix new user "createNewAccount" code to not fatal
- PhortuneAccount, PhortuneMerchant, and PhortuneCart needed PhabricatorApplicationTransactionInterface implemented
- setShouldTerminate(true) on Account view, merchant view, and cart view controller
- Fund
- Legalpad
- Nuance
- NuanceSource needed PhabricatorApplicationTransactionInterface implemented
- Releeph (this product is kind of a mess...)
- HACKQUEST - had to manually create an arcanist project to even be able to make a "product" and get started...!
- BONUS BUG FIX - make sure to "setName" on product edit
- ReleephProject (should be ReleepProduct...?), ReleephBranch, and ReleepRequest needed PhabricatorApplicationTransactionInterface implemented
- Harbormaster
- HarbormasterBuildable, HarbormasterBuild, HarbormasterBuildPlan, and HarbormasterBuildStep all needed PhabricatorApplicationTransactionInterface implemented
- setShouldTerminate(true) all over the place
Test Plan: foreach application, viewed the timeline(s) and made sure they still rendered
Reviewers: epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T4712
Differential Revision: https://secure.phabricator.com/D10925
2014-12-04 00:35:47 +01:00
|
|
|
$view_uri = "/Q{$qid}#A{$aid}";
|
2013-07-29 02:40:11 +02:00
|
|
|
|
|
|
|
$xactions = array();
|
|
|
|
$xactions[] = id(new PonderAnswerTransaction())
|
|
|
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
|
|
|
->attachComment(
|
|
|
|
id(new PonderAnswerTransactionComment())
|
|
|
|
->setContent($request->getStr('comment')));
|
|
|
|
|
|
|
|
$editor = id(new PonderAnswerEditor())
|
|
|
|
->setActor($viewer)
|
|
|
|
->setContinueOnNoEffect($request->isContinueRequest())
|
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->setIsPreview($is_preview);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$xactions = $editor->applyTransactions($answer, $xactions);
|
|
|
|
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
|
|
|
|
return id(new PhabricatorApplicationTransactionNoEffectResponse())
|
|
|
|
->setCancelURI($view_uri)
|
|
|
|
->setException($ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
// if ($draft) {
|
|
|
|
// $draft->replaceOrDelete();
|
|
|
|
// }
|
|
|
|
|
2014-06-21 21:50:40 +02:00
|
|
|
if ($request->isAjax() && $is_preview) {
|
2013-07-29 02:40:11 +02:00
|
|
|
return id(new PhabricatorApplicationTransactionResponse())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->setTransactions($xactions)
|
2014-09-16 21:12:35 +02:00
|
|
|
->setIsPreview($is_preview);
|
2013-07-29 02:40:11 +02:00
|
|
|
} else {
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI($view_uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|