Task::addAccomplice

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. Task
  4. addAccomplice
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/dispatcher/publicaction/task.php
  • Класс: BitrixTasksDispatcherPublicActionTask
  • Вызов: Task::addAccomplice
public function addAccomplice($id, $accompliceId)
{
	$result = [];

	$oldTask = TaskModel::createFromId((int)$id);
	$newTask = clone $oldTask;
	$members = $newTask->getMembers();
	$members[RoleDictionary::ROLE_ACCOMPLICE][] = (int)$accompliceId;
	$newTask->setMembers($members);

	if (!(new TaskAccessController($this->userId))->check(ActionDictionary::ACTION_TASK_CHANGE_ACCOMPLICES, $oldTask, $newTask))
	{
		$this->addForbiddenError();
		return $result;
	}

	$task = CTaskItem::getInstance($id, $this->userId);
	try
	{
		$arTask = $task->getData(false);
	}
	catch (TasksException $e)
	{
		return [];
	}

	$arTask['ACCOMPLICES'][] = $accompliceId;
	$task->update(array('ACCOMPLICES' => $arTask['ACCOMPLICES']));

	return $result;
}

Добавить комментарий