From 2920640c2b0a4c2c1e5c47aac285ebec49cd6241 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 16 Jan 2009 04:06:03 +0000 Subject: Fix validation when adding new comments. Fire off the appropriate item_related_update events as appropriate. --- modules/comment/controllers/comments.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'modules/comment/controllers/comments.php') diff --git a/modules/comment/controllers/comments.php b/modules/comment/controllers/comments.php index 998ed1ac..1b936671 100644 --- a/modules/comment/controllers/comments.php +++ b/modules/comment/controllers/comments.php @@ -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, -- cgit v1.2.3