2021-11-10 02:42:14 +01:00
< ? php
if ( $domains_processed == 1 ) {
//clear the array if it exists
if ( isset ( $array )) {
unset ( $array );
}
2021-12-04 02:05:00 +01:00
//make the default groups exist
$group = new groups ;
$group -> defaults ();
2021-11-10 02:42:14 +01:00
//get the groups
$sql = " select * from v_groups " ;
$sql .= " where domain_uuid is null " ;
2023-05-17 18:07:49 +02:00
$groups = $database -> select ( $sql , null , 'all' );
2021-11-10 02:42:14 +01:00
2021-11-24 04:29:29 +01:00
//get the dashboard
$sql = " select " ;
$sql .= " dashboard_uuid, " ;
$sql .= " dashboard_name, " ;
$sql .= " dashboard_path, " ;
$sql .= " dashboard_order, " ;
$sql .= " cast(dashboard_enabled as text), " ;
$sql .= " dashboard_description " ;
$sql .= " from v_dashboard " ;
2023-05-17 18:07:49 +02:00
$dashboard_widgets = $database -> select ( $sql , null , 'all' );
2021-11-24 04:29:29 +01:00
unset ( $sql , $parameters );
2021-11-10 02:42:14 +01:00
//add the dashboard widgets
$config_files = glob ( $_SERVER [ " DOCUMENT_ROOT " ] . PROJECT_PATH . '/*/*/resources/dashboard/config.php' );
$x = 0 ;
foreach ( $config_files as $file ) {
include ( $file );
$x ++ ;
}
$widgets = $array ;
unset ( $array );
//build the array
$x = 0 ;
foreach ( $widgets [ 'dashboard' ] as $row ) {
2021-11-24 04:29:29 +01:00
//check if the dashboard widget is already in the database
$dashboard_found = false ;
foreach ( $dashboard_widgets as $dashboard_widget ) {
if ( $dashboard_widget [ 'dashboard_uuid' ] == $row [ 'dashboard_uuid' ]) {
$dashboard_found = true ;
}
}
//add the dashboard widget to the array
if ( ! $dashboard_found ) {
$array [ 'dashboard' ][ $x ][ 'dashboard_uuid' ] = $row [ 'dashboard_uuid' ];
$array [ 'dashboard' ][ $x ][ 'dashboard_name' ] = $row [ 'dashboard_name' ];
$array [ 'dashboard' ][ $x ][ 'dashboard_path' ] = $row [ 'dashboard_path' ];
2025-03-27 22:41:38 +01:00
$array [ 'dashboard' ][ $x ][ 'dashboard_chart_type' ] = $row [ 'dashboard_chart_type' ];
2024-06-17 23:24:23 +02:00
$array [ 'dashboard' ][ $x ][ 'dashboard_column_span' ] = $row [ 'dashboard_column_span' ] ? ? 1 ;
2025-03-27 22:41:38 +01:00
$array [ 'dashboard' ][ $x ][ 'dashboard_row_span' ] = $row [ 'dashboard_row_span' ] ? ? 1 ;
$array [ 'dashboard' ][ $x ][ 'dashboard_details_state' ] = $row [ 'dashboard_details_state' ];
2021-11-24 04:29:29 +01:00
$array [ 'dashboard' ][ $x ][ 'dashboard_order' ] = $row [ 'dashboard_order' ];
$array [ 'dashboard' ][ $x ][ 'dashboard_enabled' ] = $row [ 'dashboard_enabled' ];
$array [ 'dashboard' ][ $x ][ 'dashboard_description' ] = $row [ 'dashboard_description' ];
2024-08-15 01:44:11 +02:00
$array [ 'dashboard' ][ $x ][ 'dashboard_label_enabled' ] = $row [ 'dashboard_label_enabled' ] ? ? 'true' ;
if ( ! empty ( $row [ 'dashboard_label_text_color' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_label_text_color' ] = $row [ 'dashboard_label_text_color' ]; }
if ( ! empty ( $row [ 'dashboard_label_text_color_hover' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_label_text_color_hover' ] = $row [ 'dashboard_label_text_color_hover' ]; }
2024-06-17 23:24:23 +02:00
if ( ! empty ( $row [ 'dashboard_number_text_color' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_number_text_color' ] = $row [ 'dashboard_number_text_color' ]; }
2024-06-22 00:44:31 +02:00
if ( ! empty ( $row [ 'dashboard_number_text_color_hover' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_number_text_color_hover' ] = $row [ 'dashboard_number_text_color_hover' ]; }
2024-12-12 05:28:45 +01:00
if ( ! empty ( $row [ 'dashboard_number_background_color' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_number_background_color' ] = $row [ 'dashboard_number_background_color' ]; }
2024-06-17 23:24:23 +02:00
if ( ! empty ( $row [ 'dashboard_icon' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_icon' ] = $row [ 'dashboard_icon' ]; }
2024-12-12 05:28:45 +01:00
if ( ! empty ( $row [ 'dashboard_icon_color' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_icon_color' ] = $row [ 'dashboard_icon_color' ]; }
2024-06-17 23:24:23 +02:00
if ( ! empty ( $row [ 'dashboard_url' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_url' ] = $row [ 'dashboard_url' ]; }
2024-08-02 07:34:30 +02:00
if ( ! empty ( $row [ 'dashboard_width' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_width' ] = $row [ 'dashboard_width' ]; }
if ( ! empty ( $row [ 'dashboard_height' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_height' ] = $row [ 'dashboard_height' ]; }
2024-06-17 23:24:23 +02:00
if ( ! empty ( $row [ 'dashboard_target' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_target' ] = $row [ 'dashboard_target' ]; }
2024-08-15 01:44:11 +02:00
if ( ! empty ( $row [ 'dashboard_label_background_color' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_label_background_color' ] = $row [ 'dashboard_label_background_color' ]; }
2025-03-26 21:57:24 +01:00
if ( ! empty ( $row [ 'dashboard_label_background_color_hover' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_label_background_color_hover' ] = $row [ 'dashboard_label_background_color_hover' ]; }
2024-06-17 23:24:23 +02:00
if ( ! empty ( $row [ 'dashboard_background_color' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_background_color' ] = $row [ 'dashboard_background_color' ]; }
2024-08-23 01:59:12 +02:00
if ( ! empty ( $row [ 'dashboard_background_color_hover' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_background_color_hover' ] = $row [ 'dashboard_background_color_hover' ]; }
2024-06-17 23:24:23 +02:00
if ( ! empty ( $row [ 'dashboard_detail_background_color' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_detail_background_color' ] = $row [ 'dashboard_detail_background_color' ]; }
if ( ! empty ( $row [ 'dashboard_content' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_content' ] = $row [ 'dashboard_content' ]; }
if ( ! empty ( $row [ 'dashboard_content_details' ])) { $array [ 'dashboard' ][ $x ][ 'dashboard_content_details' ] = $row [ 'dashboard_content_details' ]; }
2021-11-24 04:29:29 +01:00
$y = 0 ;
2023-05-17 18:07:49 +02:00
if ( ! empty ( $row [ 'dashboard_groups' ])) {
2021-11-24 04:29:29 +01:00
foreach ( $row [ 'dashboard_groups' ] as $row ) {
if ( isset ( $row [ 'group_name' ])) {
foreach ( $groups as $field ) {
if ( $row [ 'group_name' ] == $field [ 'group_name' ]) {
$array [ 'dashboard' ][ $x ][ 'dashboard_groups' ][ $y ][ 'dashboard_group_uuid' ] = $row [ 'dashboard_group_uuid' ];
$array [ 'dashboard' ][ $x ][ 'dashboard_groups' ][ $y ][ 'dashboard_uuid' ] = $row [ 'dashboard_uuid' ];
$array [ 'dashboard' ][ $x ][ 'dashboard_groups' ][ $y ][ 'group_uuid' ] = $field [ 'group_uuid' ];
}
2021-11-10 02:42:14 +01:00
}
2021-11-24 04:29:29 +01:00
$y ++ ;
2021-11-10 02:42:14 +01:00
}
}
}
$x ++ ;
2021-11-24 04:29:29 +01:00
}
2021-11-10 02:42:14 +01:00
}
2021-11-10 18:15:00 +01:00
//add the temporary permissions
2024-11-29 21:57:01 +01:00
$p = permissions :: new ();
2021-11-10 18:15:00 +01:00
$p -> add ( 'dashboard_add' , 'temp' );
$p -> add ( 'dashboard_group_add' , 'temp' );
2021-11-10 02:42:14 +01:00
//save the data
2023-05-17 18:07:49 +02:00
if ( ! empty ( $array )) {
2021-11-24 04:29:29 +01:00
$database -> app_name = 'dashboard' ;
$database -> app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7' ;
2021-12-24 20:36:18 +01:00
$database -> save ( $array , false );
2021-11-24 04:29:29 +01:00
//$result = $database->message;
//view_array($result);
}
2021-11-10 02:42:14 +01:00
2021-11-10 18:15:00 +01:00
//delete the temporary permissions
$p -> delete ( 'dashboard_add' , 'temp' );
$p -> delete ( 'dashboard_group_add' , 'temp' );
2024-08-10 02:14:52 +02:00
//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-%' " ;
2024-08-22 00:58:44 +02:00
//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'; " ;
2024-08-10 02:14:52 +02:00
//execute array of queries
foreach ( $queries as $sql ) {
$database -> execute ( $sql );
}
unset ( $queries , $sql );
2021-11-10 02:42:14 +01:00
}
2024-08-15 01:44:11 +02:00
?>