From 365389cd0bb78afac6e7ceab46d22acd08506228 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 2 Apr 2020 21:19:23 +0200 Subject: [PATCH] show license message depending on setting --- lam/lib/config.inc | 20 ++++++++++++++++++++ lam/templates/login.php | 2 +- lam/tests/lib/LAMCfgMainTest.php | 25 +++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/lam/lib/config.inc b/lam/lib/config.inc index 65db3327..ca8c3770 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -3146,6 +3146,26 @@ class LAMCfgMain { return $this->licenseWarningType; } + /** + * Returns if the license warning should be shown on screen. + * + * @return bool show on screen + */ + public function showLicenseWarningOnScreen() { + $type = $this->getLicenseWarningType(); + return ($type === self::LICENSE_WARNING_ALL) || ($type === self::LICENSE_WARNING_SCREEN); + } + + /** + * Returns if the license warning should be sent via email. + * + * @return bool send via email + */ + public function sendLicenseWarningByEmail() { + $type = $this->getLicenseWarningType(); + return ($type === self::LICENSE_WARNING_ALL) || ($type === self::LICENSE_WARNING_EMAIL); + } + } ?> diff --git a/lam/templates/login.php b/lam/templates/login.php index 4ff31b6e..7106e2d9 100644 --- a/lam/templates/login.php +++ b/lam/templates/login.php @@ -452,7 +452,7 @@ function display_LoginPage($licenseValidator, $error_message) { ?>

isExpiringSoon()) { + if (isLAMProVersion() && $cfgMain->showLicenseWarningOnScreen() && $licenseValidator->isExpiringSoon()) { $licenseMessage = sprintf(_('Your licence expires on %s. You need to purchase a new licence to be able to use LAM Pro after this date.'), $licenseValidator->getLicense()->getExpirationDate()->format('Y-m-d')); StatusMessage('WARN', $licenseMessage); } diff --git a/lam/tests/lib/LAMCfgMainTest.php b/lam/tests/lib/LAMCfgMainTest.php index 7a41aceb..b17cfdb7 100644 --- a/lam/tests/lib/LAMCfgMainTest.php +++ b/lam/tests/lib/LAMCfgMainTest.php @@ -92,4 +92,29 @@ class LAMCfgMainTest extends TestCase { $this->assertEquals(array('123', '456'), $this->conf->getLicenseLines()); } + /** + * License warning type related settings. + */ + public function testLicenseWarningTypes() { + $this->conf->licenseWarningType = LAMCfgMain::LICENSE_WARNING_ALL; + + $this->assertTrue($this->conf->sendLicenseWarningByEmail()); + $this->assertTrue($this->conf->showLicenseWarningOnScreen()); + + $this->conf->licenseWarningType = LAMCfgMain::LICENSE_WARNING_EMAIL; + + $this->assertTrue($this->conf->sendLicenseWarningByEmail()); + $this->assertFalse($this->conf->showLicenseWarningOnScreen()); + + $this->conf->licenseWarningType = LAMCfgMain::LICENSE_WARNING_SCREEN; + + $this->assertFalse($this->conf->sendLicenseWarningByEmail()); + $this->assertTrue($this->conf->showLicenseWarningOnScreen()); + + $this->conf->licenseWarningType = LAMCfgMain::LICENSE_WARNING_NONE; + + $this->assertFalse($this->conf->sendLicenseWarningByEmail()); + $this->assertFalse($this->conf->showLicenseWarningOnScreen()); + } + } \ No newline at end of file