Skip to content

Commit

Permalink
Merge pull request #3816 from 3liz/backport-3814-to-release_3_6
Browse files Browse the repository at this point in the history
[Backport release_3_6] Mailer: set the replyTo parameter
  • Loading branch information
laurentj authored Jul 30, 2023
2 parents 69f1496 + ffb212d commit 5f08412
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lizmap/app/system/mainconfig.ini.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
; CSP header for the admin interface
adminCSPHeader=

setAdminContactEmailAsReplyTo=off

[modules]
jelix.enabled=on
jelix.installparam[wwwfiles]=copy
Expand Down
3 changes: 3 additions & 0 deletions lizmap/modules/lizmap/classes/lizmapServices.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
26 changes: 26 additions & 0 deletions lizmap/modules/lizmap/install/upgrade_replyto.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

class lizmapModuleUpgrader_replyto extends jInstallerModule
{
public $targetVersions = array(
'3.7.0-alpha.2',
'3.6.5',
'3.5.14',
);
public $date = '2023-07-27';

public function install()
{
if (isset($this->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();
}
}
}
9 changes: 8 additions & 1 deletion tests/units/classes/lizmapServicesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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} = '';
Expand Down

0 comments on commit 5f08412

Please sign in to comment.