Sfoglia il codice sorgente

Simplify the dashboard path

FusionPBX 1 anno fa
parent
commit
24bb799000

+ 4 - 0
core/dashboard/app_defaults.php

@@ -118,6 +118,9 @@ if ($domains_processed == 1) {
 	//update dashboard icons to be prefixed with v6.x font awesome style class name (e.g. 'fa-solid ')
 		$queries[] = "update v_dashboard set dashboard_icon = concat('fa-solid ', dashboard_icon) where dashboard_icon is not null and dashboard_icon not like 'fa-solid fa-%' and dashboard_icon not like 'fa-regular fa-%' and dashboard_icon not like 'fa-brands fa-%' ";
 
+	//simplify the dashboard path
+		$queries[] = "update v_dashboard set dashboard_path =  regexp_replace(dashboard_path, 'app/|core/|resources/dashboard/|\.php', '', 'g') where dashboard_path like '%.php';";
+
 	//execute array of queries
 		foreach ($queries as $sql) {
 			$database = new database;
@@ -128,3 +131,4 @@ if ($domains_processed == 1) {
 }
 
 ?>
+

+ 30 - 30
core/dashboard/dashboard_edit.php

@@ -44,7 +44,7 @@
 
 //set the defaults
 	$dashboard_name = '';
-	$dashboard_path = '/core/dashboard/resources/dashboard/icon.php';
+	$dashboard_path = 'dashboard/icon';
  	//$dashboard_path = '';
 	$dashboard_icon = '';
 	$dashboard_url = '';
@@ -479,11 +479,11 @@
 //adjust form by type entered
 	echo "<script>\n";
 	echo "	function adjust_form() {\n";
-	echo "		if ($('#dashboard_path').val() == 'core/dashboard/resources/dashboard/icon.php') {\n";
+	echo "		if ($('#dashboard_path').val() == 'dashboard/icon') {\n";
 	echo "			$('.type_content').hide();\n";
 	echo "			$('.type_icon').show();\n";
 	echo "		}\n";
-	echo "		else if ($('#dashboard_path').val() == 'core/dashboard/resources/dashboard/content.php') {\n";
+	echo "		else if ($('#dashboard_path').val() == 'dashboard/content') {\n";
 	echo "			$('.type_icon').hide();\n";
 	echo "			$('.type_content').show();\n";
 	echo "		}\n";
@@ -548,7 +548,7 @@
 	echo "	<select name='dashboard_path' class='formfld' id='dashboard_path' onchange=\"adjust_form();\">\n";
 	echo "		<option value=''></option>\n";
 	foreach($dashboard_tools as $key => $value) {
-		echo "		<option value='$value' ".($value == $dashboard_path ? "selected='selected'" : null).">".$key."</option>\n";
+		echo "		<option value='$key' ".($key == $dashboard_path ? "selected='selected'" : null).">".$key."</option>\n";
 	}
 	echo "	</select>\n";
 	echo "<br />\n";
@@ -558,9 +558,9 @@
 
 	if (
 		$action == "add" ||
-		$dashboard_path == "core/dashboard/resources/dashboard/icon.php"
+		$dashboard_path == "dashboard/icon"
 		) {
-		echo "	<tr class='type_icon' ".($dashboard_path != 'core/dashboard/resources/dashboard/icon.php' ? "style='display: none;'" : null).">";
+		echo "	<tr class='type_icon' ".($dashboard_path != 'dashboard/icon' ? "style='display: none;'" : null).">";
 		echo "		<td class='vncell'>".$text['label-icon']."</td>";
 		echo "		<td class='vtable' style='vertical-align: bottom;'>";
 		if (file_exists($_SERVER["PROJECT_ROOT"].'/resources/fontawesome/fa_icons.php')) {
@@ -610,7 +610,7 @@
 		echo "		</td>";
 		echo "	</tr>";
 
-		echo "<tr class='type_icon' ".($dashboard_path != 'core/dashboard/resources/dashboard/icon.php' ? "style='display: none;'" : null).">\n";
+		echo "<tr class='type_icon' ".($dashboard_path != 'dashboard/icon' ? "style='display: none;'" : null).">\n";
 		echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
 		echo "	".$text['label-link']."\n";
 		echo "</td>\n";
@@ -622,7 +622,7 @@
 		echo "</td>\n";
 		echo "</tr>\n";
 
-		echo "<tr class='type_icon' ".($dashboard_path != 'core/dashboard/resources/dashboard/icon.php' ? "style='display: none;'" : null).">\n";
+		echo "<tr class='type_icon' ".($dashboard_path != 'dashboard/icon' ? "style='display: none;'" : null).">\n";
 		echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
 		echo "	".$text['label-width']."\n";
 		echo "</td>\n";
@@ -634,7 +634,7 @@
 		echo "</td>\n";
 		echo "</tr>\n";
 
-		echo "<tr class='type_icon' ".($dashboard_path != 'core/dashboard/resources/dashboard/icon.php' ? "style='display: none;'" : null).">\n";
+		echo "<tr class='type_icon' ".($dashboard_path != 'dashboard/icon' ? "style='display: none;'" : null).">\n";
 		echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
 		echo "	".$text['label-height']."\n";
 		echo "</td>\n";
@@ -646,7 +646,7 @@
 		echo "</td>\n";
 		echo "</tr>\n";
 
-		echo "<tr class='type_icon' ".($dashboard_path != 'core/dashboard/resources/dashboard/icon.php' ? "class='type_icon' style='display: none;'" : null).">\n";
+		echo "<tr class='type_icon' ".($dashboard_path != 'dashboard/icon' ? "class='type_icon' style='display: none;'" : null).">\n";
 		echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
 		echo $text['label-target']."\n";
 		echo "</td>\n";
@@ -663,9 +663,9 @@
 
 	if (
 		$action == "add" ||
-		$dashboard_path == "core/dashboard/resources/dashboard/content.php"
+		$dashboard_path == "dashboard/content"
 		) {
-		echo "<tr class='type_content' ".($dashboard_path != 'core/dashboard/resources/dashboard/content.php' ? "style='display: none;'" : null).">\n";
+		echo "<tr class='type_content' ".($dashboard_path != 'dashboard/content' ? "style='display: none;'" : null).">\n";
 		echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
 		echo "	".$text['label-content']."\n";
 		echo "</td>\n";
@@ -676,7 +676,7 @@
 		echo "</td>\n";
 		echo "</tr>\n";
 
-		echo "<tr class='type_content' ".($dashboard_path != 'core/dashboard/resources/dashboard/content.php' ? "style='display: none;'" : null).">\n";
+		echo "<tr class='type_content' ".($dashboard_path != 'dashboard/content' ? "style='display: none;'" : null).">\n";
 		echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
 		echo "	".$text['label-dashboard_content_text_align']."\n";
 		echo "</td>\n";
@@ -693,10 +693,10 @@
 
 	if (
 		$action == "add" ||
-		$dashboard_path == "core/dashboard/resources/dashboard/content.php" ||
-		$dashboard_path == "core/dashboard/resources/dashboard/icon.php"
+		$dashboard_path == "dashboard/content" ||
+		$dashboard_path == "dashboard/icon"
 		) {
-		echo "<tr class='type_icon type_content' ".($dashboard_path != 'core/dashboard/resources/dashboard/content.php' && $dashboard_path != 'core/dashboard/resources/dashboard/icon.php' ? "style='display: none;'" : null).">\n";
+		echo "<tr class='type_icon type_content' ".($dashboard_path != 'dashboard/content' && $dashboard_path != 'dashboard/icon' ? "style='display: none;'" : null).">\n";
 		echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
 		echo "	".$text['label-details']."\n";
 		echo "</td>\n";
@@ -752,18 +752,18 @@
 
 	if (
 		$action == "add" ||
-		$dashboard_path == "app/voicemails/resources/dashboard/voicemails.php" ||
-		$dashboard_path == "app/xml_cdr/resources/dashboard/missed_calls.php" ||
-		$dashboard_path == "app/xml_cdr/resources/dashboard/recent_calls.php" ||
-		$dashboard_path == "app/system/resources/dashboard/system_status.php" ||
-		$dashboard_path == "app/system/resources/dashboard/system_cpu_status.php" ||
-		$dashboard_path == "app/system/resources/dashboard/system_counts.php" ||
-		$dashboard_path == "app/switch/resources/dashboard/switch_status.php" ||
-		$dashboard_path == "app/domain_limits/resources/dashboard/domain_limits.php" ||
-		$dashboard_path == "app/call_forward/resources/dashboard/call_forward.php" ||
-		$dashboard_path == "app/ring_groups/resources/dashboard/ring_group_forward.php" ||
-		$dashboard_path == "app/extensions/resources/dashboard/caller_id.php" ||
-		$dashboard_path == "app/maintenance/resources/dashboard/maintenance.php"
+		$dashboard_path == "voicemails/voicemails" ||
+		$dashboard_path == "xml_cdr/missed_calls" ||
+		$dashboard_path == "xml_cdr/recent_calls" ||
+		$dashboard_path == "system/system_status" ||
+		$dashboard_path == "system/system_cpu_status" ||
+		$dashboard_path == "system/system_counts" ||
+		$dashboard_path == "switch/switch_status" ||
+		$dashboard_path == "domain_limits/domain_limits" ||
+		$dashboard_path == "call_forward/call_forward" ||
+		$dashboard_path == "ring_groups/ring_group_forward" ||
+		$dashboard_path == "extensions/caller_id" ||
+		$dashboard_path == "maintenance/maintenance"
 		) {
 		echo "<tr class='type_chart' ".($action == "add" ? "style='display: none;'" : null).">\n";
 		echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
@@ -814,8 +814,8 @@
 	echo "</td>\n";
 	echo "</tr>\n";
 
-	if ($action == "add" || $dashboard_path == "core/dashboard/resources/dashboard/icon.php") {
-		echo "<tr class='type_icon type_label' ".($dashboard_path != 'core/dashboard/resources/dashboard/icon.php' || $dashboard_label_enabled != 'true' ? "style='display: none;'" : null).">\n";
+	if ($action == "add" || $dashboard_path == "dashboard/icon") {
+		echo "<tr class='type_icon type_label' ".($dashboard_path != 'dashboard/icon' || $dashboard_label_enabled != 'true' ? "style='display: none;'" : null).">\n";
 		echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
 		echo $text['label-dashboard_label_text_color_hover']."\n";
 		echo "</td>\n";

+ 14 - 2
core/dashboard/index.php

@@ -309,7 +309,7 @@ foreach ($dashboard as $row) {
 		echo "	align-content: center;\n";
 		echo "}\n";
 	}
-	if ($row['dashboard_path'] == "core/dashboard/resources/dashboard/icon.php") {
+	if ($row['dashboard_path'] == "dashboard/icon") {
 		echo "#".$dashboard_name." div.hud_content,\n";
 		echo "#".$dashboard_name." span.hud_title,\n";
 		echo "#".$dashboard_name." span.hud_stat {\n";
@@ -505,8 +505,19 @@ function toggle_grid_row_end_all() {
 		}
 
 		echo "<div class='widget' style='grid-row-end: span ".$dashboard_row_span.";' data-state='".$dashboard_details_state."' id='".trim(preg_replace("/[^a-z]/", '_', strtolower($dashboard_name)),'_')."' draggable='false'>\n";
-		include $row['dashboard_path'];
+		$dashboard_path_array = explode('/', $row['dashboard_path']);
+		$path_array = glob(dirname(__DIR__, 2).'/*/'.$dashboard_path_array[0].'/resources/dashboard/'.$dashboard_path_array[1].'.php');
+		include $path_array[0];
+		//$file_name = dirname(__DIR__, 2).'/app/'.$dashboard_path_array[0].'/resources/dashboard/'.$dashboard_path_array[1].'.php';
+		//if (file_exists(dirname(__DIR__, 2).'/core/'.$dashboard_path_array[0].'/resources/dashboard/'.$dashboard_path_array[1].'.php')) {
+		//	include dirname(__DIR__, 2).'/core/'.$dashboard_path_array[0].'/resources/dashboard/'.$dashboard_path_array[1].'.php';
+		//}
+		//elseif (file_exists(dirname(__DIR__, 2).'/app/'.$dashboard_path_array[0].'/resources/dashboard/'.$dashboard_path_array[1].'.php')) {
+		//	include dirname(__DIR__, 2).'/app/'.$dashboard_path_array[0].'/resources/dashboard/'.$dashboard_path_array[1].'.php';
+		//}
+
 		echo "</div>\n";
+
 		$x++;
 	}
 	echo "</div>\n";
@@ -611,3 +622,4 @@ function toggle_grid_row_end_all() {
 	require_once "resources/footer.php";
 
 ?>
+

+ 3 - 3
core/users/resources/dashboard/config.php

@@ -3,7 +3,7 @@
 //users icon
 $array['dashboard'][$x]['dashboard_uuid'] = '57fd7761-6ffb-4a11-bdf0-4ce632f50c3c';
 $array['dashboard'][$x]['dashboard_name'] = 'Users';
-$array['dashboard'][$x]['dashboard_path'] = 'core/dashboard/resources/dashboard/icon.php';
+$array['dashboard'][$x]['dashboard_path'] = 'dashboard/icon';
 $array['dashboard'][$x]['dashboard_icon'] = 'fa-solid fa-user-group';
 $array['dashboard'][$x]['dashboard_url'] = '/core/users/users.php';
 $array['dashboard'][$x]['dashboard_target'] = 'self';
@@ -43,7 +43,7 @@ $x++;
 //account settings icon
 $array['dashboard'][$x]['dashboard_uuid'] = '8aa9bb66-7a62-4a90-b52e-68bd4ccf325f';
 $array['dashboard'][$x]['dashboard_name'] = 'Account Settings';
-$array['dashboard'][$x]['dashboard_path'] = 'core/dashboard/resources/dashboard/icon.php';
+$array['dashboard'][$x]['dashboard_path'] = 'dashboard/icon';
 $array['dashboard'][$x]['dashboard_icon'] = 'fa-solid fa-user-gear';
 $array['dashboard'][$x]['dashboard_url'] = '/core/users/user_edit.php?id=user';
 $array['dashboard'][$x]['dashboard_target'] = 'self';
@@ -79,7 +79,7 @@ $x++;
 //logout icon
 $array['dashboard'][$x]['dashboard_uuid'] = 'b04ad600-9acc-45e5-a89a-d7a59a6fcb4c';
 $array['dashboard'][$x]['dashboard_name'] = 'Logout';
-$array['dashboard'][$x]['dashboard_path'] = 'core/dashboard/resources/dashboard/icon.php';
+$array['dashboard'][$x]['dashboard_path'] = 'dashboard/icon';
 $array['dashboard'][$x]['dashboard_icon'] = 'fa-solid fa-right-from-bracket';
 $array['dashboard'][$x]['dashboard_url'] = '/logout.php';
 $array['dashboard'][$x]['dashboard_target'] = 'self';