aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/blog/actions/comments/delete.php34
-rw-r--r--mod/blog/languages/en.php2
-rw-r--r--mod/blog/start.php1
-rw-r--r--mod/blog/views/default/object/blog-comment.php27
-rw-r--r--mod/blog/views/default/object/blog-comments.php27
-rw-r--r--mod/blog/views/default/object/blog.php43
6 files changed, 96 insertions, 38 deletions
diff --git a/mod/blog/actions/comments/delete.php b/mod/blog/actions/comments/delete.php
new file mode 100644
index 000000000..8eee2c961
--- /dev/null
+++ b/mod/blog/actions/comments/delete.php
@@ -0,0 +1,34 @@
+<?php
+
+ /**
+ * Elgg blog: delete comment action
+ *
+ * @package ElggBlog
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Ben Werdmuller <ben@curverider.co.uk>
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Ensure we're logged in
+ if (!isloggedin()) forward();
+
+ // Make sure we can get the comment in question
+ $comment_id = (int) get_input('comment_id');
+ if ($comment = get_annotation($comment_id)) {
+
+ $url = "mod/blog/read.php?blogpost=" . $comment->entity_guid;
+ if ($comment->canEdit()) {
+ $comment->delete();
+ system_message(elgg_echo("comment:deleted"));
+ forward($url);
+ }
+
+ } else {
+ $url = "";
+ }
+
+ system_message(elgg_echo("comment:notdeleted"));
+ forward($url);
+
+?> \ No newline at end of file
diff --git a/mod/blog/languages/en.php b/mod/blog/languages/en.php
index be2407440..845303700 100644
--- a/mod/blog/languages/en.php
+++ b/mod/blog/languages/en.php
@@ -32,6 +32,7 @@
'blog:posted' => "Your blog post was successfully posted.",
'comment:success' => "Your comment was successfully added.",
'blog:deleted' => "Your blog post was successfully deleted.",
+ 'comment:deleted' => "The comment was successfully deleted.",
/**
* Error messages
@@ -42,6 +43,7 @@
'blog:notdeleted' => "Sorry; we could not delete this blog post.",
'comment:failure' => "An unexpected error occurred when adding your comment. Please try again.",
+ 'comment:notdeleted' => "The comment could not be deleted.",
);
diff --git a/mod/blog/start.php b/mod/blog/start.php
index ff3890a69..0a3a50cd8 100644
--- a/mod/blog/start.php
+++ b/mod/blog/start.php
@@ -56,5 +56,6 @@
register_action("blog/edit",false,$CONFIG->pluginspath . "blog/actions/edit.php");
register_action("blog/delete",false,$CONFIG->pluginspath . "blog/actions/delete.php");
register_action("blog/comments/add",false,$CONFIG->pluginspath . "blog/actions/comments/add.php");
+ register_action("blog/comments/delete",false,$CONFIG->pluginspath . "blog/actions/comments/delete.php");
?> \ No newline at end of file
diff --git a/mod/blog/views/default/object/blog-comment.php b/mod/blog/views/default/object/blog-comment.php
index ecbf5fcff..a36490ec2 100644
--- a/mod/blog/views/default/object/blog-comment.php
+++ b/mod/blog/views/default/object/blog-comment.php
@@ -16,9 +16,9 @@
?>
<li>
-
- <?php echo elgg_view("output/longtext",array("value" => $vars['entity']->value)); ?>
- <p>
+ <div class="blog-comment">
+ <p class="blog-comment-text"><?php echo elgg_view("output/longtext",array("value" => $vars['entity']->value)); ?></p>
+ <p class="blog-comment-byline">
<?php
if ($owner = get_entity($vars['entity']->owner_guid)) {
@@ -27,5 +27,24 @@
?>, <?php echo date("F j, g:i a",$vars['entity']->time_created); ?>
</p>
-
+ <?php
+
+ if ($vars['entity']->canEdit()) {
+?>
+ <p class="blog-comment-menu">
+ <?php
+
+ echo elgg_view("output/confirmlink",array(
+ 'href' => $vars['url'] . "action.php?action=blog/comments/delete&comment_id=" . $vars['entity']->id,
+ 'text' => elgg_echo('delete'),
+ 'confirm' => elgg_echo('deleteconfirm'),
+ ));
+
+ ?>
+ </p>
+<?php
+ }
+
+ ?>
+ </div>
</li> \ No newline at end of file
diff --git a/mod/blog/views/default/object/blog-comments.php b/mod/blog/views/default/object/blog-comments.php
index 991c42301..188214ff1 100644
--- a/mod/blog/views/default/object/blog-comments.php
+++ b/mod/blog/views/default/object/blog-comments.php
@@ -12,6 +12,11 @@
* @uses $vars['comments'] Array of comments
*/
+?>
+
+ <div class="blog-comments">
+
+<?php
if (isset($vars['comments']) && is_array($vars['comments']) && sizeof($vars['comments']) > 0) {
echo "<h3>". elgg_echo("comments") ."</h3><ol>";
@@ -24,4 +29,24 @@
}
-?> \ No newline at end of file
+?>
+ <form action="<?php echo $vars['url']; ?>action/blog/comments/add" method="post">
+ <h3>
+ <?php echo elgg_echo("blog:comment:add"); ?>
+ </h3>
+ <p>
+ <label><?php echo elgg_echo("blog:comment:text"); ?>
+ <?php
+
+ echo elgg_view("input/longtext",array('internalname' => 'comment'));
+
+ ?>
+ </label>
+ </p>
+ <p>
+ <input type="hidden" name="blogpost_guid" value="<?php echo $vars['entity']->getGUID(); ?>" />
+ <input type="submit" value="<?php echo elgg_echo("save"); ?>" />
+ </p>
+ </form>
+
+ </div> \ No newline at end of file
diff --git a/mod/blog/views/default/object/blog.php b/mod/blog/views/default/object/blog.php
index 01fbe4b4c..c4b718045 100644
--- a/mod/blog/views/default/object/blog.php
+++ b/mod/blog/views/default/object/blog.php
@@ -47,10 +47,16 @@
<?php
if ($vars['entity']->canEdit()) {
+
?>
<a href="<?php echo $vars['url']; ?>mod/blog/edit.php?blogpost=<?php echo $vars['entity']->getGUID(); ?>"><?php echo elgg_echo("edit"); ?></a>
- <a href="<?php echo $vars['url']; ?>action.php?action=blog/delete&blogpost=<?php echo $vars['entity']->getGUID(); ?>"><?php echo elgg_echo("delete"); ?></a>
<?php
+
+ echo elgg_view("output/confirmlink", array(
+ 'href' => $vars['url'] . "action.php?action=blog/delete&blogpost=" . $vars['entity']->getGUID(),
+ 'text' => elgg_echo('delete'),
+ 'confirm' => elgg_echo('deleteconfirm'),
+ ));
// Allow the menu to be extended
echo elgg_view("editmenu",array('entity' => $vars['entity']));
@@ -66,41 +72,12 @@
// If we've been asked to display the full view
if (isset($vars['full']) && $vars['full'] == true) {
-
-?>
-
- <div class="blog-comments">
-
-<?php
+ echo elgg_view('object/blog-comments',array('entity' => $vars['entity'], 'comments' => $vars['comments']));
+ }
// Display comments if any
- echo elgg_view('object/blog-comments',array('comments' => $vars['comments']));
+ // echo elgg_view('object/blog-comments',array('entity' => $vars['entity'], 'comments' => $vars['comments']));
-?>
- <form action="<?php echo $vars['url']; ?>action/blog/comments/add" method="post">
- <h3>
- <?php echo elgg_echo("blog:comment:add"); ?>
- </h3>
- <p>
- <label><?php echo elgg_echo("blog:comment:text"); ?>
- <?php
-
- echo elgg_view("input/longtext",array('internalname' => 'comment'));
-
- ?>
- </label>
- </p>
- <p>
- <input type="hidden" name="blogpost_guid" value="<?php echo $vars['entity']->getGUID(); ?>" />
- <input type="submit" value="<?php echo elgg_echo("save"); ?>" />
- </p>
- </form>
-
- </div>
-
-<?php
-
- }
}
?> \ No newline at end of file