| 1 |
<?php |
| 2 |
|
| 3 |
function acym_level(int $neededLevel): bool |
| 4 |
{ |
| 5 |
$levels = [ |
| 6 |
'Starter' => ACYM_STARTER, |
| 7 |
'Essential' => ACYM_ESSENTIAL, |
| 8 |
'Enterprise' => ACYM_ENTERPRISE, |
| 9 |
]; |
| 10 |
|
| 11 |
$config = acym_config(); |
| 12 |
$currentLevel = $config->get('level'); |
| 13 |
|
| 14 |
$expirationDate = $config->get('expirationdate', 'not-set'); |
| 15 |
|
| 16 |
if ($config->get('isTrial', 0) == 1 && ($expirationDate !== 'not-set' && $expirationDate < time())) { |
| 17 |
$currentLevel = 'Starter'; |
| 18 |
} |
| 19 |
|
| 20 |
$currentLevelNumber = $levels[$currentLevel] ?? 0; |
| 21 |
|
| 22 |
return $currentLevelNumber >= $neededLevel; |
| 23 |
} |
| 24 |
|
| 25 |
function acym_upgradeTo(string $version, string $utmMedium): void |
| 26 |
{ |
| 27 |
$link = ACYM_ACYMAILING_WEBSITE.'pricing?utm_source=acymailing_plugin&utm_medium='.$utmMedium.'&utm_campaign=purchase'; |
| 28 |
$text = $version === 'essential' ? 'AcyMailing Essential' : 'AcyMailing Enterprise'; |
| 29 |
echo '<div class="acym__upgrade cell grid-x text-center align-center"> |
| 30 |
<h2 class="acym__listing__empty__title cell">'.acym_translationSprintf('ACYM_USE_THIS_FEATURE', '<span class="acym__color__blue">'.$text.'</span>').'</h2> |
| 31 |
<a target="_blank" href="'.$link.'" class="cell medium-6 large-shrink button acym__button__upgrade">'.acym_translation('ACYM_UPGRADE_NOW_SIMPLE').'</a> |
| 32 |
</div>'; |
| 33 |
} |
| 34 |
|
| 35 |
function acym_existsAcyMailing59(): bool |
| 36 |
{ |
| 37 |
$allTables = acym_getTables(); |
| 38 |
|
| 39 |
if (!in_array(acym_getPrefix().'acymailing_config', $allTables)) { |
| 40 |
return false; |
| 41 |
} |
| 42 |
|
| 43 |
$version = acym_loadResult('SELECT `value` FROM #__acymailing_config WHERE `namekey` = "version"'); |
| 44 |
|
| 45 |
return version_compare($version, '5.9.0', '>='); |
| 46 |
} |
| 47 |
|
| 48 |
function acym_buttonGetProVersion(string $class = 'cell shrink', string $text = 'ACYM_UPGRADE_NOW_SIMPLE'): string |
| 49 |
{ |
| 50 |
return '<a href="'.ACYM_ACYMAILING_WEBSITE.'pricing" target="_blank" class="button acym__button__upgrade '.$class.'">'.acym_translation($text).'</a>'; |
| 51 |
} |
| 52 |
|