mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 18:22:41 +01:00
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
This commit is contained in:
parent
e2ae82d455
commit
76d78acfae
2 changed files with 12 additions and 2 deletions
|
@ -40,6 +40,16 @@ final class PonderCommentSaveController extends PonderController {
|
||||||
}
|
}
|
||||||
$content = $request->getStr('content');
|
$content = $request->getStr('content');
|
||||||
|
|
||||||
|
if (!strlen(trim($content))) {
|
||||||
|
$dialog = new AphrontDialogView();
|
||||||
|
$dialog->setUser($request->getUser());
|
||||||
|
$dialog->setTitle('Empty comment');
|
||||||
|
$dialog->appendChild('<p>Your comment must not be empty.</p>');
|
||||||
|
$dialog->addCancelButton('/Q'.$question_id);
|
||||||
|
|
||||||
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||||
|
}
|
||||||
|
|
||||||
$res = new PonderComment();
|
$res = new PonderComment();
|
||||||
$res
|
$res
|
||||||
->setContent($content)
|
->setContent($content)
|
||||||
|
@ -51,8 +61,7 @@ final class PonderCommentSaveController extends PonderController {
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())
|
return id(new AphrontRedirectResponse())
|
||||||
->setURI(
|
->setURI(
|
||||||
id(new PhutilURI('/Q'. $question->getID()))
|
id(new PhutilURI('/Q'. $question->getID())));
|
||||||
->setFragment('comment-' . $res->getID()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ final class PonderAddCommentView extends AphrontView {
|
||||||
$form
|
$form
|
||||||
->setUser($this->user)
|
->setUser($this->user)
|
||||||
->setAction($this->actionURI)
|
->setAction($this->actionURI)
|
||||||
|
->setWorkflow(true)
|
||||||
->addHiddenInput('target', $target)
|
->addHiddenInput('target', $target)
|
||||||
->addHiddenInput('question_id', $questionID)
|
->addHiddenInput('question_id', $questionID)
|
||||||
->appendChild(
|
->appendChild(
|
||||||
|
|
Loading…
Reference in a new issue