2013-07-28 03:37:17 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PonderQuestionStatusController
|
|
|
|
extends PonderController {
|
|
|
|
|
2015-07-22 22:23:11 +02:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $request->getViewer();
|
|
|
|
$id = $request->getURIData('id');
|
2013-07-29 02:40:11 +02:00
|
|
|
|
|
|
|
$question = id(new PonderQuestionQuery())
|
|
|
|
->setViewer($viewer)
|
2015-07-22 22:23:11 +02:00
|
|
|
->withIDs(array($id))
|
2013-07-29 02:40:11 +02:00
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
|
|
|
->executeOne();
|
2013-07-28 03:37:17 +02:00
|
|
|
if (!$question) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2015-08-08 19:23:33 +02:00
|
|
|
$view_uri = '/Q'.$question->getID();
|
|
|
|
$v_status = $question->getStatus();
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$v_status = $request->getStr('status');
|
|
|
|
|
|
|
|
$xactions = array();
|
|
|
|
$xactions[] = id(new PonderQuestionTransaction())
|
2017-05-01 20:16:38 +02:00
|
|
|
->setTransactionType(PonderQuestionStatusTransaction::TRANSACTIONTYPE)
|
2015-08-08 19:23:33 +02:00
|
|
|
->setNewValue($v_status);
|
|
|
|
|
|
|
|
$editor = id(new PonderQuestionEditor())
|
|
|
|
->setActor($viewer)
|
|
|
|
->setContentSourceFromRequest($request);
|
|
|
|
|
|
|
|
$editor->applyTransactions($question, $xactions);
|
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($view_uri);
|
2013-07-28 03:37:17 +02:00
|
|
|
}
|
|
|
|
|
2015-08-08 19:23:33 +02:00
|
|
|
$radio = id(new AphrontFormRadioButtonControl())
|
|
|
|
->setLabel(pht('Status'))
|
|
|
|
->setName('status')
|
|
|
|
->setValue($v_status);
|
|
|
|
|
|
|
|
foreach (PonderQuestionStatus::getQuestionStatusMap() as $value => $name) {
|
|
|
|
$description = PonderQuestionStatus::getQuestionStatusDescription($value);
|
|
|
|
$radio->addButton($value, $name, $description);
|
|
|
|
}
|
2013-07-29 02:52:35 +02:00
|
|
|
|
2015-08-08 19:23:33 +02:00
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->appendChild($radio);
|
2013-07-29 02:52:35 +02:00
|
|
|
|
2015-08-08 19:23:33 +02:00
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle(pht('Change Question Status'))
|
|
|
|
->appendChild($form->buildLayoutView())
|
|
|
|
->addSubmitButton(pht('Submit'))
|
|
|
|
->addCancelButton($view_uri);
|
2013-07-28 03:37:17 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|