diff options
Diffstat (limited to 'app/Model/SubTask.php')
-rw-r--r-- | app/Model/SubTask.php | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/app/Model/SubTask.php b/app/Model/SubTask.php index 3fccad47..dd243b1f 100644 --- a/app/Model/SubTask.php +++ b/app/Model/SubTask.php @@ -223,13 +223,43 @@ class SubTask extends Base $values = array( 'id' => $subtask['id'], 'status' => ($subtask['status'] + 1) % 3, - 'task_id' => $subtask['task_id'], ); return $this->update($values); } /** + * 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(self::TABLE) + ->eq('status', self::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->config->get('subtask_restriction') == 1 && + $this->db->table(self::TABLE) + ->eq('status', self::STATUS_INPROGRESS) + ->eq('user_id', $user_id) + ->count() === 1; + } + + /** * Remove * * @access public |