- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/classes/general/timermanager.php
- Класс: CTaskTimerManager
- Вызов: CTaskTimerManager::start
public function start($taskId)
{
global $CACHE_MANAGER;
// Stop timer of user (if it is run)
$this->stop();
$task = CTaskItem::getInstance($taskId, $this->userId);
try
{
$taskData = $task->getData(false);
}
catch (TasksException $e)
{
return false;
}
if (!$task->checkAccess(ActionDictionary::ACTION_TASK_TIME_TRACKING))
{
return false;
}
// Run timer for given task
$timer = CTaskTimerCore::start($this->userId, $taskId);
$this->cachedLastTimer = null;
$affectedUsers = array_unique(
array_merge(
[$this->userId, $taskData['RESPONSIBLE_ID']],
(array)$taskData['ACCOMPLICES']
)
);
foreach ($affectedUsers as $userId)
{
$CACHE_MANAGER->ClearByTag("tasks_user_{$userId}");
}
if ($timer === false)
{
return false;
}
// Add task to day plan
$currentUserId = User::getId();
if ($currentUserId && ($currentUserId === $this->userId))
{
$dayPlanTasks = CTaskPlannerMaintance::getCurrentTasksList();
if (!in_array($taskId, $dayPlanTasks))
{
CTaskPlannerMaintance::plannerActions(['add' => [$taskId]]);
}
}
if ((int)$taskData['REAL_STATUS'] !== Status::IN_PROGRESS)
{
if ($task->checkAccess(ActionDictionary::ACTION_TASK_START))
{
$task->startExecution();
}
elseif ($task->checkAccess(ActionDictionary::ACTION_TASK_RENEW))
{
$task->renew();
}
}
PushService::addEvent(
$this->userId,
[
'module_id' => 'tasks',
'command' => PushCommand::TASK_TIMER_STARTED,
'params' => [
'taskId' => $taskId,
'timeElapsed' => (int)$taskData['TIME_SPENT_IN_LOGS'] + (time() - $timer['TIMER_STARTED_AT']),
],
]
);
return $timer;
}