1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Disallow contentless Ponder answers

Summary:
Any answer without non whitespace characters results in an
error.

Test Plan:
 - Submitted an empty answer, was told off
 - Submitted an answer full of whitespace, didn't like that either
 - Submitted a real answer, accepted

Reviewers: pieter, epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin, davidreuss

Maniphest Tasks: T1644

Differential Revision: https://secure.phabricator.com/D3492
This commit is contained in:
zacharyg 2012-09-17 13:48:36 -07:00
parent cfea1d29ee
commit e2ae82d455
2 changed files with 14 additions and 3 deletions

View file

@ -34,6 +34,17 @@ final class PonderAnswerSaveController extends PonderController {
$answer = $request->getStr('answer');
// Only want answers with some non whitespace content
if (!strlen(trim($answer))) {
$dialog = new AphrontDialogView();
$dialog->setUser($request->getUser());
$dialog->setTitle('Empty answer');
$dialog->appendChild('<p>Your answer must not be empty.</p>');
$dialog->addCancelButton('/Q'.$question_id);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_WEB,
array(
@ -55,8 +66,7 @@ final class PonderAnswerSaveController extends PonderController {
PhabricatorSearchPonderIndexer::indexQuestion($question);
return id(new AphrontRedirectResponse())
->setURI(id(new PhutilURI('/Q'. $question->getID()))
->setFragment('A'.$res->getID()));
return id(new AphrontRedirectResponse())->setURI(
id(new PhutilURI('/Q'. $question->getID())));
}
}

View file

@ -53,6 +53,7 @@ final class PonderAddAnswerView extends AphrontView {
$form
->setUser($this->user)
->setAction($this->actionURI)
->setWorkflow(true)
->addHiddenInput('question_id', $question->getID())
->appendChild(
id(new AphrontFormTextAreaControl())