Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / ponder / controller / PonderQuestionStatusController.php
blobab791b740fa0e9f1a781cce68d4d67986acb5ef9
1 <?php
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())
11 ->setViewer($viewer)
12 ->withIDs(array($id))
13 ->requireCapabilities(
14 array(
15 PhabricatorPolicyCapability::CAN_VIEW,
16 PhabricatorPolicyCapability::CAN_EDIT,
18 ->executeOne();
19 if (!$question) {
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');
29 $xactions = array();
30 $xactions[] = id(new PonderQuestionTransaction())
31 ->setTransactionType(PonderQuestionStatusTransaction::TRANSACTIONTYPE)
32 ->setNewValue($v_status);
34 $editor = id(new PonderQuestionEditor())
35 ->setActor($viewer)
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'))
45 ->setName('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())
54 ->setUser($viewer)
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);