mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
Added button to select ehorus conf type and box into user conf
This commit is contained in:
parent
7da73afd08
commit
ecce1160e1
@ -52,8 +52,9 @@ $table_enable->style['name'] = 'font-weight: bold';
|
|||||||
|
|
||||||
// Enable eHorus.
|
// Enable eHorus.
|
||||||
$row = [];
|
$row = [];
|
||||||
$row['name'] = __('Enable eHorus');
|
$row['name'] = ('Enable eHorus');
|
||||||
$row['control'] = html_print_checkbox_switch('ehorus_enabled', 1, $config['ehorus_enabled'], true);
|
$row['control'] = html_print_checkbox_switch('ehorus_enabled', 1, $config['ehorus_enabled'], true);
|
||||||
|
$row['button'] = html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"', true);
|
||||||
$table_enable->data['ehorus_enabled'] = $row;
|
$table_enable->data['ehorus_enabled'] = $row;
|
||||||
|
|
||||||
// Remote config table.
|
// Remote config table.
|
||||||
@ -66,6 +67,12 @@ $table_remote->class = 'databox filters';
|
|||||||
$table_remote->size['name'] = '30%';
|
$table_remote->size['name'] = '30%';
|
||||||
$table_remote->style['name'] = 'font-weight: bold';
|
$table_remote->style['name'] = 'font-weight: bold';
|
||||||
|
|
||||||
|
|
||||||
|
// Enable eHorus user configuration.
|
||||||
|
$row = [];
|
||||||
|
$row['name'] = ('Enable eHorus user configuration');
|
||||||
|
$row['control'] = html_print_checkbox_switch('ehorus-user-login', 1, $config['ehorus-user-login'], true);
|
||||||
|
$table_remote->data['ehorus-user-login'] = $row;
|
||||||
// User.
|
// User.
|
||||||
$row = [];
|
$row = [];
|
||||||
$row['name'] = __('User');
|
$row['name'] = __('User');
|
||||||
@ -108,7 +115,6 @@ $row['control'] .= '<span id="test-ehorus-success" style="display:none;"> '
|
|||||||
$row['control'] .= '<span id="test-ehorus-failure" style="display:none;"> '.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
|
$row['control'] .= '<span id="test-ehorus-failure" style="display:none;"> '.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
|
||||||
$row['control'] .= ' <span id="test-ehorus-message" style="display:none;"></span>';
|
$row['control'] .= ' <span id="test-ehorus-message" style="display:none;"></span>';
|
||||||
$table_remote->data['ehorus_test'] = $row;
|
$table_remote->data['ehorus_test'] = $row;
|
||||||
|
|
||||||
// Print.
|
// Print.
|
||||||
echo '<div style="text-align: center; padding-bottom: 20px;">';
|
echo '<div style="text-align: center; padding-bottom: 20px;">';
|
||||||
echo '<a target="_blank" rel="noopener noreferrer" href="http://ehorus.com">';
|
echo '<a target="_blank" rel="noopener noreferrer" href="http://ehorus.com">';
|
||||||
@ -162,8 +168,6 @@ if ($config['ehorus_enabled']) {
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$('input:checkbox[name="ehorus_enabled"]').attr('checked', false);
|
|
||||||
$('form#form_remote').hide();
|
|
||||||
$('form#form_enable').css('margin-bottom','20px');
|
$('form#form_enable').css('margin-bottom','20px');
|
||||||
var showFields = function () {
|
var showFields = function () {
|
||||||
$('form#form_remote').show();
|
$('form#form_remote').show();
|
||||||
@ -175,13 +179,14 @@ if ($config['ehorus_enabled']) {
|
|||||||
var is_checked = $('input:checkbox[name="ehorus_enabled"]').is(':checked');
|
var is_checked = $('input:checkbox[name="ehorus_enabled"]').is(':checked');
|
||||||
if (event.target.value == '1' && is_checked) {
|
if (event.target.value == '1' && is_checked) {
|
||||||
showFields();
|
showFields();
|
||||||
$('input:checkbox[name="ehorus_enabled"]').attr('checked', false);
|
$('input:checkbox[name="ehorus_enabled"]').attr('checked', true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hideFields();
|
hideFields();
|
||||||
$('input:checkbox[name="ehorus_enabled"]').attr('checked', true);
|
$('input:checkbox[name="ehorus_enabled"]').attr('checked', false);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
$('input:checkbox[name="ehorus_enabled"]').change(handleEnable);
|
$('input:checkbox[name="ehorus_enabled"]').change(handleEnable);
|
||||||
|
|
||||||
var handleTest = function (event) {
|
var handleTest = function (event) {
|
||||||
|
@ -1349,10 +1349,14 @@ function config_update_config()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ehorus':
|
case 'ehorus':
|
||||||
if (!config_update_value('ehorus_enabled', (int) get_parameter('ehorus_enabled', $config['ehorus_enabled']))) {
|
if (!config_update_value('ehorus_enabled', (int) get_parameter('ehorus_enabled', 0))) {
|
||||||
$error_update[] = __('Enable eHorus');
|
$error_update[] = __('Enable eHorus');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!config_update_value('ehorus-user-login', (int) get_parameter('ehorus-user-login', 0))) {
|
||||||
|
$error_update[] = __('eHorus user login');
|
||||||
|
}
|
||||||
|
|
||||||
if (!config_update_value('ehorus_user', (string) get_parameter('ehorus_user', $config['ehorus_user']))) {
|
if (!config_update_value('ehorus_user', (string) get_parameter('ehorus_user', $config['ehorus_user']))) {
|
||||||
$error_update[] = __('eHorus user');
|
$error_update[] = __('eHorus user');
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ if (isset($_GET['modified']) && !$view_mode) {
|
|||||||
$dashboard = get_parameter('dashboard', '');
|
$dashboard = get_parameter('dashboard', '');
|
||||||
$visual_console = get_parameter('visual_console', '');
|
$visual_console = get_parameter('visual_console', '');
|
||||||
|
|
||||||
|
|
||||||
// Save autorefresh list.
|
// Save autorefresh list.
|
||||||
$autorefresh_list = get_parameter_post('autorefresh_list');
|
$autorefresh_list = get_parameter_post('autorefresh_list');
|
||||||
if (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) {
|
if (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) {
|
||||||
@ -597,6 +598,8 @@ echo '<form name="user_mod" method="post" action="'.ui_get_full_url().'&modi
|
|||||||
<div class="edit_user_options">'.$language.$size_pagination.$skin.$home_screen.$event_filter.$newsletter.$newsletter_reminder.$double_authentication.'</div>
|
<div class="edit_user_options">'.$language.$size_pagination.$skin.$home_screen.$event_filter.$newsletter.$newsletter_reminder.$double_authentication.'</div>
|
||||||
<div class="edit_user_timezone">'.$timezone;
|
<div class="edit_user_timezone">'.$timezone;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!is_metaconsole()) {
|
if (!is_metaconsole()) {
|
||||||
echo '<div id="timezone-picker">
|
echo '<div id="timezone-picker">
|
||||||
<img id="timezone-image" src="'.$local_file.'" width="'.$map_width.'" height="'.$map_height.'" usemap="#timezone-map" />
|
<img id="timezone-image" src="'.$local_file.'" width="'.$map_width.'" height="'.$map_height.'" usemap="#timezone-map" />
|
||||||
@ -611,6 +614,11 @@ if (!is_metaconsole()) {
|
|||||||
<div class="edit_user_comments">'.$comments.'</div>
|
<div class="edit_user_comments">'.$comments.'</div>
|
||||||
</div>
|
</div>
|
||||||
</div>';
|
</div>';
|
||||||
|
if ($config['ehorus_enabled'] && $config['ehorus-user-login']) {
|
||||||
|
ehorus_user_login_conf();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo '<div class="edit_user_button">';
|
echo '<div class="edit_user_button">';
|
||||||
if (!$config['user_can_update_info']) {
|
if (!$config['user_can_update_info']) {
|
||||||
@ -622,8 +630,6 @@ if (!$config['user_can_update_info']) {
|
|||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
echo '</form>';
|
|
||||||
|
|
||||||
echo '<div id="edit_user_profiles" class="white_box">';
|
echo '<div id="edit_user_profiles" class="white_box">';
|
||||||
if (!defined('METACONSOLE')) {
|
if (!defined('METACONSOLE')) {
|
||||||
echo '<p class="edit_user_labels">'.__('Profiles/Groups assigned to this user').'</p>';
|
echo '<p class="edit_user_labels">'.__('Profiles/Groups assigned to this user').'</p>';
|
||||||
@ -727,7 +733,56 @@ if (!defined('METACONSOLE')) {
|
|||||||
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.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";
|
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.
|
// Closes no meta condition.
|
||||||
|
}function ehorus_user_login_conf()
|
||||||
|
{
|
||||||
|
// eHorus user login
|
||||||
|
$table_remote = new StdClass();
|
||||||
|
$table_remote->data = [];
|
||||||
|
$table_remote->width = '100%';
|
||||||
|
$table_remote->styleTable = 'margin-bottom: 10px;';
|
||||||
|
$table_remote->id = 'ehorus-user-login';
|
||||||
|
$table_remote->class = 'ehorus-user-login white_box';
|
||||||
|
$table_remote->size['name'] = '30%';
|
||||||
|
$table_remote->style['name'] = 'font-weight: bold';
|
||||||
|
|
||||||
|
// User.
|
||||||
|
$row = [];
|
||||||
|
$row['name'] = __('User');
|
||||||
|
$row['control'] = html_print_input_text('ehorus_user', $config['ehorus_user'], '', 30, 100, true);
|
||||||
|
$table_remote->data['ehorus_user'] = $row;
|
||||||
|
|
||||||
|
// Pass.
|
||||||
|
$row = [];
|
||||||
|
$row['name'] = __('Password');
|
||||||
|
$row['control'] = html_print_input_password('ehorus_pass', io_output_password($config['ehorus_pass']), '', 30, 100, true);
|
||||||
|
$table_remote->data['ehorus_pass'] = $row;
|
||||||
|
|
||||||
|
// Test.
|
||||||
|
$ehorus_port = db_get_value('value', 'tconfig', 'token', 'ehorus_port');
|
||||||
|
$ehorus_host = db_get_value('value', 'tconfig', 'token', 'ehorus_hostname');
|
||||||
|
|
||||||
|
$row = [];
|
||||||
|
$row['name'] = __('Test');
|
||||||
|
$row['control'] = html_print_button(__('Start'), 'test-ehorus', false, 'ehorus_connection_test('.$ehorus_host.','.$ehorus_port.')', 'class="sub next"', true);
|
||||||
|
$row['control'] .= '<span id="test-ehorus-spinner" style="display:none;"> '.html_print_image('images/spinner.gif', true).'</span>';
|
||||||
|
$row['control'] .= '<span id="test-ehorus-success" style="display:none;"> '.html_print_image('images/status_sets/default/severity_normal.png', true).'</span>';
|
||||||
|
$row['control'] .= '<span id="test-ehorus-failure" style="display:none;"> '.html_print_image('images/status_sets/default/severity_critical.png', true).'</span>';
|
||||||
|
$row['control'] .= ' <span id="test-ehorus-message" style="display:none;"></span>';
|
||||||
|
$table_remote->data['ehorus_test'] = $row;
|
||||||
|
|
||||||
|
echo ' <div class="ehorus-userlogin white_box">
|
||||||
|
|
||||||
|
<p class="edit_user_labels">'._('eHorus login').ui_print_help_tip(
|
||||||
|
__('This will activate autorefresh in selected pages'),
|
||||||
|
true
|
||||||
|
).'</p>';
|
||||||
|
html_print_input_hidden('update_config', 1);
|
||||||
|
html_print_table($table_remote);
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<script language="javascript" type="text/javascript">
|
<script language="javascript" type="text/javascript">
|
||||||
@ -1052,4 +1107,85 @@ function show_double_auth_deactivation () {
|
|||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ehorus_connection_test (host, port) {
|
||||||
|
var user = $('input#text-ehorus_user').val();
|
||||||
|
var pass = $('input#password-ehorus_pass').val();
|
||||||
|
|
||||||
|
|
||||||
|
var badRequestMessage = '<?php echo __('Empty user or password'); ?>';
|
||||||
|
var notFoundMessage = '<?php echo __('User not found'); ?>';
|
||||||
|
var invalidPassMessage = '<?php echo __('Invalid password'); ?>';
|
||||||
|
|
||||||
|
var hideLoadingImage = function () {
|
||||||
|
$('span#test-ehorus-spinner').hide();
|
||||||
|
}
|
||||||
|
var showLoadingImage = function () {
|
||||||
|
$('span#test-ehorus-spinner').show();
|
||||||
|
}
|
||||||
|
var hideSuccessImage = function () {
|
||||||
|
$('span#test-ehorus-success').hide();
|
||||||
|
}
|
||||||
|
var showSuccessImage = function () {
|
||||||
|
$('span#test-ehorus-success').show();
|
||||||
|
}
|
||||||
|
var hideFailureImage = function () {
|
||||||
|
$('span#test-ehorus-failure').hide();
|
||||||
|
}
|
||||||
|
var showFailureImage = function () {
|
||||||
|
$('span#test-ehorus-failure').show();
|
||||||
|
}
|
||||||
|
var hideMessage = function () {
|
||||||
|
$('span#test-ehorus-message').hide();
|
||||||
|
}
|
||||||
|
var showMessage = function () {
|
||||||
|
$('span#test-ehorus-message').show();
|
||||||
|
}
|
||||||
|
var changeTestMessage = function (message) {
|
||||||
|
$('span#test-ehorus-message').text(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
hideSuccessImage();
|
||||||
|
hideFailureImage();
|
||||||
|
hideMessage();
|
||||||
|
showLoadingImage();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: 'https://' + host + ':' + port + '/login',
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
timeout: timeout ? timeout * 1000 : 0,
|
||||||
|
data: {
|
||||||
|
user: user,
|
||||||
|
pass: pass
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.done(function(data, textStatus, xhr) {
|
||||||
|
showSuccessImage();
|
||||||
|
})
|
||||||
|
.fail(function(xhr, textStatus, errorThrown) {
|
||||||
|
showFailureImage();
|
||||||
|
|
||||||
|
if (xhr.status === 400) {
|
||||||
|
changeTestMessage(badRequestMessage);
|
||||||
|
}
|
||||||
|
else if (xhr.status === 401 || xhr.status === 403) {
|
||||||
|
changeTestMessage(invalidPassMessage);
|
||||||
|
}
|
||||||
|
else if (xhr.status === 404) {
|
||||||
|
changeTestMessage(notFoundMessage);
|
||||||
|
}
|
||||||
|
else if (errorThrown === 'timeout') {
|
||||||
|
changeTestMessage(timeoutMessage);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
changeTestMessage(errorThrown);
|
||||||
|
}
|
||||||
|
showMessage();
|
||||||
|
})
|
||||||
|
.always(function(xhr, textStatus) {
|
||||||
|
hideLoadingImage();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$('input#button-test-ehorus').click(handleTest);
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user