• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/controller/session/groupactions.php
  • Класс: BitrixImOpenLinesControllerSessionGroupActions
  • Вызов: GroupActions::getAccessSession
protected function getAccessSession($fields): array
{
	$result = [];
	$currentUserId = SecurityHelper::getCurrentUserId();

	$fields['idsChat'] = $this->getValidIds($fields['idsChat']);
	$fields['idsSession'] = $this->getValidIds($fields['idsSession']);

	if(
		!empty($fields['idsSession']) ||
		!empty($fields['idsChat'] )
	)
	{
		$sessions = SessionTable::getList([
			'filter' => [
				[
					'LOGIC' => 'OR',
					'ID' => $fields['idsSession'],
					'CHAT_ID' => $fields['idsChat']
				],
				//Not closed
				' Session::STATUS_CLOSE,
				'!=CLOSED' => 'Y',
			],
			'select' => [
				'ID',
				'CHAT_ID',
				'OPERATOR_ID',
				'CONFIG_ID'
			]
		]);

		while ($session = $sessions->fetch())
		{
			if(
				!empty($session['CHAT_ID']) &&
				(
					(
						!empty($currentUserId) &&
						!empty($session['OPERATOR_ID']) &&
						(int)$session['OPERATOR_ID'] === (int)$currentUserId
					) ||
					Config::canJoin($session['CONFIG_ID'])
				)
			)
			{
				$result[] = $session;
			}
		}
	}

	return $result;
}