From a9df7e2ec5e79d2f86a492fd454264255e957425 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Fri, 3 Feb 2023 16:36:04 +0100 Subject: [PATCH] WIP: Improve somethings --- .../godmode/users/configure_user.php | 115 ++++++++---------- .../godmode/users/user_management.php | 78 ++++++++++-- 2 files changed, 118 insertions(+), 75 deletions(-) diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index ae00ca718b..2b2f31eb30 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -28,7 +28,7 @@ // Load global vars. global $config; -hd($_REQUEST); +// hd($_REQUEST); //TODO. For testing purposes. check_login(); require_once $config['homedir'].'/vendor/autoload.php'; @@ -1424,7 +1424,7 @@ $size_pagination .= html_print_input_text( true ).''; -if ($id == $config['id_user']) { +if ($id === $config['id_user']) { $language .= html_print_input_hidden( 'quick_language_change', 1, @@ -1432,7 +1432,7 @@ if ($id == $config['id_user']) { ); } -if (enterprise_installed() && defined('METACONSOLE')) { +if (enterprise_installed() && is_metaconsole() === true) { $user_info_metaconsole_access = 'only_console'; if (isset($user_info['metaconsole_access'])) { $user_info_metaconsole_access = $user_info['metaconsole_access']; @@ -1457,36 +1457,37 @@ if (enterprise_installed() && defined('METACONSOLE')) { ).''; } -$not_login = '

'.__('Not Login').'

'; -$not_login .= ui_print_help_tip( +/* + $not_login = '

'.__('Not Login').'

'; + $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 .= html_print_checkbox_switch( 'not_login', 1, $user_info['not_login'], true -).'
'; + ).'
'; -$local_user = '

'.__('Local user').'

'; -$local_user .= ui_print_help_tip( + $local_user = '

'.__('Local user').'

'; + $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 .= html_print_checkbox_switch( 'local_user', 1, $user_info['local_user'], true -).'
'; + ).'
'; -$session_time = '

'.__('Session Time'); -$session_time .= ui_print_help_tip( + $session_time = '

'.__('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 -).'

'; -$session_time .= html_print_input_text( + ).'

'; + $session_time .= html_print_input_text( 'session_time', $user_info['session_time'], '', @@ -1496,8 +1497,8 @@ $session_time .= html_print_input_text( false, '', 'class="input_line_small"' -).'
'; - + ).'
'; +*/ $user_groups = implode(',', array_keys((users_get_groups($id, 'AR', $display_all_group)))); if (empty($user_groups) === false) { @@ -1820,33 +1821,15 @@ echo '
'.$comments.'
'; -html_print_div( - [ - 'class' => 'user_edit_third_row white_box', - 'content' => html_print_div( - [ - 'class' => 'edit_user_allowed_ip', - 'content' => $allowedIP, - ], - true - ), - ] -); - if (!empty($ehorus)) { echo '
'.$ehorus.'
'; } echo ''; -echo '
'; if ($config['admin_can_add_user']) { html_print_csrf_hidden(); - if ($new_user) { - html_print_input_hidden('create_user', 1); - } else { - html_print_input_hidden('update_user', 1); - } + html_print_input_hidden((($new_user === true) ? 'create_user' : 'update_user'), 1); } echo '
'; @@ -1857,40 +1840,38 @@ if ($new_user === true) { echo ''; -if ($is_err === true && $new_user === true) { - profile_print_profile_table($id, io_safe_output($json_profile), false, true); -} else { - profile_print_profile_table($id, io_safe_output($json_profile)); -} +$actionButtons = []; -echo '
'; - -echo '
'; -if ($config['admin_can_add_user']) { - if ($new_user) { - html_print_submit_button( - __('Create'), - 'crtbutton', - false, - [ - 'icon' => 'wand', - 'form' => 'user_profile_form', - ] - ); +if ((bool) $config['admin_can_add_user'] === true) { + if ($new_user === true) { + $submitButtonCaption = __('Create'); + $submitButtonName = 'crtbutton'; + $submitButtonIcon = 'wand'; } else { - html_print_submit_button( - __('Update'), - 'uptbutton', - false, - [ - 'icon' => 'update', - 'form' => 'user_profile_form', - ] - ); + $submitButtonCaption = __('Update'); + $submitButtonName = 'uptbutton'; + $submitButtonIcon = 'update'; } + + $actionButtons[] = html_print_submit_button( + $submitButtonCaption, + $submitButtonName, + false, + [ + 'icon' => $submitButtonIcon, + 'form' => 'user_profile_form', + ], + true + ); } -echo '
'; +$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 +); + +html_print_action_buttons(implode('', $actionButtons), ['type' => 'form_action']); echo ''; diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index 9acd4684b0..f9c96da433 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -585,6 +585,10 @@ $userManagementTable->data['title_additionalSettings'][1] = html_print_subtitle_ $userManagementTable->rowclass['captions_addSettings'] = 'field_half_width pdd_t_10px'; $userManagementTable->rowclass['fields_addSettings'] = 'field_half_width'; $userManagementTable->cellstyle['fields_addSettings'][1] = 'flex-wrap: wrap'; +$userManagementTable->cellstyle['captions_addSettings'][1] = 'width: 35%'; +$userManagementTable->cellstyle['captions_addSettings'][2] = 'width: 15%'; +$userManagementTable->cellstyle['fields_addSettings'][1] = 'width: 35%'; +$userManagementTable->cellstyle['fields_addSettings'][2] = 'width: 15%'; $userManagementTable->data['captions_addSettings'][0] = __('Comments'); $userManagementTable->data['fields_addSettings'][0] = html_print_textarea( 'comments', @@ -600,16 +604,23 @@ $userManagementTable->data['captions_addSettings'][1] .= ui_print_help_tip( __('Add the source IPs that will allow console access. Each IP must be separated only by comma. * allows all.'), true ); -$userManagementTable->data['fields_addSettings'][1] = html_print_textarea( - 'allowed_ip_list', - 2, - 65, - $user_info['allowed_ip_list'], - (((bool) $view_mode === true) ? 'readonly="readonly"' : ''), +$userManagementTable->data['fields_addSettings'][1] = html_print_div( + [ + 'class' => 'edit_user_allowed_ip', + 'content' => html_print_textarea( + 'allowed_ip_list', + 2, + 65, + $user_info['allowed_ip_list'], + (((bool) $view_mode === true) ? 'readonly="readonly"' : ''), + true + ), + ], true ); -$userManagementTable->data['fields_addSettings'][1] .= html_print_div( +$userManagementTable->data['captions_addSettings'][2] = __('Allow all IPs'); +$userManagementTable->data['fields_addSettings'][2] = html_print_div( [ 'class' => 'margin-top-10', 'content' => html_print_checkbox_switch( @@ -617,9 +628,60 @@ $userManagementTable->data['fields_addSettings'][1] .= html_print_div( 0, $user_info['allowed_ip_active'], true - ).''.__('Allow all IPs').'', + ), ], true ); + +$userManagementTable->rowclass['captions_loginErrorUser'] = 'field_half_width pdd_t_10px'; +$userManagementTable->rowclass['fields_loginErrorUser'] = 'field_half_width'; +$userManagementTable->cellstyle['captions_loginErrorUser'][0] = 'width: 25%'; +$userManagementTable->cellstyle['captions_loginErrorUser'][1] = 'width: 25%'; +$userManagementTable->cellstyle['fields_loginErrorUser'][0] = 'width: 25%'; +$userManagementTable->cellstyle['fields_loginErrorUser'][1] = 'width: 25%'; +$userManagementTable->data['captions_loginErrorUser'][0] = __('Not Login'); +$userManagementTable->data['captions_loginErrorUser'][0] .= ui_print_help_tip( + __('The user with not login set only can access to API.'), + true +); +$userManagementTable->data['fields_loginErrorUser'][0] = html_print_checkbox_switch( + 'not_login', + 1, + $user_info['not_login'], + true +); + +$userManagementTable->data['captions_loginErrorUser'][1] = __('Local user'); +$userManagementTable->data['captions_loginErrorUser'][1] .= ui_print_help_tip( + __('The user with local authentication enabled will always use local authentication.'), + true +); +$userManagementTable->data['fields_loginErrorUser'][1] = html_print_checkbox_switch( + 'local_user', + 1, + $user_info['local_user'], + true +); + +$userManagementTable->data['captions_loginErrorUser'][2] = __('Session time'); +$userManagementTable->data['captions_loginErrorUser'][2] .= ui_print_help_tip( + __('This is defined in minutes, If you wish a permanent session should putting -1 in this field.'), + true +); +$userManagementTable->data['fields_loginErrorUser'][2] = html_print_input_text( + 'session_time', + $user_info['session_time'], + '', + 5, + 5, + true.false, + false, + '', + 'class="input_line_small"' +); + html_print_table($userManagementTable); + +// User Profile definition table. +profile_print_profile_table($id, io_safe_output($json_profile), false, ($is_err === true && $new_user === true));