blob: c99d6055399840ee8b00fedec64c8df145532bda (
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
<?php
namespace Kanboard\Model;
use Kanboard\Core\Base;
/**
* Class SubtaskStatusModel
*
* @package Kanboard\Model
* @author Frederic Guillot
*/
class SubtaskStatusModel extends Base
{
/**
* Get the subtask in progress for this user
*
* @access public
* @param integer $user_id
* @return array
*/
public function getSubtaskInProgress($user_id)
{
return $this->db->table(SubtaskModel::TABLE)
->eq('status', SubtaskModel::STATUS_INPROGRESS)
->eq('user_id', $user_id)
->findOne();
}
/**
* Return true if the user have a subtask in progress
*
* @access public
* @param integer $user_id
* @return boolean
*/
public function hasSubtaskInProgress($user_id)
{
return $this->configModel->get('subtask_restriction') == 1 &&
$this->db->table(SubtaskModel::TABLE)
->eq('status', SubtaskModel::STATUS_INPROGRESS)
->eq('user_id', $user_id)
->exists();
}
/**
* Change the status of subtask
*
* @access public
* @param integer $subtask_id
* @return boolean|integer
*/
public function toggleStatus($subtask_id)
{
$subtask = $this->subtaskModel->getById($subtask_id);
$status = ($subtask['status'] + 1) % 3;
$values = array(
'id' => $subtask['id'],
'status' => $status,
'task_id' => $subtask['task_id'],
);
if (empty($subtask['user_id']) && $this->userSession->isLogged()) {
$values['user_id'] = $this->userSession->getId();
$subtask['user_id'] = $values['user_id'];
}
$this->subtaskTimeTrackingModel->toggleTimer($subtask_id, $subtask['user_id'], $status);
return $this->subtaskModel->update($values) ? $status : false;
}
/**
* Close all subtasks of a task
*
* @access public
* @param integer $task_id
* @return boolean
*/
public function closeAll($task_id)
{
return $this->db
->table(SubtaskModel::TABLE)
->eq('task_id', $task_id)
->update(array('status' => SubtaskModel::STATUS_DONE));
}
}
|