Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -1154,13 +1154,13 @@ public static function getExistingSettings(): array
],
[
'name' => 'mailer_from_email',
'title' => "Mail: 'From' address",
'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.",
'title' => 'Send all e-mails from this e-mail address',
'comment' => 'Sets the default email address used in the "from" field of emails.',
],
[
'name' => 'mailer_from_name',
'title' => "Mail: 'From' name",
'comment' => 'The name that appears as the sender (next to the From e-mail address) when the platform sends an e-mail.',
'title' => 'Send all e-mails as originating from this (organizational) name',
'comment' => 'Sets the default display name used for sending platform emails. e.g. "Support team".',
],
[
'name' => 'mailer_mails_charset',
Expand Down Expand Up @@ -3084,16 +3084,6 @@ public static function getNewConfigurationSettings(): array
],
],
'mail' => [
[
'name' => 'mailer_from_name',
'title' => 'Send all e-mails from this e-mail address',
'comment' => 'Sets the default email address used in the "from" field of emails.',
],
[
'name' => 'mailer_from_email',
'title' => 'Send all e-mails as originating from this (organizational) name',
'comment' => 'Sets the default display name used for sending platform emails. e.g. "Support team".',
],
[
'name' => 'allow_email_editor_for_anonymous',
'title' => 'E-mail editor for anonymous',
Expand Down
85 changes: 85 additions & 0 deletions src/CoreBundle/Migrations/Schema/V200/Version20250918152000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

declare(strict_types=1);

/* For licensing terms, see /license.txt */

namespace Chamilo\CoreBundle\Migrations\Schema\V200;

use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;

final class Version20250918152000 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return "Mail settings: fix titles/comments and upsert defaults for mailer_from_email & mailer_from_name in settings.";
}

public function up(Schema $schema): void
{
$pairs = [
[
'variable' => 'mailer_from_email',
'title' => 'Send all e-mails from this e-mail address',
'comment' => 'Sets the default email address used in the "from" field of emails.',
'category' => 'mail',
'default' => '',
],
[
'variable' => 'mailer_from_name',
'title' => 'Send all e-mails as originating from this (organizational) name',
'comment' => 'Sets the default display name used for sending platform emails. e.g. "Support team".',
'category' => 'mail',
'default' => '',
],
];

foreach ($pairs as $p) {
$exists = (int) $this->connection->fetchOne(
"SELECT COUNT(*) FROM settings
WHERE variable = ? AND subkey IS NULL AND access_url = 1",
[$p['variable']]
);

if ($exists === 0) {
$this->connection->executeStatement(
"INSERT INTO settings
(variable, subkey, type, category, selected_value, title, comment,
access_url_changeable, access_url_locked, access_url)
VALUES
(?, NULL, NULL, ?, ?, ?, ?, 1, 0, 1)",
[$p['variable'], $p['category'], $p['default'], $p['title'], $p['comment']]
);
$this->write(sprintf("Inserted missing setting: %s", $p['variable']));
} else {
$this->connection->executeStatement(
"UPDATE settings
SET title = ?, comment = ?, category = ?
WHERE variable = ? AND subkey IS NULL AND access_url = 1",
[$p['title'], $p['comment'], $p['category'], $p['variable']]
);
$this->write(sprintf("Updated setting metadata: %s", $p['variable']));
}
}
}

public function down(Schema $schema): void
{
$this->connection->executeStatement(
"UPDATE settings
SET title = 'Send all e-mails as originating from this (organizational) name',
comment = 'Sets the default display name used for sending platform emails. e.g. \"Support team\".'
WHERE variable = 'mailer_from_email'
AND subkey IS NULL AND access_url = 1"
);

$this->connection->executeStatement(
"UPDATE settings
SET title = 'Send all e-mails from this e-mail address',
comment = 'Sets the default email address used in the \"from\" field of emails.'
WHERE variable = 'mailer_from_name'
AND subkey IS NULL AND access_url = 1"
);
}
}
Loading