-
Notifications
You must be signed in to change notification settings - Fork 510
Internal: Add setting to limit number of same e-mails - refs #5112 #6381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
6df344b
Internal: Add setting to limit number of same e-mails - refs #5112
christianbeeznest ce903cb
Merge remote-tracking branch 'upstream/master' into GH-5112
christianbeeznest d967a41
Internal: Sanitize timezone slashes and migrate identical email limit…
christianbeeznest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/CoreBundle/Migrations/Schema/V200/Version20250709201100.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/* For licensing terms, see /license.txt */ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chamilo\CoreBundle\Migrations\Schema\V200; | ||
|
||
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; | ||
use Doctrine\DBAL\Schema\Schema; | ||
|
||
final class Version20250709201100 extends AbstractMigrationChamilo | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Insert or update the platform setting for hosting_limit_identical_email.'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$setting = [ | ||
'variable' => 'hosting_limit_identical_email', | ||
'selected_value' => '0', | ||
'title' => 'Limit identical email usage', | ||
'comment' => 'Maximum number of accounts allowed to share the same e-mail address. Set to 0 to disable this limit.', | ||
'category' => 'platform', | ||
]; | ||
|
||
$sqlCheck = sprintf( | ||
"SELECT COUNT(*) as count | ||
FROM settings | ||
WHERE variable = '%s' | ||
AND subkey IS NULL | ||
AND access_url = 1", | ||
addslashes($setting['variable']) | ||
); | ||
|
||
$stmt = $this->connection->executeQuery($sqlCheck); | ||
$result = $stmt->fetchAssociative(); | ||
|
||
if ($result && (int)$result['count'] > 0) { | ||
// UPDATE existing setting | ||
$this->addSql(sprintf( | ||
"UPDATE settings | ||
SET selected_value = '%s', | ||
title = '%s', | ||
comment = '%s', | ||
category = '%s' | ||
WHERE variable = '%s' | ||
AND subkey IS NULL | ||
AND access_url = 1", | ||
addslashes($setting['selected_value']), | ||
addslashes($setting['title']), | ||
addslashes($setting['comment']), | ||
addslashes($setting['category']), | ||
addslashes($setting['variable']) | ||
)); | ||
$this->write(sprintf("Updated setting: %s", $setting['variable'])); | ||
} else { | ||
// INSERT new setting | ||
$this->addSql(sprintf( | ||
"INSERT INTO settings | ||
(variable, subkey, type, category, selected_value, title, comment, access_url_changeable, access_url_locked, access_url) | ||
VALUES | ||
('%s', NULL, NULL, '%s', '%s', '%s', '%s', 1, 0, 1)", | ||
addslashes($setting['variable']), | ||
addslashes($setting['category']), | ||
addslashes($setting['selected_value']), | ||
addslashes($setting['title']), | ||
addslashes($setting['comment']) | ||
)); | ||
$this->write(sprintf("Inserted setting: %s", $setting['variable'])); | ||
} | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql(" | ||
DELETE FROM settings | ||
WHERE variable = 'hosting_limit_identical_email' | ||
AND subkey IS NULL | ||
AND access_url = 1 | ||
"); | ||
|
||
$this->write("Removed setting: hosting_limit_identical_email."); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.