User management for meta

This commit is contained in:
Jose Gonzalez 2023-03-14 13:11:57 +01:00
parent 93a912b76b
commit b428e77e7c
5 changed files with 161 additions and 345 deletions

View File

@ -407,7 +407,6 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
// User.
// $headerUserImage = (is_user_admin($config['id_user']) === true) ? 'images/header_user_admin_green.png' : 'images/header_user_green.png';
$headerUser = [];
$headerUser[] = html_print_image(
'images/edit_user@header.svg',

View File

@ -1,5 +1,4 @@
<?php
/**
* User creation / update.
*
@ -996,15 +995,6 @@ if (!users_is_admin() && $config['id_user'] !== $id && $new_user === false) {
}
}
if (is_metaconsole() === true) {
html_print_div(
[
'class' => 'user_form_title',
'content' => ((bool) $id === true) ? sprintf('%s [ %s ]', __('Update User'), $id) : __('Create User'),
]
);
}
if (!$new_user) {
$user_id = '<div class="label_select_simple"><p class="edit_user_labels">'.__('User ID').': </p>';
$user_id .= '<span>'.$id.'</span>';
@ -1282,8 +1272,9 @@ if (is_metaconsole() === false) {
if (is_metaconsole() === true) {
$array_filters = get_filters_custom_fields_view(0, true);
$search_custom_fields_view = '<div class="label_select"><p class="edit_user_labels">'.__('Search custom field view').' '.ui_print_help_tip(__('Load by default the selected view in custom field view'), true).'</p>';
$search_custom_fields_view .= html_print_select(
$searchCustomFieldView = [];
$searchCustomFieldView[] = __('Search custom field view');
$searchCustomFieldView[] = html_print_select(
$array_filters,
'default_custom_view',
$user_info['default_custom_view'],
@ -1295,7 +1286,10 @@ if (is_metaconsole() === true) {
true,
'',
false
).'</div>';
).ui_print_input_placeholder(
__('Load by default the selected view in custom field view'),
true
);
}
$values = [
@ -1377,6 +1371,8 @@ $home_screen .= html_print_input_text(
false
);
$home_screen = '';
$size_pagination = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Block size for pagination').'</p>';
$size_pagination .= html_print_input_text(
'block_size',
@ -1395,19 +1391,20 @@ if ($id === $config['id_user']) {
);
}
if (enterprise_installed() && is_metaconsole() === true) {
if (enterprise_installed() === true && is_metaconsole() === true) {
$user_info_metaconsole_access = 'only_console';
if (isset($user_info['metaconsole_access'])) {
$user_info_metaconsole_access = $user_info['metaconsole_access'];
}
// TODO review help tips on meta.
$meta_access = '<div class="label_select"><p class="edit_user_labels">'.__('Metaconsole access').' './* ui_print_help_icon('meta_access', true). */ '</p>';
$metaconsole_accesses = [
'basic' => __('Basic'),
'advanced' => __('Advanced'),
];
$meta_access .= html_print_select(
$outputMetaAccess = [];
$outputMetaAccess[] = __('Metaconsole access');
$outputMetaAccess[] = html_print_select(
$metaconsole_accesses,
'metaconsole_access',
$user_info_metaconsole_access,
@ -1417,51 +1414,9 @@ if (enterprise_installed() && is_metaconsole() === true) {
true,
false,
false
).'</div>';
);
}
/*
$not_login = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Not Login').'</p>';
$not_login .= ui_print_help_tip(
__('The user with not login set only can access to API.'),
true
);
$not_login .= html_print_checkbox_switch(
'not_login',
1,
$user_info['not_login'],
true
).'</div>';
$local_user = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Local user').'</p>';
$local_user .= ui_print_help_tip(
__('The user with local authentication enabled will always use local authentication.'),
true
);
$local_user .= html_print_checkbox_switch(
'local_user',
1,
$user_info['local_user'],
true
).'</div>';
$session_time = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Session Time');
$session_time .= ui_print_help_tip(
__('This is defined in minutes, If you wish a permanent session should putting -1 in this field.'),
true
).'</p>';
$session_time .= html_print_input_text(
'session_time',
$user_info['session_time'],
'',
5,
5,
true.false,
false,
'',
'class="input_line_small"'
).'</div>';
*/
$user_groups = implode(',', array_keys((users_get_groups($id, 'AR', $display_all_group))));
if (empty($user_groups) === false) {
@ -1582,31 +1537,6 @@ if (empty($doubleAuthElementsContent) === false) {
$doubleAuthentication = '';
}
/*
if (isset($double_authentication)) {
$double_authentication .= '</div>';
}*/
$autorefresh_list_out = [];
if (is_metaconsole() === false || is_centralized() === true) {
$autorefresh_list_out['operation/agentes/estado_agente'] = 'Agent detail';
@ -1665,31 +1595,32 @@ if (isset($autorefresh_list) === false) {
}
}
if (is_metaconsole() === true) {
enterprise_include_once('include/functions_metaconsole.php');
$access_node = db_get_value('metaconsole_access_node', 'tusuario', 'id_user', $id);
$metaconsole_agents_manager = '<div class="label_select_simple" id="metaconsole_agents_manager_div"><p class="edit_user_labels">'.__('Enable agents managment').'</p>';
$metaconsole_agents_manager .= html_print_checkbox_switch(
$metaconsoleAgentManager = [];
$metaconsoleAgentManager[] = __('Enable agents managment');
$metaconsoleAgentManager[] = html_print_checkbox_switch(
'metaconsole_agents_manager',
1,
$user_info['metaconsole_agents_manager'],
true
).'</div>';
);
$metaconsole_access_node = '<div class="label_select_simple" id="metaconsole_access_node_div"><p class="edit_user_labels">'.__('Enable node access').ui_print_help_tip(__('With this option enabled, the user will can access to nodes console'), true).'</p>';
$metaconsole_access_node .= html_print_checkbox(
$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(
'metaconsole_access_node',
1,
$access_node,
true
).'</div>';
);
}
echo '<div class="max_floating_element_size">';
echo '<form id="user_profile_form" name="user_profile_form" method="post" autocomplete="off" action="#">';
@ -1701,141 +1632,8 @@ if (!$id) {
$user_id_create = $user_id;
}
if (is_metaconsole() === true) {
$access_or_pagination = $meta_access;
if ($id != '' && !$is_err) {
$div_user_info = '<div class="edit_user_info_left">'.$avatar.$user_id_create.'</div>
<div class="edit_user_info_right">'.$user_id_update_view.$full_name.$new_pass.$new_pass_confirm.$own_pass_confirm.$global_profile.'</div>';
} else {
$div_user_info = '<div class="edit_user_info_left">'.$avatar.'</div>
<div class="edit_user_info_right">'.$user_id_create.$user_id_update_view.$full_name.$new_pass.$new_pass_confirm.$global_profile.'</div>';
}
echo '<div id="user_form">
<div class="user_edit_first_row">
<div class="edit_user_info white_box">'.$div_user_info.'</div>
<div class="edit_user_autorefresh white_box"><p class="bolder">Extra info</p>'.$email.$phone.$not_login.$local_user.$session_time.'</div>
</div>
<div class="user_edit_second_row white_box">
<div class="edit_user_options">'.$language.$access_or_pagination.$skin.$default_event_filter.$double_authentication.'</div>
<div class="edit_user_timezone">'.$timezone;
echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_access_node;
$autorefresh_show = '<p class="edit_user_labels">'._('Autorefresh').ui_print_help_tip(
__('This will activate autorefresh in selected pages'),
true
).'</p>';
$select_out = html_print_select(
$autorefresh_list_out,
'autorefresh_list_out[]',
'',
'',
'',
'',
true,
true,
true,
'',
false,
'width:100%'
);
$arrows = ' ';
$select_in = html_print_select(
$autorefresh_list,
'autorefresh_list[]',
'',
'',
'',
'',
true,
true,
true,
'',
false,
'width:100%'
);
$table_ichanges = '<div class="autorefresh_select">
<div class="autorefresh_select_list_out">
<p class="autorefresh_select_text">'.__('Full list of pages').': </p>
<div>'.$select_out.'</div>
</div>
<div class="autorefresh_select_arrows" style="display:grid">
<a href="javascript:">'.html_print_image(
'images/darrowright_green.png',
true,
[
'id' => 'right_autorefreshlist',
'alt' => __('Push selected pages into autorefresh list'),
'title' => __('Push selected pages into autorefresh list'),
]
).'</a>
<a href="javascript:">'.html_print_image(
'images/darrowleft_green.png',
true,
[
'id' => 'left_autorefreshlist',
'alt' => __('Pop selected pages out of autorefresh list'),
'title' => __('Pop selected pages out of autorefresh list'),
]
).'</a>
</div>
<div class="autorefresh_select_list">
<p class="autorefresh_select_text">'.__('List of pages with autorefresh').': </p>
<div>'.$select_in.'</div>
</div>
</div>';
$autorefresh_show .= $table_ichanges;
// Time autorefresh.
$times = get_refresh_time_array();
$time_autorefresh = '<div class="label_select"><p class="edit_user_labels">'.__('Time autorefresh');
$time_autorefresh .= ui_print_help_tip(
__('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'),
true
).'</p>';
$time_autorefresh .= html_print_select(
$times,
'time_autorefresh',
$user_info['time_autorefresh'],
'',
'',
'',
true,
false,
false
).'</div>';
echo '</div>
</div>
<div class="edit_user_autorefresh white_box">'.$autorefresh_show.$time_autorefresh.'</div>
<div class="user_edit_third_row white_box">
<div class="edit_user_comments">'.$comments.'</div>
</div>';
if (empty($ehorus) === false) {
html_print_div(
[
'class' => 'user_edit_third_row white_box',
'content' => $ehorus,
],
true
);
}
// User Profile definition table. (Only where user is not creating).
if ($new_user === false && ((bool) check_acl($config['id_user'], 0, 'UM') === true)) {
profile_print_profile_table($id, io_safe_output($json_profile), false, ($is_err === true));
}
} else {
$access_or_pagination = $size_pagination;
// WIP: Only for node.
include_once 'user_management.php';
}
// User management form.
require_once 'user_management.php';
if ((bool) $config['admin_can_add_user'] === true) {
html_print_csrf_hidden();
@ -1916,7 +1714,7 @@ if (is_metaconsole() === false) {
$(document).ready(function() {
// Set up the picker to update target timezone and country select lists.
$('#timezone-image').timezonePicker({
target: '#timezone',
target: '#timezone1',
});
// Optionally an auto-detect button to trigger JavaScript geolocation.
@ -1938,17 +1736,6 @@ if (is_metaconsole() === false) {
var json_profile = $('#hidden-json_profile');
/* <![CDATA[ */
$(document).ready(function() {
// Set up the picker to update target timezone and country select lists.
$('#timezone-image').timezonePicker({
target: '#timezone1',
});
// Optionally an auto-detect button to trigger JavaScript geolocation.
$('#timezone-detect').click(function() {
$('#timezone-image').timezonePicker('detectLocation');
});
$("#right_autorefreshlist").click(function() {
jQuery.each($("select[name='autorefresh_list_out[]'] option:selected"), function(key, value) {
imodule_name = $(value).html();

View File

@ -395,8 +395,6 @@ if ($delete_user === true) {
__('There was a problem deleting the user from %s', io_safe_input($server['server_name']))
);
}
header('Refresh:1');
}
} else {
ui_print_error_message(__('There was a problem deleting the user'));

View File

@ -325,53 +325,55 @@ if ($new_user === false) {
$userManagementTable->data['passwordManage_table'] = html_print_table($passwordManageTable, true);
if (users_is_admin() === true) {
$userManagementTable->rowclass['captions_loginErrorUser'] = 'field_half_width w50p';
$userManagementTable->cellclass['captions_loginErrorUser'][0] = 'wrap';
$userManagementTable->cellclass['captions_loginErrorUser'][1] = 'wrap';
$notLoginCheckContent = [];
$notLoginCheckContent[] = '<span>'.__('Not Login').'</span>';
$notLoginCheckContent[] = html_print_checkbox_switch(
'not_login',
1,
$user_info['not_login'],
true
);
$userManagementTable->rowclass['captions_loginErrorUser'] = 'field_half_width w50p';
$userManagementTable->cellclass['captions_loginErrorUser'][0] = 'wrap';
$userManagementTable->cellclass['captions_loginErrorUser'][1] = 'wrap';
$notLoginCheckContent = [];
$notLoginCheckContent[] = '<span>'.__('Not Login').'</span>';
$notLoginCheckContent[] = html_print_checkbox_switch(
'not_login',
1,
$user_info['not_login'],
true
);
$userManagementTable->data['captions_loginErrorUser'][0] = html_print_div(
[
'class' => 'margin-top-10',
'style' => 'display: flex; flex-direction: row-reverse; align-items: center;',
'content' => implode('', $notLoginCheckContent),
],
true
);
$userManagementTable->data['captions_loginErrorUser'][0] .= ui_print_input_placeholder(
__('The user with not login set only can access to API.'),
true
);
$userManagementTable->data['captions_loginErrorUser'][0] = html_print_div(
[
'class' => 'margin-top-10',
'style' => 'display: flex; flex-direction: row-reverse; align-items: center;',
'content' => implode('', $notLoginCheckContent),
],
true
);
$userManagementTable->data['captions_loginErrorUser'][0] .= ui_print_input_placeholder(
__('The user with not login set only can access to API.'),
true
);
$localUserCheckContent = [];
$localUserCheckContent[] = '<span>'.__('Local User').'</span>';
$localUserCheckContent[] = html_print_checkbox_switch(
'local_user',
1,
$user_info['local_user'],
true
);
$localUserCheckContent = [];
$localUserCheckContent[] = '<span>'.__('Local User').'</span>';
$localUserCheckContent[] = html_print_checkbox_switch(
'local_user',
1,
$user_info['local_user'],
true
);
$userManagementTable->data['captions_loginErrorUser'][1] = html_print_div(
[
'class' => 'margin-top-10',
'style' => 'display: flex; flex-direction: row-reverse; align-items: center;',
'content' => implode('', $localUserCheckContent),
],
true
);
$userManagementTable->data['captions_loginErrorUser'][1] .= ui_print_input_placeholder(
__('The user with local authentication enabled will always use local authentication.'),
true
);
}
$userManagementTable->data['captions_loginErrorUser'][1] = html_print_div(
[
'class' => 'margin-top-10',
'style' => 'display: flex; flex-direction: row-reverse; align-items: center;',
'content' => implode('', $localUserCheckContent),
],
true
);
$userManagementTable->data['captions_loginErrorUser'][1] .= ui_print_input_placeholder(
__('The user with local authentication enabled will always use local authentication.'),
true
);
$userManagementTable->data['show_tips_startup'][0] = html_print_checkbox_switch('show_tips_startup', 1, ($user_info['show_tips_startup'] === null) ? true : $user_info['show_tips_startup'], true);
$userManagementTable->data['show_tips_startup'][1] = '<span>'.__('Show usage tips at startup').'</span>';
@ -551,10 +553,10 @@ $userManagementTable->data['fields_autorefreshTime'][0] .= ui_print_input_placeh
// Title for Language and Appearance.
$userManagementTable->data['title_lookAndFeel'] = html_print_subtitle_table(__('Language and Appearance'));
// Language and color scheme.
$userManagementTable->rowclass['captions_lang_colorscheme'] = 'field_half_width';
$userManagementTable->rowclass['fields_lang_colorscheme'] = 'field_half_width';
$userManagementTable->data['captions_lang_colorscheme'][0] = __('Language');
$userManagementTable->data['fields_lang_colorscheme'][0] = html_print_select_from_sql(
$userManagementTable->rowclass['line1_looknfeel'] = 'field_half_width';
$userManagementTable->rowclass['line2_looknfeel'] = 'field_half_width';
$userManagementTable->data['line1_looknfeel'][0] = __('Language');
$userManagementTable->data['line2_looknfeel'][0] = html_print_select_from_sql(
'SELECT id_language, name FROM tlanguage',
'language',
$user_info['language'],
@ -564,8 +566,15 @@ $userManagementTable->data['fields_lang_colorscheme'][0] = html_print_select_fro
true
);
$userManagementTable->data['captions_lang_colorscheme'][1] = __('User color scheme');
$userManagementTable->data['fields_lang_colorscheme'][1] = skins_print_select($id_usr, 'skin', $user_info['id_skin'], '', __('None'), 0, true);
if (is_metaconsole() === true) {
if (users_is_admin() === true) {
$userManagementTable->data['line1_looknfeel'][1] = $outputMetaAccess[0];
$userManagementTable->data['line2_looknfeel'][1] = $outputMetaAccess[1];
}
} else {
$userManagementTable->data['line1_looknfeel'][1] = __('User color scheme');
$userManagementTable->data['line2_looknfeel'][1] = skins_print_select($id_usr, 'skin', $user_info['id_skin'], '', __('None'), 0, true);
}
$userManagementTable->rowclass['captions_blocksize_eventfilter'] = 'field_half_width';
$userManagementTable->rowclass['fields_blocksize_eventfilter'] = 'field_half_width';
@ -591,41 +600,55 @@ $userManagementTable->data['fields_blocksize_eventfilter'][1] = html_print_selec
false,
false
);
if (is_metaconsole() === false) {
// Home screen table.
$homeScreenTable = new stdClass();
$homeScreenTable->class = 'w100p table_section full_section';
$homeScreenTable->id = 'home_screen_table';
$homeScreenTable->style = [];
$homeScreenTable->rowclass = [];
$homeScreenTable->data = [];
// Home screen.
$homeScreenTable->data['captions_homescreen'][0] = __('Home screen');
$homeScreenTable->colspan['captions_homescreen'][0] = 2;
$homeScreenTable->rowclass['captions_homescreen'] = 'field_half_width';
$homeScreenTable->rowclass['fields_homescreen'] = 'field_half_width flex';
$homeScreenTable->data['fields_homescreen'][0] = html_print_select(
$homeScreenValues,
'section',
io_safe_output($user_info['section']),
'show_data_section();',
'',
-1,
true,
false,
false
);
$homeScreenTable->data['fields_homescreen'][1] = html_print_div(
[
'class' => 'w100p',
'content' => $customHomeScreenDataField,
],
true
);
// Home screen table.
$homeScreenTable = new stdClass();
$homeScreenTable->class = 'w100p table_section full_section';
$homeScreenTable->id = 'home_screen_table';
$homeScreenTable->style = [];
$homeScreenTable->rowclass = [];
$homeScreenTable->data = [];
$userManagementTable->rowclass['homescreen_table'] = 'w100p';
$userManagementTable->data['homescreen_table'] = html_print_table($homeScreenTable, true);
}
// Home screen.
$homeScreenTable->data['captions_homescreen'][0] = __('Home screen');
$homeScreenTable->colspan['captions_homescreen'][0] = 2;
$homeScreenTable->rowclass['captions_homescreen'] = 'field_half_width';
$homeScreenTable->rowclass['fields_homescreen'] = 'field_half_width flex';
$homeScreenTable->data['fields_homescreen'][0] = html_print_select(
$homeScreenValues,
'section',
io_safe_output($user_info['section']),
'show_data_section();',
'',
-1,
true,
false,
false
);
$homeScreenTable->data['fields_homescreen'][1] = html_print_div(
[
'class' => 'w100p',
'content' => $customHomeScreenDataField,
],
true
);
if (is_metaconsole() === true && users_is_admin() === true) {
$userManagementTable->rowclass['search_custom1_looknfeel'] = 'field_half_width';
$userManagementTable->rowclass['search_custom2_looknfeel'] = 'field_half_width flex-column';
$userManagementTable->data['search_custom1_looknfeel'][0] = $searchCustomFieldView[0];
$userManagementTable->data['search_custom2_looknfeel'][0] = $searchCustomFieldView[1];
$userManagementTable->rowclass['homescreen_table'] = 'w100p';
$userManagementTable->data['homescreen_table'] = html_print_table($homeScreenTable, true);
$userManagementTable->rowclass['agent_manager1_looknfeel'] = 'field_half_width';
$userManagementTable->rowclass['agent_manager2_looknfeel'] = 'field_half_width flex-column';
$userManagementTable->data['agent_manager1_looknfeel'][0] = $metaconsoleAgentManager[0];
$userManagementTable->data['agent_manager1_looknfeel'][1] = $metaconsoleAgentManager[2];
$userManagementTable->data['agent_manager2_looknfeel'][0] = $metaconsoleAgentManager[1];
$userManagementTable->data['agent_manager2_looknfeel'][1] = $metaconsoleAgentManager[3];
}
// Timezone.
$userManagementTable->rowclass['captions_timezone'] = 'field_half_width';
@ -639,14 +662,15 @@ $userManagementTable->data['fields_timezone'][0] .= ui_print_input_placeholder(
__('The timezone must be that of the associated server.'),
true
);
$userManagementTable->data['fields_timezone'][1] = html_print_div(
[
'id' => 'timezone-picker',
'content' => implode('', $timezoneContent),
],
true
);
if (is_metaconsole() === false) {
$userManagementTable->data['fields_timezone'][1] = html_print_div(
[
'id' => 'timezone-picker',
'content' => implode('', $timezoneContent),
],
true
);
}
// Title for Language and Appearance.
$userManagementTable->data['title_additionalSettings'] = html_print_subtitle_table(__('Additional settings'));
@ -743,3 +767,19 @@ html_print_table($userManagementTable);
if ($new_user === false && ((bool) check_acl($config['id_user'], 0, 'UM') === true)) {
profile_print_profile_table($id, io_safe_output($json_profile), false, ($is_err === true));
}
?>
<!--
<script>
paint_qrcode(
"
<?php
// echo ui_get_full_url('mobile/index.php?page=agent&id='.$id_agente);
?>
",
"#qr_code_agent_view",
128,
128
);
</script>
-->

View File

@ -191,15 +191,9 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c
$table->id = 'table_profiles';
$table->width = '100%';
$table->class = 'info_table';
if (is_metaconsole() === true) {
$table->head_colspan[0] = 0;
$table->width = '100%';
$table->class = 'databox_tactical data';
$table->title = $title;
} else {
echo '<div id="edit_user_profiles" class="floating_form white_box">';
echo '<p class="subsection_header_title padding-lft-10">'.$title.'</p>';
}
echo '<div id="edit_user_profiles" class="floating_form white_box">';
echo '<p class="subsection_header_title padding-lft-10">'.$title.'</p>';
$table->data = [];
$table->head = [];
@ -405,9 +399,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c
array_push($table->data, $data);
html_print_table($table, $return);
if (is_metaconsole() === false) {
echo '</div>';
}
echo '</div>';
unset($table);
}