<?php /** * Edit question/answer comment */ $comment_id = (int) get_input('comment_id'); // modified to work with ckeditor wysiwyg $comment_text = get_input("comment_text{$comment_id}", false); $comment = elgg_get_annotation_from_id($comment_id); if (!$comment instanceof ElggAnnotation || $comment->name != "comment") { register_error(elgg_echo("answers:notfound")); forward("answers"); } $entity = get_entity($comment->entity_guid); if (empty($comment_text) || !answers_can_edit_comment($comment)) { register_error(elgg_echo("answers:comment:error")); forward($entity->getURL()); } $comment->value = $comment_text; if (!$comment->save()) { register_error(elgg_echo("answers:comment:failure")); } else { system_message(elgg_echo("answers:comment:updated")); } forward($entity->getURL());
<?php /** * Display comment view */ if (isset($vars['entity'])) { $comment = $vars['entity']; $owner = get_user($comment->owner_guid); $canedit = answers_can_edit_comment($comment); $markdown = is_callable('markdown_text'); if ($comment && $owner) { $full_comment_text = parse_urls(filter_tags($comment->value)) . ($markdown ? "\n" : " ") . "— " . "<span class=\"answers_comment_owner\">" . "<a href=\"" . $owner->getURL() . "\">" . $owner->name . "</a>" . " " . elgg_view_friendly_time($comment->time_created) . "</span>"; if ($canedit) { $full_comment_text .= " " . elgg_view("output/confirmlink", array('href' => $vars['url'] . "action/answers/comment/delete?comment_id=" . $comment->id, 'text' => elgg_echo('delete'), 'confirm' => elgg_echo('deleteconfirm'), 'class' => '', 'is_action' => true)); $edit = elgg_echo('edit'); $full_comment_text .= " <a class=\"collapsibleboxlink\">{$edit}</a>"; } if ($markdown) { $full_comment_text = markdown_text($full_comment_text); } else { $full_comment_text = autop($full_comment_text); } ?> <div class="answers_comment"> <a name="<?php echo $comment->id; ?> "></a> <?php echo $full_comment_text; ?>
<?php /** * Delete question/answer comment action */ $comment_id = (int) get_input('comment_id'); $comment = elgg_get_annotation_from_id($comment_id); if (!$comment instanceof ElggAnnotation || $comment->name != "comment") { register_error(elgg_echo("answers:notfound")); forward("answers"); } $entity = get_entity($comment->entity_guid); if (!answers_can_edit_comment($comment)) { register_error(elgg_echo("answers:comment:error")); forward($entity->getURL()); } if (!$comment->delete()) { register_error(elgg_echo("answers:comment:failure")); } else { system_message(elgg_echo("answers:comment:deleted")); } forward($entity->getURL());