@@ -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 */
27822781function 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/**
0 commit comments