From 76d78acfae7610a7ddd89d8cbad9a0e966346668 Mon Sep 17 00:00:00 2001 From: zacharyg Date: Mon, 17 Sep 2012 13:52:43 -0700 Subject: [PATCH] Disallow contentless ponder questions Test Plan: * submitted various comments (empty, whitespace, real) and verified response Reviewers: pieter, epriestley CC: vrana, aran, Korvin Maniphest Tasks: T1644 Differential Revision: https://secure.phabricator.com/D3505 --- .../controller/PonderCommentSaveController.php | 13 +++++++++++-- .../ponder/view/PonderAddCommentView.php | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/applications/ponder/controller/PonderCommentSaveController.php b/src/applications/ponder/controller/PonderCommentSaveController.php index 2a81e2b48e..8574e85d85 100644 --- a/src/applications/ponder/controller/PonderCommentSaveController.php +++ b/src/applications/ponder/controller/PonderCommentSaveController.php @@ -40,6 +40,16 @@ final class PonderCommentSaveController extends PonderController { } $content = $request->getStr('content'); + if (!strlen(trim($content))) { + $dialog = new AphrontDialogView(); + $dialog->setUser($request->getUser()); + $dialog->setTitle('Empty comment'); + $dialog->appendChild('

Your comment must not be empty.

'); + $dialog->addCancelButton('/Q'.$question_id); + + return id(new AphrontDialogResponse())->setDialog($dialog); + } + $res = new PonderComment(); $res ->setContent($content) @@ -51,8 +61,7 @@ final class PonderCommentSaveController extends PonderController { return id(new AphrontRedirectResponse()) ->setURI( - id(new PhutilURI('/Q'. $question->getID())) - ->setFragment('comment-' . $res->getID())); + id(new PhutilURI('/Q'. $question->getID()))); } } diff --git a/src/applications/ponder/view/PonderAddCommentView.php b/src/applications/ponder/view/PonderAddCommentView.php index 2fdbf354df..83e491726b 100644 --- a/src/applications/ponder/view/PonderAddCommentView.php +++ b/src/applications/ponder/view/PonderAddCommentView.php @@ -55,6 +55,7 @@ final class PonderAddCommentView extends AphrontView { $form ->setUser($this->user) ->setAction($this->actionURI) + ->setWorkflow(true) ->addHiddenInput('target', $target) ->addHiddenInput('question_id', $questionID) ->appendChild(