summaryrefslogtreecommitdiff
path: root/app/Model/Comment.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-08-15 17:23:41 -0700
committerFrédéric Guillot <fred@kanboard.net>2014-08-15 17:23:41 -0700
commit9eeded33f68872515954a2fc177fcb47a9273ae9 (patch)
treef3ef9507e087ca6bf3ce624232da240a8689b051 /app/Model/Comment.php
parentc539bdc8ab746c5afd48cf87de057dc38d50adac (diff)
Add email notifications
Diffstat (limited to 'app/Model/Comment.php')
-rw-r--r--app/Model/Comment.php23
1 files changed, 21 insertions, 2 deletions
diff --git a/app/Model/Comment.php b/app/Model/Comment.php
index b5102070..b849fc23 100644
--- a/app/Model/Comment.php
+++ b/app/Model/Comment.php
@@ -21,6 +21,14 @@ class Comment extends Base
const TABLE = 'comments';
/**
+ * Events
+ *
+ * @var string
+ */
+ const EVENT_UPDATE = 'comment.update';
+ const EVENT_CREATE = 'comment.create';
+
+ /**
* Get all comments for a given task
*
* @access public
@@ -95,7 +103,14 @@ class Comment extends Base
{
$values['date'] = time();
- return $this->db->table(self::TABLE)->save($values);
+ if ($this->db->table(self::TABLE)->save($values)) {
+
+ $values['id'] = $this->db->getConnection()->getLastId();
+ $this->event->trigger(self::EVENT_CREATE, $values);
+ return true;
+ }
+
+ return false;
}
/**
@@ -107,10 +122,14 @@ class Comment extends Base
*/
public function update(array $values)
{
- return $this->db
+ $result = $this->db
->table(self::TABLE)
->eq('id', $values['id'])
->update(array('comment' => $values['comment']));
+
+ $this->event->trigger(self::EVENT_UPDATE, $values);
+
+ return $result;
}
/**