summaryrefslogtreecommitdiff
path: root/app/Api/Comment.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-05-23 21:44:33 -0400
committerFrederic Guillot <fred@kanboard.net>2015-05-23 21:44:33 -0400
commite32f26d048249b84166542d6442efdf202ff44fd (patch)
tree1868c5e83cec5ea8b821ad8a2036543aa37e5adb /app/Api/Comment.php
parentc9ba525bab06eff76b1d5fb8701848d0e3990122 (diff)
API refactoring
Diffstat (limited to 'app/Api/Comment.php')
-rw-r--r--app/Api/Comment.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/app/Api/Comment.php b/app/Api/Comment.php
new file mode 100644
index 00000000..19b84383
--- /dev/null
+++ b/app/Api/Comment.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Api;
+
+/**
+ * Comment API controller
+ *
+ * @package api
+ * @author Frederic Guillot
+ */
+class Comment extends Base
+{
+ public function getComment($comment_id)
+ {
+ return $this->comment->getById($comment_id);
+ }
+
+ public function getAllComments($task_id)
+ {
+ return $this->comment->getAll($task_id);
+ }
+
+ public function removeComment($comment_id)
+ {
+ return $this->comment->remove($comment_id);
+ }
+
+ public function createComment($task_id, $user_id, $content)
+ {
+ $values = array(
+ 'task_id' => $task_id,
+ 'user_id' => $user_id,
+ 'comment' => $content,
+ );
+
+ list($valid,) = $this->comment->validateCreation($values);
+
+ return $valid ? $this->comment->create($values) : false;
+ }
+
+ public function updateComment($id, $content)
+ {
+ $values = array(
+ 'id' => $id,
+ 'comment' => $content,
+ );
+
+ list($valid,) = $this->comment->validateModification($values);
+ return $valid && $this->comment->update($values);
+ }
+}