} action_required_parameters("title", "content", "parent"); $comment = new Comment; if ( in_array($_POST['parent'], ["pro", "contra", "discussion"]) ) { $comment->parent = 0; $comment->rubric = $_POST['parent']; } else { $parent = new Comment($_POST['parent']); if (!$parent->id) { warning(_("Parent comment does not exist.")); redirect(); } $comment->parent = $parent->id; $comment->rubric = $parent->rubric; } if ( !$proposal->allowed_add_comments($comment->rubric) ) { warning(_("Adding or rating comments is not allowed in this phase.")); redirect(); } $comment->proposal = $proposal->id; $comment->title = trim($_POST['title']); if (!$comment->title) { warning(_("The title of the comment must be not empty.")); break; } $comment->content = trim($_POST['content']); if (!$comment->content) { warning(_("The content of the comment must be not empty.")); break; } $comment->add($proposal);
/** * content area of one comment * * @param Comment $comment */ private function display_comment_content(Comment $comment) { ?> <p><?php echo content2html($comment->content); ?> </p> <? // reply if ( self::$proposal->allowed_add_comments($this->rubric) and self::$parent!=$comment->id and !$comment->removed ) { if (Login::access_allowed("comment")) { $open = self::$open; $open[] = $comment->id; $open = array_unique($open); ?> <div class="reply"><a href="<?php echo URI::append(['open' => $open, 'parent' => $comment->id]); ?> #form" class="iconlink"><img src="img/reply.png" width="16" height="16" <?alt(_("reply"))?>></a></div> <? } else { ?> <div class="reply iconlink disabled"><img src="img/reply.png" width="16" height="16" <?alt(_("reply"))?>></div> <? } } // rating and remove/restore if ($comment->rating) { ?><span class="rating" title="<?php echo _("sum of ratings"); ?> ">+<?php echo $comment->rating; ?> </span> <? } if (Login::$admin) { form(URI::same(), 'class="button"'); ?> <input type="hidden" name="id" value="<?php echo $comment->id; ?> "> <? if ($comment->removed) { ?> <input type="hidden" name="action" value="restore_comment"> <input type="submit" value="<?php echo _("restore"); ?> "> <? } else { ?> <input type="hidden" name="action" value="remove_comment"> <input type="submit" value="<?php echo _("remove"); ?> "> <? } form_end(); } elseif ( self::$proposal->allowed_add_comments($this->rubric) and // don't allow to rate ones own comments !$comment->is_author() and // don't allow to rate removed comments !$comment->removed ) { if (Login::access_allowed("rate")) { $disabled = ""; $uri = URI::same()."#comment".$comment->id; } else { $disabled = " disabled"; $uri = ""; } if ($comment->score) { form($uri, 'class="button rating reset"'); ?> <input type="hidden" name="comment" value="<?php echo $comment->id; ?> "> <input type="hidden" name="action" value="reset_rating"> <input type="submit" value="0"<?php echo $disabled; ?> > <? form_end(); } for ($score=1; $score <= Comment::rating_score_max; $score++) { form($uri, 'class="button rating'.($score <= $comment->score?' selected':'').'"'); ?> <input type="hidden" name="comment" value="<?php echo $comment->id; ?> "> <input type="hidden" name="action" value="set_rating"> <input type="hidden" name="rating" value="<?php echo $score; ?> "> <input type="submit" value="+<?php echo $score; ?> "<?php echo $disabled; ?> > <? form_end(); } } }