diff --git a/lam/HISTORY b/lam/HISTORY index 5ee66f67..b71088c7 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -1,6 +1,7 @@ June 2020 7.2 - LAM Pro: -> EMail sending can be done via SMTP without local mail server + -> License expiration warning can be sent via email or disabled 17.03.2020 7.1 diff --git a/lam/docs/manual-sources/chapter-configuration.xml b/lam/docs/manual-sources/chapter-configuration.xml index 27481c7f..cc1ce670 100644 --- a/lam/docs/manual-sources/chapter-configuration.xml +++ b/lam/docs/manual-sources/chapter-configuration.xml @@ -60,6 +60,10 @@ When you entered the license key then the license details can be seen on LAM configuration overview page. + By default, LAM Pro will show a warning message on the login page + 3 weeks before expiration. You can disable this here and/or send out an + email instead. + diff --git a/lam/docs/manual-sources/images/configGeneral7.png b/lam/docs/manual-sources/images/configGeneral7.png index dd4e1869..c0decd8d 100644 Binary files a/lam/docs/manual-sources/images/configGeneral7.png and b/lam/docs/manual-sources/images/configGeneral7.png differ diff --git a/lam/lib/config.inc b/lam/lib/config.inc index ca8c3770..fef1ae1c 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -3166,6 +3166,18 @@ class LAMCfgMain { return ($type === self::LICENSE_WARNING_ALL) || ($type === self::LICENSE_WARNING_EMAIL); } + /** + * Returns if the license warning was already sent. + * + * @param int $timeStamp time stamp + */ + public function wasLicenseWarningSent($timeStamp) { + if (empty($this->licenseEmailDateSent)) { + return false; + } + return $timeStamp == $this->licenseEmailDateSent; + } + } ?> diff --git a/lam/templates/login.php b/lam/templates/login.php index 7106e2d9..4cb74df6 100644 --- a/lam/templates/login.php +++ b/lam/templates/login.php @@ -452,9 +452,19 @@ function display_LoginPage($licenseValidator, $error_message) { ?>

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); + if (isLAMProVersion() && $licenseValidator->isExpiringSoon()) { + $expirationDate = $licenseValidator->getLicense()->getExpirationDate()->format('Y-m-d'); + $expirationTimeStamp = $licenseValidator->getLicense()->getExpirationDate()->getTimestamp(); + if ($cfgMain->showLicenseWarningOnScreen()) { + $licenseMessage = sprintf(_('Your licence expires on %s. You need to purchase a new licence to be able to use LAM Pro after this date.'), $expirationDate); + StatusMessage('WARN', $licenseMessage); + } + if ($cfgMain->sendLicenseWarningByEmail() && !$cfgMain->wasLicenseWarningSent($expirationTimeStamp)) { + $cfgMain->licenseEmailDateSent = $expirationTimeStamp; + $cfgMain->save(); + $mailer = new \LAM\ENV\LicenseWarningMailer($cfgMain); + $mailer->sendMail($expirationDate); + } } ?>

diff --git a/lam/tests/lib/LAMCfgMainTest.php b/lam/tests/lib/LAMCfgMainTest.php index b17cfdb7..aa4b2d64 100644 --- a/lam/tests/lib/LAMCfgMainTest.php +++ b/lam/tests/lib/LAMCfgMainTest.php @@ -75,19 +75,22 @@ class LAMCfgMainTest extends TestCase { * License related settings. */ public function testLicense() { + $timestamp = '12345'; $this->assertEquals(LAMCfgMain::LICENSE_WARNING_SCREEN, $this->conf->getLicenseWarningType()); + $this->assertFalse($this->conf->wasLicenseWarningSent($timestamp)); $this->conf->licenseEmailTo = 'TO'; $this->conf->licenseEmailFrom = 'FROM'; - $this->conf->licenseEmailDateSent = 'date'; $this->conf->licenseWarningType = LAMCfgMain::LICENSE_WARNING_ALL; $this->conf->setLicenseLines(array('123', '456')); + $this->conf->licenseEmailDateSent = $timestamp; $this->conf->save(); $this->conf = new LAMCfgMain($this->file); $this->assertEquals('TO', $this->conf->licenseEmailTo); $this->assertEquals('FROM', $this->conf->licenseEmailFrom); - $this->assertEquals('date', $this->conf->licenseEmailDateSent); + $this->assertEquals($timestamp, $this->conf->licenseEmailDateSent); + $this->assertTrue($this->conf->wasLicenseWarningSent($timestamp)); $this->assertEquals(LAMCfgMain::LICENSE_WARNING_ALL, $this->conf->licenseWarningType); $this->assertEquals(array('123', '456'), $this->conf->getLicenseLines()); }