summaryrefslogtreecommitdiff
path: root/app/Model/TaskPermission.php
blob: b1e0258931b4f01c6c1cd49eca9b0f74640f7a93 (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
<?php

namespace Kanboard\Model;

use Kanboard\Core\Security\Role;

/**
 * Task permission model
 *
 * @package  model
 * @author   Frederic Guillot
 */
class TaskPermission extends Base
{
    /**
     * Return true if the user can remove a task
     *
     * Regular users can't remove tasks from other people
     *
     * @public
     * @param  array $task
     * @return bool
     */
    public function canRemoveTask(array $task)
    {
        if ($this->userSession->isAdmin() || $this->projectUserRole->getUserRole($task['project_id'], $this->userSession->getId()) === Role::PROJECT_MANAGER) {
            return true;
        } elseif (isset($task['creator_id']) && $task['creator_id'] == $this->userSession->getId()) {
            return true;
        }

        return false;
    }
}