Skip to content

Commit 33a9660

Browse files
committed
Merge branch 'master' of github.com:chamilo/chamilo-lms
2 parents 8b479c4 + 89ac1eb commit 33a9660

File tree

22 files changed

+452
-84
lines changed

22 files changed

+452
-84
lines changed

public/main/auth/justification.php

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

1111
api_block_anonymous_users(true);
1212

13-
$allowJustification = 'true' === api_get_plugin_setting('justification', 'tool_enable');
13+
$allowJustification = Container::getPluginHelper()->isPluginEnabled('Justification');
1414

1515
if (!$allowJustification) {
1616
api_not_allowed(true);

public/main/auth/pausetraining.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

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

5+
use Chamilo\CoreBundle\Framework\Container;
6+
57
$cidReset = true;
68
require_once __DIR__.'/../inc/global.inc.php';
79

810
api_block_anonymous_users(true);
911

10-
$allow = 'true' === api_get_plugin_setting('pausetraining', 'tool_enable');
11-
$allowPauseFormation = 'true' === api_get_plugin_setting('pausetraining', 'allow_users_to_edit_pause_formation');
12+
$allow = Container::getPluginHelper()->isPluginEnabled('PauseTraining');
13+
$allowPauseFormation = 'true' === api_get_plugin_setting('PauseTraining', 'allow_users_to_edit_pause_formation');
1214

1315
if (false === $allow || false === $allowPauseFormation) {
1416
api_not_allowed(true);

public/main/auth/registration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
}
4444

4545
$pluginTccDirectoryPath = api_get_path(SYS_PLUGIN_PATH) . 'logintcc';
46-
$isTccEnabled = (is_dir($pluginTccDirectoryPath) && 'true' === api_get_plugin_setting('logintcc', 'tool_enable'));
46+
$isTccEnabled = (is_dir($pluginTccDirectoryPath) && Container::getPluginHelper()->isPluginEnabled('logintcc'));
4747
$webserviceUrl = '';
4848
$hash = '';
4949

public/main/course_info/legal.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
/* For licensing terms, see /license.txt */
33

4+
use Chamilo\CoreBundle\Framework\Container;
45
use ChamiloSession as Session;
56

67
$cidReset = true;
@@ -19,13 +20,13 @@
1920
$course_info = api_get_course_info($course_code);
2021
$course_legal = $course_info['legal'];
2122

22-
$enabled = api_get_plugin_setting('courselegal', 'tool_enable');
23+
$enabled = Container::getPluginHelper()->isPluginEnabled('CourseLegal');
2324
$pluginExtra = null;
2425
$pluginLegal = false;
2526

2627
if ('true' === $enabled) {
2728
$pluginLegal = true;
28-
require_once api_get_path(SYS_PLUGIN_PATH).'courselegal/config.php';
29+
require_once api_get_path(SYS_PLUGIN_PATH).'CourseLegal/config.php';
2930
$plugin = CourseLegalPlugin::create();
3031
$data = $plugin->getData($course_info['real_id'], $session_id);
3132

public/main/exercise/exercise_submit.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Chamilo\CoreBundle\Enums\ActionIcon;
66
use Chamilo\CoreBundle\Enums\StateIcon;
7+
use Chamilo\CoreBundle\Framework\Container;
78
use ChamiloSession as Session;
89

910
/**
@@ -180,7 +181,7 @@
180181
exit;
181182
}
182183

183-
if ('true' === api_get_plugin_setting('positioning', 'tool_enable')) {
184+
if (Container::getPluginHelper()->isPluginEnabled('Positioning')) {
184185
$plugin = Positioning::create();
185186
if ($plugin->blockFinalExercise(api_get_user_id(), $objExercise->iId, api_get_course_int_id(), $sessionId)) {
186187
api_not_allowed(true);

public/main/exercise/overview.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/* For licensing terms, see /license.txt */
44

55
use Chamilo\CoreBundle\Enums\ActionIcon;
6+
use Chamilo\CoreBundle\Framework\Container;
67

78
/**
89
* Exercise preview.
@@ -32,7 +33,7 @@
3233
api_not_allowed(true);
3334
}
3435

35-
if ('true' === api_get_plugin_setting('positioning', 'tool_enable')) {
36+
if (Container::getPluginHelper()->isPluginEnabled('Positioning')) {
3637
$plugin = Positioning::create();
3738
if ($plugin->blockFinalExercise(api_get_user_id(), $exercise_id, $courseId, $sessionId)) {
3839
api_not_allowed(true);

public/main/inc/ajax/exercise.ajax.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ function (array $exercise) {
10431043
break;
10441044
case 'sign_attempt':
10451045
api_block_anonymous_users();
1046-
if ('true' !== api_get_plugin_setting('exercise_signature', 'tool_enable')) {
1046+
if (!Container::getPluginHelper()->isPluginEnabled('ExerciseSignature')) {
10471047
exit;
10481048
}
10491049

public/main/inc/lib/NotificationEvent.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
/* For licensing terms, see /license.txt */
33

4+
use Chamilo\CoreBundle\Framework\Container;
5+
46
class NotificationEvent extends Model
57
{
68
const ACCOUNT_EXPIRATION = 1;
@@ -138,7 +140,7 @@ public function getNotificationsByUser($userId)
138140
$userInfo = api_get_user_info($userId);
139141
$events = $this->get_all();
140142
$extraFieldData = $this->getUserExtraData(api_get_user_id());
141-
$allowJustification = 'true' === api_get_plugin_setting('justification', 'tool_enable');
143+
$allowJustification = Container::getPluginHelper()->isPluginEnabled('Justification');
142144

143145
$userJustificationList = [];
144146
if ($allowJustification) {

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

Lines changed: 14 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2774,58 +2774,29 @@ function api_get_setting_in_list($variable, $option)
27742774
}
27752775

27762776
/**
2777-
* @param string $plugin
2778-
* @param string $variable
2779-
*
2780-
* @return string
2777+
* Legacy helper: read plugin setting.
2778+
* Now reads from access_url_rel_plugin.configuration (JSON) via PluginHelper.
2779+
* Keeps BC for 'tool_enable' returning 'true'/'false' strings.
27812780
*/
27822781
function api_get_plugin_setting($plugin, $variable)
27832782
{
2784-
$variableName = $plugin.'_'.$variable;
2785-
//$result = api_get_setting($variableName);
2786-
$params = [
2787-
'category = ? AND subkey = ? AND variable = ?' => [
2788-
'Plugins',
2789-
$plugin,
2790-
$variableName,
2791-
],
2792-
];
2793-
$table = Database::get_main_table(TABLE_MAIN_SETTINGS);
2794-
$result = Database::select(
2795-
'selected_value',
2796-
$table,
2797-
['where' => $params],
2798-
'one'
2799-
);
2800-
if ($result) {
2801-
$value = $result['selected_value'];
2802-
$serializedValue = @unserialize($result['selected_value'], []);
2803-
if (false !== $serializedValue) {
2804-
$value = $serializedValue;
2805-
}
2783+
$helper = \Chamilo\CoreBundle\Framework\Container::getPluginHelper();
28062784

2807-
return $value;
2785+
// Preserve legacy expectation for tool_enable as string 'true'/'false'
2786+
if ($variable === 'tool_enable') {
2787+
return $helper->isPluginEnabled((string) $plugin) ? 'true' : 'false';
28082788
}
28092789

2810-
return null;
2811-
/// Old code
2790+
$value = $helper->getPluginConfigValue((string) $plugin, (string) $variable, null);
28122791

2813-
$variableName = $plugin.'_'.$variable;
2814-
$result = api_get_setting($variableName);
2815-
2816-
if (isset($result[$plugin])) {
2817-
$value = $result[$plugin];
2818-
2819-
$unserialized = UnserializeApi::unserialize('not_allowed_classes', $value, true);
2820-
2821-
if (false !== $unserialized) {
2822-
$value = $unserialized;
2823-
}
2824-
2825-
return $value;
2792+
// BC: many legacy callers expect strings; normalize booleans to 'true'/'false'
2793+
if (\is_bool($value)) {
2794+
return $value ? 'true' : 'false';
28262795
}
28272796

2828-
return null;
2797+
// If the value is serialized in old code paths, keep it as-is.
2798+
// For arrays/objects coming from JSON config, return them directly.
2799+
return $value;
28292800
}
28302801

28312802
/**

public/main/inc/lib/course.lib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4384,7 +4384,7 @@ public static function is_user_accepted_legal($user_id, $course_code, $session_i
43844384
$courseId = $courseInfo['real_id'];
43854385

43864386
// Course legal
4387-
$enabled = api_get_plugin_setting('courselegal', 'tool_enable');
4387+
$enabled = Container::getPluginHelper()->isPluginEnabled('CourseLegal');
43884388

43894389
if ('true' == $enabled) {
43904390
require_once api_get_path(SYS_PLUGIN_PATH).'courselegal/config.php';
@@ -4439,7 +4439,7 @@ public static function save_user_legal($user_id, $courseInfo, $session_id = 0)
44394439
$course_code = $courseInfo['code'];
44404440

44414441
// Course plugin legal
4442-
$enabled = api_get_plugin_setting('courselegal', 'tool_enable');
4442+
$enabled = Container::getPluginHelper()->isPluginEnabled('CourseLegal');
44434443
if ('true' == $enabled) {
44444444
require_once api_get_path(SYS_PLUGIN_PATH).'courselegal/config.php';
44454445
$plugin = CourseLegalPlugin::create();

0 commit comments

Comments
 (0)