Files
grzanieplus.pl/plugins/stTaskSchedulerImportPlugin/lib/stTaskSchedulerImportLimit.class.php
2025-03-12 17:06:23 +01:00

41 lines
1.2 KiB
PHP

<?php
class stTaskSchedulerImportLimit
{
const LIMITS = [
stCommunication::SUBSCRIPTION_START => 0,
stCommunication::SUBSCRIPTION_STANDARD => 1,
stCommunication::SUBSCRIPTION_PRO => 3,
stCommunication::SUBSCRIPTION_VIP => 10,
];
/**
* Zwraca limit aktywnych importów
*
* @return integer
*/
public static function getLimit(): int
{
return isset(self::LIMITS[stCommunication::getSubscriptionType()]) ? self::LIMITS[stCommunication::getSubscriptionType()] : self::LIMITS[stCommunication::SUBSCRIPTION_STANDARD];
}
/**
* Sprawdza czy ilość aktywnych importów jest poniżej ustalonego limitu
*
* @return bool Zwraca false w przypadku, gdy ilość jest równa lub większa od ustalonego limitu
*/
public static function checkLimit(): bool
{
$active = 0;
foreach (stTaskSchedulerImportConfiguration::getAll() as $config)
{
if ($config->isActive() && !$config->getParent() && !$config->getOption('ignore_limit'))
{
$active++;
}
}
return $active < self::getLimit();
}
}