• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/classes/general/im_contact_list.php
  • Класс: CAllIMContactList
  • Вызов: CAllIMContactList::SetOffline
static function SetOffline($userId = null)
{
	global $USER, $DB;

	$userId = BitrixImCommon::getUserId($userId);
	if (!$userId)
	{
		return false;
	}

	$sqlDateFunction = 'NULL';
	if ($DB->type == "MYSQL")
		$sqlDateFunction = "DATE_SUB(NOW(), INTERVAL 120 SECOND)";
	elseif ($DB->type == "MSSQL")
		$sqlDateFunction = "dateadd(SECOND, -120, getdate())";
	elseif ($DB->type == "ORACLE")
		$sqlDateFunction = "SYSDATE-(1/24/60/60*120)";

	$DB->Query("UPDATE b_user SET LAST_ACTIVITY_DATE = ".$sqlDateFunction." WHERE ID = ".$userId);

	if ($userId == $USER->GetId())
	{
		unset($_SESSION['IM_LAST_ONLINE']);
		unset($_SESSION['USER_LAST_ONLINE_'.$userId]);
	}

	$USER->Logout();

	return true;
}