
Summary: Ref T3373. This is still pretty messy: - The JS bugs out a bit with multiple primary object PHIDs on a single page. I'll fix this in a followup. - The comment form itself is enormous, I'll restore some show/hide stuff in a followup. Test Plan: Added answer comments in Ponder. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3373 Differential Revision: https://secure.phabricator.com/D6608
51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
final class PonderQuestionStatusController
|
|
extends PonderController {
|
|
|
|
private $status;
|
|
private $id;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->status = idx($data, 'status');
|
|
$this->id = idx($data, 'id');
|
|
}
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
$viewer = $request->getUser();
|
|
|
|
$question = id(new PonderQuestionQuery())
|
|
->setViewer($viewer)
|
|
->withIDs(array($this->id))
|
|
->requireCapabilities(
|
|
array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
))
|
|
->executeOne();
|
|
if (!$question) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
// TODO: Use transactions.
|
|
|
|
switch ($this->status) {
|
|
case 'open':
|
|
$question->setStatus(PonderQuestionStatus::STATUS_OPEN);
|
|
break;
|
|
case 'close':
|
|
$question->setStatus(PonderQuestionStatus::STATUS_CLOSED);
|
|
break;
|
|
default:
|
|
return new Aphront400Response();
|
|
}
|
|
|
|
$question->save();
|
|
|
|
return id(new AphrontRedirectResponse())->setURI('/Q'.$question->getID());
|
|
}
|
|
|
|
}
|