show license message depending on setting

This commit is contained in:
Roland Gruber 2020-04-02 21:19:23 +02:00
parent 0609c748ea
commit 365389cd0b
3 changed files with 46 additions and 1 deletions

View File

@ -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);
}
}
?>

View File

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

View File

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