summaryrefslogtreecommitdiff
path: root/app/Api/ProjectPermissionApi.php
blob: 10ee38522beabb3606b00604f8aa73cf4fd55feb (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php

namespace Kanboard\Api;

use Kanboard\Core\Base;
use Kanboard\Core\Security\Role;

/**
 * Project Permission API controller
 *
 * @package  Kanboard\Api
 * @author   Frederic Guillot
 */
class ProjectPermissionApi extends Base
{
    public function getProjectUsers($project_id)
    {
        return $this->projectUserRole->getAllUsers($project_id);
    }

    public function getAssignableUsers($project_id, $prepend_unassigned = false)
    {
        return $this->projectUserRole->getAssignableUsersList($project_id, $prepend_unassigned);
    }

    public function addProjectUser($project_id, $user_id, $role = Role::PROJECT_MEMBER)
    {
        return $this->projectUserRole->addUser($project_id, $user_id, $role);
    }

    public function addProjectGroup($project_id, $group_id, $role = Role::PROJECT_MEMBER)
    {
        return $this->projectGroupRole->addGroup($project_id, $group_id, $role);
    }

    public function removeProjectUser($project_id, $user_id)
    {
        return $this->projectUserRole->removeUser($project_id, $user_id);
    }

    public function removeProjectGroup($project_id, $group_id)
    {
        return $this->projectGroupRole->removeGroup($project_id, $group_id);
    }

    public function changeProjectUserRole($project_id, $user_id, $role)
    {
        return $this->projectUserRole->changeUserRole($project_id, $user_id, $role);
    }

    public function changeProjectGroupRole($project_id, $group_id, $role)
    {
        return $this->projectGroupRole->changeGroupRole($project_id, $group_id, $role);
    }

    // Deprecated
    public function getMembers($project_id)
    {
        return $this->getProjectUsers($project_id);
    }

    // Deprecated
    public function revokeUser($project_id, $user_id)
    {
        return $this->removeProjectUser($project_id, $user_id);
    }

    // Deprecated
    public function allowUser($project_id, $user_id)
    {
        return $this->addProjectUser($project_id, $user_id);
    }
}