Fix validation when adding new comments.

Fire off the appropriate item_related_update events as appropriate.
This commit is contained in:
Bharat Mediratta
2009-01-16 04:06:03 +00:00
parent ecf94c74d8
commit 2920640c2b
3 changed files with 25 additions and 2 deletions

View File

@@ -59,7 +59,20 @@ class Comments_Controller extends REST_Controller {
access::required("view", $item);
$form = comment::get_add_form($item);
if ($form->validate()) {
$valid = $form->validate();
if ($valid) {
if (user::active()->guest && !$form->add_comment->inputs["name"]->value) {
$form->add_comment->inputs["name"]->add_error("missing", 1);
$valid = false;
}
if (!$form->add_comment->text->value) {
$form->add_comment->text->add_error("missing", 1);
$valid = false;
}
}
if ($valid) {
$comment = comment::create(
$item, user::active(),
$form->add_comment->text->value,