|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
|
4
|
|
|
|
|
5
|
|
|
declare(strict_types=1); |
|
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 Version20250709174500 extends AbstractMigrationChamilo |
|
13
|
|
|
{ |
|
14
|
|
|
public function getDescription(): string |
|
15
|
|
|
{ |
|
16
|
|
|
return 'Insert or update the platform setting for hosting_limit_users_per_course.'; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function up(Schema $schema): void |
|
20
|
|
|
{ |
|
21
|
|
|
$setting = [ |
|
22
|
|
|
'variable' => 'hosting_limit_users_per_course', |
|
23
|
|
|
'selected_value' => '0', |
|
24
|
|
|
'title' => 'Global limit of users per course', |
|
25
|
|
|
'comment' => 'Defines a global maximum number of users (teachers included) allowed to be subscribed to any single course in the platform. Set this value to 0 to disable the limit. This helps avoid courses being overloaded in open portals.', |
|
26
|
|
|
'category' => 'platform', |
|
27
|
|
|
]; |
|
28
|
|
|
|
|
29
|
|
|
// Check if the setting exists for access_url = 1 |
|
30
|
|
|
$sqlCheck = sprintf( |
|
31
|
|
|
"SELECT COUNT(*) as count |
|
32
|
|
|
FROM settings |
|
33
|
|
|
WHERE variable = '%s' |
|
34
|
|
|
AND subkey IS NULL |
|
35
|
|
|
AND access_url = 1", |
|
36
|
|
|
addslashes($setting['variable']) |
|
37
|
|
|
); |
|
38
|
|
|
|
|
39
|
|
|
$stmt = $this->connection->executeQuery($sqlCheck); |
|
40
|
|
|
$result = $stmt->fetchAssociative(); |
|
41
|
|
|
|
|
42
|
|
|
if ($result && (int)$result['count'] > 0) { |
|
43
|
|
|
// UPDATE existing setting |
|
44
|
|
|
$this->addSql(sprintf( |
|
45
|
|
|
"UPDATE settings |
|
46
|
|
|
SET selected_value = '%s', |
|
47
|
|
|
title = '%s', |
|
48
|
|
|
comment = '%s', |
|
49
|
|
|
category = '%s' |
|
50
|
|
|
WHERE variable = '%s' |
|
51
|
|
|
AND subkey IS NULL |
|
52
|
|
|
AND access_url = 1", |
|
53
|
|
|
addslashes($setting['selected_value']), |
|
54
|
|
|
addslashes($setting['title']), |
|
55
|
|
|
addslashes($setting['comment']), |
|
56
|
|
|
addslashes($setting['category']), |
|
57
|
|
|
addslashes($setting['variable']) |
|
58
|
|
|
)); |
|
59
|
|
|
$this->write(sprintf("Updated setting: %s", $setting['variable'])); |
|
60
|
|
|
} else { |
|
61
|
|
|
// INSERT new setting |
|
62
|
|
|
$this->addSql(sprintf( |
|
63
|
|
|
"INSERT INTO settings |
|
64
|
|
|
(variable, subkey, type, category, selected_value, title, comment, access_url_changeable, access_url_locked, access_url) |
|
65
|
|
|
VALUES |
|
66
|
|
|
('%s', NULL, NULL, '%s', '%s', '%s', '%s', 1, 0, 1)", |
|
67
|
|
|
addslashes($setting['variable']), |
|
68
|
|
|
addslashes($setting['category']), |
|
69
|
|
|
addslashes($setting['selected_value']), |
|
70
|
|
|
addslashes($setting['title']), |
|
71
|
|
|
addslashes($setting['comment']) |
|
72
|
|
|
)); |
|
73
|
|
|
$this->write(sprintf("Inserted setting: %s", $setting['variable'])); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function down(Schema $schema): void |
|
78
|
|
|
{ |
|
79
|
|
|
$this->addSql(" |
|
80
|
|
|
DELETE FROM settings |
|
81
|
|
|
WHERE variable = 'hosting_limit_users_per_course' |
|
82
|
|
|
AND subkey IS NULL |
|
83
|
|
|
AND access_url = 1 |
|
84
|
|
|
"); |
|
85
|
|
|
|
|
86
|
|
|
$this->write("Removed setting: hosting_limit_users_per_course."); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|