• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/livefeed/forumpost.php
  • Класс: BitrixSocialnetworkLivefeedForumPost
  • Вызов: ForumPost::getForumId
static function getForumId($params = [])
{
	$result = 0;

	$siteId = (
		isset($params['SITE_ID'])
		&& $params['SITE_ID'] <> ''
			? $params['SITE_ID']
			: SITE_ID
	);

	if (isset($params['type']))
	{
		if ($params['type'] === 'TK')
		{
			$result = Option::get('tasks', 'task_forum_id', 0, $siteId);

			if (
				(int)$result <= 0
				&& Loader::includeModule('forum')
			)
			{
				$res = ForumTable::getList([
					'filter' => [
						'=XML_ID' => 'intranet_tasks',
					],
					'select' => [ 'ID' ],
				]);
				if ($forumFields = $res->fetch())
				{
					$result = (int)$forumFields['ID'];
				}
			}
		}
		elseif ($params['type'] === 'WF')
		{
			$result = Option::get('bizproc', 'forum_id', 0, $siteId);

			if ((int)$result <= 0)
			{
				$res = ForumTable::getList([
					'filter' => [
						'=XML_ID' => 'bizproc_workflow',
					],
					'select' => [ 'ID' ],
				]);
				if ($forumFields = $res->fetch())
				{
					$result = (int)$forumFields['ID'];
				}
			}
		}
		elseif (in_array($params['type'], [ 'TM', 'TR' ]))
		{
			$result = Option::get('timeman', 'report_forum_id', 0, $siteId);
		}
		elseif (
			$params['type'] === 'EV'
			&& Loader::includeModule('calendar')
		)
		{
			$calendarSettings = CCalendar::getSettings();
			$result = $calendarSettings["forum_id"];
		}
		elseif (
			$params['type'] === 'PH'
			&& Loader::includeModule('forum')
		)
		{
			$res = ForumTable::getList(array(
				'filter' => array(
					'=XML_ID' => 'PHOTOGALLERY_COMMENTS'
				),
				'select' => array('ID')
			));
			if ($forumFields = $res->fetch())
			{
				$result = (int)$forumFields['ID'];
			}
		}
		elseif ($params['type'] === 'IBLOCK')
		{
			$result = Option::get('wiki', 'socnet_forum_id', 0, $siteId);
		}
		else
		{
			$res = ForumTable::getList(array(
				'filter' => array(
					'=XML_ID' => 'USERS_AND_GROUPS'
				),
				'select' => array('ID')
			));
			if ($forumFields = $res->fetch())
			{
				$result = (int)$forumFields['ID'];
			}
		}
	}

	return $result;
}