diff --git a/lizmap/app/system/mainconfig.ini.php b/lizmap/app/system/mainconfig.ini.php index d628860e08..ef634fdbaf 100644 --- a/lizmap/app/system/mainconfig.ini.php +++ b/lizmap/app/system/mainconfig.ini.php @@ -55,6 +55,8 @@ ; CSP header for the admin interface adminCSPHeader= +setAdminContactEmailAsReplyTo=off + [modules] jelix.enabled=on jelix.installparam[wwwfiles]=copy diff --git a/lizmap/modules/lizmap/classes/lizmapServices.class.php b/lizmap/modules/lizmap/classes/lizmapServices.class.php index 8e76afbb04..db88219628 100644 --- a/lizmap/modules/lizmap/classes/lizmapServices.class.php +++ b/lizmap/modules/lizmap/classes/lizmapServices.class.php @@ -438,6 +438,9 @@ public function saveIntoIni($ini, $liveIni) $liveIni->setValue($key, $this->{$prop}, $section); } elseif ($this->{$prop} != '') { $ini->setValue($prop, $this->{$prop}, 'services'); + if ($prop == 'adminContactEmail' && $this->globalConfig->lizmap['setAdminContactEmailAsReplyTo']) { + $liveIni->setValue('replyTo', $this->{$prop}, 'mailer'); + } } else { $ini->removeValue($prop, 'services'); } diff --git a/lizmap/modules/lizmap/install/upgrade_replyto.php b/lizmap/modules/lizmap/install/upgrade_replyto.php new file mode 100644 index 0000000000..0c6623ebd3 --- /dev/null +++ b/lizmap/modules/lizmap/install/upgrade_replyto.php @@ -0,0 +1,26 @@ +entryPoint->getConfigObj()->lizmap['setAdminContactEmailAsReplyTo']) + && $this->entryPoint->getConfigObj()->lizmap['setAdminContactEmailAsReplyTo'] + ) { + $lizmapConfFile = jApp::varConfigPath('lizmapConfig.ini.php'); + $ini = new \Jelix\IniFile\IniModifier($lizmapConfFile); + $replyTo = $ini->getValue('adminContactEmail', 'services'); + + $liveIni = new \Jelix\IniFile\IniModifier(jApp::varConfigPath('liveconfig.ini.php')); + $liveIni->setValue('replyTo', $replyTo, 'mailer'); + $liveIni->save(); + } + } +} diff --git a/tests/units/classes/lizmapServicesTest.php b/tests/units/classes/lizmapServicesTest.php index 23a57e3e97..722f8a5f70 100644 --- a/tests/units/classes/lizmapServicesTest.php +++ b/tests/units/classes/lizmapServicesTest.php @@ -324,7 +324,14 @@ public function testSaveIntoIni($dataModification, $expectedIniValues, $expected 'cacheRedisPort', ); - $testLizmapServices = new LizmapServices(array('hideSensitiveServicesProperties' => $hide), (object) array(), false, '', null); + $testLizmapServices = new LizmapServices( + array('hideSensitiveServicesProperties' => $hide), + (object) array( + 'lizmap' => [ + 'setAdminContactEmailAsReplyTo' => false + ] + ), + false, '', null); foreach ($defaultPropList as $prop) { $testLizmapServices->{$prop} = '';