From 96e7f766ff03e9db5b3fab47ddb4ba053b65f2bd Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sat, 29 Aug 2015 11:18:22 -0700 Subject: [PATCH] Nudge users to close their question if it's been answered Summary: Adds a notice reminding viewers of their own question to resolve it and mark the correct answer. Test Plan: View my own open question, see notice. Resolve question, notice goes away. {F743481} Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D13958 --- .../PonderQuestionViewController.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/applications/ponder/controller/PonderQuestionViewController.php b/src/applications/ponder/controller/PonderQuestionViewController.php index fde0f067a3..3a4256c394 100644 --- a/src/applications/ponder/controller/PonderQuestionViewController.php +++ b/src/applications/ponder/controller/PonderQuestionViewController.php @@ -20,7 +20,7 @@ final class PonderQuestionViewController extends PonderController { return new Aphront404Response(); } - $answers = $this->buildAnswers($question->getAnswers()); + $answers = $this->buildAnswers($question); $answer_add_panel = id(new PonderAddAnswerView()) ->setQuestion($question) @@ -81,6 +81,20 @@ final class PonderQuestionViewController extends PonderController { ->addPropertyList($properties) ->appendChild($footer); + if ($viewer->getPHID() == $question->getAuthorPHID()) { + $status = $question->getStatus(); + $answers_list = $question->getAnswers(); + if ($answers_list && ($status == PonderQuestionStatus::STATUS_OPEN)) { + $info_view = id(new PHUIInfoView()) + ->setSeverity(PHUIInfoView::SEVERITY_WARNING) + ->appendChild( + pht( + 'If this question has been resolved, please consider closing + the question and marking the answer as helpful.')); + $object_box->setInfoView($info_view); + } + } + $crumbs = $this->buildApplicationCrumbs($this->buildSideNavView()); $crumbs->addTextCrumb('Q'.$id, '/Q'.$id); @@ -206,8 +220,9 @@ final class PonderQuestionViewController extends PonderController { * TODO - re-factor this to ajax in one answer panel at a time in a more * standard fashion. This is necessary to scale this application. */ - private function buildAnswers(array $answers) { + private function buildAnswers(PonderQuestion $question) { $viewer = $this->getViewer(); + $answers = $question->getAnswers(); $author_phids = mpull($answers, 'getAuthorPHID'); $handles = $this->loadViewerHandles($author_phids);