3 final class PonderQuestionStatusController
4 extends PonderController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
10 $question = id(new PonderQuestionQuery())
13 ->requireCapabilities(
15 PhabricatorPolicyCapability
::CAN_VIEW
,
16 PhabricatorPolicyCapability
::CAN_EDIT
,
20 return new Aphront404Response();
23 $view_uri = '/Q'.$question->getID();
24 $v_status = $question->getStatus();
26 if ($request->isFormPost()) {
27 $v_status = $request->getStr('status');
30 $xactions[] = id(new PonderQuestionTransaction())
31 ->setTransactionType(PonderQuestionStatusTransaction
::TRANSACTIONTYPE
)
32 ->setNewValue($v_status);
34 $editor = id(new PonderQuestionEditor())
36 ->setContentSourceFromRequest($request);
38 $editor->applyTransactions($question, $xactions);
40 return id(new AphrontRedirectResponse())->setURI($view_uri);
43 $radio = id(new AphrontFormRadioButtonControl())
44 ->setLabel(pht('Status'))
46 ->setValue($v_status);
48 foreach (PonderQuestionStatus
::getQuestionStatusMap() as $value => $name) {
49 $description = PonderQuestionStatus
::getQuestionStatusDescription($value);
50 $radio->addButton($value, $name, $description);
53 $form = id(new AphrontFormView())
55 ->appendChild($radio);
57 return $this->newDialog()
58 ->setTitle(pht('Change Question Status'))
59 ->appendChild($form->buildLayoutView())
60 ->addSubmitButton(pht('Submit'))
61 ->addCancelButton($view_uri);