| Server IP : 185.252.147.100 / Your IP : 216.73.216.196 Web Server : nginx/1.27.3 System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 User : mitr ( 1000) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/html/kanboard/app/Model/ |
Upload File : |
<?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));
}
}