Skip to content

Commit 62568aa

Browse files
authored
Merge pull request #6164 from AngelFQC/settings_overrides
Internal: Rename hosting_limits.yaml to settings_overrides.yaml
2 parents 39d6865 + fb55da6 commit 62568aa

File tree

11 files changed

+44
-58
lines changed

11 files changed

+44
-58
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var/upload/*
2727
/main/inc/conf/configuration.php
2828

2929
/config/authentication.yaml
30-
/config/hosting_limits.yaml
30+
/config/settings_overrides.yaml
3131
/config/plugin.yaml
3232

3333
# Home

config/hosting_limits.dist.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

config/services.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,5 @@ imports:
136136
- { resource: ../src/CoreBundle/Resources/config/services.yml }
137137
- { resource: ../src/LtiBundle/Resources/config/services.yml }
138138
- { resource: ./authentication.yaml, ignore_errors: not_found }
139-
- { resource: ./hosting_limits.yaml, ignore_errors: not_found }
139+
- { resource: ./settings_overrides.yaml, ignore_errors: not_found }
140140
- { resource: ./plugin.yaml, ignore_errors: not_found }

config/settings_overrides.dist.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
settings_overrides:
3+
default:
4+
hosting_limit:
5+
users: 0
6+
teachers: 0
7+
courses: 0
8+
sessions: 0
9+
disk_space: 0
10+
active_courses: 0
11+
total_size: 0

public/main/course_info/infocours.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@
993993

994994
$access_url_id = api_get_current_access_url_id();
995995

996-
$limitCourses = get_hosting_limit($access_url_id, 'hosting_limit_active_courses');
996+
$limitCourses = get_hosting_limit($access_url_id, 'active_courses');
997997
if ($limitCourses !== null && $limitCourses > 0) {
998998
$courseInfo = api_get_course_info_by_id($courseId);
999999

public/main/inc/lib/api.lib.php

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6832,22 +6832,6 @@ function api_get_configuration_value($variable)
68326832
return false;
68336833
}
68346834

6835-
/**
6836-
* Loads hosting limits from the YAML file.
6837-
*
6838-
* @return array The hosting limits.
6839-
*/
6840-
function load_hosting_limits(): array
6841-
{
6842-
if (!Container::$container->hasParameter('hosting_limits')) {
6843-
return [];
6844-
}
6845-
6846-
$hostingLimits =Container::$container->getParameter('hosting_limits');
6847-
6848-
return $hostingLimits['urls'] ?? [];
6849-
}
6850-
68516835
/**
68526836
* Gets a specific hosting limit.
68536837
*
@@ -6857,13 +6841,15 @@ function load_hosting_limits(): array
68576841
*/
68586842
function get_hosting_limit(int $urlId, string $limitName): mixed
68596843
{
6860-
$limits = load_hosting_limits();
6861-
6862-
if (!isset($limits[$urlId])) {
6863-
return null;
6844+
if (!Container::$container->hasParameter('settings_overrides')) {
6845+
return [];
68646846
}
68656847

6866-
foreach ($limits[$urlId] as $limitArray) {
6848+
$settingsOverrides = Container::$container->getParameter('settings_overrides');
6849+
6850+
$limits = $settingsOverrides[$urlId]['hosting_limit'] ?? $settingsOverrides['default']['hosting_limit'];
6851+
6852+
foreach ($limits as $limitArray) {
68676853
if (isset($limitArray[$limitName])) {
68686854
return $limitArray[$limitName];
68696855
}

public/main/inc/lib/diagnoser.lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public function get_chamilo_data()
223223
list($size, $none) = explode("\t", $du);
224224
unset($none);
225225

226-
$limit = get_hosting_limit($access_url_id, 'hosting_limit_disk_space');
226+
$limit = get_hosting_limit($access_url_id, 'disk_space');
227227
if ($limit === null) {
228228
$limit = 0;
229229
}

public/main/inc/lib/sessionmanager.lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public static function create_session(
173173
? (empty($accessUrlId) ? api_get_current_access_url_id() : (int) $accessUrlId)
174174
: 1;
175175

176-
$hostingLimitSessions = get_hosting_limit($accessUrlId, 'hosting_limit_sessions');
176+
$hostingLimitSessions = get_hosting_limit($accessUrlId, 'sessions');
177177

178178
if ($hostingLimitSessions !== null && $hostingLimitSessions > 0) {
179179
$num = self::count_sessions();

public/main/inc/lib/usermanager.lib.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ public static function create_user(
184184
$accessUrl = Container::getAccessUrlHelper()->getCurrent();
185185
$access_url_id = $accessUrl->getId();
186186

187-
$hostingLimitUsers = get_hosting_limit($access_url_id, 'hosting_limit_users');
187+
$hostingLimitUsers = get_hosting_limit($access_url_id, 'users');
188188

189189
if ($hostingLimitUsers !== null && $hostingLimitUsers > 0) {
190190
$num = self::get_number_of_users();
191191
if ($num >= $hostingLimitUsers) {
192-
api_warn_hosting_contact('hosting_limit_users');
192+
api_warn_hosting_contact('users');
193193
Display::addFlash(
194194
Display::return_message(
195195
get_lang('Sorry, this installation has a users limit, which has now been reached. To increase the number of users allowed on this Chamilo installation, please contact your hosting provider or, if available, upgrade to a superior hosting plan.'),
@@ -202,7 +202,7 @@ public static function create_user(
202202
}
203203

204204
if (1 === $status) {
205-
$hostingLimitTeachers = get_hosting_limit($access_url_id, 'hosting_limit_teachers');
205+
$hostingLimitTeachers = get_hosting_limit($access_url_id, 'teachers');
206206

207207
if ($hostingLimitTeachers !== null && $hostingLimitTeachers > 0) {
208208
$num = self::get_number_of_users(1);

public/main/install/install.lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1966,7 +1966,7 @@ function executeLexikKeyPair(\Chamilo\Kernel $kernel): void
19661966
function createExtraConfigFile(): void {
19671967
$files = [
19681968
'authentication',
1969-
'hosting_limits',
1969+
'settings_overrides',
19701970
'plugin',
19711971
];
19721972

0 commit comments

Comments
 (0)