1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 08:12:40 +01:00
phorge-phorge/src/applications/ponder/controller/PonderQuestionStatusController.php
Gareth Evans 70a5ec600d Allowing Closing of questions
Summary:
Fixes T3579

As a basic overview, this enables the author of a question to open/close a question.

Other bits;

- Add "Open" filter to the builtin queries
- Add "Status" to search form
- Refactor ponder constants
- Add coloured bars for different question statuses

Test Plan:
- Open/Close questions
- Search for some bits
- Use filters

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T3579

Differential Revision: https://secure.phabricator.com/D6590

Conflicts:
	src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
2013-07-27 18:41:03 -07:00

40 lines
886 B
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();
$user = $request->getUser();
$question = id(new PonderQuestion())->load($this->id);
if (!$question) {
return new Aphront404Response();
}
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());
}
}