• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/commentaux/createtask.php
  • Класс: BitrixSocialnetworkCommentAuxCreateTask
  • Вызов: CreateTask::getText
public function getText(): string
{
	static $userPage = null;
	static $parser = null;

	$result = '';
	$params = $this->params;
	$options = $this->options;

	$siteId = (!empty($options['siteId']) ? $options['siteId'] : SITE_ID);

	if (
		!isset($params['sourcetype'], $params['sourceid'], $params['taskid'])
		|| (int)$params['sourceid'] <= 0
		|| (int)$params['taskid'] <= 0
		|| !in_array($params['sourcetype'], $this->getSourceTypeList(), true)
	)
	{
		return $result;
	}

	if ($provider = $this->getLivefeedProvider())
	{
		$options['suffix'] = $provider->getSuffix($options['suffix']);
	}

	if ($userPage === null)
	{
		$userPage = Option::get(
				'socialnetwork',
				'user_page',
				SITE_DIR . 'company/personal/',
				$siteId
			) . 'user/#user_id#/';
	}

	if ($task = $this->getTask($params['taskid'], false))
	{
		$taskPath = (
			(!isset($options['cache']) || !$options['cache'])
			&& (!isset($options['im']) || !$options['im'])
			&& (!isset($options['bPublicPage']) || !$options['bPublicPage'])
				? str_replace(array("#user_id#", "#USER_ID#"), $task['RESPONSIBLE_ID'], $userPage).'tasks/task/view/'.$task['ID'].'/'
				: ''
		);

		$taskTitle = $task['TITLE'];
	}
	else
	{
		$taskPath = '';
		$taskTitle = Loc::getMessage('SONET_COMMENTAUX_CREATETASK_NOT_FOUND');
	}

	if (in_array($params['sourcetype'], $this->getCommentTypeList(), true))
	{
		$sourceData = $this->getSourceCommentData([
			'userPage' => $userPage,
		]);

		$suffix = (
			$options['suffix']
				? '_' . $options['suffix']
				: (!empty($sourceData['suffix']) ? '_' . $sourceData['suffix'] : '')
		);

		$result = Loc::getMessage('SONET_COMMENTAUX_CREATETASK_COMMENT_' . $params['sourcetype'] . $suffix, [
			'#TASK_NAME#' => (!empty($taskPath) ? '[URL=' . $taskPath . ']' . $taskTitle . '[/URL]' : $taskTitle),
			'#A_BEGIN#' => (!empty($sourceData['path']) ? '[URL=' . $sourceData['path'] . ']' : ''),
			'#A_END#' => (!empty($sourceData['path']) ? '[/URL]' : '')
		]);
	}
	elseif (in_array($params['sourcetype'], $this->getPostTypeList(), true))
	{
		$suffix = ($options['suffix'] ?? ($params['sourcetype'] === static::SOURCE_TYPE_BLOG_POST ? '2' : ''));

		$result = Loc::getMessage('SONET_COMMENTAUX_CREATETASK_POST_' . $params['sourcetype'].(!empty($suffix) ? '_' . $suffix : ''), [
			'#TASK_NAME#' => (!empty($taskPath) ? '[URL='.$taskPath.']'.$taskTitle.'[/URL]' : $taskTitle),
		]);
	}

	if (!empty($result))
	{
		if ($parser === null)
		{
			$parser = new CTextParser();
			$parser->allow = [ 'HTML' => 'N', 'ANCHOR' => 'Y' ];
		}
		$result = $parser->convertText($result);
	}

	return $result;
}