• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/user.php
  • Класс: CAllUser
  • Вызов: CAllUser::CheckUsersCount
static function CheckUsersCount($user_id)
{
	$user_id = (int)$user_id;
	$license = MainApplication::getInstance()->getLicense();
	$limitUsersCount = $license->getMaxUsers();

	if ($limitUsersCount > 0)
	{
		// users logged in today
		$today = new MainTypeDate();
		$count = $license->getActiveUsersCount($today);

		if ($count >= $limitUsersCount)
		{
			// additional check for the current user

			$select = ['LAST_LOGIN'];

			$intranet = MainModuleManager::isModuleInstalled("intranet");
			if ($intranet)
			{
				$select[] = 'UF_DEPARTMENT';
			}

			// last_login in server time
			CTimeZone::Disable();

			$query = static::GetList('id', 'asc',
				['ID_EQUAL_EXACT' => $user_id],
				['SELECT' => $select]
			);

			CTimeZone::Enable();

			if ($currentUser = $query->Fetch())
			{
				if ($currentUser["LAST_LOGIN"] != '')
				{
					$loginDate = new MainTypeDateTime($currentUser["LAST_LOGIN"]);
					if ($loginDate->getTimestamp() > $today->getTimestamp())
					{
						// if the user already logged in today, he is allowed
						return true;
					}
				}

				if ($intranet && empty($currentUser["UF_DEPARTMENT"]))
				{
					// only intranet AND extranet users are countable
					if ($license->isExtraCountable())
					{
						$groupId = (int)Option::get('extranet', 'extranet_group');
						if ($groupId > 0 && in_array($groupId, static::GetUserGroup($user_id)))
						{
							return false;
						}
					}
					return true;
				}
			}
			return false;
		}
	}
	return true;
}