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
This commit is contained in:
@@ -29,7 +29,7 @@ final class PonderAnswerPreviewController
|
||||
->setPreview(true)
|
||||
->setUser($user)
|
||||
->setHandles($handles)
|
||||
->setAction(PonderConstants::ANSWERED_LITERAL);
|
||||
->setAction(PonderLiterals::LITERAL_ANSWERED);
|
||||
|
||||
return id(new AphrontAjaxResponse())
|
||||
->setContent($view->render());
|
||||
|
||||
@@ -17,6 +17,7 @@ final class PonderQuestionAskController extends PonderController {
|
||||
if ($request->isFormPost()) {
|
||||
$question->setTitle($request->getStr('title'));
|
||||
$question->setContent($request->getStr('content'));
|
||||
$question->setStatus(PonderQuestionStatus::STATUS_OPEN);
|
||||
|
||||
$len = phutil_utf8_strlen($question->getTitle());
|
||||
if ($len < 1) {
|
||||
|
||||
@@ -45,6 +45,9 @@ final class PonderQuestionListController extends PonderController
|
||||
$item->setHeader($question->getTitle());
|
||||
$item->setHref('/Q'.$question->getID());
|
||||
$item->setObject($question);
|
||||
$item->setBarColor(
|
||||
PonderQuestionStatus::getQuestionStatusTagColor(
|
||||
$question->getStatus()));
|
||||
|
||||
$created_date = phabricator_date($question->getDateCreated(), $viewer);
|
||||
$item->addIcon('none', $created_date);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -92,10 +92,34 @@ final class PonderQuestionViewController extends PonderController {
|
||||
|
||||
private function buildActionListView(PonderQuestion $question) {
|
||||
$request = $this->getRequest();
|
||||
return id(new PhabricatorActionListView())
|
||||
->setUser($request->getUser())
|
||||
$user = $request->getUser();
|
||||
|
||||
$action_list = id(new PhabricatorActionListView())
|
||||
->setUser($user)
|
||||
->setObject($question)
|
||||
->setObjectURI($request->getRequestURI());
|
||||
|
||||
if ($user->getPhid() === $question->getAuthorPhid()) {
|
||||
if ($question->getStatus() == PonderQuestionStatus::STATUS_OPEN) {
|
||||
$name = pht("Close Question");
|
||||
$icon = "delete";
|
||||
$href = "close";
|
||||
} else {
|
||||
$name = pht("Open Question");
|
||||
$icon = "enable";
|
||||
$href = "open";
|
||||
}
|
||||
$action_list->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName($name)
|
||||
->setIcon($icon)
|
||||
->setRenderAsForm(true)
|
||||
->setHref(
|
||||
$this->getApplicationURI(
|
||||
"/question/{$href}/{$this->questionID}/")));
|
||||
}
|
||||
|
||||
return $action_list;
|
||||
}
|
||||
|
||||
private function buildPropertyListView(
|
||||
@@ -105,6 +129,11 @@ final class PonderQuestionViewController extends PonderController {
|
||||
$view = id(new PhabricatorPropertyListView())
|
||||
->setUser($viewer)
|
||||
->setObject($question);
|
||||
|
||||
$view->addProperty(
|
||||
pht('Status'),
|
||||
PonderQuestionStatus::getQuestionStatusFullName($question->getStatus()));
|
||||
|
||||
$view->addProperty(
|
||||
pht('Author'),
|
||||
$this->getHandle($question->getAuthorPHID())->renderLink());
|
||||
|
||||
Reference in New Issue
Block a user