- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/dispatcher/publicaction/integration/timemanager.php
- Класс: BitrixTasksDispatcherPublicActionIntegrationTimeManager
- Вызов: TimeManager::start
public function start($taskId, $stopPrevious = false)
{
$result = array();
if($taskId = $this->checkTaskId($taskId))
{
global $USER;
$timer = CTaskTimerManager::getInstance($USER->getId());
$lastTimer = $timer->getLastTimer();
if(!$stopPrevious && $lastTimer['TASK_ID'] && $lastTimer['TIMER_STARTED_AT'] > 0 && intval($lastTimer['TASK_ID']) && $lastTimer['TASK_ID'] != $taskId)
{
$additional = array();
// use direct query here, avoiding cached CTaskItem::getData(), because $lastTimer['TASK_ID'] unlikely will be in cache
list($tasks, $res) = CTaskItem::fetchList($USER->getId(), array(), array('ID' => intval($lastTimer['TASK_ID'])), array(), array('ID', 'TITLE'));
if(is_array($tasks))
{
$task = array_shift($tasks);
if($task)
{
$data = $task->getData(false);
if(intval($data['ID']))
{
$additional['TASK'] = array(
'ID' => $data['ID'],
'TITLE' => $data['TITLE']
);
}
}
}
$this->errors->add('OTHER_TASK_ON_TIMER', 'Some other task is on timer', false, $additional);
}
else
{
if($timer->start($taskId) === false)
{
$this->errors->add('TIMER_ACTION_FAILED.START', 'Timer action failed');
}
}
}
return $result;
}