Skip to content

Commit 3542886

Browse files
Merge pull request #6772 from christianbeeznest/GH-6758
Settings: Update mailer_from_* titles - refs #6758
2 parents 1081a35 + 26aadb2 commit 3542886

File tree

2 files changed

+89
-14
lines changed

2 files changed

+89
-14
lines changed

src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,13 +1154,13 @@ public static function getExistingSettings(): array
11541154
],
11551155
[
11561156
'name' => 'mailer_from_email',
1157-
'title' => "Mail: 'From' address",
1158-
'comment' => "The e-mail address from which e-mails will be sent when the platform sends an e-mail, also used as 'reply-to' header. We recommend using a 'no-reply' e-mail address here, to avoid excessive filling of an e-mail box. The support e-mail address defined in the Platform section should be used to contact you, but replying to automatic notifications should not be encouraged.",
1157+
'title' => 'Send all e-mails from this e-mail address',
1158+
'comment' => 'Sets the default email address used in the "from" field of emails.',
11591159
],
11601160
[
11611161
'name' => 'mailer_from_name',
1162-
'title' => "Mail: 'From' name",
1163-
'comment' => 'The name that appears as the sender (next to the From e-mail address) when the platform sends an e-mail.',
1162+
'title' => 'Send all e-mails as originating from this (organizational) name',
1163+
'comment' => 'Sets the default display name used for sending platform emails. e.g. "Support team".',
11641164
],
11651165
[
11661166
'name' => 'mailer_mails_charset',
@@ -3084,16 +3084,6 @@ public static function getNewConfigurationSettings(): array
30843084
],
30853085
],
30863086
'mail' => [
3087-
[
3088-
'name' => 'mailer_from_name',
3089-
'title' => 'Send all e-mails from this e-mail address',
3090-
'comment' => 'Sets the default email address used in the "from" field of emails.',
3091-
],
3092-
[
3093-
'name' => 'mailer_from_email',
3094-
'title' => 'Send all e-mails as originating from this (organizational) name',
3095-
'comment' => 'Sets the default display name used for sending platform emails. e.g. "Support team".',
3096-
],
30973087
[
30983088
'name' => 'allow_email_editor_for_anonymous',
30993089
'title' => 'E-mail editor for anonymous',
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/* For licensing terms, see /license.txt */
6+
7+
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
8+
9+
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
10+
use Doctrine\DBAL\Schema\Schema;
11+
12+
final class Version20250918152000 extends AbstractMigrationChamilo
13+
{
14+
public function getDescription(): string
15+
{
16+
return "Mail settings: fix titles/comments and upsert defaults for mailer_from_email & mailer_from_name in settings.";
17+
}
18+
19+
public function up(Schema $schema): void
20+
{
21+
$pairs = [
22+
[
23+
'variable' => 'mailer_from_email',
24+
'title' => 'Send all e-mails from this e-mail address',
25+
'comment' => 'Sets the default email address used in the "from" field of emails.',
26+
'category' => 'mail',
27+
'default' => '',
28+
],
29+
[
30+
'variable' => 'mailer_from_name',
31+
'title' => 'Send all e-mails as originating from this (organizational) name',
32+
'comment' => 'Sets the default display name used for sending platform emails. e.g. "Support team".',
33+
'category' => 'mail',
34+
'default' => '',
35+
],
36+
];
37+
38+
foreach ($pairs as $p) {
39+
$exists = (int) $this->connection->fetchOne(
40+
"SELECT COUNT(*) FROM settings
41+
WHERE variable = ? AND subkey IS NULL AND access_url = 1",
42+
[$p['variable']]
43+
);
44+
45+
if ($exists === 0) {
46+
$this->connection->executeStatement(
47+
"INSERT INTO settings
48+
(variable, subkey, type, category, selected_value, title, comment,
49+
access_url_changeable, access_url_locked, access_url)
50+
VALUES
51+
(?, NULL, NULL, ?, ?, ?, ?, 1, 0, 1)",
52+
[$p['variable'], $p['category'], $p['default'], $p['title'], $p['comment']]
53+
);
54+
$this->write(sprintf("Inserted missing setting: %s", $p['variable']));
55+
} else {
56+
$this->connection->executeStatement(
57+
"UPDATE settings
58+
SET title = ?, comment = ?, category = ?
59+
WHERE variable = ? AND subkey IS NULL AND access_url = 1",
60+
[$p['title'], $p['comment'], $p['category'], $p['variable']]
61+
);
62+
$this->write(sprintf("Updated setting metadata: %s", $p['variable']));
63+
}
64+
}
65+
}
66+
67+
public function down(Schema $schema): void
68+
{
69+
$this->connection->executeStatement(
70+
"UPDATE settings
71+
SET title = 'Send all e-mails as originating from this (organizational) name',
72+
comment = 'Sets the default display name used for sending platform emails. e.g. \"Support team\".'
73+
WHERE variable = 'mailer_from_email'
74+
AND subkey IS NULL AND access_url = 1"
75+
);
76+
77+
$this->connection->executeStatement(
78+
"UPDATE settings
79+
SET title = 'Send all e-mails from this e-mail address',
80+
comment = 'Sets the default email address used in the \"from\" field of emails.'
81+
WHERE variable = 'mailer_from_name'
82+
AND subkey IS NULL AND access_url = 1"
83+
);
84+
}
85+
}

0 commit comments

Comments
 (0)