From 16454c30a1827607b07e4208a31d6bc5d18c4ff8 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Mon, 9 May 2016 19:22:10 +0200 Subject: [PATCH] Now the eHorusID custom field is created automatically when the feature is enabled --- .../godmode/setup/setup_ehorus.php | 96 +++++++------------ 1 file changed, 37 insertions(+), 59 deletions(-) diff --git a/pandora_console/godmode/setup/setup_ehorus.php b/pandora_console/godmode/setup/setup_ehorus.php index fbe9c37705..82a177a0e9 100644 --- a/pandora_console/godmode/setup/setup_ehorus.php +++ b/pandora_console/godmode/setup/setup_ehorus.php @@ -27,16 +27,16 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user } // Check custom field -$custom_field_exists = false; -if (!empty($config['ehorus_custom_field'])) { - $custom_field = db_get_value('name', 'tagent_custom_fields', 'name', $config['ehorus_custom_field']); - $custom_field_exists = !empty($custom_field); -} -$create_custom_field = (bool) get_parameter('create_custom_field'); -if ($create_custom_field) { - $result = (bool) db_process_sql_insert('tagent_custom_fields', array('name' => $config['ehorus_custom_field'])); - ui_print_result_message($result, __('Custom field for eHorus ID created'), __('Error creating custom field')); - $custom_field_exists = $result; +$custom_field = db_get_value('name', 'tagent_custom_fields', 'name', $config['ehorus_custom_field']); +$custom_field_exists = !empty($custom_field); +$custom_field_created = null; +if ($config['ehorus_enabled'] && !$custom_field_exists) { + $values = array( + 'name' => $config['ehorus_custom_field'], + 'display_on_front' => 1 + ); + $result = (bool) db_process_sql_insert('tagent_custom_fields', $values); + $custom_field_exists = $custom_field_created = $result; } /* Enable table */ @@ -57,26 +57,6 @@ $row['control'] .= __('No').' '.html_print_radio_button ('ehorus_enabled', $row['button'] = html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"', true); $table_enable->data['ehorus_enabled'] = $row; -/* Agents config table */ - -$table_agents = new StdClass(); -$table_agents->data = array(); -$table_agents->width = '100%'; -$table_agents->styleTable = 'margin-bottom: 10px;'; -$table_agents->id = 'ehorus-agents-setup'; -$table_agents->class = 'databox filters'; -$table_agents->size['name'] = '30%'; -$table_agents->style['name'] = 'font-weight: bold'; - -// Custom Fields -$row = array(); -$row['name'] = __('Custom field name'); -$row['control'] = html_print_input_text('ehorus_custom_field', $config['ehorus_custom_field'], '', 30, 100, true); -$row['button'] = html_print_submit_button(__('Use'), 'use_custom_field', false, 'class="sub upd"', true); -$row['button'] .= ' ' . html_print_submit_button(__('Create and use'), 'create_custom_field', false, 'class="sub upd"', true); -$row['button'] .= ui_print_help_tip(__('The previous item will not be deleted or modified by performing this operations'), true); -$table_agents->data['ehorus_custom_field'] = $row; - /* Remote config table */ $table_remote = new StdClass(); @@ -133,40 +113,40 @@ $table_remote->data['ehorus_test'] = $row; /* Print */ -// Form enable -echo '
'; -if (!$config['ehorus_enabled']) { - $info_page = "http://ehorus.com/"; - $link = 'this'; - $info_messsage = __('eHorus is a web based remote management system which allows you to easily connect to machines that have internet connection'); - $info_messsage .= '. ' . __('Forget about firewalls and proxies'); - $info_messsage .= '. ' . sprintf(__('Check %s for more info'), $link) . '.'; - ui_print_info_message($info_messsage); -} -html_print_input_hidden('update_config', 1); -html_print_table($table_enable); -echo '
'; +echo '
'; +echo ''; +html_print_image('include/ehorus/images/ehorus-logo-grey.png'); +echo ''; +echo '
'; +echo '
'; +echo __('Remote Management System'); +echo '
'; +echo ''; +echo 'http://ehorus.com'; +echo ''; +echo '
'; -// Form agents -if ($config['ehorus_enabled']) { - echo '
'; +if ($custom_field_created !== null) { + ui_print_result_message($custom_field_created, __('Custom field eHorusID created'), __('Error creating custom field')); +} +if ($custom_field_created) { $info_messsage = __('eHorus has his own agent identifiers'); $info_messsage .= '. ' . __('To store them, it will be necessary to use an agent custom field'); $info_messsage .= '.
' . __('Possibly the eHorus id will have to be filled in by hand for every agent') . '.'; ui_print_info_message($info_messsage); - - if (!$custom_field_exists) { - $error_message = __('The custom field does not exists already'); - ui_print_error_message($error_message); - } - echo "
"; - echo "" . __('Pandora agents') . ""; - html_print_input_hidden('update_config', 1); - html_print_table($table_agents); - echo "
"; - echo '
'; } +if ($config['ehorus_enabled'] && !$custom_field_exists) { + $error_message = __('The custom field does not exists already'); + ui_print_error_message($error_message); +} + +// Form enable +echo '
'; +html_print_input_hidden('update_config', 1); +html_print_table($table_enable); +echo '
'; + // Form remote if ($config['ehorus_enabled']) { echo '
'; @@ -185,11 +165,9 @@ if ($config['ehorus_enabled']) {