• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/integration/main/uiselector/sonetgroups.php
  • Класс: BitrixSocialnetworkIntegrationMainUISelectorSonetGroups
  • Вызов: SonetGroups::getWorkgroupName
static function getWorkgroupName($itemCode = '')
{
	global $USER;

	$result = '';

	$entityId = (
		preg_match('/^SG(d+)$/i', $itemCode, $matches)
		&& intval($matches[1]) > 0
			? intval($matches[1])
			: 0
	);

	if ($entityId  > 0)
	{
		$res = WorkgroupTable::getList(array(
			'filter' => array(
				'=ID' => $entityId
			),
			'select' => array('VISIBLE', 'NAME')
		));
		if (
			($workgroupFields = $res->fetch())
			&& ($workgroupFields["VISIBLE"] == "Y")
			|| (CSocNetUser::isCurrentUserModuleAdmin(SITE_ID, false))
		)
		{
			$result = $workgroupFields['NAME'];
		}

		if (empty($result))
		{
			$res = UserToGroupTable::getList(
				array(
					'filter' => array(
						'=GROUP_ID' => $entityId,
						'=USER_ID' => $USER->getId()
					),
					'select' => array(
						'GROUP_ID',
						'GROUP_NAME' => 'GROUP.NAME'
					)
				)
			);
			if ($relationFields = $res->fetch())
			{
				$result = $relationFields['GROUP_NAME'];
			}
		}
	}

	return $result;
}