Browse Source

show license message depending on setting

pull/91/head
Roland Gruber 3 years ago
parent
commit
ffb8fca488
  1. 1
      lam/HISTORY
  2. 4
      lam/docs/manual-sources/chapter-configuration.xml
  3. BIN
      lam/docs/manual-sources/images/configGeneral7.png
  4. 12
      lam/lib/config.inc
  5. 16
      lam/templates/login.php
  6. 7
      lam/tests/lib/LAMCfgMainTest.php

1
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

4
lam/docs/manual-sources/chapter-configuration.xml

@ -60,6 +60,10 @@
<para>When you entered the license key then the license details can be
seen on LAM configuration overview page.</para>
<para>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.</para>
<screenshot>
<mediaobject>
<imageobject>

BIN
lam/docs/manual-sources/images/configGeneral7.png

Before

Width: 898  |  Height: 293  |  Size: 13 KiB

After

Width: 1339  |  Height: 480  |  Size: 70 KiB

12
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;
}
}
?>

16
lam/templates/login.php

@ -452,9 +452,19 @@ function display_LoginPage($licenseValidator, $error_message) {
?>
<br><br>
<?PHP
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);
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);
}
}
?>
<br><br>

7
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());
}

Loading…
Cancel
Save