summaryrefslogtreecommitdiff
path: root/app/Api/Comment.php
blob: 1fc1c708b096b81cb9c065cdba953faceeb35143 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php

namespace Kanboard\Api;

/**
 * Comment API controller
 *
 * @package  api
 * @author   Frederic Guillot
 */
class Comment extends \Kanboard\Core\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, $reference = '')
    {
        $values = array(
            'task_id' => $task_id,
            'user_id' => $user_id,
            'comment' => $content,
            'reference' => $reference,
        );

        list($valid, ) = $this->commentValidator->validateCreation($values);

        return $valid ? $this->comment->create($values) : false;
    }

    public function updateComment($id, $content)
    {
        $values = array(
            'id' => $id,
            'comment' => $content,
        );

        list($valid, ) = $this->commentValidator->validateModification($values);
        return $valid && $this->comment->update($values);
    }
}