• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/classes/general/taskcomments.php
  • Класс: CTaskComments
  • Вызов: CTaskComments::add
static function add($taskId, $commentAuthorId, $commentText, $arFields = array())
{
	CTaskAssert::assertLaxIntegers($taskId, $commentAuthorId);
	CTaskAssert::assert(is_string($commentText));

	if ( ! CModule::includeModule('forum') )
	{
		throw new TasksException(
			'forum module can not be loaded',
			TasksException::TE_ACTION_FAILED_TO_BE_PROCESSED
		);
	}

	IncludeModuleLangFile(__FILE__);

	$forumId = CTasksTools::GetForumIdForIntranet();
	$oTask = CTaskItem::getInstance($taskId, $commentAuthorId);

	$arErrorCodes = array();

	try
	{
		$arTask = $oTask->getData();
	}
	catch (TasksException $e)
	{
		throw new TasksException(
			serialize($arErrorCodes),
			TasksException::TE_ACTION_FAILED_TO_BE_PROCESSED
			| TasksException::TE_FLAG_SERIALIZED_ERRORS_IN_MESSAGE
		);
	}

	$outForumTopicId = $outStrUrl = null;

	$messageId = self::__deprecated_Add(
		$commentText,
		$forumTopicId      = $arTask['FORUM_TOPIC_ID'],
		$forumId,
		$nameTemplate      = CSite::GetNameFormat(false),
		$arTask            = $arTask,
		$permissions       = 'Y',
		$commentId         = 0,
		$givenUserId       = $commentAuthorId,
		$imageWidth        = 300,
		$imageHeight       = 300,
		$arSmiles          = array(),
		$arForum           = CForumNew::GetByID($forumId),
		$messagesPerPage   = 10,
		$arUserGroupArray  = CUser::GetUserGroup($commentAuthorId),
		$backPage          = null,
		$strMsgAddComment  = GetMessage("TASKS_COMMENT_MESSAGE_ADD"),
		$strMsgEditComment = GetMessage("TASKS_COMMENT_MESSAGE_EDIT"),
		$strMsgNewTask     = GetMessage("TASKS_COMMENT_SONET_NEW_TASK_MESSAGE"),
		$componentName     = null,
		$outForumTopicId,
		$arErrorCodes,
		$outStrUrl,
		$arFields
	);

	if ( ! ($messageId >= 1) )
	{
		throw new TasksException(
			serialize($arErrorCodes),
			TasksException::TE_ACTION_FAILED_TO_BE_PROCESSED
				| TasksException::TE_FLAG_SERIALIZED_ERRORS_IN_MESSAGE
		);
	}

	return ( (int) $messageId );
}