| 1 |
<?php |
| 2 |
|
| 3 |
function acym_level($neededLevel) |
| 4 |
{ |
| 5 |
$levels = [ |
| 6 |
'Starter' => 0, |
| 7 |
'Essential' => 1, |
| 8 |
'Enterprise' => 2, |
| 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 = in_array($currentLevel, array_keys($levels)) ? $levels[$currentLevel] : 0; |
| 21 |
|
| 22 |
return $currentLevelNumber >= $neededLevel; |
| 23 |
} |
| 24 |
|
| 25 |
function acym_upgradeTo(string $version, string $utmMedium) |
| 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() |
| 36 |
{ |
| 37 |
$allTables = acym_getTables(); |
| 38 |
if (!in_array(acym_getPrefix().'acymailing_config', $allTables)) return false; |
| 39 |
|
| 40 |
$version = acym_loadResult('SELECT `value` FROM #__acymailing_config WHERE `namekey` LIKE "version"'); |
| 41 |
|
| 42 |
return version_compare($version, '5.9.0', '>='); |
| 43 |
} |
| 44 |
|
| 45 |
function acym_buttonGetProVersion($class = 'cell shrink', $text = 'ACYM_UPGRADE_NOW_SIMPLE') |
| 46 |
{ |
| 47 |
return '<a href="'.ACYM_ACYMAILING_WEBSITE.'pricing" target="_blank" class="button acym__button__upgrade '.$class.'">'.acym_translation($text).'</a>'; |
| 48 |
} |
| 49 |
|