2006-03-27 05:37:27 +02:00
< ? php
2022-09-12 12:41:09 +02:00
/**
* User creation / update .
*
* @ category Users
* @ package Pandora FMS
* @ subpackage Community
* @ version 1.0 . 0
* @ license See below
*
* ______ ___ _______ _______ ________
2023-06-08 12:42:10 +02:00
* | __ \ .-----.--.--.--| |.-----.----.-----. | ___ | | | __ |
* | __ /| _ | | _ || _ | _ | _ | | ___ | | __ |
2022-09-12 12:41:09 +02:00
* | ___ | | ___ . _ | __ | __ | _____ || _____ | __ | | ___ . _ | | ___ | | __ | _ | __ | _______ |
*
* ============================================================================
2023-06-08 11:53:13 +02:00
* Copyright ( c ) 2005 - 2023 Pandora FMS
2023-06-08 13:19:01 +02:00
* Please see https :// pandorafms . com / community / for full contribution list
2022-09-12 12:41:09 +02:00
* 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.
2010-03-03 18:10:37 +01:00
global $config ;
2023-02-16 12:59:23 +01:00
2019-01-30 16:18:44 +01:00
check_login ();
2010-03-10 18:58:29 +01:00
2020-05-05 12:50:15 +02:00
require_once $config [ 'homedir' ] . '/vendor/autoload.php' ;
2020-03-26 12:29:38 +01:00
use PandoraFMS\Dashboard\Manager ;
2019-01-30 16:18:44 +01:00
require_once $config [ 'homedir' ] . '/include/functions_profile.php' ;
require_once $config [ 'homedir' ] . '/include/functions_users.php' ;
require_once $config [ 'homedir' ] . '/include/functions_groups.php' ;
require_once $config [ 'homedir' ] . '/include/functions_visual_map.php' ;
require_once $config [ 'homedir' ] . '/include/functions_custom_fields.php' ;
2018-03-20 16:51:41 +01:00
enterprise_include_once ( 'include/functions_profile.php' );
* include/functions_graph.php
include/functions_html.php
include/functions_messages.php
include/db/postgresql.php
include/db/mysql.php
include/db/oracle.php
include/functions_reporting.php
include/functions_filemanager.php
include/functions_gis.php
include/auth/ldap.php
include/auth/mysql.php
include/functions_networkmap.php
include/functions_network_components.php
include/ajax/skins.ajax.php
include/ajax/reporting.ajax.php
include/ajax/visual_console_builder.ajax.php
include/ajax/alert_list.ajax.php
include/ajax/module.php
include/functions_config.php
include/functions_api.php
include/help/en/help_timesource.php
include/help/es/help_timesource.php
include/help/ja/help_timesource.php
include/config_process.php
include/functions_ui.php
include/functions_custom_graphs.php
include/fgraph.php
include/functions_incidents.php
include/api.php
include/functions_reports.php
include/functions_ui_renders.php
extensions/insert_data.php
extensions/system_info.php
extensions/extension_uploader.php
extensions/pandora_logs.php
extensions/agents_modules.php
extensions/update_manager.php
extensions/ssh_console.php
extensions/dbmanager.php
extensions/vnc_view.php
extensions/resource_registration.php
extensions/resource_exportation.php
extensions/users_connected.php
extensions/module_groups.php
extensions/update_manager/load_updatemanager.php
extensions/update_manager/lib/libupdate_manager_client.php
extensions/update_manager/lib/libupdate_manager.php
extensions/update_manager/lib/libupdate_manager_components.php
extensions/update_manager/lib/libupdate_manager_updates.php
extensions/update_manager/settings.php
extensions/update_manager/main.php
extensions/plugin_registration.php
operation/incidents/incident.php
operation/incidents/incident_detail.php
operation/incidents/incident_statistics.php
operation/search_modules.php
operation/visual_console/render_view.php
operation/visual_console/index.php
operation/extensions.php
operation/agentes/status_monitor.php
operation/agentes/export_csv.php
operation/agentes/estado_ultimopaquete.php
operation/agentes/datos_agente.php
operation/agentes/alerts_status.php
operation/agentes/estado_generalagente.php
operation/agentes/custom_fields.php
operation/agentes/estado_agente.php
operation/agentes/networkmap.topology.php
operation/agentes/networkmap.groups.php
operation/agentes/sla_view.php
operation/agentes/exportdata.php
operation/agentes/gis_view.php
operation/agentes/estado_monitores.php
operation/agentes/ver_agente.php
operation/agentes/graphs.php
operation/agentes/agent_fields.php
operation/agentes/tactical.php
operation/agentes/group_view.php
operation/agentes/networkmap.php
operation/agentes/stat_win.php
operation/servers/view_server.php
operation/servers/view_server_detail.php
operation/menu.php
operation/search_agents.php
operation/search_graphs.php
operation/snmpconsole/snmp_view.php
operation/users/user_edit.php
operation/gis_maps/render_view.php
operation/gis_maps/ajax.php
operation/integria_incidents/incident.php
operation/integria_incidents/incident_detail.php
operation/integria_incidents/incident_statistics.php
operation/events/event_statistics.php
operation/events/events_rss.php
operation/events/export_csv.php
operation/events/sound_events.php
operation/events/events_validate.php
operation/events/events_list.php
operation/events/events_marquee.php
operation/events/events.php
operation/search_alerts.php
operation/messages/message.php
operation/reporting/reporting_xml.php
operation/reporting/reporting_viewer.php
operation/reporting/graph_viewer.php
operation/search_reports.php
operation/search_maps.php
operation/search_users.php
extras/pandora_diag.php
mobile/operation/agents/monitor_status.php
mobile/operation/agents/view_agents.php
mobile/operation/agents/view_alerts.php
mobile/operation/agents/group_view.php
mobile/operation/events/events.php
mobile/index.php
general/error_authconfig.php
general/links_menu.php
general/logon_ok.php
general/error_dbconfig.php
general/ui/agents_list.php
general/header.php
godmode/groups/modu_group_list.php
godmode/groups/configure_group.php
godmode/groups/configure_modu_group.php
godmode/groups/group_list.php
godmode/admin_access_logs.php
godmode/db/db_main.php
godmode/db/db_audit.php
godmode/db/db_sanity.php
godmode/db/db_refine.php
godmode/db/db_info.php
godmode/db/db_event.php
godmode/db/db_purge.php
godmode/extensions.php
godmode/agentes/agent_template.php
godmode/agentes/module_manager_editor_common.php
godmode/agentes/fields_manager.php
godmode/agentes/agent_conf_gis.php
godmode/agentes/module_manager_editor_prediction.php
godmode/agentes/module_manager.php
godmode/agentes/modificar_agente.php
godmode/agentes/configurar_agente.php
godmode/agentes/configure_field.php
godmode/agentes/module_manager_editor.php
godmode/agentes/planned_downtime.php
godmode/agentes/manage_config_remote.php
godmode/agentes/agent_manager.php
godmode/servers/recon_script.php
godmode/servers/plugin.php
godmode/servers/manage_recontask.php
godmode/servers/modificar_server.php
godmode/servers/manage_recontask_form.php
godmode/alerts/alert_list.list.php
godmode/alerts/configure_alert_compound.php
godmode/alerts/alert_compounds.php
godmode/alerts/alert_list.php
godmode/alerts/configure_alert_template.php
godmode/alerts/alert_templates.php
godmode/alerts/configure_alert_action.php
godmode/alerts/configure_alert_command.php
godmode/alerts/alert_actions.php
godmode/alerts/alert_list.builder.php
godmode/alerts/alert_commands.php
godmode/setup/file_manager.php
godmode/setup/os.list.php
godmode/setup/news.php
godmode/setup/gis_step_2.php
godmode/setup/links.php
godmode/setup/setup.php
godmode/setup/os.php
godmode/setup/performance.php
godmode/setup/setup_auth.php
godmode/setup/gis.php
godmode/setup/os.builder.php
godmode/setup/setup_visuals.php
godmode/snmpconsole/snmp_alert.php
godmode/snmpconsole/snmp_filters.php
godmode/users/user_list.php
godmode/users/configure_profile.php
godmode/gis_maps/configure_gis_map.php
godmode/gis_maps/index.php
godmode/massive/massive_add_alerts.php
godmode/massive/massive_copy_modules.php
godmode/massive/massive_delete_agents.php
godmode/massive/massive_enable_disable_alerts.php
godmode/massive/massive_operations.php
godmode/massive/massive_delete_profiles.php
godmode/massive/massive_edit_agents.php
godmode/massive/massive_delete_action_alerts.php
godmode/massive/massive_delete_modules.php
godmode/massive/massive_add_profiles.php
godmode/massive/massive_delete_alerts.php
godmode/massive/massive_edit_modules.php
godmode/massive/massive_standby_alerts.php
godmode/massive/massive_add_action_alerts.php
godmode/modules/manage_network_components_form.php
godmode/modules/manage_nc_groups_form.php
godmode/modules/manage_network_templates.php
godmode/modules/module_list.php
godmode/modules/manage_network_components_form_common.php
godmode/modules/manage_network_components_form_network.php
godmode/modules/manage_network_templates_form.php
godmode/modules/manage_network_components_form_wmi.php
godmode/modules/manage_network_components.php
godmode/modules/manage_nc_groups.php
godmode/reporting/visual_console_builder.wizard.php
godmode/reporting/graph_builder.main.php
godmode/reporting/reporting_builder.list_items.php
godmode/reporting/visual_console_builder.php
godmode/reporting/reporting_builder.preview.php
godmode/reporting/reporting_builder.main.php
godmode/reporting/visual_console_builder.data.php
godmode/reporting/visual_console_builder.elements.php
godmode/reporting/graph_builder.php
godmode/reporting/visual_console_builder.preview.php
godmode/reporting/graph_builder.graph_editor.php
godmode/reporting/reporting_builder.php
godmode/reporting/visual_console_builder.editor.php
godmode/reporting/reporting_builder.item_editor.php
godmode/reporting/map_builder.php
godmode/reporting/graphs.php
godmode/reporting/graph_builder.preview.php
include/functions_db.php: Added some includes and functions of this code have "db_" prefix.
* include/functions.php: Moved function check_login(), check_acl(),
dame_nombre_pluginid(), get_os_name() from functions_db.php to functions.php.
* include/functions_groups.php: Moved functions get_childrens(), safe_acl_group()
and get_parents(), give_disabled_group(), isAllGroups(), get_group_icon(), get_all_groups(),
get_id_groups_recursive(), get_user_groups_tree_recursive(), get_group_status(),
get_group_name(), get_group_users() from functions_db.php to this code.
* include/functions_profile.php: New library with profile functions. Moved functions
get_profile_name(), get_profiles(), create_user_profile(), delete_user_profile(),
delete_profile() from functions_db.php to this code. Added new parameter in function
get_profile() to retrieve profiles with filter conditions applied.
* include/functions_users.php: New library with users functions. Moved functions
get_users_info(), get_all_model_groups(), get_user_groups(), get_user_groups_tree(),
get_user_first_group(), user_access_to_agent() from funtions_db.php to this code.
* godmode/users/configure_user.php: Changed get_profile_filter() function to get_profile().
* include/functions_agents.php: Moved functions get_group_agents(), get_agent_modules(),
get_agent_module_id(), get_agent_id(), get_agent_name(), get_agent_modules_data_count(),
check_alert_fired(), get_agent_interval(), get_agent_os(), give_agentmodule_flag(),
agent_add_address(), agent_delete_address(), get_agent_address(), get_agent_with_ip(),
get_agent_addresses(), get_agent_status(), delete_agent(), get_agentmodule_group(),
get_agent_group() from functions_db.php to this code.
* include/functions_modules.php: Moved functions get_agentmodule(), get_agentmodule_id(),
get_agentmodule_is_init(), get_agent_modules_count(), get_module_type_name(),
get_module_type_icon(), get_agentmodule_agent(), get_agentmodule_agent_name(),
get_agentmodule_name(), get_agentmodule_type(), get_monitor_downs_in_period(),
get_monitor_last_down_timestamp_in_period(), get_monitors_in_group(),
get_monitors_in_agent(), get_monitors_down(), get_moduletype_name(),
get_moduletype_description(), get_moduletypes(), get_module_interval(), show_icon_type(),
give_modulecategory_name(),
give_agent_id_from_module_id(), get_module_status(), get_agent_module_last_value(),
get_previous_data(), get_agentmodule_modulegroup(), get_modulegroups(),
get_modulegroup_name() from functions_db.php to this code.
* include/functions_alerts.php: Moved functions get_alert_type(), get_agent_alert_fired(),
get_module_alert_fired(), get_alert_fires_in_period(), get_group_alerts(), get_alerts_fired(),
get_alert_last_fire_timestamp_in_period(), get_agentmodule_status(),
get_agentmodule_last_status() from functions_db.php to this code.
* include/functions_exportserver.php: Moved function dame_nombre_servidorexportacion()
from functions_db.php to this code.
* include/functions_events.php: Moved functions get_group_events(), get_agent_events(),
get_module_events() from functions_db.php to this code.
* include/functions_servers.php: Moved functions get_server_name(), show_server_type(),
check_server_status(), server_status() from functions_db.php to this code.
* include/functions_network_profiles.php: Moved function get_networkprofile_name()
from functions_db.php to this code.
* include/functions_visual_map.php: Moved functions get_layoutdata_x(), get_layoutdata_y()
from fucntions_db.php to this code.
* include/functions_io.php: Moved function __() from functions_db.php to this code.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2011-04-19 20:42:49 +02:00
2019-01-30 16:18:44 +01:00
$isFunctionSkins = enterprise_include_once ( 'include/functions_skins.php' );
2011-04-25 11:41:35 +02:00
2019-01-30 16:18:44 +01:00
// Add the columns for the enterprise Pandora edition.
2011-05-10 17:53:43 +02:00
$enterprise_include = false ;
if ( ENTERPRISE_NOT_HOOK !== enterprise_include ( 'include/functions_policies.php' )) {
2019-01-30 16:18:44 +01:00
$enterprise_include = true ;
2011-05-10 17:53:43 +02:00
}
2022-06-28 17:24:49 +02:00
if ( $enterprise_include === true ) {
2019-01-30 16:18:44 +01:00
enterprise_include_once ( 'meta/include/functions_users_meta.php' );
}
2012-12-11 18:39:48 +01:00
2023-05-11 16:44:11 +02:00
$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' ),
];
2023-02-06 23:10:28 +01:00
// This defines the working user. Beware with this, old code get confusses
// and operates with current logged user (dangerous).
$id = get_parameter ( 'id' , get_parameter ( 'id_user' , '' ));
2023-04-25 10:57:21 +02:00
if ( empty ( $id ) === true ) {
$id = $config [ 'id_user' ];
}
2023-02-06 23:10:28 +01:00
// Check if we are the same user for edit or we have a proper profile for edit users.
if ( $id !== $config [ 'id_user' ]) {
2023-03-14 09:05:59 +01:00
if (( bool ) check_acl ( $config [ 'id_user' ], 0 , 'UM' ) === false ) {
2023-02-06 23:10:28 +01:00
db_pandora_audit (
AUDIT_LOG_ACL_VIOLATION ,
'Trying to access User Management'
);
include 'general/noaccess.php' ;
2020-05-19 08:20:04 +02:00
2023-02-06 23:10:28 +01:00
return ;
2020-05-19 08:20:04 +02:00
}
}
2022-06-28 17:24:49 +02:00
// ID given as parameter.
2012-12-11 18:39:48 +01:00
$pure = get_parameter ( 'pure' , 0 );
2019-01-30 16:18:44 +01:00
$user_info = get_user_info ( $id );
2023-05-19 10:49:16 +02:00
if ( is_metaconsole () === true ) {
$user_info [ 'section' ] = $user_info [ 'metaconsole_section' ];
$user_info [ 'data_section' ] = $user_info [ 'metaconsole_data_section' ];
2023-05-22 12:08:27 +02:00
$user_info [ 'default_event_filter' ] = $user_info [ 'metaconsole_default_event_filter' ];
2023-05-19 10:49:16 +02:00
}
2020-09-09 14:32:02 +02:00
$is_err = false ;
2009-01-22 18:44:33 +01:00
2022-06-17 12:13:23 +02:00
if ( is_ajax () === true ) {
2020-07-23 13:26:39 +02:00
$delete_profile = ( bool ) get_parameter ( 'delete_profile' );
2022-11-22 17:09:13 +01:00
$get_user_profile = ( bool ) get_parameter ( 'get_user_profile' );
if ( $get_user_profile === true ) {
$profile_id = ( int ) get_parameter ( 'profile_id' );
$group_id = ( int ) get_parameter ( 'group_id' , - 1 );
$user_id = ( string ) get_parameter ( 'user_id' , '' );
$no_hierarchy = ( int ) get_parameter ( 'no_hierarchy' , - 1 );
$assigned_by = ( string ) get_parameter ( 'assigned_by' , '' );
$id_policy = ( int ) get_parameter ( 'id_policy' , - 1 );
$tags = ( string ) get_parameter ( 'id_policy' , '' );
$filter = [];
if ( $group_id > - 1 ) {
$filter [ 'id_perfil' ] = $profile_id ;
}
if ( $group_id > - 1 ) {
$filter [ 'id_grupo' ] = $group_id ;
}
if ( $user_id !== '' ) {
$filter [ 'id_usuario' ] = $user_id ;
}
if ( $no_hierarchy > - 1 ) {
$filter [ 'no_hierarchy' ] = $no_hierarchy ;
}
if ( $assigned_by !== '' ) {
$filter [ 'assigned_by' ] = $assigned_by ;
}
2020-11-30 14:52:03 +01:00
2022-11-22 17:09:13 +01:00
if ( $id_policy > - 1 ) {
$filter [ 'id_policy' ] = $id_policy ;
}
if ( $tags !== '' ) {
$filter [ 'tags' ] = $tags ;
}
$profile = db_get_all_rows_filter (
'tusuario_perfil' ,
$filter
);
if ( $profile !== false && count ( $profile ) > 0 ) {
echo json_encode ( $profile );
return ;
} else {
echo json_encode ( '' );
}
return ;
}
2020-07-23 13:26:39 +02:00
}
2011-11-03 18:28:18 +01:00
2011-06-29 19:21:13 +02:00
$tab = get_parameter ( 'tab' , 'user' );
2023-02-03 14:10:26 +01:00
// Save autorefresh list.
2023-02-06 23:10:28 +01:00
$autorefresh_list = ( array ) get_parameter_post ( 'autorefresh_list' );
2023-02-03 14:10:26 +01:00
$autorefresh_white_list = (( $autorefresh_list [ 0 ] === '' ) || ( $autorefresh_list [ 0 ] === '0' )) ? '' : json_encode ( $autorefresh_list );
2022-06-17 12:13:23 +02:00
// Header.
2022-06-28 17:24:49 +02:00
if ( is_metaconsole () === true ) {
2019-01-30 16:18:44 +01:00
user_meta_print_header ();
$sec = 'advanced' ;
} else {
2023-02-13 14:23:31 +01:00
if (( bool ) check_acl ( $config [ 'id_user' ], 0 , 'UM' ) === false ) {
$buttons = [];
} else {
$buttons = [
'user' => [
'active' => false ,
'text' => '<a href="index.php?sec=gusuarios&sec2=godmode/users/user_list&tab=user&pure=' . $pure . '">' . html_print_image (
'images/user.svg' ,
true ,
[
'title' => __ ( 'User management' ),
'class' => 'invert_filter main_menu_icon' ,
]
) . '</a>' ,
],
'profile' => [
'active' => false ,
'text' => '<a href="index.php?sec=gusuarios&sec2=godmode/users/profile_list&tab=profile&pure=' . $pure . '">' . html_print_image (
'images/suitcase@svg.svg' ,
true ,
[
'title' => __ ( 'Profile management' ),
'class' => 'invert_filter main_menu_icon' ,
]
) . '</a>' ,
],
];
2019-01-30 16:18:44 +01:00
2023-02-13 14:23:31 +01:00
$buttons [ $tab ][ 'active' ] = true ;
}
2019-01-30 16:18:44 +01:00
2023-06-22 10:51:26 +02:00
$edit_user = get_parameter ( 'edit_user' );
2022-06-28 17:24:49 +02:00
ui_print_standard_header (
2023-06-22 10:51:26 +02:00
( $edit_user ) ? sprintf ( '%s [ %s ]' , __ ( 'Update User' ), $id ) : __ ( 'Create User' ),
2019-04-29 14:36:02 +02:00
'images/gm_users.png' ,
false ,
2020-05-29 11:37:06 +02:00
'' ,
2019-04-29 14:36:02 +02:00
true ,
2022-06-28 17:24:49 +02:00
$buttons ,
[
[
'link' => '' ,
'label' => __ ( 'Profiles' ),
],
[
'link' => ui_get_full_url ( 'index.php?sec=gusuarios&sec2=godmode/users/user_list' ),
'label' => __ ( 'Manage users' ),
],
[
'link' => '' ,
'label' => __ ( 'User Detail Editor' ),
],
]
2019-04-29 14:36:02 +02:00
);
2022-06-28 17:24:49 +02:00
2019-01-30 16:18:44 +01:00
$sec = 'gusuarios' ;
2012-12-11 18:39:48 +01:00
}
2010-02-22 20:03:55 +01:00
2013-05-20 10:42:02 +02:00
2022-06-28 17:24:49 +02:00
if (( bool ) $config [ 'user_can_update_info' ] === true ) {
2019-01-30 16:18:44 +01:00
$view_mode = false ;
} else {
$view_mode = true ;
2008-08-11 Esteban Sanchez <estebans@artica.es>
* include/functions_db.php: Added __ as an alias of lang_string().
* include/functions_reporting_pdf.php,
include/functions_reporting.php, include/functions.php,
include/functions_visual_map.php, index.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/incidents/incident_note.php,
operation/incidents/incident_search.php,
operation/incidents/incident_statistics.php,
operation/snmpconsole/snmp_alert.php,
operation/snmpconsole/snmp_view.php, operation/users/user.php,
operation/users/user_edit.php, operation/users/user_statistics.php,
operation/events/event_statistics.php, operation/events/events.php,
operation/visual_console/render_view.php,
operation/visual_console/index.php, operation/extensions.php,
operation/agentes/estado_alertas.php,
operation/agentes/status_monitor.php,
operation/agentes/estado_grupo.php, operation/agentes/export_csv.php,
operation/agentes/datos_agente.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/bulbs.php,
operation/agentes/status_events.php, operation/agentes/sla_view.php,
operation/agentes/exportdata.php,
operation/agentes/estado_monitores.php,
operation/agentes/ver_agente.php, operation/agentes/estadisticas.php,
operation/agentes/tactical.php, operation/agentes/networkmap.php,
operation/messages/message.php,
operation/reporting/reporting_viewer.php,
operation/reporting/graph_viewer.php,
operation/reporting/custom_reporting.php,
operation/servers/view_server.php,
operation/servers/view_server_detail.php, operation/menu.php,
reporting/fgraph.php, reporting/stat_win.php, ajax.php,
general/logoff.php, general/pandora_help.php, general/footer.php,
general/noaccess.php, general/logon_failed.php,
general/links_menu.php, general/login_page.php, general/logon_ok.php,
general/header.php, general/main_menu.php,
godmode/groups/configure_group.php, godmode/groups/group_list.php,
godmode/setup/news.php, godmode/setup/links.php,
godmode/setup/setup.php, godmode/users/user_list.php,
godmode/users/configure_user.php, godmode/profiles/profile_list.php,
godmode/admin_access_logs.php, godmode/db/db_info_data.php,
godmode/db/db_main.php, godmode/db/db_audit.php,
godmode/db/db_sanity.php, godmode/db/db_refine.php,
godmode/db/db_info.php, godmode/db/db_event.php,
godmode/db/db_purge.php, godmode/extensions.php,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_wmi.php,
godmode/agentes/alert_manager.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/alert_manager_editor.php,
godmode/agentes/manage_config.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/agent_disk_conf_editor.php,
godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php,
godmode/agentes/agent_manager.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_nc_groups_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/module_list.php,
godmode/modules/manage_network_templates_form.php,
godmode/modules/manage_network_components_form_network.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/map_builder.php,
godmode/reporting/graph_builder.php, godmode/servers/plugin.php,
godmode/servers/manage_recontask.php,
godmode/servers/modificar_server.php,
godmode/servers/manage_recontask_form.php,
godmode/alerts/modify_alert.php, godmode/alerts/configure_alert.php,
godmode/menu.php: Replaced $id_user with $config['id_user']. Use __a
instead of $lang_label to future use of gettext. Style
corrections.
* godmode/agentes/planned_downtime.php: Rewritten to use Pandora
functions and adopt the UI style. Replaced lang_string with __().
* pandoradb.sql: Fields in tplanned_downtime renamed to fit
guidelines.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1005 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-08-11 12:59:07 +02:00
}
2023-05-08 11:03:21 +02:00
$delete_profile = ( bool ) get_parameter ( 'delete_profile' );
2019-01-30 16:18:44 +01:00
$new_user = ( bool ) get_parameter ( 'new_user' );
$create_user = ( bool ) get_parameter ( 'create_user' );
$add_profile = ( bool ) get_parameter ( 'add_profile' );
$update_user = ( bool ) get_parameter ( 'update_user' );
2022-06-17 12:13:23 +02:00
$renewAPIToken = ( bool ) get_parameter ( 'renewAPIToken' );
2019-01-30 16:18:44 +01:00
$status = get_parameter ( 'status' , - 1 );
2020-07-23 13:26:39 +02:00
$json_profile = get_parameter ( 'json_profile' , '' );
2009-03-26 Esteban Sanchez <estebans@artica.es>
* godmode/users/configure_user.php: Complete rewritten to fix minor
errors and fit the Pandora style.
* include/auth/ldap.php: Removed process_user_isadmin(). Renamed
process_user_password() to update_user_password(). Renamed
process_user_info to update_user(). update_user_password() does not
require old password anymore.
* include/functions_db.php: Added empty checks on
create_user_profile().
* include/functions_ui.php: print_error_message() renamed to
print_result_message().
* godmode/agentes/configurar_agente.php,
godmode/alerts/alert_actions.php, godmode/alerts/alert_commands.php,
godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_template.php,
godmode/modules/manage_nc_groups.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_templates_form.php,
godmode/reporting/map_builder_wizard.php,
godmode/reporting/reporting_builder.php,
operation/agentes/alerts_status.php, operation/events/events.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/messages/message.php, operation/snmpconsole/snmp_view.php,
operation/users/user_edit.php: Renamed print_result_message(). Some
translatable strings reused to simplify i18n work.
* godmode/users/user_list.php: Renamed print_result_message(). Use
cross.png for deletion links. Style corrections.
* godmode/setup/news.php: Renamed print_result_message(). Use
process_sql_delete() instead of direct mysql_query.
* godmode/reporting/map_builder.php: Renamed print_result_message().
Style correction on process_sql_update().
* godmode/alerts/configure_alert_compound.php: Renamed
print_result_message(). Fixed steps_clean div.
* godmode/setup/setup.php: Return control to index instead of exit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1567 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-03-26 12:14:49 +01:00
2022-06-28 17:24:49 +02:00
// Reset status var if current action is not update_user.
if ( $new_user === true || $create_user === true || $add_profile === true
|| $delete_profile === true || $update_user === true
2019-01-30 16:18:44 +01:00
) {
$status = - 1 ;
2011-08-30 17:21:40 +02:00
}
2011-08-30 16:51:03 +02:00
2022-06-28 17:24:49 +02:00
if ( $new_user === true && ( bool ) $config [ 'admin_can_add_user' ] === true ) {
2019-01-30 16:18:44 +01:00
$user_info = [];
$id = '' ;
$user_info [ 'fullname' ] = '' ;
$user_info [ 'firstname' ] = '' ;
$user_info [ 'lastname' ] = '' ;
$user_info [ 'email' ] = '' ;
$user_info [ 'phone' ] = '' ;
$user_info [ 'comments' ] = '' ;
$user_info [ 'is_admin' ] = 0 ;
$user_info [ 'language' ] = 'default' ;
$user_info [ 'timezone' ] = '' ;
$user_info [ 'not_login' ] = false ;
2022-02-01 09:37:02 +01:00
$user_info [ 'local_user' ] = false ;
2019-01-30 16:18:44 +01:00
$user_info [ 'strict_acl' ] = false ;
$user_info [ 'session_time' ] = 0 ;
2019-07-09 14:08:06 +02:00
$user_info [ 'middlename' ] = 0 ;
2019-01-30 16:18:44 +01:00
if ( $isFunctionSkins !== ENTERPRISE_NOT_HOOK ) {
$user_info [ 'id_skin' ] = '' ;
}
$user_info [ 'section' ] = '' ;
$user_info [ 'data_section' ] = '' ;
2022-06-28 17:24:49 +02:00
// This attributes are inherited from global configuration.
2019-01-30 16:18:44 +01:00
$user_info [ 'block_size' ] = $config [ 'block_size' ];
2022-06-28 17:24:49 +02:00
if ( enterprise_installed () === true && is_metaconsole () === true ) {
2019-01-30 16:18:44 +01:00
$user_info [ 'metaconsole_agents_manager' ] = 0 ;
$user_info [ 'metaconsole_access_node' ] = 0 ;
}
2019-05-27 18:49:47 +02:00
2023-04-14 10:02:41 +02:00
if ( isset ( $config [ 'ehorus_user_level_conf' ]) === true && ( bool ) $config [ 'ehorus_user_level_conf' ] === true ) {
2019-05-27 18:49:47 +02:00
$user_info [ 'ehorus_user_level_user' ] = '' ;
$user_info [ 'ehorus_user_level_pass' ] = '' ;
2019-05-28 13:14:42 +02:00
$user_info [ 'ehorus_user_level_enabled' ] = true ;
2019-05-27 18:49:47 +02:00
}
2009-03-27 12:33:11 +01:00
}
2022-06-28 17:24:49 +02:00
if ( $create_user === true ) {
if (( bool ) $config [ 'admin_can_add_user' ] === false ) {
ui_print_error_message (
__ ( 'The current authentication scheme doesn\'t support creating users on %s' , get_product_name ())
);
2019-01-30 16:18:44 +01:00
return ;
}
2022-06-28 17:24:49 +02:00
if ( html_print_csrf_error () === true ) {
2019-01-30 16:18:44 +01:00
return ;
}
2022-06-27 16:48:00 +02:00
$user_is_admin = ( get_parameter ( 'is_admin' , 0 ) === 0 ) ? 0 : 1 ;
2019-01-30 16:18:44 +01:00
2022-03-03 16:35:31 +01:00
if ( users_is_admin () === false && $user_is_admin !== 0 ) {
db_pandora_audit (
AUDIT_LOG_ACL_VIOLATION ,
2022-03-10 07:57:34 +01:00
'Trying to create with administrator privileges to user by non administrator user ' . $config [ 'id_user' ]
2022-03-03 16:35:31 +01:00
);
include 'general/noaccess.php' ;
exit ;
}
2019-01-30 16:18:44 +01:00
$values = [];
$values [ 'id_user' ] = ( string ) get_parameter ( 'id_user' );
$values [ 'fullname' ] = ( string ) get_parameter ( 'fullname' );
$values [ 'firstname' ] = ( string ) get_parameter ( 'firstname' );
$values [ 'lastname' ] = ( string ) get_parameter ( 'lastname' );
$password_new = ( string ) get_parameter ( 'password_new' , '' );
$password_confirm = ( string ) get_parameter ( 'password_confirm' , '' );
$values [ 'email' ] = ( string ) get_parameter ( 'email' );
$values [ 'phone' ] = ( string ) get_parameter ( 'phone' );
2020-09-09 11:58:09 +02:00
$values [ 'comments' ] = io_safe_input ( strip_tags ( io_safe_output (( string ) get_parameter ( 'comments' ))));
2022-09-12 12:41:09 +02:00
$values [ 'allowed_ip_active' ] = (( int ) get_parameter_switch ( 'allowed_ip_active' , - 1 ) === 0 );
$values [ 'allowed_ip_list' ] = io_safe_input ( strip_tags ( io_safe_output (( string ) get_parameter ( 'allowed_ip_list' ))));
2019-01-30 16:18:44 +01:00
$values [ 'is_admin' ] = $user_is_admin ;
$values [ 'language' ] = get_parameter ( 'language' , 'default' );
$values [ 'timezone' ] = ( string ) get_parameter ( 'timezone' );
$values [ 'default_event_filter' ] = ( int ) get_parameter ( 'default_event_filter' );
$values [ 'default_custom_view' ] = ( int ) get_parameter ( 'default_custom_view' );
2023-03-17 12:00:51 +01:00
$values [ 'time_autorefresh' ] = ( int ) get_parameter ( 'time_autorefresh' , 0 );
2023-03-23 12:41:39 +01:00
$values [ 'show_tips_startup' ] = ( int ) get_parameter_switch ( 'show_tips_startup' );
2019-01-30 16:18:44 +01:00
$dashboard = get_parameter ( 'dashboard' , '' );
$visual_console = get_parameter ( 'visual_console' , '' );
if ( $isFunctionSkins !== ENTERPRISE_NOT_HOOK ) {
$values [ 'id_skin' ] = ( int ) get_parameter ( 'skin' , 0 );
}
$values [ 'block_size' ] = ( int ) get_parameter ( 'block_size' , $config [ 'block_size' ]);
$values [ 'section' ] = get_parameter ( 'section' );
2023-02-03 14:10:26 +01:00
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 )) {
2019-01-30 16:18:44 +01:00
$values [ 'data_section' ] = '' ;
2023-02-03 14:10:26 +01:00
} else if ( $values [ 'section' ] === HOME_SCREEN_DASHBOARD ) {
2019-01-30 16:18:44 +01:00
$values [ 'data_section' ] = $dashboard ;
2023-02-03 14:10:26 +01:00
} else if ( io_safe_output ( $values [ 'section' ]) === HOME_SCREEN_VISUAL_CONSOLE ) {
2019-01-30 16:18:44 +01:00
$values [ 'data_section' ] = $visual_console ;
2023-02-03 14:10:26 +01:00
} else if ( $values [ 'section' ] === HOME_SCREEN_OTHER || io_safe_output ( $values [ 'section' ]) === HOME_SCREEN_EXTERNAL_LINK ) {
2019-01-30 16:18:44 +01:00
$values [ 'data_section' ] = get_parameter ( 'data_section' );
}
2023-06-28 15:08:09 +02:00
// $values['section'] = $homeScreenValues[$values['section']];
2022-09-12 12:41:09 +02:00
if ( enterprise_installed () === true ) {
2019-01-30 16:18:44 +01:00
$values [ 'force_change_pass' ] = 1 ;
$values [ 'last_pass_change' ] = date ( 'Y/m/d H:i:s' , get_system_time ());
2022-09-12 12:41:09 +02:00
if ( is_metaconsole () === true ) {
2019-01-30 16:18:44 +01:00
$values [ 'metaconsole_access' ] = get_parameter ( 'metaconsole_access' , 'basic' );
$values [ 'metaconsole_agents_manager' ] = ( $user_is_admin == 1 ? 1 : get_parameter ( 'metaconsole_agents_manager' , '0' ));
$values [ 'metaconsole_access_node' ] = ( $user_is_admin == 1 ? 1 : get_parameter ( 'metaconsole_access_node' , '0' ));
}
}
$values [ 'not_login' ] = ( bool ) get_parameter ( 'not_login' , false );
2022-02-01 09:37:02 +01:00
$values [ 'local_user' ] = ( bool ) get_parameter ( 'local_user' , false );
2019-07-09 14:08:06 +02:00
$values [ 'middlename' ] = get_parameter ( 'middlename' , 0 );
2019-01-30 16:18:44 +01:00
$values [ 'strict_acl' ] = ( bool ) get_parameter ( 'strict_acl' , false );
$values [ 'session_time' ] = ( int ) get_parameter ( 'session_time' , 0 );
2023-05-30 16:26:06 +02:00
// Previously defined.
$values [ 'autorefresh_white_list' ] = $autorefresh_white_list ;
2022-09-12 12:41:09 +02:00
// eHorus user level conf.
if (( bool ) $config [ 'ehorus_user_level_conf' ] === true ) {
2019-05-28 13:14:42 +02:00
$values [ 'ehorus_user_level_enabled' ] = ( bool ) get_parameter ( 'ehorus_user_level_enabled' , false );
if ( $values [ 'ehorus_user_level_enabled' ] === true ) {
$values [ 'ehorus_user_level_user' ] = ( string ) get_parameter ( 'ehorus_user_level_user' );
$values [ 'ehorus_user_level_pass' ] = ( string ) get_parameter ( 'ehorus_user_level_pass' );
} else {
$values [ 'ehorus_user_level_user' ] = null ;
$values [ 'ehorus_user_level_pass' ] = null ;
}
2019-05-27 18:49:47 +02:00
}
2022-06-29 09:14:21 +02:00
// Generate new API token.
$values [ 'api_token' ] = api_token_generate ();
2023-06-01 10:31:14 +02:00
// Validate the user ID if it already exists.
2023-06-22 10:51:26 +02:00
$user_exists = get_user_info ( $values [ 'id_user' ]);
if ( empty ( $values [ 'id_user' ]) === true ) {
2019-01-30 16:18:44 +01:00
ui_print_error_message ( __ ( 'User ID cannot be empty' ));
2020-09-09 14:32:02 +02:00
$is_err = true ;
2019-01-30 16:18:44 +01:00
$user_info = $values ;
$password_new = '' ;
$password_confirm = '' ;
$new_user = true ;
2023-06-01 10:31:14 +02:00
} else if ( isset ( $user_exists [ 'id_user' ])) {
$is_err = true ;
ui_print_error_message ( __ ( 'User ID already exists' ));
$user_info = $values ;
$password_new = '' ;
$password_confirm = '' ;
$new_user = true ;
2020-01-10 13:50:04 +01:00
} else if ( preg_match ( '/^\s+|\s+$/' , io_safe_output ( $id ))) {
ui_print_error_message ( __ ( 'Invalid user ID: leading or trailing blank spaces not allowed' ));
2020-09-09 14:32:02 +02:00
$is_err = true ;
2020-01-10 13:24:00 +01:00
$user_info = $values ;
$password_new = '' ;
$password_confirm = '' ;
$new_user = true ;
2022-09-12 12:41:09 +02:00
} else if ( empty ( $password_new ) === true ) {
2020-09-09 14:32:02 +02:00
$is_err = true ;
2019-01-30 16:18:44 +01:00
ui_print_error_message ( __ ( 'Passwords cannot be empty' ));
$user_info = $values ;
$password_new = '' ;
$password_confirm = '' ;
$new_user = true ;
} else if ( $password_new != $password_confirm ) {
2020-09-09 14:32:02 +02:00
$is_err = true ;
2019-01-30 16:18:44 +01:00
ui_print_error_message ( __ ( 'Passwords didn\'t match' ));
$user_info = $values ;
$password_new = '' ;
$password_confirm = '' ;
$new_user = true ;
2022-11-16 13:26:25 +01:00
} else if ( enterprise_hook ( 'excludedPassword' , [ $password_new ]) === true ) {
2022-10-25 09:37:49 +02:00
$is_err = true ;
ui_print_error_message ( __ ( 'The password provided is not valid. Please set another one.' ));
$user_info = $values ;
$password_new = '' ;
$password_confirm = '' ;
$new_user = true ;
2019-01-30 16:18:44 +01:00
} else {
2020-03-31 15:12:39 +02:00
if (( ! is_user_admin ( $config [ 'id_user' ]) || $config [ 'enable_pass_policy_admin' ]) && $config [ 'enable_pass_policy' ]) {
$pass_ok = login_validate_pass ( $password_new , $id , true );
if ( $pass_ok != 1 ) {
ui_print_error_message ( $pass_ok );
} else {
2020-01-21 17:31:21 +01:00
$result = create_user ( $id , $password_new , $values );
2019-08-22 15:25:35 +02:00
}
2019-08-30 11:28:24 +02:00
} else {
$result = create_user ( $id , $password_new , $values );
2019-08-22 15:25:35 +02:00
}
2019-01-30 16:18:44 +01:00
$info = '{"Id_user":"' . $values [ 'id_user' ] . '","FullName":"' . $values [ 'fullname' ] . '","Firstname":"' . $values [ 'firstname' ] . '","Lastname":"' . $values [ 'lastname' ] . '","Email":"' . $values [ 'email' ] . '","Phone":"' . $values [ 'phone' ] . '","Comments":"' . $values [ 'comments' ] . '","Is_admin":"' . $values [ 'is_admin' ] . '","Language":"' . $values [ 'language' ] . '","Timezone":"' . $values [ 'timezone' ] . '","Block size":"' . $values [ 'block_size' ] . '"' ;
2022-09-12 12:41:09 +02:00
if ( $values [ 'allowed_ip_active' ] === true ) {
$info .= ',"IPS Allowed":"' . $values [ 'allowed_ip_list' ] . '"' ;
}
2019-01-30 16:18:44 +01:00
if ( $isFunctionSkins !== ENTERPRISE_NOT_HOOK ) {
$info .= ',"Skin":"' . $values [ 'id_skin' ] . '"}' ;
} else {
$info .= '}' ;
}
2019-08-22 15:25:35 +02:00
$can_create = false ;
2019-01-30 16:18:44 +01:00
if ( $result ) {
$res = save_pass_history ( $id , $password_new );
2021-04-29 11:15:20 +02:00
} else {
$is_err = true ;
$user_info = $values ;
$password_new = '' ;
$password_confirm = '' ;
$new_user = true ;
2019-01-30 16:18:44 +01:00
}
db_pandora_audit (
2022-01-20 10:55:23 +01:00
AUDIT_LOG_USER_MANAGEMENT ,
2020-08-28 13:56:15 +02:00
'Created user ' . io_safe_output ( $id ),
2019-01-30 16:18:44 +01:00
false ,
false ,
$info
);
ui_print_result_message (
$result ,
__ ( 'Successfully created' ),
__ ( 'Could not be created' )
);
$password_new = '' ;
$password_confirm = '' ;
if ( $result ) {
if ( $values [ 'strict_acl' ]) {
if ( $values [ 'is_admin' ]) {
ui_print_info_message ( __ ( 'Strict ACL is not recommended for admin users because performance could be affected.' ));
}
}
$user_info = get_user_info ( $id );
$new_user = false ;
2020-07-23 13:26:39 +02:00
2023-02-13 14:23:31 +01:00
if ( empty ( $json_profile ) === false ) {
2020-07-23 13:26:39 +02:00
$json_profile = json_decode ( io_safe_output ( $json_profile ), true );
foreach ( $json_profile as $key => $profile ) {
2022-10-17 12:26:38 +02:00
if ( is_array ( $profile ) === false ) {
$profile = json_decode ( $profile , true );
}
2020-07-23 13:26:39 +02:00
if ( ! empty ( $profile )) {
$group2 = $profile [ 'group' ];
$profile2 = $profile [ 'profile' ];
$tags = $profile [ 'tags' ];
foreach ( $tags as $k => $tag ) {
if ( empty ( $tag )) {
unset ( $tags [ $k ]);
}
}
$tags = implode ( ',' , $tags );
$no_hierarchy = $profile [ 'hierarchy' ];
db_pandora_audit (
2022-01-20 10:55:23 +01:00
AUDIT_LOG_USER_MANAGEMENT ,
2020-08-28 13:56:15 +02:00
'Added profile for user ' . io_safe_output ( $id2 ),
2020-07-23 13:26:39 +02:00
false ,
false ,
'Profile: ' . $profile2 . ' Group: ' . $group2 . ' Tags: ' . $tags
);
$result_profile = profile_create_user_profile ( $id , $profile2 , $group2 , false , $tags , $no_hierarchy );
2022-09-22 17:07:43 +02:00
if ( $result_profile === false ) {
$is_err = true ;
$user_info = $values ;
$password_new = '' ;
$password_confirm = '' ;
$new_user = true ;
2022-11-03 15:42:13 +01:00
} else {
$pm = db_get_value_filter ( 'pandora_management' , 'tperfil' , [ 'id_perfil' => $profile2 ]);
if (( int ) $pm === 1 ) {
$user_source = db_get_value_filter (
'id_source' ,
'tnotification_source_user' ,
[
'id_source' => $notification [ 'id' ],
'id_user' => $id ,
]
);
if ( $user_source === false ) {
$notificationSources = db_get_all_rows_filter ( 'tnotification_source' , [], 'id' );
foreach ( $notificationSources as $notification ) {
if (( int ) $notification [ 'id' ] === 1 || ( int ) $notification [ 'id' ] === 5 ) {
2022-11-03 16:01:30 +01:00
$notification_user = db_get_value_filter (
'id_source' ,
2022-11-03 15:42:13 +01:00
'tnotification_source_user' ,
[
'id_source' => $notification [ 'id' ],
'id_user' => $id ,
]
);
2022-11-03 16:01:30 +01:00
if ( $notification_user === false ) {
@ db_process_sql_insert (
'tnotification_source_user' ,
[
'id_source' => $notification [ 'id' ],
'id_user' => $id ,
]
);
}
2022-11-03 15:42:13 +01:00
}
}
}
}
2022-09-22 17:07:43 +02:00
}
2020-07-23 13:26:39 +02:00
ui_print_result_message (
$result_profile ,
__ ( 'Profile added successfully' ),
__ ( 'Profile cannot be added' )
);
}
}
}
2019-01-30 16:18:44 +01:00
} else {
$user_info = $values ;
$new_user = true ;
}
}
2009-03-26 Esteban Sanchez <estebans@artica.es>
* godmode/users/configure_user.php: Complete rewritten to fix minor
errors and fit the Pandora style.
* include/auth/ldap.php: Removed process_user_isadmin(). Renamed
process_user_password() to update_user_password(). Renamed
process_user_info to update_user(). update_user_password() does not
require old password anymore.
* include/functions_db.php: Added empty checks on
create_user_profile().
* include/functions_ui.php: print_error_message() renamed to
print_result_message().
* godmode/agentes/configurar_agente.php,
godmode/alerts/alert_actions.php, godmode/alerts/alert_commands.php,
godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_template.php,
godmode/modules/manage_nc_groups.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_templates_form.php,
godmode/reporting/map_builder_wizard.php,
godmode/reporting/reporting_builder.php,
operation/agentes/alerts_status.php, operation/events/events.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/messages/message.php, operation/snmpconsole/snmp_view.php,
operation/users/user_edit.php: Renamed print_result_message(). Some
translatable strings reused to simplify i18n work.
* godmode/users/user_list.php: Renamed print_result_message(). Use
cross.png for deletion links. Style corrections.
* godmode/setup/news.php: Renamed print_result_message(). Use
process_sql_delete() instead of direct mysql_query.
* godmode/reporting/map_builder.php: Renamed print_result_message().
Style correction on process_sql_update().
* godmode/alerts/configure_alert_compound.php: Renamed
print_result_message(). Fixed steps_clean div.
* godmode/setup/setup.php: Return control to index instead of exit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1567 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-03-26 12:14:49 +01:00
}
if ( $update_user ) {
2022-06-28 17:24:49 +02:00
if ( html_print_csrf_error () === true ) {
2019-01-30 16:18:44 +01:00
return ;
}
$values = [];
$values [ 'fullname' ] = ( string ) get_parameter ( 'fullname' );
$values [ 'firstname' ] = ( string ) get_parameter ( 'firstname' );
$values [ 'lastname' ] = ( string ) get_parameter ( 'lastname' );
$values [ 'email' ] = ( string ) get_parameter ( 'email' );
$values [ 'phone' ] = ( string ) get_parameter ( 'phone' );
2020-09-09 11:58:09 +02:00
$values [ 'comments' ] = io_safe_input ( strip_tags ( io_safe_output (( string ) get_parameter ( 'comments' ))));
2022-09-12 12:41:09 +02:00
$values [ 'allowed_ip_active' ] = (( int ) get_parameter ( 'allowed_ip_active' , - 1 ) === 0 );
$values [ 'allowed_ip_list' ] = io_safe_input ( strip_tags ( io_safe_output (( string ) get_parameter ( 'allowed_ip_list' ))));
2022-06-27 16:48:00 +02:00
$values [ 'is_admin' ] = ( get_parameter ( 'is_admin' , 0 ) === 0 ) ? 0 : 1 ;
2019-01-30 16:18:44 +01:00
$values [ 'language' ] = ( string ) get_parameter ( 'language' );
$values [ 'timezone' ] = ( string ) get_parameter ( 'timezone' );
$values [ 'default_event_filter' ] = ( int ) get_parameter ( 'default_event_filter' );
$values [ 'default_custom_view' ] = ( int ) get_parameter ( 'default_custom_view' );
2023-03-07 17:57:09 +01:00
$values [ 'show_tips_startup' ] = ( int ) get_parameter_switch ( 'show_tips_startup' );
2023-03-17 12:00:51 +01:00
$values [ 'time_autorefresh' ] = ( int ) get_parameter ( 'time_autorefresh' );
2022-06-28 17:24:49 +02:00
// API Token information.
$apiTokenRenewed = ( bool ) get_parameter ( 'renewAPIToken' );
2023-03-27 17:13:23 +02:00
$values [ 'api_token' ] = ( $apiTokenRenewed === true ) ? api_token_generate () : users_get_API_token ( $id );
2019-07-09 14:08:06 +02:00
2022-03-03 16:35:31 +01:00
if ( users_is_admin () === false && ( bool ) $values [ 'is_admin' ] !== false ) {
db_pandora_audit (
AUDIT_LOG_ACL_VIOLATION ,
2022-03-10 07:57:34 +01:00
'Trying to add administrator privileges to user by non administrator user ' . $config [ 'id_user' ]
2022-03-03 16:35:31 +01:00
);
include 'general/noaccess.php' ;
exit ;
}
2022-06-28 17:24:49 +02:00
// Ehorus user level conf.
2019-05-28 17:19:13 +02:00
$values [ 'ehorus_user_level_enabled' ] = ( bool ) get_parameter ( 'ehorus_user_level_enabled' , false );
$values [ 'ehorus_user_level_user' ] = ( string ) get_parameter ( 'ehorus_user_level_user' );
$values [ 'ehorus_user_level_pass' ] = ( string ) get_parameter ( 'ehorus_user_level_pass' );
2019-07-09 14:08:06 +02:00
$values [ 'middlename' ] = get_parameter ( 'middlename' , 0 );
2019-05-28 13:14:42 +02:00
2019-01-30 16:18:44 +01:00
$dashboard = get_parameter ( 'dashboard' , '' );
$visual_console = get_parameter ( 'visual_console' , '' );
if ( $isFunctionSkins !== ENTERPRISE_NOT_HOOK ) {
$values [ 'id_skin' ] = get_parameter ( 'skin' , 0 );
}
$values [ 'block_size' ] = get_parameter ( 'block_size' , $config [ 'block_size' ]);
$values [ 'section' ] = get_parameter ( 'section' );
2023-02-03 14:10:26 +01:00
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 )) {
2019-01-30 16:18:44 +01:00
$values [ 'data_section' ] = '' ;
2023-02-03 14:10:26 +01:00
} else if ( $values [ 'section' ] === HOME_SCREEN_DASHBOARD ) {
2019-01-30 16:18:44 +01:00
$values [ 'data_section' ] = $dashboard ;
2023-02-03 14:10:26 +01:00
} else if ( io_safe_output ( $values [ 'section' ]) === HOME_SCREEN_VISUAL_CONSOLE ) {
2019-01-30 16:18:44 +01:00
$values [ 'data_section' ] = $visual_console ;
2023-02-03 14:10:26 +01:00
} else if ( $values [ 'section' ] === HOME_SCREEN_OTHER || io_safe_output ( $values [ 'section' ]) === HOME_SCREEN_EXTERNAL_LINK ) {
2019-01-30 16:18:44 +01:00
$values [ 'data_section' ] = get_parameter ( 'data_section' );
}
2023-06-28 15:08:09 +02:00
// $values['section'] = $homeScreenValues[$values['section']];
2022-09-12 12:41:09 +02:00
if ( enterprise_installed () === true && is_metaconsole () === true ) {
2023-05-22 15:01:04 +02:00
if ( users_is_admin () === true ) {
2023-05-22 17:12:35 +02:00
$values [ 'metaconsole_access' ] = get_parameter ( 'metaconsole_access' );
$values [ 'metaconsole_agents_manager' ] = get_parameter ( 'metaconsole_agents_manager' , '0' );
2023-05-22 15:01:04 +02:00
$values [ 'metaconsole_access_node' ] = get_parameter ( 'metaconsole_access_node' , '0' );
} else {
2023-05-22 17:12:35 +02:00
$values [ 'metaconsole_access' ] = $user_info [ 'metaconsole_access' ];
$values [ 'metaconsole_agents_manager' ] = $user_info [ 'metaconsole_agents_manager' ];
2023-05-22 15:01:04 +02:00
$values [ 'metaconsole_access_node' ] = db_get_value ( 'metaconsole_access_node' , 'tusuario' , 'id_user' , $id );
}
2019-01-30 16:18:44 +01:00
}
$values [ 'not_login' ] = ( bool ) get_parameter ( 'not_login' , false );
2022-02-01 09:37:02 +01:00
$values [ 'local_user' ] = ( bool ) get_parameter ( 'local_user' , false );
2019-01-30 16:18:44 +01:00
$values [ 'strict_acl' ] = ( bool ) get_parameter ( 'strict_acl' , false );
$values [ 'session_time' ] = ( int ) get_parameter ( 'session_time' , 0 );
2023-06-08 14:06:15 +02:00
$force_update_session_expire = false ;
if ( $values [ 'session_time' ] !== $user_info [ 'session_time' ]) {
$force_update_session_expire = true ;
}
2023-02-03 14:10:26 +01:00
// Previously defined.
$values [ 'autorefresh_white_list' ] = $autorefresh_white_list ;
2019-01-30 16:18:44 +01:00
$res1 = update_user ( $id , $values );
2023-06-08 14:06:15 +02:00
if ( $force_update_session_expire === true ) {
config_prepare_expire_time_session ( true );
}
2019-01-30 16:18:44 +01:00
if ( $config [ 'user_can_update_password' ]) {
$password_new = ( string ) get_parameter ( 'password_new' , '' );
$password_confirm = ( string ) get_parameter ( 'password_confirm' , '' );
2020-12-02 16:29:45 +01:00
$own_password_confirm = ( string ) get_parameter ( 'own_password_confirm' , '' );
2023-05-11 14:48:06 +02:00
$id_user = ( string ) get_parameter ( 'id_user' , '' );
2020-12-02 16:29:45 +01:00
2019-01-30 16:18:44 +01:00
if ( $password_new != '' ) {
2020-12-02 16:29:45 +01:00
$correct_password = false ;
2023-05-11 14:48:06 +02:00
$user_credentials_check = process_user_login ( $id_user , $own_password_confirm , true );
2020-12-02 16:29:45 +01:00
if ( $user_credentials_check !== false ) {
$correct_password = true ;
}
2022-09-12 12:41:09 +02:00
if (( string ) $password_confirm === ( string ) $password_new ) {
2020-12-02 16:29:45 +01:00
if ( $correct_password === true || is_user_admin ( $config [ 'id_user' ])) {
2022-09-12 12:41:09 +02:00
if (( is_user_admin ( $config [ 'id_user' ]) === false || $config [ 'enable_pass_policy_admin' ]) && $config [ 'enable_pass_policy' ]) {
2020-12-02 16:29:45 +01:00
$pass_ok = login_validate_pass ( $password_new , $id , true );
if ( $pass_ok != 1 ) {
ui_print_error_message ( $pass_ok );
} else {
$res2 = update_user_password ( $id , $password_new );
if ( $res2 ) {
db_process_sql_insert (
'tsesion' ,
[
'id_sesion' => '' ,
'id_usuario' => $id ,
'ip_origen' => $_SERVER [ 'REMOTE_ADDR' ],
'accion' => 'Password change' ,
'descripcion' => 'Access password updated' ,
'fecha' => date ( 'Y-m-d H:i:s' ),
'utimestamp' => time (),
]
);
$res3 = save_pass_history ( $id , $password_new );
2023-04-25 15:43:02 +02:00
// Generate new API token.
$newToken = api_token_generate ();
$res4 = update_user ( $id , [ 'api_token' => $newToken ]);
2020-12-02 16:29:45 +01:00
}
ui_print_result_message (
$res1 || $res2 ,
__ ( 'User info successfully updated' ),
__ ( 'Error updating user info (no change?)' )
);
}
2019-01-30 16:18:44 +01:00
} else {
$res2 = update_user_password ( $id , $password_new );
if ( $res2 ) {
2020-12-02 16:29:45 +01:00
$res3 = save_pass_history ( $id , $password_new );
2019-01-30 16:18:44 +01:00
db_process_sql_insert (
'tsesion' ,
[
'id_sesion' => '' ,
'id_usuario' => $id ,
'ip_origen' => $_SERVER [ 'REMOTE_ADDR' ],
'accion' => 'Password change' ,
'descripcion' => 'Access password updated' ,
'fecha' => date ( 'Y-m-d H:i:s' ),
'utimestamp' => time (),
]
);
2023-04-25 15:43:02 +02:00
// Generate new API token.
$newToken = api_token_generate ();
$res4 = update_user ( $id , [ 'api_token' => $newToken ]);
2019-01-30 16:18:44 +01:00
}
ui_print_result_message (
$res1 || $res2 ,
__ ( 'User info successfully updated' ),
__ ( 'Error updating user info (no change?)' )
);
}
} else {
2020-12-02 16:29:45 +01:00
if ( $own_password_confirm === '' ) {
ui_print_error_message ( __ ( 'Password of the active user is required to perform password change' ));
} else {
ui_print_error_message ( __ ( 'Password of active user is not correct' ));
2019-01-30 16:18:44 +01:00
}
}
} else {
db_process_sql_insert (
'tsesion' ,
[
'id_sesion' => '' ,
'id_usuario' => $id ,
'ip_origen' => $_SERVER [ 'REMOTE_ADDR' ],
'accion' => 'Password change' ,
'descripcion' => 'Access password update failed' ,
'fecha' => date ( 'Y-m-d H:i:s' ),
'utimestamp' => time (),
]
);
ui_print_error_message ( __ ( 'Passwords does not match' ));
}
} else {
$has_skin = false ;
$has_wizard = false ;
2023-03-27 17:13:23 +02:00
$info = '{"id_user":"' . $id . ' " ,
2019-01-30 16:18:44 +01:00
" FullName " : " '. $values['fullname'] .' " ,
" Firstname " : " '. $values['firstname'] .' " ,
" Lastname " : " '. $values['lastname'] .' " ,
" Email " : " '. $values['email'] .' " ,
" Phone " : " '. $values['phone'] .' " ,
" Comments " : " '. $values['comments'] .' " ,
" Is_admin " : " '. $values['is_admin'] .' " ,
" Language " : " '. $values['language'] .' " ,
" Timezone " : " '. $values['timezone'] .' " ,
" Block size " : " '. $values['block_size'] .' " ,
" Section " : " '. $values['section'] .' " ' ;
2022-09-12 12:41:09 +02:00
if ( $values [ 'allowed_ip_active' ] === true ) {
$info .= ',"IPS Allowed":"' . $values [ 'allowed_ip_list' ] . '"' ;
}
2019-01-30 16:18:44 +01:00
if ( $isFunctionSkins !== ENTERPRISE_NOT_HOOK ) {
$info .= ',"Skin":"' . $values [ 'id_skin' ] . '"' ;
$has_skin = true ;
}
2022-09-12 12:41:09 +02:00
if ( enterprise_installed () === true && is_metaconsole () === true ) {
2019-01-30 16:18:44 +01:00
$info .= ',"Wizard access":"' . $values [ 'metaconsole_access' ] . '"}' ;
$has_wizard = true ;
2022-09-12 12:41:09 +02:00
} else if ( $has_skin === true ) {
2019-01-30 16:18:44 +01:00
$info .= '}' ;
}
2022-09-12 12:41:09 +02:00
if ( $has_skin === false && $has_wizard === false ) {
2019-01-30 16:18:44 +01:00
$info .= '}' ;
}
db_pandora_audit (
2022-01-20 10:55:23 +01:00
AUDIT_LOG_USER_MANAGEMENT ,
2020-08-28 13:56:15 +02:00
'Updated user ' . io_safe_output ( $id ),
2019-01-30 16:18:44 +01:00
false ,
false ,
$info
);
2023-02-16 12:59:23 +01:00
2019-01-30 16:18:44 +01:00
ui_print_result_message (
$res1 ,
2022-06-28 17:24:49 +02:00
( $apiTokenRenewed === true ) ? __ ( 'You have generated a new API Token.' ) : __ ( 'User info successfully updated' ),
2019-01-30 16:18:44 +01:00
__ ( 'Error updating user info (no change?)' )
);
}
} else {
ui_print_result_message (
$res1 ,
__ ( 'User info successfully updated' ),
__ ( 'Error updating user info (no change?)' )
);
}
2021-10-07 16:11:23 +02:00
2022-09-12 12:41:09 +02:00
if (( bool ) $values [ 'strict_acl' ] === true ) {
2019-01-30 16:18:44 +01:00
$count_groups = 0 ;
$count_tags = 0 ;
$profiles = db_get_all_rows_field_filter ( 'tusuario_perfil' , 'id_usuario' , $id );
if ( $profiles === false ) {
$profiles = [];
}
foreach ( $profiles as $profile ) {
2022-09-12 12:41:09 +02:00
$count_groups ++ ;
2019-01-30 16:18:44 +01:00
$arr_tags = explode ( ',' , $profile [ 'tags' ]);
$count_tags = ( $count_tags + count ( $arr_tags ));
}
if (( $count_groups > 3 ) && ( $count_tags > 10 )) {
ui_print_info_message ( __ ( 'Strict ACL is not recommended for this user. Performance could be affected.' ));
}
}
$user_info = $values ;
2011-08-30 17:21:40 +02:00
}
2023-05-08 11:03:21 +02:00
if ( $delete_profile ) {
$id2 = ( string ) get_parameter ( 'id_user' );
$id_up = ( int ) get_parameter ( 'id_user_profile' );
$perfilUser = db_get_row ( 'tusuario_perfil' , 'id_up' , $id_up );
$id_perfil = $perfilUser [ 'id_perfil' ];
$perfil = db_get_row ( 'tperfil' , 'id_perfil' , $id_perfil );
db_pandora_audit (
AUDIT_LOG_USER_MANAGEMENT ,
'Deleted profile for user ' . io_safe_output ( $id2 ),
false ,
false ,
'The profile with id ' . $id_perfil . ' in the group ' . $perfilUser [ 'id_grupo' ]
);
$return = profile_delete_user_profile ( $id2 , $id_up );
ui_print_result_message (
$return ,
__ ( 'Successfully deleted' ),
__ ( 'Could not be deleted' )
);
$has_profile = db_get_row ( 'tusuario_perfil' , 'id_usuario' , $id2 );
$user_is_global_admin = users_is_admin ( $id2 );
if ( $has_profile === false && $user_is_global_admin === false ) {
$result = delete_user ( $id2 );
if ( $result === true ) {
db_pandora_audit (
AUDIT_LOG_USER_MANAGEMENT ,
__ ( 'Deleted user %s' , io_safe_output ( $id_user ))
);
}
ui_print_result_message (
$result ,
__ ( 'Successfully deleted' ),
__ ( 'There was a problem deleting the user' )
);
// Delete the user in all the consoles.
if ( is_metaconsole () === true ) {
$servers = metaconsole_get_servers ();
foreach ( $servers as $server ) {
// Connect to the remote console.
metaconsole_connect ( $server );
// Delete the user.
$result = delete_user ( $id_user );
if ( $result === true ) {
db_pandora_audit (
AUDIT_LOG_USER_MANAGEMENT ,
__ ( 'Deleted user %s from metaconsole' , io_safe_output ( $id_user ))
);
}
// Restore the db connection.
metaconsole_restore_db ();
// Log to the metaconsole too.
if ( $result === true ) {
db_pandora_audit (
AUDIT_LOG_USER_MANAGEMENT ,
__ (
'Deleted user %s from %s' ,
io_safe_input ( $id_user ),
io_safe_input ( $server [ 'server_name' ])
)
);
}
ui_print_result_message (
$result ,
__ ( 'Successfully deleted from %s' , io_safe_input ( $server [ 'server_name' ])),
__ ( 'There was a problem deleting the user from %s' , io_safe_input ( $server [ 'server_name' ]))
);
}
}
}
}
2022-06-28 17:24:49 +02:00
if (( int ) $status !== - 1 ) {
2019-01-30 16:18:44 +01:00
ui_print_result_message (
$status ,
__ ( 'User info successfully updated' ),
__ ( 'Error updating user info (no change?)' )
);
2009-03-26 Esteban Sanchez <estebans@artica.es>
* godmode/users/configure_user.php: Complete rewritten to fix minor
errors and fit the Pandora style.
* include/auth/ldap.php: Removed process_user_isadmin(). Renamed
process_user_password() to update_user_password(). Renamed
process_user_info to update_user(). update_user_password() does not
require old password anymore.
* include/functions_db.php: Added empty checks on
create_user_profile().
* include/functions_ui.php: print_error_message() renamed to
print_result_message().
* godmode/agentes/configurar_agente.php,
godmode/alerts/alert_actions.php, godmode/alerts/alert_commands.php,
godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_template.php,
godmode/modules/manage_nc_groups.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_templates_form.php,
godmode/reporting/map_builder_wizard.php,
godmode/reporting/reporting_builder.php,
operation/agentes/alerts_status.php, operation/events/events.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/messages/message.php, operation/snmpconsole/snmp_view.php,
operation/users/user_edit.php: Renamed print_result_message(). Some
translatable strings reused to simplify i18n work.
* godmode/users/user_list.php: Renamed print_result_message(). Use
cross.png for deletion links. Style corrections.
* godmode/setup/news.php: Renamed print_result_message(). Use
process_sql_delete() instead of direct mysql_query.
* godmode/reporting/map_builder.php: Renamed print_result_message().
Style correction on process_sql_update().
* godmode/alerts/configure_alert_compound.php: Renamed
print_result_message(). Fixed steps_clean div.
* godmode/setup/setup.php: Return control to index instead of exit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1567 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-03-26 12:14:49 +01:00
}
2020-07-23 13:26:39 +02:00
if ( $add_profile && empty ( $json_profile )) {
2023-02-13 14:23:31 +01:00
$id2 = ( string ) get_parameter ( 'id' , get_parameter ( 'id_user' ));
2019-01-30 16:18:44 +01:00
$group2 = ( int ) get_parameter ( 'assign_group' );
$profile2 = ( int ) get_parameter ( 'assign_profile' );
$tags = ( array ) get_parameter ( 'assign_tags' );
$no_hierarchy = ( int ) get_parameter ( 'no_hierarchy' , 0 );
foreach ( $tags as $k => $tag ) {
2022-09-12 12:41:09 +02:00
if ( empty ( $tag ) === true ) {
2019-01-30 16:18:44 +01:00
unset ( $tags [ $k ]);
}
}
$tags = implode ( ',' , $tags );
db_pandora_audit (
2022-01-20 10:55:23 +01:00
AUDIT_LOG_USER_MANAGEMENT ,
2020-08-28 13:56:15 +02:00
'Added profile for user ' . io_safe_output ( $id2 ),
2019-01-30 16:18:44 +01:00
false ,
false ,
'Profile: ' . $profile2 . ' Group: ' . $group2 . ' Tags: ' . $tags
);
2023-02-16 12:59:23 +01:00
2019-01-30 16:18:44 +01:00
$return = profile_create_user_profile ( $id2 , $profile2 , $group2 , false , $tags , $no_hierarchy );
2022-10-17 12:26:38 +02:00
if ( $return === false ) {
$is_err = true ;
2022-11-03 15:42:13 +01:00
} else {
$pm = db_get_value_filter ( 'pandora_management' , 'tperfil' , [ 'id_perfil' => $profile2 ]);
if (( int ) $pm === 1 ) {
$user_source = db_get_value_filter (
'id_source' ,
'tnotification_source_user' ,
[
'id_source' => $notification [ 'id' ],
'id_user' => $id ,
]
);
if ( $user_source === false ) {
$notificationSources = db_get_all_rows_filter ( 'tnotification_source' , [], 'id' );
foreach ( $notificationSources as $notification ) {
if (( int ) $notification [ 'id' ] === 1 || ( int ) $notification [ 'id' ] === 5 ) {
2022-11-03 16:01:30 +01:00
$notification_user = db_get_value_filter (
'id_source' ,
2022-11-03 15:42:13 +01:00
'tnotification_source_user' ,
[
'id_source' => $notification [ 'id' ],
'id_user' => $id ,
]
);
2022-11-03 16:01:30 +01:00
if ( $notification_user === false ) {
@ db_process_sql_insert (
'tnotification_source_user' ,
[
'id_source' => $notification [ 'id' ],
'id_user' => $id ,
]
);
}
2022-11-03 15:42:13 +01:00
}
}
}
}
2022-10-17 12:26:38 +02:00
}
2019-01-30 16:18:44 +01:00
ui_print_result_message (
$return ,
__ ( 'Profile added successfully' ),
__ ( 'Profile cannot be added' )
);
2009-03-26 Esteban Sanchez <estebans@artica.es>
* godmode/users/configure_user.php: Complete rewritten to fix minor
errors and fit the Pandora style.
* include/auth/ldap.php: Removed process_user_isadmin(). Renamed
process_user_password() to update_user_password(). Renamed
process_user_info to update_user(). update_user_password() does not
require old password anymore.
* include/functions_db.php: Added empty checks on
create_user_profile().
* include/functions_ui.php: print_error_message() renamed to
print_result_message().
* godmode/agentes/configurar_agente.php,
godmode/alerts/alert_actions.php, godmode/alerts/alert_commands.php,
godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_template.php,
godmode/modules/manage_nc_groups.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_templates_form.php,
godmode/reporting/map_builder_wizard.php,
godmode/reporting/reporting_builder.php,
operation/agentes/alerts_status.php, operation/events/events.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/messages/message.php, operation/snmpconsole/snmp_view.php,
operation/users/user_edit.php: Renamed print_result_message(). Some
translatable strings reused to simplify i18n work.
* godmode/users/user_list.php: Renamed print_result_message(). Use
cross.png for deletion links. Style corrections.
* godmode/setup/news.php: Renamed print_result_message(). Use
process_sql_delete() instead of direct mysql_query.
* godmode/reporting/map_builder.php: Renamed print_result_message().
Style correction on process_sql_update().
* godmode/alerts/configure_alert_compound.php: Renamed
print_result_message(). Fixed steps_clean div.
* godmode/setup/setup.php: Return control to index instead of exit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1567 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-03-26 12:14:49 +01:00
}
2023-02-06 23:10:28 +01:00
if ( isset ( $values ) === true && empty ( $values ) === false ) {
2020-07-23 13:26:39 +02:00
$user_info = $values ;
}
2019-01-30 16:18:44 +01:00
2023-02-13 14:23:31 +01:00
if ( ! users_is_admin () && $config [ 'id_user' ] !== $id && $new_user === false ) {
2020-07-23 13:26:39 +02:00
$group_um = users_get_groups_UM ( $config [ 'id_user' ]);
2023-02-13 14:23:31 +01:00
if ( isset ( $group_um [ 0 ]) === true ) {
2020-07-23 13:26:39 +02:00
$group_um_string = implode ( ',' , array_keys ( users_get_groups ( $config [ 'id_user' ], 'um' , true )));
} else {
$group_um_string = implode ( ',' , array_keys ( $group_um ));
}
2019-01-30 16:18:44 +01:00
2020-07-23 13:26:39 +02:00
$sql = sprintf (
" SELECT tusuario_perfil.* FROM tusuario_perfil
INNER JOIN tperfil ON tperfil . id_perfil = tusuario_perfil . id_perfil
2020-12-01 08:46:09 +01:00
WHERE id_usuario like '%s' AND id_grupo IN ( % s ) AND user_management = 1 " ,
$config [ 'id_user' ],
2020-07-23 13:26:39 +02:00
$group_um_string
2019-01-30 16:18:44 +01:00
);
2020-07-23 13:26:39 +02:00
$result = db_get_all_rows_sql ( $sql );
2022-09-12 12:41:09 +02:00
if (( bool ) $result === false && ( bool ) $user_info [ 'is_admin' ] === false ) {
2020-07-23 13:26:39 +02:00
db_pandora_audit (
2022-01-20 10:55:23 +01:00
AUDIT_LOG_ACL_VIOLATION ,
2020-07-23 13:26:39 +02:00
'Trying to access User Management'
);
include 'general/noaccess.php' ;
2008-08-11 Esteban Sanchez <estebans@artica.es>
* include/functions_db.php: Added __ as an alias of lang_string().
* include/functions_reporting_pdf.php,
include/functions_reporting.php, include/functions.php,
include/functions_visual_map.php, index.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/incidents/incident_note.php,
operation/incidents/incident_search.php,
operation/incidents/incident_statistics.php,
operation/snmpconsole/snmp_alert.php,
operation/snmpconsole/snmp_view.php, operation/users/user.php,
operation/users/user_edit.php, operation/users/user_statistics.php,
operation/events/event_statistics.php, operation/events/events.php,
operation/visual_console/render_view.php,
operation/visual_console/index.php, operation/extensions.php,
operation/agentes/estado_alertas.php,
operation/agentes/status_monitor.php,
operation/agentes/estado_grupo.php, operation/agentes/export_csv.php,
operation/agentes/datos_agente.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_generalagente.php,
operation/agentes/estado_agente.php, operation/agentes/bulbs.php,
operation/agentes/status_events.php, operation/agentes/sla_view.php,
operation/agentes/exportdata.php,
operation/agentes/estado_monitores.php,
operation/agentes/ver_agente.php, operation/agentes/estadisticas.php,
operation/agentes/tactical.php, operation/agentes/networkmap.php,
operation/messages/message.php,
operation/reporting/reporting_viewer.php,
operation/reporting/graph_viewer.php,
operation/reporting/custom_reporting.php,
operation/servers/view_server.php,
operation/servers/view_server_detail.php, operation/menu.php,
reporting/fgraph.php, reporting/stat_win.php, ajax.php,
general/logoff.php, general/pandora_help.php, general/footer.php,
general/noaccess.php, general/logon_failed.php,
general/links_menu.php, general/login_page.php, general/logon_ok.php,
general/header.php, general/main_menu.php,
godmode/groups/configure_group.php, godmode/groups/group_list.php,
godmode/setup/news.php, godmode/setup/links.php,
godmode/setup/setup.php, godmode/users/user_list.php,
godmode/users/configure_user.php, godmode/profiles/profile_list.php,
godmode/admin_access_logs.php, godmode/db/db_info_data.php,
godmode/db/db_main.php, godmode/db/db_audit.php,
godmode/db/db_sanity.php, godmode/db/db_refine.php,
godmode/db/db_info.php, godmode/db/db_event.php,
godmode/db/db_purge.php, godmode/extensions.php,
godmode/agentes/agent_template.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_wmi.php,
godmode/agentes/alert_manager.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/alert_manager_editor.php,
godmode/agentes/manage_config.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager.php,
godmode/agentes/modificar_agente.php,
godmode/agentes/configurar_agente.php,
godmode/agentes/agent_disk_conf_editor.php,
godmode/agentes/planned_downtime.php,
godmode/agentes/manage_config_remote.php,
godmode/agentes/agent_manager.php,
godmode/modules/manage_network_components_form.php,
godmode/modules/manage_nc_groups_form.php,
godmode/modules/manage_network_templates.php,
godmode/modules/module_list.php,
godmode/modules/manage_network_templates_form.php,
godmode/modules/manage_network_components_form_network.php,
godmode/modules/manage_network_components_form_wmi.php,
godmode/modules/manage_network_components.php,
godmode/modules/manage_nc_groups.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/map_builder.php,
godmode/reporting/graph_builder.php, godmode/servers/plugin.php,
godmode/servers/manage_recontask.php,
godmode/servers/modificar_server.php,
godmode/servers/manage_recontask_form.php,
godmode/alerts/modify_alert.php, godmode/alerts/configure_alert.php,
godmode/menu.php: Replaced $id_user with $config['id_user']. Use __a
instead of $lang_label to future use of gettext. Style
corrections.
* godmode/agentes/planned_downtime.php: Rewritten to use Pandora
functions and adopt the UI style. Replaced lang_string with __().
* pandoradb.sql: Fields in tplanned_downtime renamed to fit
guidelines.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1005 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-08-11 12:59:07 +02:00
2020-07-23 13:26:39 +02:00
return ;
}
2019-08-19 12:31:47 +02:00
}
2020-05-19 08:20:04 +02:00
if ( ! $new_user ) {
2020-12-09 15:23:16 +01:00
$user_id = '<div class="label_select_simple"><p class="edit_user_labels">' . __ ( 'User ID' ) . ': </p>' ;
2020-05-19 08:20:04 +02:00
$user_id .= '<span>' . $id . '</span>' ;
$user_id .= html_print_input_hidden ( 'id_user' , $id , true );
$user_id .= '</div>' ;
2023-02-16 12:44:11 +01:00
2023-03-14 08:04:48 +01:00
$apiTokenContentElements [] = '<span style="line-height: 15px; height: 15px;font-size: 14px;">' . __ ( 'API Token' ) . '</span>' ;
2023-02-16 12:44:11 +01:00
$apiTokenContentElements [] = html_print_button (
__ ( 'Renew' ),
'renew_api_token' ,
false ,
sprintf (
2023-03-14 08:04:48 +01:00
'javascript:renewAPIToken("%s", "%s", "%s")' ,
2023-02-16 12:44:11 +01:00
__ ( 'Warning' ),
__ ( 'The API token will be renewed. After this action, the last token you were using will not work. Are you sure?' ),
'user_profile_form' ,
),
2022-06-28 17:24:49 +02:00
[
2023-02-16 12:44:11 +01:00
'mode' => 'link' ,
'style' => 'min-width: initial;' ,
2022-06-28 17:24:49 +02:00
],
2023-02-16 12:44:11 +01:00
true ,
);
$apiTokenContentElements [] = html_print_button (
__ ( 'Show' ),
'show_api_token' ,
false ,
sprintf (
2023-06-12 16:18:28 +02:00
'javascript:showAPIToken("%s", "%s", "%s", "%s")' ,
2023-02-16 12:44:11 +01:00
__ ( 'API Token' ),
2023-06-12 16:18:28 +02:00
__ ( 'Your API Token is:' ),
base64_encode ( users_get_API_token ( $id )),
__ ( 'Please, avoid share this string with others.' ),
2023-02-16 12:44:11 +01:00
),
[
'mode' => 'link' ,
'style' => 'min-width: initial;' ,
],
true ,
2022-06-28 17:24:49 +02:00
);
2023-02-16 12:44:11 +01:00
$apiTokenContent = html_print_div (
2022-06-28 17:24:49 +02:00
[
2023-02-16 12:44:11 +01:00
'class' => 'flex-row-center' ,
'content' => implode ( '' , $apiTokenContentElements ),
2022-06-28 17:24:49 +02:00
],
true
);
2023-02-16 12:44:11 +01:00
$user_id .= $apiTokenContent ;
2023-04-04 09:24:29 +02:00
$CodeQRContent .= html_print_div ([ 'id' => 'qr_container_image' , 'class' => 'scale-0-8' ], true );
$CodeQRContent .= html_print_anchor (
[ 'id' => 'qr_code_agent_view' ],
true
);
$CodeQRContent .= '<br/>' . $custom_id_div ;
// QR code div.
$CodeQRTable = html_print_div (
[
'class' => 'agent_qr' ,
'content' => $CodeQRContent ,
],
true
);
2020-05-19 08:20:04 +02:00
} else {
$user_id = '<div class="label_select_simple">' . html_print_input_text_extended (
'id_user' ,
$id ,
'' ,
'' ,
20 ,
2022-06-03 12:25:24 +02:00
255 ,
2020-05-19 08:20:04 +02:00
! $new_user || $view_mode ,
'' ,
[
2023-02-06 10:17:51 +01:00
'class' => 'input_line' ,
2020-05-19 08:20:04 +02:00
'placeholder' => __ ( 'User ID' ),
],
true
) . '</div>' ;
2015-03-06 12:28:05 +01:00
}
2019-01-30 16:18:44 +01:00
2022-06-28 17:24:49 +02:00
if ( is_user_admin ( $id ) === true ) {
2021-03-11 15:40:23 +01:00
$avatar = html_print_image (
'images/people_1.png' ,
true ,
[ 'class' => 'user_avatar' ]
);
2020-05-19 08:20:04 +02:00
} else {
2021-03-11 15:40:23 +01:00
$avatar = html_print_image (
'images/people_2.png' ,
true ,
[ 'class' => 'user_avatar' ]
);
2020-05-19 08:20:04 +02:00
}
2009-03-26 Esteban Sanchez <estebans@artica.es>
* godmode/users/configure_user.php: Complete rewritten to fix minor
errors and fit the Pandora style.
* include/auth/ldap.php: Removed process_user_isadmin(). Renamed
process_user_password() to update_user_password(). Renamed
process_user_info to update_user(). update_user_password() does not
require old password anymore.
* include/functions_db.php: Added empty checks on
create_user_profile().
* include/functions_ui.php: print_error_message() renamed to
print_result_message().
* godmode/agentes/configurar_agente.php,
godmode/alerts/alert_actions.php, godmode/alerts/alert_commands.php,
godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_template.php,
godmode/modules/manage_nc_groups.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_templates_form.php,
godmode/reporting/map_builder_wizard.php,
godmode/reporting/reporting_builder.php,
operation/agentes/alerts_status.php, operation/events/events.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/messages/message.php, operation/snmpconsole/snmp_view.php,
operation/users/user_edit.php: Renamed print_result_message(). Some
translatable strings reused to simplify i18n work.
* godmode/users/user_list.php: Renamed print_result_message(). Use
cross.png for deletion links. Style corrections.
* godmode/setup/news.php: Renamed print_result_message(). Use
process_sql_delete() instead of direct mysql_query.
* godmode/reporting/map_builder.php: Renamed print_result_message().
Style correction on process_sql_update().
* godmode/alerts/configure_alert_compound.php: Renamed
print_result_message(). Fixed steps_clean div.
* godmode/setup/setup.php: Return control to index instead of exit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1567 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-03-26 12:14:49 +01:00
2020-05-19 08:20:04 +02:00
$full_name = ' <div class="label_select_simple">' . html_print_input_text_extended (
2019-01-30 16:18:44 +01:00
'fullname' ,
$user_info [ 'fullname' ],
2020-05-19 08:20:04 +02:00
'fullname' ,
2019-01-30 16:18:44 +01:00
'' ,
2020-05-19 08:20:04 +02:00
20 ,
100 ,
2019-01-30 16:18:44 +01:00
$view_mode ,
'' ,
2020-05-19 08:20:04 +02:00
[
'class' => 'input' ,
'placeholder' => __ ( 'Full (display) name' ),
],
2019-01-30 16:18:44 +01:00
true
2020-05-19 08:20:04 +02:00
) . '</div>' ;
2009-03-26 Esteban Sanchez <estebans@artica.es>
* godmode/users/configure_user.php: Complete rewritten to fix minor
errors and fit the Pandora style.
* include/auth/ldap.php: Removed process_user_isadmin(). Renamed
process_user_password() to update_user_password(). Renamed
process_user_info to update_user(). update_user_password() does not
require old password anymore.
* include/functions_db.php: Added empty checks on
create_user_profile().
* include/functions_ui.php: print_error_message() renamed to
print_result_message().
* godmode/agentes/configurar_agente.php,
godmode/alerts/alert_actions.php, godmode/alerts/alert_commands.php,
godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_template.php,
godmode/modules/manage_nc_groups.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_templates_form.php,
godmode/reporting/map_builder_wizard.php,
godmode/reporting/reporting_builder.php,
operation/agentes/alerts_status.php, operation/events/events.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/messages/message.php, operation/snmpconsole/snmp_view.php,
operation/users/user_edit.php: Renamed print_result_message(). Some
translatable strings reused to simplify i18n work.
* godmode/users/user_list.php: Renamed print_result_message(). Use
cross.png for deletion links. Style corrections.
* godmode/setup/news.php: Renamed print_result_message(). Use
process_sql_delete() instead of direct mysql_query.
* godmode/reporting/map_builder.php: Renamed print_result_message().
Style correction on process_sql_update().
* godmode/alerts/configure_alert_compound.php: Renamed
print_result_message(). Fixed steps_clean div.
* godmode/setup/setup.php: Return control to index instead of exit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1567 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-03-26 12:14:49 +01:00
2020-05-29 11:37:06 +02:00
$language = '<div class="label_select"><p class="edit_user_labels">' . __ ( 'Language' ) . '</p>' ;
2020-05-19 08:20:04 +02:00
$language .= html_print_select_from_sql (
2019-01-30 16:18:44 +01:00
'SELECT id_language, name FROM tlanguage' ,
'language' ,
$user_info [ 'language' ],
'' ,
__ ( 'Default' ),
'default' ,
true
2020-05-19 08:20:04 +02:00
) . '</div>' ;
2009-11-27 Sancho lerena <slerena@artica.es>
* operation/menu.php: User section has no ACL check, always can be seen.
* index.php: Added suppor for user-defined custom language (this code was
on my disk for 3 months, pending to be commited!).
* include/functions_db.php,
* include/functions_agents.php,
* godmode/alerts/alert_list.php,
* godmode/agentes/modificar_agente.php,
* godmode/agentes/configurar_agente.php: Added audit calls to several
management operations who don't have or have insufficient audit info.
* godmode/users/configure_user.php: Fixed several annoyings bugs. Added
custom language support, and added more audit info on management operations.
* godmode/users/user_list.php: More audit info.
* include/config_process.php: Add new debug option to render error log to
/pandora_console.log. Also set timezone if not defined (this makes warnings
on several PHP 5.x setups). Added user custom language support.
* include/functions_events.php: More audit info. Fixed problems with HTML
encoding render.
* functions_io.php: Some cleaning.
* include/functions_messages.php: Fixed problems with HTML
encoding render.
* functions_ui.php: Fixed problems with HTML encoding render in
print_string_substr() function.
* auth/mysql.php: is_user_admin() functions seems to be broken ¿?¿!. Fixed.
* styles/pandora.css: removed green colored left border in default style.
* message.php, incident*: Fixed problems with HTML encoding render.
* user.php: Better ACL check before let user to view/edit another user.
* user_edit: Removed some un-used form fields, some arrangements in layout,
and FIXED forever problems with password change (new code written).
* users/user_statistics.php: Now user can see its own audit records.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2139 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-11-27 21:02:12 +01:00
2020-05-19 08:20:04 +02:00
2021-03-11 15:40:23 +01:00
$timezone = '<div class="label_select"><p class="edit_user_labels">' . __ ( 'Timezone' ) . ui_print_help_tip (
__ ( 'The timezone must be that of the associated server.' ),
true
) . '</p>' ;
2020-05-19 08:20:04 +02:00
$timezone .= html_print_timezone_select ( 'timezone' , $user_info [ 'timezone' ]) . '</div>' ;
2018-06-11 16:40:10 +02:00
2009-03-26 Esteban Sanchez <estebans@artica.es>
* godmode/users/configure_user.php: Complete rewritten to fix minor
errors and fit the Pandora style.
* include/auth/ldap.php: Removed process_user_isadmin(). Renamed
process_user_password() to update_user_password(). Renamed
process_user_info to update_user(). update_user_password() does not
require old password anymore.
* include/functions_db.php: Added empty checks on
create_user_profile().
* include/functions_ui.php: print_error_message() renamed to
print_result_message().
* godmode/agentes/configurar_agente.php,
godmode/alerts/alert_actions.php, godmode/alerts/alert_commands.php,
godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_template.php,
godmode/modules/manage_nc_groups.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_templates_form.php,
godmode/reporting/map_builder_wizard.php,
godmode/reporting/reporting_builder.php,
operation/agentes/alerts_status.php, operation/events/events.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/messages/message.php, operation/snmpconsole/snmp_view.php,
operation/users/user_edit.php: Renamed print_result_message(). Some
translatable strings reused to simplify i18n work.
* godmode/users/user_list.php: Renamed print_result_message(). Use
cross.png for deletion links. Style corrections.
* godmode/setup/news.php: Renamed print_result_message(). Use
process_sql_delete() instead of direct mysql_query.
* godmode/reporting/map_builder.php: Renamed print_result_message().
Style correction on process_sql_update().
* godmode/alerts/configure_alert_compound.php: Renamed
print_result_message(). Fixed steps_clean div.
* godmode/setup/setup.php: Return control to index instead of exit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1567 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-03-26 12:14:49 +01:00
if ( $config [ 'user_can_update_password' ]) {
2020-05-19 08:20:04 +02:00
$new_pass = '<div class="label_select_simple"><span>' . html_print_input_text_extended (
2019-01-30 16:18:44 +01:00
'password_new' ,
'' ,
2020-05-19 08:20:04 +02:00
'password_new' ,
2019-01-30 16:18:44 +01:00
'' ,
2020-05-19 08:20:04 +02:00
'25' ,
'45' ,
2019-01-30 16:18:44 +01:00
$view_mode ,
'' ,
2020-05-19 08:20:04 +02:00
[
'class' => 'input' ,
'placeholder' => __ ( 'Password' ),
],
2019-01-30 16:18:44 +01:00
true ,
true
2020-05-19 08:20:04 +02:00
) . '</span></div>' ;
$new_pass_confirm = '<div class="label_select_simple"><span>' . html_print_input_text_extended (
2019-01-30 16:18:44 +01:00
'password_confirm' ,
'' ,
2020-05-19 08:20:04 +02:00
'password_conf' ,
2019-01-30 16:18:44 +01:00
'' ,
2020-05-19 08:20:04 +02:00
'20' ,
'45' ,
2019-01-30 16:18:44 +01:00
$view_mode ,
'' ,
2020-05-19 08:20:04 +02:00
[
'class' => 'input' ,
'placeholder' => __ ( 'Password confirmation' ),
],
2019-01-30 16:18:44 +01:00
true ,
true
2020-05-19 08:20:04 +02:00
) . '</span></div>' ;
2020-12-02 16:29:45 +01:00
if ( ! is_user_admin ( $config [ 'id_user' ])) {
$own_pass_confirm = '<div class="label_select_simple"><span>' . html_print_input_text_extended (
'own_password_confirm' ,
'' ,
'own_password_confirm' ,
'' ,
'20' ,
'45' ,
$view_mode ,
'' ,
[
'class' => 'input' ,
'placeholder' => __ ( 'Own password confirmation' ),
],
true ,
true
) . '</span></div>' ;
}
2019-01-30 16:18:44 +01:00
}
2022-06-27 16:48:00 +02:00
if ( users_is_admin () === true ) {
$global_profile = '<div class="label_select_simple" style="display: flex;align-items: center;">' ;
$global_profile .= '<p class="edit_user_labels" style="margin-top: 0;">' . __ ( 'Administrator user' ) . '</p>' ;
$global_profile .= html_print_checkbox_switch (
2020-07-23 13:26:39 +02:00
'is_admin' ,
2022-06-27 16:48:00 +02:00
0 ,
2020-07-23 13:26:39 +02:00
$user_info [ 'is_admin' ],
2022-06-27 16:48:00 +02:00
true
);
$global_profile .= '</div>' ;
} else {
$global_profile = html_print_input_hidden (
'is_admin_sent' ,
0 ,
2020-07-23 13:26:39 +02:00
true
);
}
2020-05-19 08:20:04 +02:00
$email = '<div class="label_select_simple">' . html_print_input_text_extended (
2019-01-30 16:18:44 +01:00
'email' ,
$user_info [ 'email' ],
2020-05-19 08:20:04 +02:00
'email' ,
2019-01-30 16:18:44 +01:00
'' ,
2020-05-19 08:20:04 +02:00
'25' ,
'100' ,
2019-01-30 16:18:44 +01:00
$view_mode ,
'' ,
2020-05-19 08:20:04 +02:00
[
2023-02-06 10:17:51 +01:00
'class' => 'input input_line' ,
2020-05-19 08:20:04 +02:00
'placeholder' => __ ( 'E-mail' ),
],
2019-01-30 16:18:44 +01:00
true
2020-05-19 08:20:04 +02:00
) . '</div>' ;
2008-06-09 19:51:18 +02:00
2020-05-19 08:20:04 +02:00
$phone = '<div class="label_select_simple">' . html_print_input_text_extended (
2019-01-30 16:18:44 +01:00
'phone' ,
$user_info [ 'phone' ],
2020-05-19 08:20:04 +02:00
'phone' ,
2019-01-30 16:18:44 +01:00
'' ,
2020-05-19 08:20:04 +02:00
'20' ,
'30' ,
2019-01-30 16:18:44 +01:00
$view_mode ,
'' ,
2020-05-19 08:20:04 +02:00
[
'class' => 'input input_line phone_icon_input' ,
'placeholder' => __ ( 'Phone number' ),
],
2019-01-30 16:18:44 +01:00
true
2020-05-19 08:20:04 +02:00
) . '</div>' ;
2008-08-12 16:41:53 +02:00
2020-05-29 11:37:06 +02:00
$comments = '<p class="edit_user_labels">' . __ ( 'Comments' ) . '</p>' ;
2020-05-19 08:20:04 +02:00
$comments .= html_print_textarea (
2019-01-30 16:18:44 +01:00
'comments' ,
2 ,
65 ,
$user_info [ 'comments' ],
( $view_mode ? 'readonly="readonly"' : '' ),
true
);
2022-09-12 12:41:09 +02:00
$allowedIP = '<p class="edit_user_labels">' ;
$allowedIP .= __ ( 'Login allowed IP list' ) . ' ' ;
$allowedIP .= ui_print_help_tip ( __ ( 'Add the source IPs that will allow console access. Each IP must be separated only by comma. * allows all.' ), true ) . ' ' ;
$allowedIP .= html_print_checkbox_switch (
'allowed_ip_active' ,
0 ,
2023-04-14 10:02:41 +02:00
( $user_info [ 'allowed_ip_active' ] ? ? 0 ),
2022-09-12 12:41:09 +02:00
true
);
$allowedIP .= '</p>' ;
$allowedIP .= html_print_textarea (
'allowed_ip_list' ,
2 ,
65 ,
2023-04-14 10:02:41 +02:00
( $user_info [ 'allowed_ip_list' ] ? ? 0 ),
2022-09-12 12:41:09 +02:00
((( bool ) $view_mode === true ) ? 'readonly="readonly"' : '' ),
true
);
2019-01-30 16:18:44 +01:00
// If we want to create a new user, skins displayed are the skins of the creator's group. If we want to update, skins displayed are the skins of the modified user.
$own_info = get_user_info ( $config [ 'id_user' ]);
if ( $own_info [ 'is_admin' ] || check_acl ( $config [ 'id_user' ], 0 , 'PM' )) {
$display_all_group = true ;
} else {
$display_all_group = false ;
}
2011-03-01 16:47:48 +01:00
2012-08-17 17:28:55 +02:00
if ( $new_user ) {
2019-01-30 16:18:44 +01:00
$usr_groups = ( users_get_groups ( $config [ 'id_user' ], 'AR' , $display_all_group ));
$id_usr = $config [ 'id_user' ];
} else {
$usr_groups = ( users_get_groups ( $id , 'AR' , $display_all_group ));
$id_usr = $id ;
2011-02-14 10:08:41 +01:00
}
2023-02-03 14:10:26 +01:00
if ( is_metaconsole () === false ) {
2022-09-12 12:41:09 +02:00
// User only can change skins if has more than one group.
2023-03-13 18:07:04 +01:00
if ( function_exists ( 'skins_print_select' )) {
if ( count ( $usr_groups ) > 1 ) {
if ( $isFunctionSkins !== ENTERPRISE_NOT_HOOK ) {
$skin = '<div class="label_select"><p class="edit_user_labels">' . __ ( 'Skin' ) . '</p>' ;
$skin .= skins_print_select ( $id_usr , 'skin' , $user_info [ 'id_skin' ], '' , __ ( 'None' ), 0 , true ) . '</div>' ;
}
2019-01-30 16:18:44 +01:00
}
}
2011-02-14 10:08:41 +01:00
}
2023-02-03 14:10:26 +01:00
if ( is_metaconsole () === true ) {
2019-01-30 16:18:44 +01:00
$array_filters = get_filters_custom_fields_view ( 0 , true );
2020-05-19 08:20:04 +02:00
2023-03-14 13:11:57 +01:00
$searchCustomFieldView = [];
$searchCustomFieldView [] = __ ( 'Search custom field view' );
$searchCustomFieldView [] = html_print_select (
2019-01-30 16:18:44 +01:00
$array_filters ,
'default_custom_view' ,
$user_info [ 'default_custom_view' ],
'' ,
__ ( 'None' ),
0 ,
true ,
false ,
true ,
'' ,
false
2023-03-14 13:11:57 +01:00
) . ui_print_input_placeholder (
__ ( 'Load by default the selected view in custom field view' ),
true
);
2019-01-30 16:18:44 +01:00
}
$values = [
- 1 => __ ( 'Use global conf' ),
1 => __ ( 'Yes' ),
0 => __ ( 'No' ),
];
2021-03-11 15:40:23 +01:00
$home_screen = '<div class="label_select"><p class="edit_user_labels">' . __ ( 'Home screen' ) . ui_print_help_tip (
__ ( '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>' ;
2019-05-27 18:49:47 +02:00
2022-12-09 09:54:20 +01:00
$dashboards = Manager :: getDashboards (
- 1 ,
- 1 ,
false ,
false ,
$id_usr
);
2020-03-26 12:29:38 +01:00
$dashboards_aux = [];
if ( $dashboards === false ) {
$dashboards = [ 'None' => 'None' ];
} else {
foreach ( $dashboards as $key => $dashboard ) {
$dashboards_aux [ $dashboard [ 'id' ]] = $dashboard [ 'name' ];
}
2017-04-06 16:17:54 +02:00
}
2021-04-13 15:37:44 +02:00
$home_screen .= '<div id="show_db" style="display: none; width: 100%;">' ;
2020-05-19 08:20:04 +02:00
$home_screen .= html_print_select ( $dashboards_aux , 'dashboard' , $user_info [ 'data_section' ], '' , '' , '' , true );
2021-04-13 15:37:44 +02:00
$home_screen .= '</div>' ;
2020-03-26 12:29:38 +01:00
2019-01-30 16:18:44 +01:00
$layouts = visual_map_get_user_layouts ( $config [ 'id_user' ], true );
$layouts_aux = [];
2017-04-06 16:17:54 +02:00
if ( $layouts === false ) {
2019-01-30 16:18:44 +01:00
$layouts_aux = [ 'None' => 'None' ];
} else {
foreach ( $layouts as $layout ) {
$layouts_aux [ $layout ] = $layout ;
}
2017-04-06 16:17:54 +02:00
}
2021-04-13 15:37:44 +02:00
$home_screen .= '<div id="show_vc" style="display: none; width: 100%;">' ;
2021-03-11 15:40:23 +01:00
$home_screen .= html_print_select (
$layouts_aux ,
'visual_console' ,
$user_info [ 'data_section' ],
'' ,
'' ,
'' ,
true
);
2021-04-13 15:37:44 +02:00
$home_screen .= '</div>' ;
2021-03-11 15:40:23 +01:00
$home_screen .= html_print_input_text (
'data_section' ,
$user_info [ 'data_section' ],
'' ,
60 ,
255 ,
true ,
false
);
2019-01-30 16:18:44 +01:00
2023-03-14 13:11:57 +01:00
$home_screen = '' ;
2020-05-19 08:20:04 +02:00
$size_pagination = '<div class="label_select_simple"><p class="edit_user_labels">' . __ ( 'Block size for pagination' ) . '</p>' ;
2021-03-11 15:40:23 +01:00
$size_pagination .= html_print_input_text (
'block_size' ,
$user_info [ 'block_size' ],
'' ,
5 ,
5 ,
true
) . '</div>' ;
2011-03-01 16:47:48 +01:00
2023-02-03 16:36:04 +01:00
if ( $id === $config [ 'id_user' ]) {
2021-03-11 15:40:23 +01:00
$language .= html_print_input_hidden (
'quick_language_change' ,
1 ,
true
);
2011-07-26 12:32:13 +02:00
}
2023-03-14 13:11:57 +01:00
if ( enterprise_installed () === true && is_metaconsole () === true ) {
2019-01-30 16:18:44 +01:00
$user_info_metaconsole_access = 'only_console' ;
if ( isset ( $user_info [ 'metaconsole_access' ])) {
$user_info_metaconsole_access = $user_info [ 'metaconsole_access' ];
}
$metaconsole_accesses = [
'basic' => __ ( 'Basic' ),
'advanced' => __ ( 'Advanced' ),
];
2023-03-14 13:11:57 +01:00
$outputMetaAccess = [];
$outputMetaAccess [] = __ ( 'Metaconsole access' );
$outputMetaAccess [] = html_print_select (
2019-01-30 16:18:44 +01:00
$metaconsole_accesses ,
'metaconsole_access' ,
$user_info_metaconsole_access ,
'' ,
'' ,
- 1 ,
true ,
false ,
false
2023-02-03 16:36:04 +01:00
);
2023-03-14 13:11:57 +01:00
}
2022-02-01 09:37:02 +01:00
2021-10-07 16:11:23 +02:00
$user_groups = implode ( ',' , array_keys (( users_get_groups ( $id , 'AR' , $display_all_group ))));
2021-10-07 14:09:02 +02:00
2022-03-11 15:42:06 +01:00
if ( empty ( $user_groups ) === false ) {
$event_filter_data = db_get_all_rows_sql ( 'SELECT id_name, id_filter FROM tevent_filter WHERE id_group_filter IN (' . $user_groups . ')' );
if ( $event_filter_data === false ) {
$event_filter_data = [];
}
} else {
2019-01-30 16:18:44 +01:00
$event_filter_data = [];
}
2022-03-11 15:42:06 +01:00
2019-01-30 16:18:44 +01:00
$event_filter = [];
2017-04-05 17:44:24 +02:00
$event_filter [ 0 ] = __ ( 'None' );
foreach ( $event_filter_data as $filter ) {
2019-01-30 16:18:44 +01:00
$event_filter [ $filter [ 'id_filter' ]] = $filter [ 'id_name' ];
2017-04-05 17:44:24 +02:00
}
2019-01-30 16:18:44 +01:00
2023-05-22 12:08:27 +02:00
if ( is_metaconsole () === true && empty ( $user_info [ 'metaconsole_default_event_filter' ]) !== true ) {
$user_info [ 'default_event_filter' ] = $user_info [ 'metaconsole_default_event_filter' ];
}
2020-05-19 08:20:04 +02:00
$default_event_filter = '<div class="label_select"><p class="edit_user_labels">' . __ ( 'Default event filter' ) . '</p>' ;
2021-03-11 15:40:23 +01:00
$default_event_filter .= html_print_select (
$event_filter ,
'default_event_filter' ,
2023-04-14 10:02:41 +02:00
( $user_info [ 'default_event_filter' ] ? ? 0 ),
2021-03-11 15:40:23 +01:00
'' ,
'' ,
__ ( 'None' ),
true ,
false ,
false
) . '</div>' ;
2019-01-30 16:18:44 +01:00
2023-02-06 23:10:28 +01:00
if ( isset ( $config [ 'ehorus_user_level_conf' ]) === true && ( bool ) $config [ 'ehorus_user_level_conf' ] === true ) {
2020-05-19 08:20:04 +02:00
$ehorus = '<div class="label_select_simple"><p class="edit_user_labels">' . __ ( 'eHorus user access enabled' ) . '</p>' ;
2021-03-11 15:40:23 +01:00
$ehorus .= html_print_checkbox_switch (
'ehorus_user_level_enabled' ,
1 ,
$user_info [ 'ehorus_user_level_enabled' ],
true
) . '</div>' ;
2020-05-19 08:20:04 +02:00
$ehorus .= '<div class="user_edit_ehorus_outer">' ;
$ehorus .= '<div class="label_select_simple user_edit_ehorus_inner"><p class="edit_user_labels">' . __ ( 'eHorus user' ) . '</p>' ;
2021-03-11 15:40:23 +01:00
$ehorus .= html_print_input_text (
'ehorus_user_level_user' ,
$user_info [ 'ehorus_user_level_user' ],
'' ,
15 ,
45 ,
true
) . '</div>' ;
2020-05-19 08:20:04 +02:00
$ehorus .= '<div class="label_select_simple user_edit_ehorus_inner"><p class="edit_user_labels">' . __ ( 'eHorus password' ) . '</p>' ;
2021-03-11 15:40:23 +01:00
$ehorus .= html_print_input_password (
'ehorus_user_level_pass' ,
io_output_password ( $user_info [ 'ehorus_user_level_pass' ]),
'' ,
15 ,
45 ,
true
) . '</div>' ;
2020-05-19 08:20:04 +02:00
$ehorus .= '</div>' ;
2019-05-27 18:49:47 +02:00
}
2023-02-16 07:25:26 +01:00
// Double authentication.
$doubleAuthElementsContent = [];
2023-02-06 23:10:28 +01:00
if ( isset ( $config [ 'double_auth_enabled' ]) === true && ( bool ) ( $config [ 'double_auth_enabled' ]) === true && check_acl ( $config [ 'id_user' ], 0 , 'PM' )) {
2023-02-16 07:25:26 +01:00
// Know if Double Auth is enabled.
$double_auth_enabled = ( bool ) db_get_value ( 'id' , 'tuser_double_auth' , 'id_user' , $id );
// Double authentication elements.
$doubleAuthElementsSubContent = [];
// Caption.
$doubleAuthElementsSubContent [] = '<span>' . __ ( 'Double authentication' ) . '</span>' ;
// Switch.
2020-10-06 17:02:58 +02:00
if (( $config [ '2FA_all_users' ] == '' && ! $double_auth_enabled )
|| ( $config [ 'double_auth_enabled' ] == '' && $double_auth_enabled )
|| check_acl ( $config [ 'id_user' ], 0 , 'PM' )
) {
2021-03-02 13:24:03 +01:00
if ( $new_user === false ) {
2023-02-16 07:25:26 +01:00
$doubleAuthElementsSubContent [] = html_print_checkbox_switch ( 'double_auth' , 1 , $double_auth_enabled , true );
2021-03-02 13:24:03 +01:00
} else {
2023-02-16 07:25:26 +01:00
$doubleAuthElementsSubContent [] = ui_print_help_tip ( __ ( 'User must be created before activating double authentication.' ), true );
2021-03-02 13:24:03 +01:00
}
2020-10-06 17:02:58 +02:00
}
2023-02-16 07:25:26 +01:00
// Control for show.
$doubleAuthElementsContent [] = html_print_div (
[
'style' => 'display: flex; flex-direction: row-reverse; align-items: center;' ,
'class' => 'margin-top-10' ,
'content' => implode ( '' , $doubleAuthElementsSubContent ),
],
true
);
2020-10-06 17:02:58 +02:00
// Dialog.
2023-02-16 07:25:26 +01:00
$doubleAuthElementsContent [] = html_print_div (
[
'id' => 'dialog-double_auth' ,
'class' => 'invisible' ,
'content' => html_print_div ([ 'id' => 'dialog-double_auth-container' ], true ),
],
true
);
2020-10-06 17:02:58 +02:00
}
2023-02-16 07:25:26 +01:00
if ( $double_auth_enabled === true && ( bool ) $config [ 'double_auth_enabled' ] === true && empty ( $config [ '2FA_all_users' ]) === false ) {
$doubleAuthElementsContent [] = html_print_button (
2021-03-11 15:40:23 +01:00
__ ( 'Show information' ),
'show_info' ,
false ,
'javascript:show_double_auth_info();' ,
'' ,
true
);
2020-10-06 17:02:58 +02:00
}
2023-02-16 12:59:23 +01:00
if ( empty ( $doubleAuthElementsContent ) === false ) {
$doubleAuthentication = html_print_div ([ 'content' => implode ( '' , $doubleAuthElementsContent )], true );
} else {
$doubleAuthentication = '' ;
}
2023-02-03 14:10:26 +01:00
$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' ;
2023-03-17 12:00:51 +01:00
if ( isset ( $autorefresh_list ) === false || empty ( $autorefresh_list ) === true || empty ( $autorefresh_list [ 0 ]) === true ) {
$select = db_process_sql ( " SELECT autorefresh_white_list FROM tusuario WHERE id_user = ' " . $id . " ' " );
2023-02-03 14:10:26 +01:00
$autorefresh_list = json_decode ( $select [ 0 ][ 'autorefresh_white_list' ]);
2023-05-22 11:54:43 +02:00
if ( $autorefresh_list === null || $autorefresh_list === 0 ) {
$autorefresh_list = [];
2023-02-03 14:10:26 +01:00
$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 ) {
2019-01-30 16:18:44 +01:00
enterprise_include_once ( 'include/functions_metaconsole.php' );
2021-10-29 16:12:23 +02:00
$access_node = db_get_value ( 'metaconsole_access_node' , 'tusuario' , 'id_user' , $id );
2023-03-14 13:11:57 +01:00
$metaconsoleAgentManager = [];
$metaconsoleAgentManager [] = __ ( 'Enable agents managment' );
$metaconsoleAgentManager [] = html_print_checkbox_switch (
2021-03-11 15:40:23 +01:00
'metaconsole_agents_manager' ,
1 ,
$user_info [ 'metaconsole_agents_manager' ],
true
2023-03-14 13:11:57 +01:00
);
2019-01-30 16:18:44 +01:00
2023-03-14 13:11:57 +01:00
$metaconsoleAgentManager [] = __ ( 'Enable node access' ) . ui_print_help_tip (
__ ( 'With this option enabled, the user will can access to nodes console' ),
true
);
$metaconsoleAgentManager [] = html_print_checkbox_switch (
2021-03-11 15:40:23 +01:00
'metaconsole_access_node' ,
1 ,
2021-10-29 16:12:23 +02:00
$access_node ,
2021-03-11 15:40:23 +01:00
true
2023-03-14 13:11:57 +01:00
);
2013-04-22 12:31:20 +02:00
}
2023-02-24 12:05:53 +01:00
echo '<div class="max_floating_element_size">' ;
2023-02-06 23:10:28 +01:00
echo '<form id="user_profile_form" name="user_profile_form" method="post" autocomplete="off" action="#">' ;
2023-02-03 14:10:26 +01:00
2020-05-19 08:20:04 +02:00
if ( ! $id ) {
$user_id_update_view = $user_id ;
$user_id_create = '' ;
} else {
$user_id_update_view = '' ;
$user_id_create = $user_id ;
}
2023-03-14 13:11:57 +01:00
// User management form.
require_once 'user_management.php' ;
2020-07-23 13:26:39 +02:00
2023-02-06 23:10:28 +01:00
if (( bool ) $config [ 'admin_can_add_user' ] === true ) {
2019-01-30 16:18:44 +01:00
html_print_csrf_hidden ();
2023-02-03 16:36:04 +01:00
html_print_input_hidden ((( $new_user === true ) ? 'create_user' : 'update_user' ), 1 );
2009-01-22 18:44:33 +01:00
}
2019-01-30 16:18:44 +01:00
2020-09-18 09:40:26 +02:00
echo '</div>' ;
2023-04-14 10:02:41 +02:00
html_print_input_hidden ( 'json_profile' , $json_profile );
2020-09-18 09:40:26 +02:00
2009-03-26 Esteban Sanchez <estebans@artica.es>
* godmode/users/configure_user.php: Complete rewritten to fix minor
errors and fit the Pandora style.
* include/auth/ldap.php: Removed process_user_isadmin(). Renamed
process_user_password() to update_user_password(). Renamed
process_user_info to update_user(). update_user_password() does not
require old password anymore.
* include/functions_db.php: Added empty checks on
create_user_profile().
* include/functions_ui.php: print_error_message() renamed to
print_result_message().
* godmode/agentes/configurar_agente.php,
godmode/alerts/alert_actions.php, godmode/alerts/alert_commands.php,
godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php,
godmode/alerts/alert_templates.php,
godmode/alerts/configure_alert_template.php,
godmode/modules/manage_nc_groups.php,
godmode/modules/manage_network_templates.php,
godmode/modules/manage_network_templates_form.php,
godmode/reporting/map_builder_wizard.php,
godmode/reporting/reporting_builder.php,
operation/agentes/alerts_status.php, operation/events/events.php,
operation/incidents/incident.php,
operation/incidents/incident_detail.php,
operation/messages/message.php, operation/snmpconsole/snmp_view.php,
operation/users/user_edit.php: Renamed print_result_message(). Some
translatable strings reused to simplify i18n work.
* godmode/users/user_list.php: Renamed print_result_message(). Use
cross.png for deletion links. Style corrections.
* godmode/setup/news.php: Renamed print_result_message(). Use
process_sql_delete() instead of direct mysql_query.
* godmode/reporting/map_builder.php: Renamed print_result_message().
Style correction on process_sql_update().
* godmode/alerts/configure_alert_compound.php: Renamed
print_result_message(). Fixed steps_clean div.
* godmode/setup/setup.php: Return control to index instead of exit.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1567 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-03-26 12:14:49 +01:00
echo '</form>' ;
2023-03-17 10:09:11 +01:00
// User Profile definition table. (Only where user is not creating).
2023-04-14 10:02:41 +02:00
if (( bool ) check_acl ( $config [ 'id_user' ], 0 , 'UM' ) === true ) {
2023-03-17 10:09:11 +01:00
profile_print_profile_table ( $id , io_safe_output ( $json_profile ), false , ( $is_err === true ));
}
2023-02-06 23:10:28 +01:00
echo '</div>' ;
2020-09-14 17:48:38 +02:00
2023-02-03 16:36:04 +01:00
$actionButtons = [];
2009-01-22 18:44:33 +01:00
2023-02-03 16:36:04 +01:00
if (( bool ) $config [ 'admin_can_add_user' ] === true ) {
if ( $new_user === true ) {
$submitButtonCaption = __ ( 'Create' );
$submitButtonName = 'crtbutton' ;
$submitButtonIcon = 'wand' ;
2020-09-18 09:40:26 +02:00
} else {
2023-02-03 16:36:04 +01:00
$submitButtonCaption = __ ( 'Update' );
$submitButtonName = 'uptbutton' ;
$submitButtonIcon = 'update' ;
2020-09-18 09:40:26 +02:00
}
2023-02-03 16:36:04 +01:00
$actionButtons [] = html_print_submit_button (
$submitButtonCaption ,
$submitButtonName ,
false ,
[
'icon' => $submitButtonIcon ,
'form' => 'user_profile_form' ,
],
true
);
2020-09-18 09:40:26 +02:00
}
2023-02-13 14:23:31 +01:00
if (( bool ) check_acl ( $config [ 'id_user' ], 0 , 'UM' ) === true ) {
$actionButtons [] = html_print_go_back_button (
ui_get_full_url ( 'index.php?sec=gusuarios&sec2=godmode/users/user_list&tab=user&pure=0' ),
[ 'button_class' => '' ],
true
);
}
2023-02-03 16:36:04 +01:00
html_print_action_buttons ( implode ( '' , $actionButtons ), [ 'type' => 'form_action' ]);
2020-09-18 09:40:26 +02:00
echo '</div>' ;
2023-02-06 23:10:28 +01:00
// This is an image generated for JS.
2021-03-11 15:40:23 +01:00
$delete_image = html_print_input_image (
'del' ,
2023-03-10 12:40:21 +01:00
'images/delete.svg' ,
2021-03-11 15:40:23 +01:00
1 ,
'' ,
true ,
[
'onclick' => 'delete_profile(event, this)' ,
2023-04-14 10:02:41 +02:00
'class' => 'invert_filter main_menu_icon' ,
2021-03-11 15:40:23 +01:00
]
);
2020-07-23 13:26:39 +02:00
2023-02-06 23:10:28 +01:00
if ( is_metaconsole () === false ) {
2020-05-19 08:20:04 +02:00
?>
< style >
/* Styles for timezone map */
#timezone-picker div.timezone-picker {
margin : 0 auto ;
}
</ style >
< script language = " javascript " type = " text/javascript " >
2023-02-16 07:25:26 +01:00
$ ( document ) . ready ( function () {
2020-05-19 08:20:04 +02:00
// Set up the picker to update target timezone and country select lists.
$ ( '#timezone-image' ) . timezonePicker ({
2023-03-14 13:11:57 +01:00
target : '#timezone1' ,
2020-05-19 08:20:04 +02:00
});
// Optionally an auto-detect button to trigger JavaScript geolocation.
$ ( '#timezone-detect' ) . click ( function () {
$ ( '#timezone-image' ) . timezonePicker ( 'detectLocation' );
});
});
</ script >
< ? php
// Include OpenLayers and timezone user map library.
echo '<script type="text/javascript" src="' . ui_get_full_url ( 'include/javascript/timezonepicker/lib/jquery.timezone-picker.min.js' ) . '"></script>' . " \n \t " ;
echo '<script type="text/javascript" src="' . ui_get_full_url ( 'include/javascript/timezonepicker/lib/jquery.maphilight.min.js' ) . '"></script>' . " \n \t " ;
// Closes no meta condition.
}
2013-03-14 17:52:05 +01:00
?>
2013-04-22 12:31:20 +02:00
< script type = " text/javascript " >
2023-02-16 07:25:26 +01:00
var json_profile = $ ( '#hidden-json_profile' );
/* <![CDATA[ */
$ ( document ) . ready ( function () {
$ ( " #right_autorefreshlist " ) . click ( function () {
jQuery . each ( $ ( " select[name='autorefresh_list_out[]'] option:selected " ), function ( key , value ) {
imodule_name = $ ( value ) . html ();
if ( imodule_name != < ? php echo " ' " . __ ( 'None' ) . " ' " ; ?> ) {
id_imodule = $ ( value ) . attr ( 'value' );
2023-03-14 13:46:49 +01:00
$ ( " select[name='autorefresh_list[]'] option " ) . each ( function () { $ ( this ) . attr ( " selected " , true ) });
$ ( " select[name='autorefresh_list[]'] " ) . append ( $ ( " <option></option> " ) . val ( id_imodule ) . html ( '<i>' + imodule_name + '</i>' ) . attr ( " selected " , true ));
2023-02-16 07:25:26 +01:00
$ ( " #autorefresh_list_out " ) . find ( " option[value=' " + id_imodule + " '] " ) . remove ();
$ ( " #autorefresh_list " ) . find ( " option[value=''] " ) . remove ();
$ ( " #autorefresh_list " ) . find ( " option[value='0'] " ) . remove ();
if ( $ ( " #autorefresh_list_out option " ) . length == 0 ) {
$ ( " select[name='autorefresh_list_out[]'] " ) . append ( $ ( " <option></option> " ) . val ( '' ) . html ( '<i><?php echo __(' None '); ?></i>' ));
}
2023-02-06 23:10:28 +01:00
}
2023-02-16 07:25:26 +01:00
});
2023-02-06 23:10:28 +01:00
});
2023-02-16 07:25:26 +01:00
$ ( " #left_autorefreshlist " ) . click ( function () {
jQuery . each ( $ ( " select[name='autorefresh_list[]'] option:selected " ), function ( key , value ) {
2023-02-06 23:10:28 +01:00
imodule_name = $ ( value ) . html ();
if ( imodule_name != < ? php echo " ' " . __ ( 'None' ) . " ' " ; ?> ) {
id_imodule = $ ( value ) . attr ( 'value' );
$ ( " #autorefresh_list " ) . find ( " option[value=' " + id_imodule + " '] " ) . remove ();
$ ( " #autorefresh_list_out " ) . find ( " option[value=''] " ) . remove ();
$ ( " select[name='autorefresh_list_out[]'] " ) . append ( $ ( " <option><option> " ) . val ( id_imodule ) . html ( '<i>' + imodule_name + '</i>' ));
$ ( " #autorefresh_list_out option " ) . last () . remove ();
2023-02-16 07:25:26 +01:00
if ( $ ( " #autorefresh_list option " ) . length == 0 ) {
2023-02-06 23:10:28 +01:00
$ ( " select[name='autorefresh_list[]'] " ) . append ( $ ( " <option></option> " ) . val ( '' ) . html ( '<i><?php echo __(' None '); ?></i>' ));
}
}
2023-02-16 07:25:26 +01:00
});
2023-02-06 23:10:28 +01:00
});
2023-03-17 12:00:51 +01:00
$ ( " #button-uptbutton " ) . click ( function () {
if ( $ ( " #autorefresh_list option " ) . length > 0 ) {
$ ( '#autorefresh_list option' ) . prop ( 'selected' , true );
}
});
2023-02-16 07:25:26 +01:00
$ ( " input#checkbox-double_auth " ) . change ( function ( e ) {
e . preventDefault ();
2020-10-06 17:02:58 +02:00
if ( this . checked ) {
show_double_auth_activation ();
} else {
show_double_auth_deactivation ();
}
2023-02-16 07:25:26 +01:00
});
2020-10-06 17:02:58 +02:00
2023-02-16 07:25:26 +01:00
$ ( '#checkbox-is_admin' ) . change ( function () {
if ( $ ( '#checkbox-is_admin' ) . is ( ':checked' ) == true ) {
$ ( '#metaconsole_agents_manager_div' ) . hide ();
$ ( '#metaconsole_access_node_div' ) . hide ();
$ ( '#metaconsole_assigned_server_div' ) . hide ();
} else {
$ ( '#metaconsole_agents_manager_div' ) . show ();
$ ( '#metaconsole_access_node_div' ) . show ();
if ( $ ( '#checkbox-metaconsole_agents_manager' ) . prop ( 'checked' )) {
$ ( '#metaconsole_assigned_server_div' ) . show ();
}
}
});
$ ( '#checkbox-metaconsole_agents_manager' ) . change ( function () {
2022-07-06 09:49:39 +02:00
if ( $ ( '#checkbox-metaconsole_agents_manager' ) . prop ( 'checked' )) {
2020-05-19 08:20:04 +02:00
$ ( '#metaconsole_assigned_server_div' ) . show ();
2023-02-16 07:25:26 +01:00
} else {
$ ( '#metaconsole_assigned_server_div' ) . hide ();
2019-01-30 16:18:44 +01:00
}
2023-02-16 07:25:26 +01:00
});
2022-06-07 15:21:07 +02:00
2023-02-16 07:25:26 +01:00
$ ( '#checkbox-is_admin' ) . trigger ( 'change' );
$ ( '#checkbox-metaconsole_agents_manager' ) . trigger ( 'change' );
2022-06-07 15:21:07 +02:00
2023-02-16 07:25:26 +01:00
show_data_section ();
$ ( '#checkbox-ehorus_user_level_enabled' ) . change ( function () {
switch_ehorus_conf ();
});
$ ( '#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 is_metaconsole(); ?>' ;
var user_is_global_admin = '<?php echo users_is_admin($id); ?>' ;
var is_err = '<?php echo $is_err; ?>' ;
var data = [];
var aux = 0 ;
function addProfile ( form ) {
try {
var data = JSON . parse ( json_profile . val ());
} catch {
var data = [];
}
2022-11-22 20:40:22 +01:00
2023-02-16 07:25:26 +01:00
var profile = $ ( '#assign_profile' ) . val ();
var profile_text = $ ( '#assign_profile option:selected' ) . text ();
var group = $ ( '#assign_group' ) . val ();
var group_text = $ ( '#assign_group option:selected' ) . text ();
var tags = $ ( '#assign_tags' ) . val ();
var tags_text = $ ( '#assign_tags option:selected' ) . toArray () . map ( item => item . text ) . join ();
if ( $ ( '#checkbox-no_hierarchy' ) . is ( ':checked' )) {
var hierarchy = 1 ;
var hierarchy_text = '<?php echo __(' yes '); ?>' ;
} else {
var hierarchy = 0 ;
var hierarchy_text = '<?php echo __(' no '); ?>' ;
}
2020-07-23 13:26:39 +02:00
2023-02-16 07:25:26 +01:00
if ( profile === '0' || group === '-1' ) {
alert ( '<?php echo __(' Please select profile and group '); ?>' );
return ;
}
2020-07-23 13:26:39 +02:00
2023-02-16 07:25:26 +01:00
if ( id_user == '' || is_err == 1 ) {
let new_json = `{"profile":${profile},"group":${group},"tags":[${tags}],"hierarchy":${hierarchy}}` ;
2022-11-22 20:40:22 +01:00
2023-02-16 07:25:26 +01:00
var profile_is_added = Object . entries ( data ) . find ( function ( _data ) {
return _data [ 1 ] === new_json ;
});
2022-11-22 20:40:22 +01:00
2023-02-16 07:25:26 +01:00
if ( typeof profile_is_added === 'undefined' ) {
data . push ( new_json );
} else {
alert ( '<?php echo __(' This profile is already defined '); ?>' );
return ;
}
2022-11-22 20:40:22 +01:00
2023-02-16 07:25:26 +01:00
json_profile . val ( JSON . stringify ( data ));
2022-11-22 20:40:22 +01:00
2023-02-16 07:25:26 +01:00
profile_text = `<a href="index.php?sec2=godmode/users/configure_profile&id=${profile}">${profile_text}</a>` ;
2023-02-22 21:19:28 +01:00
group_img = `<img id="img_group_${aux}" src="" data-title="${group_text}" data-use_title_for_force_title="1" class="invert_filter main_menu_icon bot forced_title" alt="${group_text}"/>` ;
2023-04-14 10:02:41 +02:00
group_text = `<a href="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id=${group}">${group_img} ${group_text}</a>` ;
2022-10-17 12:26:38 +02:00
2023-02-16 07:25:26 +01:00
$ ( '#table_profiles tr:last' ) . before (
` < tr >
2020-07-23 13:26:39 +02:00
< td > $ { profile_text } </ td >
< td > $ { group_text } </ td >
< td > $ { tags_text } </ td >
< td > $ { hierarchy_text } </ td >
< td > $ { img_delete } </ td >
</ tr > `
2023-02-16 07:25:26 +01:00
);
2022-10-17 12:26:38 +02:00
2023-02-16 07:25:26 +01:00
getGroupIcon ( group , $ ( `#img_group_${aux}` ));
aux ++ ;
2022-10-17 12:26:38 +02:00
2023-02-16 07:25:26 +01:00
} else {
form . submit ();
}
2020-07-23 13:26:39 +02:00
}
2022-11-22 17:09:13 +01:00
2023-02-16 07:25:26 +01:00
$ ( 'input:image[name="add"]' ) . click ( function ( e ) {
e . preventDefault ();
2022-11-22 17:09:13 +01:00
2023-02-16 07:25:26 +01:00
if ( id_user . length === 0 ) {
addProfile ( this . form );
return ;
}
2022-11-22 20:40:22 +01:00
2023-02-16 07:25:26 +01:00
var params = [];
params . push ( " get_user_profile=1 " );
params . push ( " profile_id= " + $ ( '#assign_profile' ) . val ())
params . push ( " group_id= " + $ ( '#assign_group' ) . val ());
params . push ( " user_id= " + id_user );
params . push ( " page=godmode/users/configure_user " );
jQuery . ajax ({
data : params . join ( " & " ),
type : 'POST' ,
dataType : " json " ,
async : false ,
form : this . form ,
url : action = " <?php echo ui_get_full_url('ajax.php', false, false, false); ?> " ,
success : function ( data ) {
if ( data . length > 0 ) {
alert ( '<?php echo __(' This profile is already defined '); ?>' );
} else {
addProfile ( this . form );
}
2022-11-22 17:09:13 +01:00
}
2023-02-16 07:25:26 +01:00
});
2022-11-22 17:09:13 +01:00
});
2020-07-23 13:26:39 +02:00
2023-02-16 07:25:26 +01:00
$ ( 'input:image[name="del"]' ) . click ( function ( e ) {
if ( $ ( json_profile ) . length > 0 ) return ;
if ( ! confirm ( 'Are you sure?' )) return ;
e . preventDefault ();
var rows = $ ( " #table_profiles tr " ) . length ;
if ((( is_metaconsole === '1' && rows <= 4 ) || ( is_metaconsole === '' && rows <= 3 )) && user_is_global_admin !== '1' ) {
if ( ! confirm ( '<?php echo __(' Deleting last profile will delete this user '); ?>' + '. ' + '<?php echo __(' Are you sure ? '); ?>' )) {
return ;
}
2020-07-23 13:26:39 +02:00
}
2023-02-16 07:25:26 +01:00
var id_user_profile = $ ( this ) . siblings ();
id_user_profile = id_user_profile [ 1 ] . value ;
var row = $ ( this ) . closest ( 'tr' );
var params = [];
params . push ( " delete_profile=1 " );
params . push ( " id_user= " + id_user );
params . push ( " id_user_profile= " + id_user_profile );
params . push ( " page=godmode/users/configure_user " );
jQuery . ajax ({
data : params . join ( " & " ),
type : 'POST' ,
url : action = " <?php echo ui_get_full_url('ajax.php', false, false, false); ?> " ,
success : function ( data ) {
row . remove ();
var rows = $ ( " #table_profiles tr " ) . length ;
if ( is_metaconsole === '' && rows <= 2 && user_is_global_admin !== '1' ) {
window . location . replace ( " <?php echo ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/user_list&tab=user&pure=0', false, false, false); ?> " );
} else if ( is_metaconsole === '1' && rows <= 3 && user_is_global_admin !== '1' ) {
window . location . replace ( " <?php echo ui_get_full_url('index.php?sec=advanced&sec2=advanced/users_setup', false, false, true); ?> " );
}
2020-07-23 13:26:39 +02:00
}
2023-02-16 07:25:26 +01:00
});
2020-07-23 13:26:39 +02:00
});
2023-02-16 07:25:26 +01:00
function checkProfiles ( e ) {
e . preventDefault ();
if ( $ ( '#checkbox-is_admin' ) . is ( ':checked' ) == true ) {
// Admin does not require profiles.
2020-11-03 10:08:23 +01:00
$ ( '#user_profile_form' ) . submit ();
2023-02-16 07:25:26 +01:00
} else {
if ( $ ( '#table_profiles tbody' ) . children () . length == 1 ) {
confirmDialog ({
title : " <?php echo __('Warning'); ?> " ,
message : " <?php echo __('User will be created without profiles assigned and won \ 't be able to log in, are you sure?'); ?> " ,
onAccept : function () {
$ ( '#user_profile_form' ) . submit ();
}
});
} else {
$ ( '#user_profile_form' ) . submit ();
}
2020-11-03 10:08:23 +01:00
}
2020-07-23 13:26:39 +02:00
}
2020-11-03 10:14:17 +01:00
2023-02-16 07:25:26 +01:00
$ ( '#submit-crtbutton' ) . click ( function ( e ) {
checkProfiles ( e );
});
2020-11-03 10:14:17 +01:00
2023-02-16 07:25:26 +01:00
$ ( '#submit-uptbutton' ) . click ( function ( e ) {
checkProfiles ( e );
});
2020-07-23 13:26:39 +02:00
});
2023-02-16 07:25:26 +01:00
function delete_profile ( event , btn ) {
event . preventDefault ();
var row = btn . parentNode . parentNode ;
var position = row . rowIndex ;
row . parentNode . removeChild ( row );
2020-07-23 13:26:39 +02:00
2023-02-16 07:25:26 +01:00
var json = json_profile . val ();
var test = JSON . parse ( json );
2022-11-23 16:29:27 +01:00
2023-02-16 07:25:26 +01:00
var position_offset = < ? php echo ( is_metaconsole () === true ) ? 2 : 1 ; ?> ;
2017-04-06 16:17:54 +02:00
2023-02-16 07:25:26 +01:00
test . splice ( position - position_offset , 1 );
json_profile . val ( JSON . stringify ( test ));
2019-05-27 18:49:47 +02:00
}
2023-02-16 07:25:26 +01:00
function show_data_section () {
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' );
}
2019-05-27 18:49:47 +02:00
2023-02-16 07:25:26 +01:00
function switch_ehorus_conf () {
if ( ! $ ( '#checkbox-ehorus_user_level_enabled' ) . prop ( 'checked' )) {
$ ( " .user_edit_ehorus_outer " ) . hide ();
2019-05-27 18:49:47 +02:00
2023-02-16 07:25:26 +01:00
} else {
$ ( " .user_edit_ehorus_outer " ) . show ();
2020-10-06 17:02:58 +02:00
}
2023-02-16 07:25:26 +01:00
}
2020-10-06 17:02:58 +02:00
2023-02-16 07:25:26 +01:00
function show_double_auth_info () {
var userID = '<?php echo io_safe_output($id); ?>' ;
2020-10-06 17:02:58 +02:00
2023-02-16 07:25:26 +01:00
var $loadingSpinner = $ ( " <img src= \" <?php echo $config['homeurl'] ; ?>/images/spinner.gif \" /> " );
var $dialogContainer = $ ( " div#dialog-double_auth-container " );
2020-10-06 17:02:58 +02:00
2023-02-16 07:25:26 +01:00
$dialogContainer . html ( $loadingSpinner );
// Load the info page
var request = $ . ajax ({
url : " <?php echo ui_get_full_url('ajax.php', false, false, false); ?> " ,
type : 'POST' ,
dataType : 'html' ,
data : {
page : 'include/ajax/double_auth.ajax' ,
id_user : userID ,
id_user_auth : userID ,
get_double_auth_data_page : 1 ,
FA_forced : 1 ,
containerID : $dialogContainer . prop ( 'id' )
},
complete : function ( xhr , textStatus ) {
2020-10-06 17:02:58 +02:00
2023-02-16 07:25:26 +01:00
},
success : function ( data , textStatus , xhr ) {
// isNaN = is not a number
if ( isNaN ( data )) {
$dialogContainer . html ( data );
}
// data is a number, convert it to integer to do the compare
else if ( Number ( data ) === - 1 ) {
$dialogContainer . html ( " <?php echo '<b><div class= \" red \" >'.__('Authentication error').'</div></b>'; ?> " );
} else {
$dialogContainer . html ( " <?php echo '<b><div class= \" red \" >'.__('Error').'</div></b>'; ?> " );
}
},
error : function ( xhr , textStatus , errorThrown ) {
$dialogContainer . html ( " <?php echo '<b><div class= \" red \" >'.__('There was an error loading the data').'</div></b>'; ?> " );
}
});
2021-03-02 13:24:03 +01:00
2023-02-16 07:25:26 +01:00
$ ( " div#dialog-double_auth " )
. css ( 'display' , 'block' )
. append ( $dialogContainer )
. dialog ({
resizable : true ,
draggable : true ,
modal : true ,
title : " <?php echo __('Double autentication information'); ?> " ,
overlay : {
opacity : 0.5 ,
background : " black "
},
width : 400 ,
height : 375 ,
close : function ( event , ui ) {
// Abort the ajax request
if ( typeof request != 'undefined' )
request . abort ();
// Remove the contained html
$dialogContainer . empty ();
}
})
. show ();
2020-10-06 17:02:58 +02:00
2023-02-16 07:25:26 +01:00
}
2020-10-06 17:02:58 +02:00
2023-02-16 07:25:26 +01:00
function show_double_auth_activation () {
var userID = '<?php echo io_safe_output($id); ?>' ;
2020-10-06 17:02:58 +02:00
2023-02-16 07:25:26 +01:00
var $loadingSpinner = $ ( " <img src= \" <?php echo $config['homeurl'] ; ?>/images/spinner.gif \" /> " );
var $dialogContainer = $ ( " div#dialog-double_auth-container " );
// Uncheck until completed successfully.
$ ( " input#checkbox-double_auth " ) . prop ( " checked " , false );
2020-10-06 17:02:58 +02:00
$dialogContainer . html ( $loadingSpinner );
2023-02-16 07:25:26 +01:00
// Load the info page
var request = $ . ajax ({
2020-10-06 17:02:58 +02:00
url : " <?php echo ui_get_full_url('ajax.php', false, false, false); ?> " ,
type : 'POST' ,
2023-02-16 07:25:26 +01:00
dataType : 'html' ,
2020-10-06 17:02:58 +02:00
data : {
page : 'include/ajax/double_auth.ajax' ,
id_user : userID ,
2023-02-16 07:25:26 +01:00
id_user_auth : userID ,
2020-10-06 17:02:58 +02:00
FA_forced : 1 ,
2023-02-16 07:25:26 +01:00
get_double_auth_info_page : 1 ,
containerID : $dialogContainer . prop ( 'id' )
2020-10-06 17:02:58 +02:00
},
complete : function ( xhr , textStatus ) {
2023-02-16 07:25:26 +01:00
2020-10-06 17:02:58 +02:00
},
success : function ( data , textStatus , xhr ) {
2023-02-16 07:25:26 +01:00
// isNaN = is not a number
if ( isNaN ( data )) {
$dialogContainer . html ( data );
2020-10-06 17:02:58 +02:00
}
2023-02-16 07:25:26 +01:00
// data is a number, convert it to integer to do the compare
else if ( Number ( data ) === - 1 ) {
$dialogContainer . html ( " <?php echo '<b><div class= \" red \" >'.__('Authentication error').'</div></b>'; ?> " );
} else {
$dialogContainer . html ( " <?php echo '<b><div class= \" red \" >'.__('Error').'</div></b>'; ?> " );
2020-10-06 17:02:58 +02:00
}
},
error : function ( xhr , textStatus , errorThrown ) {
2023-02-16 07:25:26 +01:00
$dialogContainer . html ( " <?php echo '<b><div class= \" red \" >'.__('There was an error loading the data').'</div></b>'; ?> " );
2020-10-06 17:02:58 +02:00
}
});
2023-02-16 07:25:26 +01:00
$ ( " div#dialog-double_auth " ) . dialog ({
resizable : true ,
draggable : true ,
modal : true ,
title : " <?php echo __('Double authentication activation'); ?> " ,
overlay : {
opacity : 0.5 ,
background : " black "
},
width : 500 ,
height : 400 ,
close : function ( event , ui ) {
// Abort the ajax request
if ( typeof request != 'undefined' )
request . abort ();
// Remove the contained html
$dialogContainer . empty ();
}
})
. show ();
}
2020-10-06 17:02:58 +02:00
2023-02-16 07:25:26 +01:00
function show_double_auth_deactivation () {
var userID = '<?php echo io_safe_output($id); ?>' ;
var $loadingSpinner = $ ( " <img src= \" <?php echo $config['homeurl'] ; ?>/images/spinner.gif \" /> " );
var $dialogContainer = $ ( " div#dialog-double_auth-container " );
var message = " <p><?php echo __('Are you sure?').'<br>'.__('The double authentication will be deactivated'); ?></p> " ;
var $button = $ ( " <input type= \" button \" value= \" <?php echo __('Deactivate'); ?> \" /> " );
// Prevent switch deactivaction until proceess is done
$ ( " input#checkbox-double_auth " ) . prop ( " checked " , true );
$dialogContainer
. empty ()
. append ( message )
. append ( $button );
var request ;
$button . click ( function ( e ) {
e . preventDefault ();
$dialogContainer . html ( $loadingSpinner );
// Deactivate the double auth
request = $ . ajax ({
url : " <?php echo ui_get_full_url('ajax.php', false, false, false); ?> " ,
type : 'POST' ,
dataType : 'json' ,
data : {
page : 'include/ajax/double_auth.ajax' ,
id_user : userID ,
FA_forced : 1 ,
deactivate_double_auth : 1
},
complete : function ( xhr , textStatus ) {
},
success : function ( data , textStatus , xhr ) {
if ( data === - 1 ) {
$dialogContainer . html ( " <?php echo '<b><div class= \" red \" >'.__('Authentication error').'</div></b>'; ?> " );
} else if ( data ) {
$dialogContainer . html ( " <?php echo '<b><div class= \" green \" >'.__('The double autentication was deactivated successfully').'</div></b>'; ?> " );
$ ( " input#checkbox-double_auth " ) . prop ( " checked " , false );
} else {
$dialogContainer . html ( " <?php echo '<b><div class= \" red \" >'.__('There was an error deactivating the double autentication').'</div></b>'; ?> " );
}
},
error : function ( xhr , textStatus , errorThrown ) {
$dialogContainer . html ( " <?php echo '<b><div class= \" red \" >'.__('There was an error deactivating the double autentication').'</div></b>'; ?> " );
}
});
});
$ ( " div#dialog-double_auth " ) . dialog ({
resizable : true ,
draggable : true ,
modal : true ,
title : " <?php echo __('Double authentication activation'); ?> " ,
overlay : {
opacity : 0.5 ,
background : " black "
},
width : 300 ,
height : 150 ,
close : function ( event , ui ) {
// Abort the ajax request
if ( typeof request != 'undefined' )
request . abort ();
// Remove the contained html
$dialogContainer . empty ();
}
})
. show ();
}
2020-10-06 17:02:58 +02:00
2023-02-16 07:25:26 +01:00
/* ]]> */
2023-04-14 10:02:41 +02:00
</ script >