From 34a78df7a694b72b759d872e4b86be4f51bfd81f Mon Sep 17 00:00:00 2001 From: Alex <40072887+alexdcrane@users.noreply.github.com> Date: Wed, 27 Aug 2025 17:08:46 -0700 Subject: [PATCH] Create dashboard_config_json.php (#7472) * Create dashboard_config_json.php * Update dashboard_config_json.php --- core/dashboard/dashboard_config_json.php | 68 ++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 core/dashboard/dashboard_config_json.php diff --git a/core/dashboard/dashboard_config_json.php b/core/dashboard/dashboard_config_json.php new file mode 100644 index 0000000000..1d7b43f350 --- /dev/null +++ b/core/dashboard/dashboard_config_json.php @@ -0,0 +1,68 @@ + + Portions created by the Initial Developer are Copyright (C) 2025 + the Initial Developer. All Rights Reserved. +*/ + +//includes files + require_once dirname(__DIR__, 2) . "/resources/require.php"; + require_once "resources/check_auth.php"; + +//check permissions + if (permission_exists('dashboard_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//find the widget config + if (!empty($_GET['dashboard_path'])) { + $dashboard_path = $_GET['dashboard_path']; + + if (!preg_match('/^[a-zA-Z0-9\/_]+$/', $dashboard_path)) { + echo json_encode(['error' => 'Invalid dashboard path']); + exit; + } + + //find the application and widget + $dashboard_path_array = explode('/', $dashboard_path); + $application_name = $dashboard_path_array[0]; + $widget_name = $dashboard_path_array[1]; + $path_array = glob(dirname(__DIR__, 2) . '/*/' . $application_name . '/resources/dashboard/config.php'); + + if (file_exists($path_array[0])) { + include($path_array[0]); + + foreach ($array['dashboard'] as $index => $row) { + if ($row['dashboard_path'] === "$application_name/$widget_name") { + echo json_encode([ + 'chart_type_options' => $row['dashboard_chart_type_options'], + ]); + exit; + } + } + } + } + echo json_encode(['error' => 'Configuration not found']); + +?>