WIP: User management View and BL
This commit is contained in:
parent
b9992c5a67
commit
0a61f6dcc7
|
@ -14,7 +14,7 @@
|
|||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
|
||||
* Copyright (c) 2005-2023 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -28,7 +28,7 @@
|
|||
|
||||
// Load global vars.
|
||||
global $config;
|
||||
|
||||
hd($_REQUEST);
|
||||
check_login();
|
||||
|
||||
require_once $config['homedir'].'/vendor/autoload.php';
|
||||
|
@ -42,8 +42,6 @@ require_once $config['homedir'].'/include/functions_visual_map.php';
|
|||
require_once $config['homedir'].'/include/functions_custom_fields.php';
|
||||
enterprise_include_once('include/functions_profile.php');
|
||||
|
||||
$meta = is_metaconsole();
|
||||
|
||||
$isFunctionSkins = enterprise_include_once('include/functions_skins.php');
|
||||
|
||||
// Add the columns for the enterprise Pandora edition.
|
||||
|
@ -83,7 +81,6 @@ if (is_metaconsole() === false) {
|
|||
'include/javascript/timezonepicker/tz_islands.txt'
|
||||
);
|
||||
|
||||
|
||||
foreach ($timezones as $timezone_name => $tz) {
|
||||
if ($timezone_name == 'America/Montreal') {
|
||||
$timezone_name = 'America/Toronto';
|
||||
|
@ -272,6 +269,10 @@ enterprise_hook('open_meta_frame');
|
|||
|
||||
$tab = get_parameter('tab', 'user');
|
||||
|
||||
// Save autorefresh list.
|
||||
$autorefresh_list = get_parameter_post('autorefresh_list');
|
||||
$autorefresh_white_list = (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) ? '' : json_encode($autorefresh_list);
|
||||
|
||||
// Header.
|
||||
if (is_metaconsole() === true) {
|
||||
user_meta_print_header();
|
||||
|
@ -442,13 +443,13 @@ if ($create_user === true) {
|
|||
$values['block_size'] = (int) get_parameter('block_size', $config['block_size']);
|
||||
|
||||
$values['section'] = get_parameter('section');
|
||||
if (($values['section'] === 'Event list') || ($values['section'] === 'Group view') || ($values['section'] === 'Alert detail') || ($values['section'] === 'Tactical view') || ($values['section'] === 'Default')) {
|
||||
if (($values['section'] === HOME_SCREEN_EVENT_LIST) || ($values['section'] === HOME_SCREEN_GROUP_VIEW) || ($values['section'] === HOME_SCREEN_ALERT_DETAIL) || ($values['section'] === HOME_SCREEN_TACTICAL_VIEW) || ($values['section'] === HOME_SCREEN_DEFAULT)) {
|
||||
$values['data_section'] = '';
|
||||
} else if ($values['section'] === 'Dashboard') {
|
||||
} else if ($values['section'] === HOME_SCREEN_DASHBOARD) {
|
||||
$values['data_section'] = $dashboard;
|
||||
} else if (io_safe_output($values['section']) === 'Visual console') {
|
||||
} else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) {
|
||||
$values['data_section'] = $visual_console;
|
||||
} else if ($values['section'] === 'Other' || io_safe_output($values['section']) === 'External link') {
|
||||
} else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) {
|
||||
$values['data_section'] = get_parameter('data_section');
|
||||
}
|
||||
|
||||
|
@ -723,13 +724,13 @@ if ($update_user) {
|
|||
$values['block_size'] = get_parameter('block_size', $config['block_size']);
|
||||
|
||||
$values['section'] = get_parameter('section');
|
||||
if (($values['section'] === 'Event list') || ($values['section'] === 'Group view') || ($values['section'] === 'Alert detail') || ($values['section'] === 'Tactical view') || ($values['section'] === 'Default')) {
|
||||
if (($values['section'] === HOME_SCREEN_EVENT_LIST) || ($values['section'] === HOME_SCREEN_GROUP_VIEW) || ($values['section'] === HOME_SCREEN_ALERT_DETAIL) || ($values['section'] === HOME_SCREEN_TACTICAL_VIEW) || ($values['section'] === HOME_SCREEN_DEFAULT)) {
|
||||
$values['data_section'] = '';
|
||||
} else if ($values['section'] === 'Dashboard') {
|
||||
} else if ($values['section'] === HOME_SCREEN_DASHBOARD) {
|
||||
$values['data_section'] = $dashboard;
|
||||
} else if (io_safe_output($values['section']) === 'Visual console') {
|
||||
} else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) {
|
||||
$values['data_section'] = $visual_console;
|
||||
} else if ($values['section'] === 'Other' || io_safe_output($values['section']) === 'External link') {
|
||||
} else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) {
|
||||
$values['data_section'] = get_parameter('data_section');
|
||||
}
|
||||
|
||||
|
@ -743,7 +744,8 @@ if ($update_user) {
|
|||
$values['local_user'] = (bool) get_parameter('local_user', false);
|
||||
$values['strict_acl'] = (bool) get_parameter('strict_acl', false);
|
||||
$values['session_time'] = (int) get_parameter('session_time', 0);
|
||||
|
||||
// Previously defined.
|
||||
$values['autorefresh_white_list'] = $autorefresh_white_list;
|
||||
|
||||
$res1 = update_user($id, $values);
|
||||
|
||||
|
@ -1304,7 +1306,7 @@ if ($new_user) {
|
|||
$id_usr = $id;
|
||||
}
|
||||
|
||||
if ((bool) $meta === false) {
|
||||
if (is_metaconsole() === false) {
|
||||
// User only can change skins if has more than one group.
|
||||
if (count($usr_groups) > 1) {
|
||||
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
|
||||
|
@ -1314,7 +1316,7 @@ if ((bool) $meta === false) {
|
|||
}
|
||||
}
|
||||
|
||||
if ((bool) $meta === true) {
|
||||
if (is_metaconsole() === true) {
|
||||
$array_filters = get_filters_custom_fields_view(0, true);
|
||||
|
||||
$search_custom_fields_view = '<div class="label_select"><p class="edit_user_labels">'.__('Search custom field view').' '.ui_print_help_tip(__('Load by default the selected view in custom field view'), true).'</p>';
|
||||
|
@ -1343,20 +1345,9 @@ $home_screen = '<div class="label_select"><p class="edit_user_labels">'.__('Home
|
|||
__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 to show agent detail view'),
|
||||
true
|
||||
).'</p>';
|
||||
;
|
||||
$values = [
|
||||
'Default' => __('Default'),
|
||||
'Visual console' => __('Visual console'),
|
||||
'Event list' => __('Event list'),
|
||||
'Group view' => __('Group view'),
|
||||
'Tactical view' => __('Tactical view'),
|
||||
'Alert detail' => __('Alert detail'),
|
||||
'External link' => __('External link'),
|
||||
'Other' => __('Other'),
|
||||
'Dashboard' => __('Dashboard'),
|
||||
];
|
||||
|
||||
$home_screen .= html_print_select(
|
||||
/*
|
||||
$home_screen .= html_print_select(
|
||||
$values,
|
||||
'section',
|
||||
io_safe_output($user_info['section']),
|
||||
|
@ -1366,8 +1357,8 @@ $home_screen .= html_print_select(
|
|||
true,
|
||||
false,
|
||||
false
|
||||
).'</div>';
|
||||
|
||||
).'</div>';
|
||||
*/
|
||||
|
||||
$dashboards = Manager::getDashboards(
|
||||
-1,
|
||||
|
@ -1602,7 +1593,69 @@ if (isset($double_authentication)) {
|
|||
$double_authentication .= '</div>';
|
||||
}
|
||||
|
||||
if ($meta) {
|
||||
|
||||
|
||||
$autorefresh_list_out = [];
|
||||
if (is_metaconsole() === false || is_centralized() === true) {
|
||||
$autorefresh_list_out['operation/agentes/estado_agente'] = 'Agent detail';
|
||||
$autorefresh_list_out['operation/agentes/alerts_status'] = 'Alert detail';
|
||||
$autorefresh_list_out['enterprise/operation/cluster/cluster'] = 'Cluster view';
|
||||
$autorefresh_list_out['operation/gis_maps/render_view'] = 'Gis Map';
|
||||
$autorefresh_list_out['operation/reporting/graph_viewer'] = 'Graph Viewer';
|
||||
$autorefresh_list_out['operation/snmpconsole/snmp_view'] = 'SNMP console';
|
||||
|
||||
if (enterprise_installed()) {
|
||||
$autorefresh_list_out['general/sap_view'] = 'SAP view';
|
||||
}
|
||||
}
|
||||
|
||||
$autorefresh_list_out['operation/agentes/tactical'] = 'Tactical view';
|
||||
$autorefresh_list_out['operation/agentes/group_view'] = 'Group view';
|
||||
$autorefresh_list_out['operation/agentes/status_monitor'] = 'Monitor detail';
|
||||
$autorefresh_list_out['enterprise/operation/services/services'] = 'Services';
|
||||
$autorefresh_list_out['operation/dashboard/dashboard'] = 'Dashboard';
|
||||
|
||||
$autorefresh_list_out['operation/agentes/pandora_networkmap'] = 'Network map';
|
||||
$autorefresh_list_out['operation/visual_console/render_view'] = 'Visual console';
|
||||
$autorefresh_list_out['operation/events/events'] = 'Events';
|
||||
|
||||
|
||||
if (isset($autorefresh_list) === false) {
|
||||
$select = db_process_sql("SELECT autorefresh_white_list FROM tusuario WHERE id_user = '".$config['id_user']."'");
|
||||
$autorefresh_list = json_decode($select[0]['autorefresh_white_list']);
|
||||
if ($autorefresh_list === null) {
|
||||
$autorefresh_list[0] = __('None');
|
||||
} else {
|
||||
$aux = [];
|
||||
$count_autorefresh_list = count($autorefresh_list);
|
||||
for ($i = 0; $i < $count_autorefresh_list; $i++) {
|
||||
$aux[$autorefresh_list[$i]] = $autorefresh_list_out[$autorefresh_list[$i]];
|
||||
unset($autorefresh_list_out[$autorefresh_list[$i]]);
|
||||
$autorefresh_list[$i] = $aux;
|
||||
}
|
||||
|
||||
$autorefresh_list = $aux;
|
||||
}
|
||||
} else {
|
||||
if (is_array($autorefresh_list) === false || empty($autorefresh_list[0]) === true || $autorefresh_list[0] === '0') {
|
||||
$autorefresh_list = [];
|
||||
$autorefresh_list[0] = __('None');
|
||||
} else {
|
||||
$aux = [];
|
||||
$count_autorefresh_list = count($autorefresh_list);
|
||||
for ($i = 0; $i < $count_autorefresh_list; $i++) {
|
||||
$aux[$autorefresh_list[$i]] = $autorefresh_list_out[$autorefresh_list[$i]];
|
||||
unset($autorefresh_list_out[$autorefresh_list[$i]]);
|
||||
$autorefresh_list[$i] = $aux;
|
||||
}
|
||||
|
||||
$autorefresh_list = $aux;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
enterprise_include_once('include/functions_metaconsole.php');
|
||||
|
||||
$access_node = db_get_value('metaconsole_access_node', 'tusuario', 'id_user', $id);
|
||||
|
@ -1627,6 +1680,11 @@ if ($meta) {
|
|||
echo '<form id="user_profile_form" name="user_profile_form" method="post" autocomplete="off" action="#">';
|
||||
|
||||
|
||||
require_once 'user_management.php';
|
||||
|
||||
|
||||
|
||||
|
||||
if (!$id) {
|
||||
$user_id_update_view = $user_id;
|
||||
$user_id_create = '';
|
||||
|
@ -1655,7 +1713,7 @@ echo '<div id="user_form">
|
|||
<div class="edit_user_autorefresh white_box"><p class="bolder">Extra info</p>'.$email.$phone.$not_login.$local_user.$session_time.'</div>
|
||||
</div>
|
||||
<div class="user_edit_second_row white_box">
|
||||
<div class="edit_user_options">'.$language.$access_or_pagination.$skin.$home_screen.$default_event_filter.$double_authentication.'</div>
|
||||
<div class="edit_user_options">'.$language.$access_or_pagination.$skin.$default_event_filter.$double_authentication.'</div>
|
||||
|
||||
<div class="edit_user_timezone">'.$timezone;
|
||||
if (is_metaconsole() === false) {
|
||||
|
@ -1668,9 +1726,96 @@ if (is_metaconsole() === false) {
|
|||
echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_access_node;
|
||||
}
|
||||
|
||||
$autorefresh_show = '<p class="edit_user_labels">'._('Autorefresh').ui_print_help_tip(
|
||||
__('This will activate autorefresh in selected pages'),
|
||||
true
|
||||
).'</p>';
|
||||
$select_out = html_print_select(
|
||||
$autorefresh_list_out,
|
||||
'autorefresh_list_out[]',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width:100%'
|
||||
);
|
||||
$arrows = ' ';
|
||||
$select_in = html_print_select(
|
||||
$autorefresh_list,
|
||||
'autorefresh_list[]',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width:100%'
|
||||
);
|
||||
|
||||
$table_ichanges = '<div class="autorefresh_select">
|
||||
<div class="autorefresh_select_list_out">
|
||||
<p class="autorefresh_select_text">'.__('Full list of pages').': </p>
|
||||
<div>'.$select_out.'</div>
|
||||
</div>
|
||||
<div class="autorefresh_select_arrows" style="display:grid">
|
||||
<a href="javascript:">'.html_print_image(
|
||||
'images/darrowright_green.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'right_autorefreshlist',
|
||||
'alt' => __('Push selected pages into autorefresh list'),
|
||||
'title' => __('Push selected pages into autorefresh list'),
|
||||
]
|
||||
).'</a>
|
||||
<a href="javascript:">'.html_print_image(
|
||||
'images/darrowleft_green.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'left_autorefreshlist',
|
||||
'alt' => __('Pop selected pages out of autorefresh list'),
|
||||
'title' => __('Pop selected pages out of autorefresh list'),
|
||||
]
|
||||
).'</a>
|
||||
</div>
|
||||
<div class="autorefresh_select_list">
|
||||
<p class="autorefresh_select_text">'.__('List of pages with autorefresh').': </p>
|
||||
<div>'.$select_in.'</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
$autorefresh_show .= $table_ichanges;
|
||||
|
||||
// Time autorefresh.
|
||||
$times = get_refresh_time_array();
|
||||
$time_autorefresh = '<div class="label_select"><p class="edit_user_labels">'.__('Time autorefresh');
|
||||
$time_autorefresh .= ui_print_help_tip(
|
||||
__('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'),
|
||||
true
|
||||
).'</p>';
|
||||
$time_autorefresh .= html_print_select(
|
||||
$times,
|
||||
'time_autorefresh',
|
||||
$user_info['time_autorefresh'],
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false
|
||||
).'</div>';
|
||||
|
||||
|
||||
echo '</div>
|
||||
</div>
|
||||
|
||||
<div class="edit_user_autorefresh white_box">'.$autorefresh_show.$time_autorefresh.'</div>
|
||||
<div class="user_edit_third_row white_box">
|
||||
<div class="edit_user_comments">'.$comments.'</div>
|
||||
</div>';
|
||||
|
@ -1840,7 +1985,7 @@ $(document).ready (function () {
|
|||
$('#checkbox-ehorus_user_level_enabled').trigger('change');
|
||||
var img_delete = '<?php echo $delete_image; ?>';
|
||||
var id_user = '<?php echo io_safe_output($id); ?>';
|
||||
var is_metaconsole = '<?php echo $meta; ?>';
|
||||
var is_metaconsole = '<?php echo is_metaconsole(); ?>';
|
||||
var user_is_global_admin = '<?php echo users_is_admin($id); ?>';
|
||||
var is_err = '<?php echo $is_err; ?>';
|
||||
var data = [];
|
||||
|
@ -2023,73 +2168,17 @@ function delete_profile(event, btn) {
|
|||
}
|
||||
|
||||
function show_data_section () {
|
||||
section = $("#section").val();
|
||||
|
||||
switch (section) {
|
||||
case <?php echo "'".'Dashboard'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "inline-grid");
|
||||
break;
|
||||
case <?php echo "'".'Visual console'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "");
|
||||
$("#show_vc").css("display", "inline-grid");
|
||||
$("#show_db").css("display", "none");
|
||||
break;
|
||||
case <?php echo "'".'Event list'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
break;
|
||||
case <?php echo "'".'Group view'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
break;
|
||||
case <?php echo "'".'Tactical view'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
break;
|
||||
case <?php echo "'".'Alert detail'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
break;
|
||||
case <?php echo "'".'External link'."'"; ?>:
|
||||
$("#text-data_section").css("display", "");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
break;
|
||||
case <?php echo "'".'Other'."'"; ?>:
|
||||
$("#text-data_section").css("display", "");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
break;
|
||||
case <?php echo "'".'Default'."'"; ?>:
|
||||
$("#text-data_section").css("display", "none");
|
||||
$("#dashboard").css("display", "none");
|
||||
$("#visual_console").css("display", "none");
|
||||
$("#show_vc").css("display", "none");
|
||||
$("#show_db").css("display", "none");
|
||||
break;
|
||||
}
|
||||
var $section = $("#section").val();
|
||||
var $allElements = $('div[id^="custom_home_screen_"]');
|
||||
var $elementSelected = $('div[id="custom_home_screen_'+$section+'"]');
|
||||
// Hide all elements.
|
||||
$allElements.each(function(){
|
||||
$(this).addClass('invisible');
|
||||
$(this).children().addClass('invisible');
|
||||
})
|
||||
// Show only the selected.
|
||||
$elementSelected.removeClass('invisible');
|
||||
$elementSelected.children().removeClass('invisible');
|
||||
}
|
||||
|
||||
function switch_ehorus_conf()
|
||||
|
|
|
@ -0,0 +1,625 @@
|
|||
<?php
|
||||
/**
|
||||
* User management.
|
||||
*
|
||||
* @category Users
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2023 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation for version 2.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Load global vars.
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
|
||||
// Bussiness Logic.
|
||||
// Data for homescreen section.
|
||||
$homeScreenValues = [
|
||||
HOME_SCREEN_DEFAULT => __('Default'),
|
||||
HOME_SCREEN_VISUAL_CONSOLE => __('Visual console'),
|
||||
HOME_SCREEN_EVENT_LIST => __('Event list'),
|
||||
HOME_SCREEN_GROUP_VIEW => __('Group view'),
|
||||
HOME_SCREEN_TACTICAL_VIEW => __('Tactical view'),
|
||||
HOME_SCREEN_ALERT_DETAIL => __('Alert detail'),
|
||||
HOME_SCREEN_EXTERNAL_LINK => __('External link'),
|
||||
HOME_SCREEN_OTHER => __('Other'),
|
||||
HOME_SCREEN_DASHBOARD => __('Dashboard'),
|
||||
];
|
||||
|
||||
// Custom Home Screen controls.
|
||||
$customHomeScreenAddition = [];
|
||||
// Home screen. Dashboard.
|
||||
$customHomeScreenAddition[HOME_SCREEN_DASHBOARD] = html_print_select($dashboards_aux, 'dashboard', $user_info['data_section'], '', '', '', true);
|
||||
// Home screen. Visual consoles.
|
||||
$customHomeScreenAddition[HOME_SCREEN_VISUAL_CONSOLE] = html_print_select($layouts_aux, 'visual_console', $user_info['data_section'], '', '', '', true);
|
||||
// Home screen. External link and Other.
|
||||
$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section', $user_info['data_section'], '', 60, 255, true, false);
|
||||
$customHomeScreenAddition[HOME_SCREEN_OTHER] = html_print_input_text('data_section', $user_info['data_section'], '', 60, 255, true, false);
|
||||
|
||||
$customHomeScreenDataField = '';
|
||||
foreach ($customHomeScreenAddition as $key => $customField) {
|
||||
$customHomeScreenDataField .= html_print_div(
|
||||
[
|
||||
'id' => sprintf('custom_home_screen_%s', $key),
|
||||
'content' => $customField,
|
||||
],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
// Timezone creation canvas.
|
||||
$timezoneContent = [];
|
||||
if (is_metaconsole() === false) {
|
||||
date_default_timezone_set('UTC');
|
||||
include_once 'include/javascript/timezonepicker/includes/parser.inc';
|
||||
|
||||
// Read in options for map builder.
|
||||
$bases = [
|
||||
'gray' => 'Gray',
|
||||
'blue-marble' => 'Blue marble',
|
||||
'night-electric' => 'Night Electric',
|
||||
'living' => 'Living Earth',
|
||||
];
|
||||
|
||||
$local_file = 'include/javascript/timezonepicker/images/gray-400.png';
|
||||
|
||||
// Dimensions must always be exact since the imagemap does not scale.
|
||||
$array_size = getimagesize($local_file);
|
||||
|
||||
$map_width = $array_size[0];
|
||||
$map_height = $array_size[1];
|
||||
|
||||
$timezones = timezone_picker_parse_files(
|
||||
$map_width,
|
||||
$map_height,
|
||||
'include/javascript/timezonepicker/tz_world.txt',
|
||||
'include/javascript/timezonepicker/tz_islands.txt'
|
||||
);
|
||||
|
||||
foreach ($timezones as $timezone_name => $tz) {
|
||||
if ($timezone_name === 'America/Montreal') {
|
||||
$timezone_name = 'America/Toronto';
|
||||
} else if ($timezone_name === 'Asia/Chongqing') {
|
||||
$timezone_name = 'Asia/Shanghai';
|
||||
}
|
||||
|
||||
$area_data_timezone_polys .= '';
|
||||
foreach ($tz['polys'] as $coords) {
|
||||
$area_data_timezone_polys .= '<area data-timezone="'.$timezone_name.'" data-country="'.$tz['country'].'" data-pin="'.implode(',', $tz['pin']).'" data-offset="'.$tz['offset'].'" shape="poly" coords="'.implode(',', $coords).'" />';
|
||||
}
|
||||
|
||||
$area_data_timezone_rects .= '';
|
||||
foreach ($tz['rects'] as $coords) {
|
||||
$area_data_timezone_rects .= '<area data-timezone="'.$timezone_name.'" data-country="'.$tz['country'].'" data-pin="'.implode(',', $tz['pin']).'" data-offset="'.$tz['offset'].'" shape="rect" coords="'.implode(',', $coords).'" />';
|
||||
}
|
||||
}
|
||||
|
||||
$timezoneContent[] = '<img id="timezone-image" src="'.$local_file.'" width="'.$map_width.'" height="'.$map_height.'" usemap="#timezone-map" />';
|
||||
$timezoneContent[] = '<img class="timezone-pin" src="include/javascript/timezonepicker/images/pin.png" class="pdd_t_4px" />';
|
||||
$timezoneContent[] = '<map name="timezone-map" id="timezone-map">'.$area_data_timezone_polys.$area_data_timezone_rects.'</map>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Create the view.
|
||||
$userManagementTable = new stdClass();
|
||||
$userManagementTable->id = 'advanced';
|
||||
$userManagementTable->width = '100%';
|
||||
$userManagementTable->class = 'w100p floating_form';
|
||||
$userManagementTable->data = [];
|
||||
$userManagementTable->style = [];
|
||||
$userManagementTable->rowclass = [];
|
||||
$userManagementTable->cellclass = [];
|
||||
$userManagementTable->colspan = [];
|
||||
$userManagementTable->rowspan = [];
|
||||
|
||||
// Title for Profile information.
|
||||
$userManagementTable->rowclass['title_profile_information'] = 'w100p';
|
||||
$userManagementTable->cellstyle['title_profile_information'][0] = 'width: 40px;';
|
||||
$userManagementTable->cellstyle['title_profile_information'][1] = 'width: 100%;';
|
||||
$userManagementTable->data['title_profile_information'][0] = html_print_div(
|
||||
[
|
||||
'class' => 'section_table_title_line',
|
||||
'content' => '',
|
||||
],
|
||||
true
|
||||
);
|
||||
$userManagementTable->data['title_profile_information'][1] = html_print_subtitle_table(__('Profile information'), [], true);
|
||||
|
||||
// Id user.
|
||||
if ($new_user === true) {
|
||||
$userManagementTable->rowclass['captions_iduser'] = 'field_half_width pdd_t_10px';
|
||||
$userManagementTable->rowclass['fields_iduser'] = 'field_half_width';
|
||||
$userManagementTable->data['captions_iduser'][0] = __('User ID');
|
||||
$userManagementTable->data['fields_iduser'][0] = html_print_input_text_extended(
|
||||
'id_user',
|
||||
$id,
|
||||
'',
|
||||
'',
|
||||
20,
|
||||
255,
|
||||
!$new_user || $view_mode,
|
||||
'',
|
||||
[
|
||||
'class' => 'input_line user_icon_input',
|
||||
'placeholder' => __('User ID'),
|
||||
],
|
||||
true
|
||||
);
|
||||
} else {
|
||||
// TODO. Show the user id with a label.
|
||||
}
|
||||
|
||||
// User Full name.
|
||||
$userManagementTable->rowclass['captions_fullname'] = 'field_half_width pdd_t_10px';
|
||||
$userManagementTable->rowclass['fields_fullname'] = 'field_half_width';
|
||||
$userManagementTable->data['captions_fullname'][0] = __('Full name');
|
||||
$userManagementTable->data['fields_fullname'][0] = html_print_input_text_extended(
|
||||
'fullname',
|
||||
$user_info['fullname'],
|
||||
'fullname',
|
||||
'',
|
||||
20,
|
||||
100,
|
||||
$view_mode,
|
||||
'',
|
||||
[
|
||||
'class' => 'input',
|
||||
'placeholder' => __('Full (display) name'),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
// User Email.
|
||||
$userManagementTable->rowclass['captions_email'] = 'field_half_width pdd_t_10px';
|
||||
$userManagementTable->rowclass['fields_email'] = 'field_half_width';
|
||||
$userManagementTable->data['captions_email'][0] = __('Email');
|
||||
$userManagementTable->data['fields_email'][0] = html_print_input_text_extended(
|
||||
'email',
|
||||
$user_info['email'],
|
||||
'email',
|
||||
'',
|
||||
'25',
|
||||
'100',
|
||||
$view_mode,
|
||||
'',
|
||||
[
|
||||
'class' => 'input input_line email_icon_input',
|
||||
'placeholder' => __('E-mail'),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
// User phone number.
|
||||
$userManagementTable->rowclass['captions_phone'] = 'field_half_width pdd_t_10px';
|
||||
$userManagementTable->rowclass['fields_phone'] = 'field_half_width';
|
||||
$userManagementTable->data['captions_phone'][0] = __('Phone number');
|
||||
$userManagementTable->data['fields_phone'][0] = html_print_input_text_extended(
|
||||
'phone',
|
||||
$user_info['phone'],
|
||||
'phone',
|
||||
'',
|
||||
'20',
|
||||
'30',
|
||||
$view_mode,
|
||||
'',
|
||||
[
|
||||
'class' => 'input input_line phone_icon_input',
|
||||
'placeholder' => __('Phone number'),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
// Password management.
|
||||
$passwordManageTable = new stdClass();
|
||||
$passwordManageTable->class = 'w100p';
|
||||
$passwordManageTable->id = 'password_manage';
|
||||
$passwordManageTable->style = [];
|
||||
$passwordManageTable->rowclass = [];
|
||||
$passwordManageTable->data = [];
|
||||
|
||||
$passwordManageTable->data['captions_newpassword'][0] = __('New password');
|
||||
$passwordManageTable->rowclass['fields_newpassword'] = 'w540px';
|
||||
$passwordManageTable->data['fields_newpassword'][0] = html_print_input_text_extended(
|
||||
'password_new',
|
||||
'',
|
||||
'password_new',
|
||||
'',
|
||||
'25',
|
||||
'45',
|
||||
$view_mode,
|
||||
'',
|
||||
[
|
||||
'class' => 'input',
|
||||
'placeholder' => __('Password'),
|
||||
],
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
$passwordManageTable->data['captions_repeatpassword'][0] = __('Repeat new password');
|
||||
$passwordManageTable->rowclass['fields_repeatpassword'] = 'w540px';
|
||||
$passwordManageTable->data['fields_repeatpassword'][0] = html_print_input_text_extended(
|
||||
'password_confirm',
|
||||
'',
|
||||
'password_conf',
|
||||
'',
|
||||
'20',
|
||||
'45',
|
||||
$view_mode,
|
||||
'',
|
||||
[
|
||||
'class' => 'input',
|
||||
'placeholder' => __('Password confirmation'),
|
||||
],
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
if ($new_user === false) {
|
||||
$passwordManageTable->data['captions_currentpassword'][0] = __('Current password');
|
||||
$passwordManageTable->rowclass['fields_currentpassword'] = 'w540px';
|
||||
$passwordManageTable->data['fields_currentpassword'][0] = html_print_input_text_extended(
|
||||
'own_password_confirm',
|
||||
'',
|
||||
'own_password_confirm',
|
||||
'',
|
||||
'20',
|
||||
'45',
|
||||
$view_mode,
|
||||
'',
|
||||
[
|
||||
'class' => 'input',
|
||||
'placeholder' => __('Own password confirmation'),
|
||||
],
|
||||
true,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
// $userManagementTable->rowclass['captions_passwordManage'] = 'full_section pdd_t_10px';
|
||||
$userManagementTable->rowclass['passwordManage_table'] = 'table_section full_section';
|
||||
// $userManagementTable->data['captions_passwordManage'][0] = __('Password management');
|
||||
$userManagementTable->data['passwordManage_table'] = html_print_table($passwordManageTable, true);
|
||||
|
||||
// Title for Autorefresh.
|
||||
$userManagementTable->rowclass['title_autorefresh'] = 'w100p';
|
||||
$userManagementTable->cellstyle['title_autorefresh'][0] = 'width: 40px;';
|
||||
$userManagementTable->cellstyle['title_autorefresh'][1] = 'width: 100%;';
|
||||
$userManagementTable->data['title_autorefresh'][0] = html_print_div(
|
||||
[
|
||||
'class' => 'section_table_title_line',
|
||||
'content' => '',
|
||||
],
|
||||
true
|
||||
);
|
||||
$userManagementTable->data['title_autorefresh'][1] = html_print_subtitle_table(__('Autorefresh'), [], true);
|
||||
|
||||
// Autorefresh selects.
|
||||
$select_out = html_print_select(
|
||||
$autorefresh_list_out,
|
||||
'autorefresh_list_out[]',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width:100%'
|
||||
);
|
||||
|
||||
$select_in = html_print_select(
|
||||
$autorefresh_list,
|
||||
'autorefresh_list[]',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
'width:100%'
|
||||
);
|
||||
|
||||
// Full list pages generation.
|
||||
$autorefreshFullListContent = [];
|
||||
$autorefreshFullListContent[] = '<p class="autorefresh_select_text">'.__('Full list of pages').'</p>';
|
||||
$autorefreshFullListContent[] = html_print_div(
|
||||
[
|
||||
'id' => 'autorefreshAllPagesList',
|
||||
'content' => $select_out,
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
// Selected pages generation.
|
||||
$autorefreshSelectedListContent = [];
|
||||
$autorefreshSelectedListContent[] = '<p class="autorefresh_select_text">'.__('Pages with autorefresh').'</p>';
|
||||
$autorefreshSelectedListContent[] = html_print_div(
|
||||
[
|
||||
'id' => 'autorefreshSelectedPagesList',
|
||||
'content' => $select_in,
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
// Controls generation.
|
||||
$autorefreshControlsContent = [];
|
||||
$autorefreshControlsContent[] = html_print_anchor(
|
||||
[
|
||||
'id' => 'addAutorefreshPage',
|
||||
'href' => 'javascript:',
|
||||
'content' => html_print_image(
|
||||
'images/darrowright_green.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'right_autorefreshlist',
|
||||
'alt' => __('Push selected pages into autorefresh list'),
|
||||
'title' => __('Push selected pages into autorefresh list'),
|
||||
]
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
$autorefreshControlsContent[] = html_print_anchor(
|
||||
[
|
||||
'id' => 'removeAutorefreshPage',
|
||||
'href' => 'javascript:',
|
||||
'content' => html_print_image(
|
||||
'images/darrowleft_green.png',
|
||||
true,
|
||||
[
|
||||
'id' => 'left_autorefreshlist',
|
||||
'alt' => __('Pop selected pages out of autorefresh list'),
|
||||
'title' => __('Pop selected pages out of autorefresh list'),
|
||||
]
|
||||
),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
// Container with all pages list.
|
||||
$autorefreshFullList = html_print_div(
|
||||
[
|
||||
'class' => 'autorefresh_select_list_out',
|
||||
'content' => implode('', $autorefreshFullListContent),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
// Container with selected pages list.
|
||||
$autorefreshSelectedList = html_print_div(
|
||||
[
|
||||
'class' => 'autorefresh_select_list',
|
||||
'content' => implode('', $autorefreshSelectedListContent),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
// Container with controls.
|
||||
$autorefreshControls = html_print_div(
|
||||
[
|
||||
'class' => 'autorefresh_select_arrows',
|
||||
'content' => implode('', $autorefreshControlsContent),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
// Generate final control table.
|
||||
$autorefreshTable = html_print_div(
|
||||
[
|
||||
'class' => 'autorefresh_select',
|
||||
'content' => $autorefreshFullList.$autorefreshControls.$autorefreshSelectedList,
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
// $userManagementTable->rowclass['captions_autorefreshList'] = 'field_half_width pdd_t_10px';
|
||||
// $userManagementTable->rowclass['fields_autorefreshList'] = 'field_half_width';
|
||||
$userManagementTable->data['captions_autorefreshList'] = __('Autorefresh pages');
|
||||
$userManagementTable->data['fields_autorefreshList'] = $autorefreshTable;
|
||||
|
||||
$userManagementTable->rowclass['captions_autorefreshTime'] = 'field_half_width pdd_t_10px';
|
||||
$userManagementTable->rowclass['fields_autorefreshTime'] = 'field_half_width';
|
||||
$userManagementTable->data['captions_autorefreshTime'][0] = __('Time for autorefresh');
|
||||
$userManagementTable->data['captions_autorefreshTime'][0] .= ui_print_help_tip(
|
||||
__('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'),
|
||||
true
|
||||
);
|
||||
$userManagementTable->data['fields_autorefreshTime'][0] = html_print_select(
|
||||
get_refresh_time_array(),
|
||||
'time_autorefresh',
|
||||
$user_info['time_autorefresh'],
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
// Title for Language and Appearance.
|
||||
$userManagementTable->rowclass['title_lookAndFeel'] = 'w100p';
|
||||
$userManagementTable->cellstyle['title_lookAndFeel'][0] = 'width: 40px;';
|
||||
$userManagementTable->cellstyle['title_lookAndFeel'][1] = 'width: 100%;';
|
||||
$userManagementTable->data['title_lookAndFeel'][0] = html_print_div(
|
||||
[
|
||||
'class' => 'section_table_title_line',
|
||||
'content' => '',
|
||||
],
|
||||
true
|
||||
);
|
||||
$userManagementTable->data['title_lookAndFeel'][1] = html_print_subtitle_table(__('Language and Appearance'), [], true);
|
||||
|
||||
$userManagementTable->rowclass['captions_lang_colorscheme'] = 'field_half_width pdd_t_10px';
|
||||
$userManagementTable->rowclass['fields_lang_colorscheme'] = 'field_half_width';
|
||||
$userManagementTable->data['captions_lang_colorscheme'][0] = __('Language');
|
||||
$userManagementTable->data['fields_lang_colorscheme'][0] = html_print_select_from_sql(
|
||||
'SELECT id_language, name FROM tlanguage',
|
||||
'language',
|
||||
$user_info['language'],
|
||||
'',
|
||||
__('Default'),
|
||||
'default',
|
||||
true
|
||||
);
|
||||
|
||||
$userManagementTable->data['captions_lang_colorscheme'][1] = __('User color scheme');
|
||||
$userManagementTable->data['fields_lang_colorscheme'][1] = skins_print_select($id_usr, 'skin', $user_info['id_skin'], '', __('None'), 0, true);
|
||||
|
||||
$userManagementTable->rowclass['captions_blocksize_eventfilter'] = 'field_half_width pdd_t_10px';
|
||||
$userManagementTable->rowclass['fields_blocksize_eventfilter'] = 'field_half_width';
|
||||
$userManagementTable->data['captions_blocksize_eventfilter'][0] = __('Block size for pagination');
|
||||
$userManagementTable->data['fields_blocksize_eventfilter'][0] = html_print_input_text(
|
||||
'block_size',
|
||||
$user_info['block_size'],
|
||||
'',
|
||||
5,
|
||||
5,
|
||||
true
|
||||
);
|
||||
|
||||
$userManagementTable->data['captions_blocksize_eventfilter'][1] = __('Event filter');
|
||||
$userManagementTable->data['fields_blocksize_eventfilter'][1] = html_print_select(
|
||||
$event_filter,
|
||||
'default_event_filter',
|
||||
$user_info['default_event_filter'],
|
||||
'',
|
||||
'',
|
||||
__('None'),
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
// Home screen table.
|
||||
$homeScreenTable = new stdClass();
|
||||
$homeScreenTable->class = 'w100p table_section';
|
||||
$homeScreenTable->id = 'home_screen_table';
|
||||
$homeScreenTable->style = [];
|
||||
$homeScreenTable->rowclass = [];
|
||||
$homeScreenTable->data = [];
|
||||
|
||||
// Home screen.
|
||||
$homeScreenTable->data['captions_homescreen'][0] = __('Home screen');
|
||||
$homeScreenTable->colspan['captions_homescreen'] = 2;
|
||||
$homeScreenTable->rowclass['captions_homescreen'] = 'field_half_width pdd_t_10px';
|
||||
$homeScreenTable->rowclass['fields_homescreen'] = 'field_half_width';
|
||||
// $homeScreenTable->rowclass['fields_homescreen'] = 'w540px';
|
||||
$homeScreenTable->data['fields_homescreen'][0] = html_print_select(
|
||||
$homeScreenValues,
|
||||
'section',
|
||||
io_safe_output($user_info['section']),
|
||||
'show_data_section();',
|
||||
'',
|
||||
-1,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
$homeScreenTable->data['fields_homescreen'][1] = $customHomeScreenDataField;
|
||||
|
||||
$userManagementTable->rowclass['homescreen_table'] = 'table_section';
|
||||
$userManagementTable->data['homescreen_table'] = html_print_table($homeScreenTable, true);
|
||||
|
||||
// Timezone.
|
||||
$userManagementTable->rowclass['captions_timezone'] = 'field_half_width pdd_t_10px';
|
||||
$userManagementTable->rowclass['fields_timezone'] = 'field_half_width';
|
||||
$userManagementTable->colspan['captions_timezone'][0] = 2;
|
||||
$userManagementTable->data['captions_timezone'][0] = __('Time zone');
|
||||
$userManagementTable->data['fields_timezone'][0] = html_print_timezone_select('timezone', $user_info['timezone']);
|
||||
$userManagementTable->data['fields_timezone'][0] .= ui_print_help_tip(
|
||||
__('The timezone must be that of the associated server.'),
|
||||
true
|
||||
);
|
||||
|
||||
$userManagementTable->data['fields_timezone'][1] = html_print_div(
|
||||
[
|
||||
'id' => 'timezone-picker',
|
||||
'content' => implode('', $timezoneContent),
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
// Title for Language and Appearance.
|
||||
$userManagementTable->rowclass['title_additionalSettings'] = 'w100p';
|
||||
$userManagementTable->cellstyle['title_additionalSettings'][0] = 'width: 40px;';
|
||||
$userManagementTable->cellstyle['title_additionalSettings'][1] = 'width: 100%;';
|
||||
$userManagementTable->data['title_additionalSettings'][0] = html_print_div(
|
||||
[
|
||||
'class' => 'section_table_title_line',
|
||||
'content' => '',
|
||||
],
|
||||
true
|
||||
);
|
||||
$userManagementTable->data['title_additionalSettings'][1] = html_print_subtitle_table(__('Additional settings'), [], true);
|
||||
|
||||
$userManagementTable->rowclass['captions_addSettings'] = 'field_half_width pdd_t_10px';
|
||||
$userManagementTable->rowclass['fields_addSettings'] = 'field_half_width';
|
||||
$userManagementTable->cellstyle['fields_addSettings'][1] = 'flex-wrap: wrap';
|
||||
$userManagementTable->data['captions_addSettings'][0] = __('Comments');
|
||||
$userManagementTable->data['fields_addSettings'][0] = html_print_textarea(
|
||||
'comments',
|
||||
2,
|
||||
65,
|
||||
$user_info['comments'],
|
||||
($view_mode ? 'readonly="readonly"' : ''),
|
||||
true
|
||||
);
|
||||
|
||||
$userManagementTable->data['captions_addSettings'][1] = __('Login allowed IP list');
|
||||
$userManagementTable->data['captions_addSettings'][1] .= ui_print_help_tip(
|
||||
__('Add the source IPs that will allow console access. Each IP must be separated only by comma. * allows all.'),
|
||||
true
|
||||
);
|
||||
$userManagementTable->data['fields_addSettings'][1] = html_print_textarea(
|
||||
'allowed_ip_list',
|
||||
2,
|
||||
65,
|
||||
$user_info['allowed_ip_list'],
|
||||
(((bool) $view_mode === true) ? 'readonly="readonly"' : ''),
|
||||
true
|
||||
);
|
||||
|
||||
$userManagementTable->data['fields_addSettings'][1] .= html_print_div(
|
||||
[
|
||||
'class' => 'margin-top-10',
|
||||
'content' => html_print_checkbox_switch(
|
||||
'allowed_ip_active',
|
||||
0,
|
||||
$user_info['allowed_ip_active'],
|
||||
true
|
||||
).'<span class="margin-top-10">'.__('Allow all IPs').'</span>',
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
html_print_table($userManagementTable);
|
|
@ -864,3 +864,14 @@ define(
|
|||
|
||||
// Pandora FMS Enterprise license.
|
||||
define('LICENSE_FILE', 'customer_key');
|
||||
|
||||
// Home screen values for user definition.
|
||||
define('HOME_SCREEN_DEFAULT', 'default');
|
||||
define('HOME_SCREEN_VISUAL_CONSOLE', 'visual_console');
|
||||
define('HOME_SCREEN_EVENT_LIST', 'event_list');
|
||||
define('HOME_SCREEN_GROUP_VIEW', 'group_view');
|
||||
define('HOME_SCREEN_TACTICAL_VIEW', 'tactical_view');
|
||||
define('HOME_SCREEN_ALERT_DETAIL', 'alert_detail');
|
||||
define('HOME_SCREEN_EXTERNAL_LINK', 'external_link');
|
||||
define('HOME_SCREEN_OTHER', 'other');
|
||||
define('HOME_SCREEN_DASHBOARD', 'dashboard');
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP script to manage Pandora FMS websockets.
|
||||
*
|
||||
|
@ -32,7 +33,7 @@ namespace PandoraFMS;
|
|||
/**
|
||||
* Object user.
|
||||
*/
|
||||
class User implements PublicLogin
|
||||
class User extends Entity implements PublicLogin
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -43,21 +44,105 @@ class User implements PublicLogin
|
|||
public $idUser;
|
||||
|
||||
/**
|
||||
* Current PHP session ids.
|
||||
* User main table.
|
||||
*
|
||||
* @var array
|
||||
* @var string
|
||||
*/
|
||||
public $sessions = [];
|
||||
protected $table;
|
||||
|
||||
|
||||
/**
|
||||
* Initializes a user object.
|
||||
*
|
||||
* @param string|null $id_user User id.
|
||||
* - Username
|
||||
*/
|
||||
public function __construct(?string $id_user)
|
||||
{
|
||||
$this->table = 'tusuario';
|
||||
|
||||
if (is_string($id_user) === true
|
||||
&& empty($id_user) === false
|
||||
) {
|
||||
$filter = ['id_user' => $id_user];
|
||||
parent::__construct(
|
||||
$this->table,
|
||||
$filter
|
||||
);
|
||||
} else {
|
||||
// Create empty skel.
|
||||
parent::__construct($this->table, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves current definition to database.
|
||||
*
|
||||
* @param boolean $alias_as_name Use alias as agent name.
|
||||
*
|
||||
* @return mixed Affected rows of false in case of error.
|
||||
* @throws \Exception On error.
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
if (empty($this->idUser) === false) {
|
||||
if (is_user($this->idUser) === true) {
|
||||
// User update.
|
||||
$updates = $this->fields;
|
||||
|
||||
$rs = \db_process_sql_update(
|
||||
$this->table,
|
||||
$updates,
|
||||
['id_user' => $this->fields['id_user']]
|
||||
);
|
||||
|
||||
if ($rs === false) {
|
||||
global $config;
|
||||
throw new \Exception(
|
||||
__METHOD__.' error: '.$config['dbconnection']->error
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// User creation.
|
||||
$userData = $this->fields;
|
||||
|
||||
// Clean null fields.
|
||||
foreach ($userData as $k => $v) {
|
||||
if ($v === null) {
|
||||
unset($userData[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
$rs = create_user($userData['id_user'], $userData['password'], $userData);
|
||||
|
||||
if ($rs === false) {
|
||||
global $config;
|
||||
$error = $config['dbconnection']->error;
|
||||
|
||||
throw new \Exception(
|
||||
__METHOD__.' error: '.$error
|
||||
);
|
||||
}
|
||||
|
||||
$this->fields['id_user'] = $rs;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Authentication.
|
||||
*
|
||||
* @param array|null $data User information.
|
||||
* - Username
|
||||
* - PHP session ID.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function __construct(?array $data)
|
||||
public static function auth(?array $data)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
@ -67,7 +152,6 @@ class User implements PublicLogin
|
|||
|
||||
if (is_array($data) === true) {
|
||||
if (isset($data['phpsessionid']) === true) {
|
||||
$this->sessions[$data['phpsessionid']] = 1;
|
||||
$info = \db_get_row_filter(
|
||||
'tsessions_php',
|
||||
['id_session' => io_safe_input($data['phpsessionid'])]
|
||||
|
@ -76,10 +160,10 @@ class User implements PublicLogin
|
|||
if ($info !== false) {
|
||||
// Process.
|
||||
$session_data = session_decode($info['data']);
|
||||
$this->idUser = $_SESSION['id_usuario'];
|
||||
$user = new self($_SESSION['id_usuario']);
|
||||
|
||||
// Valid session.
|
||||
return $this;
|
||||
return $user;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -105,15 +189,12 @@ class User implements PublicLogin
|
|||
$_SESSION['id_usuario'] = $data['id_usuario'];
|
||||
session_write_close();
|
||||
|
||||
$this->idUser = $data['id_usuario'];
|
||||
$user = new self($data['id_usuario']);
|
||||
// Valid session.
|
||||
return $this;
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,7 +207,7 @@ class User implements PublicLogin
|
|||
*/
|
||||
public static function login(?array $data)
|
||||
{
|
||||
$user = new self($data);
|
||||
$user = self::auth($data);
|
||||
|
||||
if ($user->idUser === null) {
|
||||
return false;
|
||||
|
@ -144,7 +225,7 @@ class User implements PublicLogin
|
|||
*
|
||||
* @return string Returns a hash with the authenticaction.
|
||||
*/
|
||||
public static function generatePublicHash(?string $other_secret=''):string
|
||||
public static function generatePublicHash(?string $other_secret=''): string
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
@ -166,7 +247,7 @@ class User implements PublicLogin
|
|||
public static function validatePublicHash(
|
||||
string $hash,
|
||||
string $other_secret=''
|
||||
):bool {
|
||||
): bool {
|
||||
global $config;
|
||||
|
||||
if (isset($config['id_user']) === true) {
|
||||
|
|
|
@ -283,7 +283,7 @@ class WSManager extends WebSocketServer
|
|||
$user->address = $user->headers['x-forwarded-for'];
|
||||
}
|
||||
|
||||
$user->account = new User(['phpsessionid' => $php_session_id]);
|
||||
$user->account = User::auth(['phpsessionid' => $php_session_id]);
|
||||
$_SERVER['REMOTE_ADDR'] = $user->address;
|
||||
|
||||
// Ensure user is allowed to connect.
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
|
||||
* Copyright (c) 2005-2023 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -84,10 +84,22 @@ if (isset($_GET['modified']) && !$view_mode) {
|
|||
$upd_info['id_skin'] = get_parameter('skin', $user_info['id_skin']);
|
||||
$upd_info['default_event_filter'] = get_parameter('event_filter', null);
|
||||
$upd_info['block_size'] = get_parameter('block_size', $config['block_size']);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// API Token information.
|
||||
$apiTokenRenewed = (bool) get_parameter('renewAPIToken');
|
||||
$upd_info['api_token'] = ($apiTokenRenewed === true) ? api_token_generate() : users_get_API_token($config['id_user']);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$default_block_size = get_parameter('default_block_size', 0);
|
||||
if ($default_block_size > 0) {
|
||||
$upd_info['block_size'] = 0;
|
||||
|
@ -98,6 +110,11 @@ if (isset($_GET['modified']) && !$view_mode) {
|
|||
$dashboard = get_parameter('dashboard', '');
|
||||
$visual_console = get_parameter('visual_console', '');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Save autorefresh list.
|
||||
$autorefresh_list = get_parameter_post('autorefresh_list');
|
||||
if (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) {
|
||||
|
@ -106,6 +123,11 @@ if (isset($_GET['modified']) && !$view_mode) {
|
|||
$upd_info['autorefresh_white_list'] = json_encode($autorefresh_list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$upd_info['time_autorefresh'] = (int) get_parameter('time_autorefresh', 0);
|
||||
$upd_info['ehorus_user_level_user'] = get_parameter('ehorus_user_level_user');
|
||||
$upd_info['ehorus_user_level_pass'] = get_parameter('ehorus_user_level_pass');
|
||||
|
@ -269,6 +291,11 @@ if (is_metaconsole() === false && is_management_allowed() === false) {
|
|||
$user_id = '<div class="label_select_simple"><p class="edit_user_labels">'.__('User ID').': </p>';
|
||||
$user_id .= '<span>'.$id.'</span></div>';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$user_id .= '<div class="label_select_simple"><p class="edit_user_labels">'.__('API Token').'</p>';
|
||||
if (is_management_allowed()) {
|
||||
$user_id .= html_print_anchor(
|
||||
|
@ -335,6 +362,13 @@ if ($http_authorization === false) {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$user_id .= '</div>';
|
||||
$full_name = ' <div class="label_select_simple">'.html_print_input_text_extended(
|
||||
'fullname',
|
||||
|
@ -551,6 +585,18 @@ if ((bool) check_acl($config['id_user'], 0, 'ER') === true) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$autorefresh_list_out = [];
|
||||
if (is_metaconsole() === false || is_centralized() === true) {
|
||||
$autorefresh_list_out['operation/agentes/estado_agente'] = 'Agent detail';
|
||||
|
@ -696,6 +742,17 @@ $time_autorefresh .= html_print_select(
|
|||
).'</div>';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$comments = '<p class="edit_user_labels">'.__('Comments').': </p>';
|
||||
$comments .= html_print_textarea(
|
||||
'comments',
|
||||
|
|
Loading…
Reference in New Issue