Profilesetup
This commit is contained in:
@@ -608,7 +608,7 @@ function getProfile($profile, $permission){
|
|||||||
else {
|
else {
|
||||||
switch ($permission) {
|
switch ($permission) {
|
||||||
case '4': //Admin++
|
case '4': //Admin++
|
||||||
$profile = admin_profile;
|
$profile = adminplus_profile;
|
||||||
break;
|
break;
|
||||||
case '3': //Admin
|
case '3': //Admin
|
||||||
$profile = admin_profile;
|
$profile = admin_profile;
|
||||||
|
|||||||
151
profiles.php
Normal file
151
profiles.php
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
<?php
|
||||||
|
defined(page_security_key) or exit;
|
||||||
|
|
||||||
|
// Configuration file
|
||||||
|
$file = './settings/settingsprofiles.php';
|
||||||
|
|
||||||
|
$page = 'profiles';
|
||||||
|
//Check if allowed
|
||||||
|
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
|
||||||
|
header('location: index.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open the configuration file for reading
|
||||||
|
$contents = file_get_contents($file);
|
||||||
|
|
||||||
|
//empty view
|
||||||
|
$view = '';
|
||||||
|
|
||||||
|
// Format key function
|
||||||
|
function format_key($key) {
|
||||||
|
$key = str_replace(
|
||||||
|
['_', 'url', 'db ', ' pass', ' user', 'ipn', 'paypal'],
|
||||||
|
[' ', 'URL', 'Database ', ' Password', ' Username', 'IPN', 'PayPal'],
|
||||||
|
strtolower($key)
|
||||||
|
);
|
||||||
|
return ucwords($key);
|
||||||
|
}
|
||||||
|
// Format HTML output function
|
||||||
|
function format_var_html($key, $value) {
|
||||||
|
|
||||||
|
include dirname(__FILE__).'/settings/settingsviews.php';
|
||||||
|
|
||||||
|
$html = '';
|
||||||
|
$value = htmlspecialchars(trim($value, '\''), ENT_QUOTES);
|
||||||
|
|
||||||
|
$profile_contents = explode(',',$value);
|
||||||
|
|
||||||
|
foreach ($all_views as $view){
|
||||||
|
$html .= '<div>';
|
||||||
|
if (in_array($view, $profile_contents)){
|
||||||
|
$html .= '<input type="checkbox" id="'.$key .'" name="'.$key .'[]" value="'.$view.'" checked> '.$view;
|
||||||
|
} else {
|
||||||
|
$html .= '<input type="checkbox" id="'.$key .'" name="'.$key .'[]" value="'.$view.'"> '.$view;
|
||||||
|
}
|
||||||
|
$html .= '</div>';
|
||||||
|
}
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format tabs
|
||||||
|
function format_tabs($contents) {
|
||||||
|
$rows = explode("\n", $contents);
|
||||||
|
$tab = '<div class="tabs">';
|
||||||
|
$tab .= '<a href="#" class="active">General</a>';
|
||||||
|
for ($i = 0; $i < count($rows); $i++) {
|
||||||
|
preg_match('/\/\*(.*?)\*\//', $rows[$i], $match);
|
||||||
|
if ($match) {
|
||||||
|
$tab .= '<a href="#">' . $match[1] . '</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$tab .= '</div>';
|
||||||
|
return $tab;
|
||||||
|
}
|
||||||
|
// Format form
|
||||||
|
function format_form($contents) {
|
||||||
|
$rows = explode("\n", $contents);
|
||||||
|
$form = '<div class="tab-content active">Each tab represents a profile. Each element in a profile represents a view and or API access.';
|
||||||
|
for ($i = 0; $i < count($rows); $i++) {
|
||||||
|
preg_match('/\/\*(.*?)\*\//', $rows[$i], $match);
|
||||||
|
if ($match) {
|
||||||
|
$form .= '</div><div class="tab-content">';
|
||||||
|
}
|
||||||
|
preg_match('/define\(\'(.*?)\', ?(.*?)\)/', $rows[$i], $match);
|
||||||
|
if ($match) {
|
||||||
|
$form .= format_var_html($match[1], $match[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$form .= '</div>';
|
||||||
|
|
||||||
|
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 .= '
|
||||||
|
<form action="" method="post">
|
||||||
|
|
||||||
|
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
|
||||||
|
<h2 class="responsive-width-100">Profiles</h2>
|
||||||
|
<input type="submit" name="submit" value="Save" class="btn">
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
if (isset($success_msg)){
|
||||||
|
$view .= ' <div class="msg success">
|
||||||
|
<i class="fas fa-check-circle"></i>
|
||||||
|
<p>'.$success_msg.'</p>
|
||||||
|
<i class="fas fa-times"></i>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$view .= format_tabs($contents);
|
||||||
|
$view .= '<div class="content-block">
|
||||||
|
<div class="form responsive-width-100">
|
||||||
|
';
|
||||||
|
$view .= format_form($contents);
|
||||||
|
|
||||||
|
$view .= '
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
';
|
||||||
|
|
||||||
|
//Output
|
||||||
|
echo $view;
|
||||||
|
|
||||||
|
template_footer();
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -16,7 +16,7 @@ $equipments_sub = array('equipments','servicereports','histories','firmwaretool'
|
|||||||
$sales_sub = array('accounts','contracts');
|
$sales_sub = array('accounts','contracts');
|
||||||
$admin_sub = array('users','communications','partners');
|
$admin_sub = array('users','communications','partners');
|
||||||
$reporting_sub = array('report_build','report_healthindex','report_usage');
|
$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
|
||||||
$urls = array(
|
$urls = array(
|
||||||
@@ -134,6 +134,12 @@ $urls = array(
|
|||||||
"icon" => "fas fa-tachometer-alt",
|
"icon" => "fas fa-tachometer-alt",
|
||||||
"name" => "menu_maintenance"
|
"name" => "menu_maintenance"
|
||||||
),
|
),
|
||||||
|
"profiles" => array(
|
||||||
|
"url" => "profiles",
|
||||||
|
"selected" => "profiles",
|
||||||
|
"icon" => "fas fa-tachometer-alt",
|
||||||
|
"name" => "menu_profiles"
|
||||||
|
),
|
||||||
"marketing" => array(
|
"marketing" => array(
|
||||||
"url" => "marketing&product_group=Emergency_Plug&product_content=Images",
|
"url" => "marketing&product_group=Emergency_Plug&product_content=Images",
|
||||||
"selected" => "marketing",
|
"selected" => "marketing",
|
||||||
|
|||||||
20
settings/settingsprofiles.php
Normal file
20
settings/settingsprofiles.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
/*Standard*/
|
||||||
|
define('standard_profile','dashboard,profile,equipments,equipment,histories,history,firmwaretool,servicereports,servicereport,application');
|
||||||
|
/*Superuser*/
|
||||||
|
define('superuser_profile','dashboard,profile,sales,contracts,contract,contract_manage,assets,equipments,equipment,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,products,products_versions,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,marketing,application');
|
||||||
|
/*Service*/
|
||||||
|
define('service','dashboard,profile,assets,equipments,equipment,equipment_manage,histories,history,history_manage,firmwaretool,servicereports,servicereport,admin,partners,partner,marketing,application');
|
||||||
|
/*Admin*/
|
||||||
|
define('admin_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,buildtool,products,products_versions,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_healthindex,report_usage,application');
|
||||||
|
/*AdminPlus*/
|
||||||
|
define('adminplus_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,buildtool,products,products_versions,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_healthindex,report_usage,config,settings,logfile,changelog,language,application,maintenance,profiles');
|
||||||
|
/*Build*/
|
||||||
|
define('build','buildtool,buildtool,application');
|
||||||
|
/*Distribution*/
|
||||||
|
define('distribution','');
|
||||||
|
/*Firmware*/
|
||||||
|
define('firmware','firmwaretool,application');
|
||||||
|
/*Interface*/
|
||||||
|
define('interface','application');
|
||||||
|
?>
|
||||||
63
settings/settingsviews.php
Normal file
63
settings/settingsviews.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// All individual views and APIs - Profile ++++++++++++++
|
||||||
|
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
$all_views = [
|
||||||
|
"dashboard",
|
||||||
|
"profile",
|
||||||
|
"buildtool",
|
||||||
|
"sales",
|
||||||
|
"accounts",
|
||||||
|
"account",
|
||||||
|
"contracts",
|
||||||
|
"contract",
|
||||||
|
"contract_manage",
|
||||||
|
"cartests",
|
||||||
|
"cartest",
|
||||||
|
"cartest_manage",
|
||||||
|
"assets",
|
||||||
|
"equipments",
|
||||||
|
"equipment",
|
||||||
|
"equipment_healthindex",
|
||||||
|
"equipment_data",
|
||||||
|
"equipment_manage",
|
||||||
|
"equipment_manage_edit",
|
||||||
|
"equipments_mass_update",
|
||||||
|
"histories",
|
||||||
|
"history",
|
||||||
|
"history_manage",
|
||||||
|
"firmwaretool",
|
||||||
|
"buildtool",
|
||||||
|
"products",
|
||||||
|
"products_versions",
|
||||||
|
"product",
|
||||||
|
"product_manage",
|
||||||
|
"servicereports",
|
||||||
|
"servicereport",
|
||||||
|
"admin",
|
||||||
|
"partners",
|
||||||
|
"partner",
|
||||||
|
"users",
|
||||||
|
"user",
|
||||||
|
"user_manage",
|
||||||
|
"communications",
|
||||||
|
"communication",
|
||||||
|
"communication_send",
|
||||||
|
"marketing",
|
||||||
|
"reporting",
|
||||||
|
"report_build",
|
||||||
|
"report_healthindex",
|
||||||
|
"report_usage",
|
||||||
|
"config",
|
||||||
|
"settings",
|
||||||
|
"logfile",
|
||||||
|
"changelog",
|
||||||
|
"language",
|
||||||
|
"application",
|
||||||
|
"maintenance",
|
||||||
|
"profiles"
|
||||||
|
];
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -26,7 +26,7 @@ $menu_report_build = 'Bestand und Produktion';
|
|||||||
$menu_report_healthindex= 'Healthindex';
|
$menu_report_healthindex= 'Healthindex';
|
||||||
$menu_report_usage = 'Systemnutzung';
|
$menu_report_usage = 'Systemnutzung';
|
||||||
$menu_maintenance = 'Maintenance';
|
$menu_maintenance = 'Maintenance';
|
||||||
|
$menu_profiles = 'Profiles';
|
||||||
|
|
||||||
//TABS
|
//TABS
|
||||||
$tab1 = 'Allgemein';
|
$tab1 = 'Allgemein';
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ $menu_report_build = 'Voorraad en Productie';
|
|||||||
$menu_report_healthindex= 'Healthindex';
|
$menu_report_healthindex= 'Healthindex';
|
||||||
$menu_report_usage = 'Systeemgebruik';
|
$menu_report_usage = 'Systeemgebruik';
|
||||||
$menu_maintenance = 'Maintenance';
|
$menu_maintenance = 'Maintenance';
|
||||||
|
$menu_profiles = 'Profielen';
|
||||||
|
|
||||||
|
|
||||||
//TABS
|
//TABS
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ $menu_report_build = 'Stock and Production';
|
|||||||
$menu_report_healthindex= 'Healthindex';
|
$menu_report_healthindex= 'Healthindex';
|
||||||
$menu_report_usage = 'System usage';
|
$menu_report_usage = 'System usage';
|
||||||
$menu_maintenance = 'Maintenance';
|
$menu_maintenance = 'Maintenance';
|
||||||
|
$menu_profiles = 'Profiles';
|
||||||
|
|
||||||
//TABS
|
//TABS
|
||||||
$tab1 = 'General';
|
$tab1 = 'General';
|
||||||
|
|||||||
7
test.php
7
test.php
@@ -9,10 +9,7 @@ include './settings/config.php';
|
|||||||
include_once './settings/translations/translations_US.php';
|
include_once './settings/translations/translations_US.php';
|
||||||
include_once './settings/systemfirmware.php';
|
include_once './settings/systemfirmware.php';
|
||||||
|
|
||||||
|
$allviews = explode(',' , standard_profile);
|
||||||
//define('standard_profile','dashboard,profile,equipments,equipment,histories,history,servicereports,servicereport,firmwaretool,application');
|
|
||||||
|
|
||||||
$allviews = ["dashboard","profile","equipments","equipment","equipmentmanage","equipment_item"];
|
|
||||||
|
|
||||||
$admin_profile = ["dashboard","profile","equipments","equipment"];
|
$admin_profile = ["dashboard","profile","equipments","equipment"];
|
||||||
|
|
||||||
@@ -20,7 +17,7 @@ $view = '<html><form action="" method="post">';
|
|||||||
|
|
||||||
foreach ($allviews as $view){
|
foreach ($allviews as $view){
|
||||||
|
|
||||||
if (in_array($view,$admin_profile)){
|
if (in_stir($view,$admin_profile)){
|
||||||
$view .= '<input type="checkbox" id="'.$view.'" name="" value="'.$view.'" checked>';
|
$view .= '<input type="checkbox" id="'.$view.'" name="" value="'.$view.'" checked>';
|
||||||
} else {
|
} else {
|
||||||
$view .= '<input type="checkbox" id="'.$view.'" name="profile[]" value="'.$view.'">';
|
$view .= '<input type="checkbox" id="'.$view.'" name="profile[]" value="'.$view.'">';
|
||||||
|
|||||||
Reference in New Issue
Block a user