From 50eb494fcc55845a0bce58b119a2200cb939d634 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 24 Jul 2024 19:57:59 -0600 Subject: [PATCH] Update dashboard_edit.php - Find the dashboard tools or widgets using a glob - Use a select box to make it easier to configure --- core/dashboard/dashboard_edit.php | 43 +++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/core/dashboard/dashboard_edit.php b/core/dashboard/dashboard_edit.php index 4261736504..a02d8d5ac5 100644 --- a/core/dashboard/dashboard_edit.php +++ b/core/dashboard/dashboard_edit.php @@ -44,8 +44,8 @@ //set the defaults $dashboard_name = ''; - $dashboard_path = 'core/dashboard/resources/dashboard/icon.php'; -// $dashboard_path = ''; + $dashboard_path = '/core/dashboard/resources/dashboard/icon.php'; + //$dashboard_path = ''; $dashboard_icon = ''; $dashboard_url = ''; $dashboard_target = 'self'; @@ -429,7 +429,36 @@ } } -// adjust form by type entered +//build the $dashboard_tools array + $i = 0; + foreach(glob($_SERVER["DOCUMENT_ROOT"].'/*/*/resources/dashboard/*.php') as $value) { + + //skip adding config.php to the array + if (basename($value) === 'config.php') { + continue; + } + + //ensure the slashes are consistent + $value = str_replace('\\', '/', $value); + + //prepare the key + $key_replace[] = $_SERVER["DOCUMENT_ROOT"].'/core/'; + $key_replace[] = $_SERVER["DOCUMENT_ROOT"].'/app/'; + $key_replace[] = 'resources/dashboard/'; + $key_replace[] = '.php'; + $key = str_replace($key_replace, '', $value); + + //prepare the value + $value_replace[] = $_SERVER["DOCUMENT_ROOT"].'/'; + $value = str_replace($value_replace, '', $value); + + //build the array + $dashboard_tools[$key] = $value; + + $i++; + } + +//adjust form by type entered echo "