diff --git a/profiles.php b/profiles.php new file mode 100644 index 0000000..782021c --- /dev/null +++ b/profiles.php @@ -0,0 +1,153 @@ +'; + if (in_array($view, $profile_contents)){ + $html .= ' '.$view; + } else { + $html .= ' '.$view; + } + $html .= ''; + } + return $html; +} + +// Format tabs +function format_tabs($contents) { + $rows = explode("\n", $contents); + $tab = '
'; + $tab .= 'General'; + for ($i = 0; $i < count($rows); $i++) { + preg_match('/\/\*(.*?)\*\//', $rows[$i], $match); + if ($match) { + $tab .= '' . $match[1] . ''; + } + } + $tab .= '
'; + return $tab; +} +// Format form +function format_form($contents) { + $rows = explode("\n", $contents); + $form = '
'; + for ($i = 0; $i < count($rows); $i++) { + preg_match('/\/\*(.*?)\*\//', $rows[$i], $match); + if ($match) { + $form .= '
'; + } + preg_match('/define\(\'(.*?)\', ?(.*?)\)/', $rows[$i], $match); + if ($match) { + $form .= format_var_html($match[1], $match[2]); + } + } + $form .= '
'; + + return $form; +} +if (isset($_POST['submit']) && !empty($_POST)) { + //remove submit from POST + unset($_POST['submit']); + + //Make POST ready for save into definition + foreach($_POST as $profile_name => $profile_views){ + + $view_input = ''; + foreach($profile_views as $profile_view){ + $view_input .= $profile_view.','; + } + $view_input = substr($view_input,0,-1); + // Update the configuration file with the new keys and values + $contents = preg_replace('/define\(\'' . $profile_name . '\'\, ?(.*?)\)/s', 'define(\'' . $profile_name . '\',' . $view_input . ')', $contents); + + } + //SAVE TO FILE + file_put_contents('./settings/settingsprofiles.php', $contents); + + //Return succesmessage + header('Location: index.php?page=profiles&success_msg=1'); + exit; +} + + +// Handle success messages +if (isset($_GET['success_msg'])) { + if ($_GET['success_msg'] == 1) { + $success_msg = 'Profiles updated successfully!'; + } +} + +template_header('Profiles', 'profiles'); + +$view .= ' +
+ +
+

Profiles

+ +
+'; + +if (isset($success_msg)){ + $view .= '
+ +

'.$success_msg.'

+ +
'; +} + +$view .= format_tabs($contents); +$view .= '
+
+ '; +$view .= format_form($contents); + +$view .= ' +
+
+
+'; + +//Output +echo $view; + +template_footer(); + +?> \ No newline at end of file diff --git a/settings/settingsmenu.php b/settings/settingsmenu.php index a62053f..7d2fc4e 100644 --- a/settings/settingsmenu.php +++ b/settings/settingsmenu.php @@ -16,7 +16,7 @@ $equipments_sub = array('equipments','servicereports','histories','firmwaretool' $sales_sub = array('accounts','contracts'); $admin_sub = array('users','communications','partners'); $reporting_sub = array('report_build','report_healthindex','report_usage'); -$settings_sub = array('config','language','log','maintenance'); +$settings_sub = array('config','language','log','maintenance','profiles'); //URLS $urls = array( @@ -134,6 +134,12 @@ $urls = array( "icon" => "fas fa-tachometer-alt", "name" => "menu_maintenance" ), + "profiles" => array( + "url" => "profiles", + "selected" => "profiles", + "icon" => "fas fa-tachometer-alt", + "name" => "menu_profiles" + ), "marketing" => array( "url" => "marketing&product_group=Emergency_Plug&product_content=Images", "selected" => "marketing", diff --git a/settings/settingsprofiles.php b/settings/settingsprofiles.php new file mode 100644 index 0000000..c8122fc --- /dev/null +++ b/settings/settingsprofiles.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/settings/settingsviews.php b/settings/settingsviews.php new file mode 100644 index 0000000..68b5fbf --- /dev/null +++ b/settings/settingsviews.php @@ -0,0 +1,63 @@ + \ No newline at end of file diff --git a/settings/translations/translations_DE.php b/settings/translations/translations_DE.php index 3a24bf2..98cfc8d 100644 --- a/settings/translations/translations_DE.php +++ b/settings/translations/translations_DE.php @@ -26,7 +26,7 @@ $menu_report_build = 'Bestand und Produktion'; $menu_report_healthindex= 'Healthindex'; $menu_report_usage = 'Systemnutzung'; $menu_maintenance = 'Maintenance'; - +$menu_profiles = 'Profiles'; //TABS $tab1 = 'Allgemein'; diff --git a/settings/translations/translations_NL.php b/settings/translations/translations_NL.php index a6a1669..310d3b7 100644 --- a/settings/translations/translations_NL.php +++ b/settings/translations/translations_NL.php @@ -26,6 +26,7 @@ $menu_report_build = 'Voorraad en Productie'; $menu_report_healthindex= 'Healthindex'; $menu_report_usage = 'Systeemgebruik'; $menu_maintenance = 'Maintenance'; +$menu_profiles = 'Profielen'; //TABS diff --git a/settings/translations/translations_US.php b/settings/translations/translations_US.php index 8f19e8a..f612842 100644 --- a/settings/translations/translations_US.php +++ b/settings/translations/translations_US.php @@ -26,6 +26,7 @@ $menu_report_build = 'Stock and Production'; $menu_report_healthindex= 'Healthindex'; $menu_report_usage = 'System usage'; $menu_maintenance = 'Maintenance'; +$menu_profiles = 'Profiles'; //TABS $tab1 = 'General'; diff --git a/test.php b/test.php index dd0ec71..be30123 100644 --- a/test.php +++ b/test.php @@ -9,10 +9,7 @@ include './settings/config.php'; include_once './settings/translations/translations_US.php'; include_once './settings/systemfirmware.php'; - -//define('standard_profile','dashboard,profile,equipments,equipment,histories,history,servicereports,servicereport,firmwaretool,application'); - -$allviews = ["dashboard","profile","equipments","equipment","equipmentmanage","equipment_item"]; +$allviews = explode(',' , standard_profile); $admin_profile = ["dashboard","profile","equipments","equipment"]; @@ -20,7 +17,7 @@ $view = '
'; foreach ($allviews as $view){ - if (in_array($view,$admin_profile)){ + if (in_stir($view,$admin_profile)){ $view .= ''; } else { $view .= '';