summaryrefslogtreecommitdiff
path: root/modules/comment
diff options
context:
space:
mode:
Diffstat (limited to 'modules/comment')
-rw-r--r--modules/comment/controllers/admin_comments.php4
-rw-r--r--modules/comment/controllers/comments.php1
-rw-r--r--modules/comment/helpers/comment.php5
-rw-r--r--modules/comment/models/comment.php17
4 files changed, 16 insertions, 11 deletions
diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php
index ea76b188..a164f79f 100644
--- a/modules/comment/controllers/admin_comments.php
+++ b/modules/comment/controllers/admin_comments.php
@@ -113,10 +113,6 @@ class Admin_Comments_Controller extends Admin_Controller {
if ($comment->loaded) {
$comment->state = $state;
$comment->save();
- module::event("comment_updated", $comment);
- if ($comment->original("state") == "published" || $comment->state == "published") {
- module::event("item_related_update", $comment->item());
- }
}
}
diff --git a/modules/comment/controllers/comments.php b/modules/comment/controllers/comments.php
index 02c38491..9fb4796e 100644
--- a/modules/comment/controllers/comments.php
+++ b/modules/comment/controllers/comments.php
@@ -152,7 +152,6 @@ class Comments_Controller extends REST_Controller {
$comment->url = $form->edit_comment->url->value;
$comment->text = $form->edit_comment->text->value;
$comment->save();
- module::event("comment_updated", $comment);
print json_encode(
array("result" => "success",
diff --git a/modules/comment/helpers/comment.php b/modules/comment/helpers/comment.php
index 08cba096..3d743325 100644
--- a/modules/comment/helpers/comment.php
+++ b/modules/comment/helpers/comment.php
@@ -61,11 +61,6 @@ class comment_Core {
$comment->server_remote_port = substr($input->server("REMOTE_PORT"), 0, 16);
$comment->save();
- module::event("comment_created", $comment);
- if ($comment->state == "published") {
- module::event("item_related_update", $comment->item());
- }
-
return $comment;
}
diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php
index 22c465df..551fb245 100644
--- a/modules/comment/models/comment.php
+++ b/modules/comment/models/comment.php
@@ -61,8 +61,23 @@ class Comment_Model extends ORM {
$this->updated = time();
if (!$this->loaded && empty($this->created)) {
$this->created = $this->updated;
+ $created = true;
}
}
- return parent::save();
+ parent::save();
+
+ if (isset($created)) {
+ module::event("comment_created", $this);
+ } else {
+ module::event("comment_updated", $this);
+ }
+
+ // We only notify on the related items if we're making a visible change, which means moving in
+ // or out of a published state
+ if ($this->original("state") == "published" || $this->state == "published") {
+ module::event("item_related_update", $this->item());
+ }
+
+ return $this;
}
}