- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/manager/task.php
- Класс: BitrixTasksManagerTask
- Вызов: Task::doAdd
static function doAdd($userId, array $data, array $parameters)
{
$userId = (int)$userId;
$errors = static::ensureHaveErrorCollection($parameters);
$data = static::normalizeData($data);
static::inviteMembers($data, $errors);
static::adaptSet($data);
static::ensureDatePlanChangeAllowed($userId, $data);
static::setDefaultUFValues($userId, $data);
$task = CTaskItem::add(static::stripSubEntityData($data), $userId, $parameters);
$taskId = $task->getId();
if ($taskId)
{
$commentPoster = CommentsTaskCommentPoster::getInstance($taskId, $userId);
$commentPoster->enableDeferredPostMode();
$commentPoster->clearComments();
if (
($data['ADD_TO_TIMEMAN'] ?? null) === 'Y'
&& $userId === (int)$data['RESPONSIBLE_ID']
&& $userId === User::getId()
&& !ExtranetUser::isExtranet($userId)
)
{
// add the task to planner only if the user this method executed under is current and responsible for the task
CTaskPlannerMaintance::plannerActions(['add' => [$taskId]]);
}
if (($data['ADD_TO_FAVORITE'] ?? null) === "Y")
{
$task->addToFavorite();
}
// add sub-entities (SE_*)
$subEntityParams = array_merge($parameters, ['MODE' => static::MODE_ADD]);
if (array_key_exists(Reminder::getCode(true), $data))
{
Reminder::manageSet($userId, $taskId, $data[ Reminder::getCode(true) ], $subEntityParams);
}
if (array_key_exists(ProjectDependence::getCode(true), $data))
{
ProjectDependence::manageSet($userId, $taskId, $data[ ProjectDependence::getCode(true) ], $subEntityParams);
}
if (array_key_exists(Checklist::getCode(true), $data))
{
TaskCheckListFacade::merge(
$taskId,
$userId,
$data[CheckList::getCode(true)],
[
'analyticsData' => $parameters['ANALYTICS_DATA'],
'context' => CheckListFacade::TASK_ADD_CONTEXT,
]
);
}
Template::manageTaskReplication($userId, $taskId, $data, $subEntityParams);
}
return $task;
}