diff --git a/pandora_console/general/login_identification_wizard.php b/pandora_console/general/login_identification_wizard.php
deleted file mode 100644
index 7bdb370b54..0000000000
--- a/pandora_console/general/login_identification_wizard.php
+++ /dev/null
@@ -1,455 +0,0 @@
- true,
- 'message' => '',
- ];
-
- if ($register_pandora) {
- // Pandora register update
- $um_message = update_manager_register_instance();
- $ui_feedback['message'] .= $um_message['message'].'
';
- if ($um_message['success']) {
- config_update_value('instance_registered', 1);
- $ui_feedback['status'] = true && $ui_feedback['status'];
- } else {
- $ui_feedback['status'] = false;
- }
- } else if (!$forced) {
- config_update_value('identification_reminder_timestamp', $future_8_days);
- }
-
- if ($newsletter) {
- // Pandora newsletter update
- $email = get_parameter('email', '');
- $um_message = update_manager_insert_newsletter($email);
- $ui_feedback['message'] .= $um_message['message'];
- if ($um_message['success']) {
- db_process_sql_update('tusuario', ['middlename' => 1], ['id_user' => $config['id_user']]);
- $ui_feedback['status'] = true && $ui_feedback['status'];
- } else {
- $ui_feedback['status'] = false;
- }
- } else if (!$forced) {
- db_process_sql_update('tusuario', ['lastname' => $future_8_days], ['id_user' => $config['id_user']]);
- }
-
- // Form answer JSON
- $ui_feedback['status'] = $ui_feedback['status'] ? 1 : 0;
- echo io_json_mb_encode($ui_feedback);
- }
-
- if (!$not_return) {
- return;
- }
-}
-
-// Check if user is admin
-if (!license_free()) {
- return;
-}
-
-if (!users_is_admin($config['id_user'])) {
- return;
-}
-
-// Get data to display properly the wizard
-$wizard_data = [];
-
-$wizard_data['newsletter_subscribed'] = db_get_value('middlename', 'tusuario', 'id_user', $config['id_user']);
-// force_* = 1 -> force show
-// force_* = 0 -> force hide
-// force_* = -1 -> show or hide depends reminder and timestamp
-$wizard_data['force_newsletter'] = get_parameter('force_newsletter', -1);
-$wizard_data['newsletter_reminder'] = db_get_value('firstname', 'tusuario', 'id_user', $config['id_user']);
-$wizard_data['newsletter_reminder_timestamp'] = db_get_value('lastname', 'tusuario', 'id_user', $config['id_user']);
-
-
-$wizard_data['instance_registered'] = $config['instance_registered'];
-$wizard_data['force_register'] = get_parameter('force_register', -1);
-$wizard_data['identification_reminder'] = $config['identification_reminder'];
-$wizard_data['identification_reminder_timestamp'] = $config['identification_reminder_timestamp'];
-
-$display_newsletter = display_newsletter($wizard_data);
-$display_register = display_register($wizard_data);
-$display_forced = ($wizard_data['force_newsletter'] != -1) || ($wizard_data['force_register'] != -1);
-
-// Return if it is fully completed
-if ((!$display_register) && (!$display_newsletter)) {
- return false;
-}
-
-$return_button = get_parameter('return_button', 0) == 1;
-
-$email = db_get_value('email', 'tusuario', 'id_user', $config['id_user']);
-// Avoid to show default email
-if ($email == 'admin@example.com') {
- $email = '';
-}
-
-// Prints accept register license
-echo '
';
- echo '
';
- echo html_print_image('images/pandora_circle_big.png', true);
- echo '
';
- echo '
';
- echo __('Stay up to date with the %s community', get_product_name()).'.';
- echo '
';
-
- echo '
';
- echo '
'.__('When you subscribe to the %s Update Manager service, you accept that we register your %s instance as an identifier on the database owned by Artica TS. This data will solely be used to provide you with information about %s and will not be conceded to third parties. You can unregister from said database at any time from the Update Manager options.', get_product_name(), get_product_name(), get_product_name()).'
';
- echo '
'.__('In the same fashion, when subscribed to the newsletter you accept that your email will pass on to a database property of Artica TS. This data will solely be used to provide you with information about %s and will not be conceded to third parties. You can unregister from said database at any time from the newsletter subscription options.', get_product_name()).'
';
- echo '
';
-
- echo '
';
- echo '
';
- html_print_submit_button(__('Finish'), 'finish_dialog_button', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok" style="width:100px;"');
- echo '
';
- $display_status_return = $return_button ? 'block' : 'none';
- echo '
';
- html_print_submit_button(__('Return'), 'return_dialog_button', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd" style="width:100px;"');
- echo '
';
- echo '
';
- html_print_checkbox('register', 1, false, false, false, 'cursor: \'pointer\'');
- echo '
'.__('Join the %s community!', get_product_name()).'!';
- html_print_checkbox('newsletter', 1, false, false, false, 'cursor: \'pointer\'');
- echo '
'.__('Subscribe to our newsletter').'';
- echo '
';
- echo '
';
- echo ' '.__('Email').': ';
- html_print_input_text_extended('email-newsletter', $email, 'text-email-newsletter', '', 30, 255, false, '', ['style' => 'display:none; width: 200px;']);
-echo ' '.__('Email').': ';
- echo ' *'.__('Required').' ';
- echo '
';
- echo '
';
- echo '
';
-echo '
';
-
-// Print yes or not dialog
-echo '';
- echo '
';
- echo __('Do you want to continue without any registration').'?';
- echo '
';
- echo '
';
- html_print_submit_button(__('No'), 'no_registration', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub cancel" style="width:100px;"');
- echo '
';
- echo '
';
- html_print_submit_button(__('Yes'), 'yes_registration', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd" style="width:100px;"');
- echo '
';
-echo '
';
-
-// Print feedback user dialog
-echo '';
- echo '
';
- echo html_print_image('images/success_circle_big.png', true);
- echo '
';
- echo '
';
-echo '
';
-?>
-
-
-
-
-
diff --git a/pandora_console/general/login_required.php b/pandora_console/general/login_required.php
deleted file mode 100644
index 726d6ab5d1..0000000000
--- a/pandora_console/general/login_required.php
+++ /dev/null
@@ -1,273 +0,0 @@
- $email],
- ['id_user' => $config['id_user']]
- );
- }
-
- // Update the alert action Mail to XXX/Administrator if it is set to default
- $mail_check = 'yourmail@domain.es';
- $mail_alert = alerts_get_alert_action_field1(1);
- if ($mail_check === $mail_alert && $email !== false) {
- alerts_update_alert_action(
- 1,
- [
- 'field1' => $email,
- 'field1_recovery' => $email,
- ]
- );
- }
-
- config_update_value('initial_wizard', 1);
- }
-
- // Change the language if is change in checkbox
- if ($change_language !== 0) {
- config_update_value('language', $change_language);
- }
-
- if ($cancel_wizard !== 0) {
- config_update_value('initial_wizard', 1);
- }
-
- return;
-}
-
-$email = db_get_value('email', 'tusuario', 'id_user', $config['id_user']);
-// Avoid to show default email
-if ($email == 'admin@example.com') {
- $email = '';
-}
-
-// Prints first step pandora registration
-echo '';
-
- echo '
';
- echo __('Please fill the following information in order to configure your %s instance successfully', get_product_name()).'.';
- echo '
';
-
- echo '
';
- $table = new StdClass();
- $table->class = 'databox filters';
- $table->width = '100%';
- $table->data = [];
- $table->size = [];
- $table->size[0] = '40%';
- $table->style[0] = 'font-weight:bold';
- $table->size[1] = '60%';
- $table->border = '5px solid';
-
- $table->data[0][0] = __('Language code');
- $table->data[0][1] = html_print_select_from_sql(
- 'SELECT id_language, name FROM tlanguage',
- 'language',
- $config['language'],
- '',
- '',
- '',
- true
- );
-
- $zone_name = [
- 'Africa' => __('Africa'),
- 'America' => __('America'),
- 'Antarctica' => __('Antarctica'),
- 'Arctic' => __('Arctic'),
- 'Asia' => __('Asia'),
- 'Atlantic' => __('Atlantic'),
- 'Australia' => __('Australia'),
- 'Europe' => __('Europe'),
- 'Indian' => __('Indian'),
- 'Pacific' => __('Pacific'),
- 'UTC' => __('UTC'),
- ];
-
- if ($zone_selected == '') {
- if ($config['timezone'] != '') {
- $zone_array = explode('/', $config['timezone']);
- $zone_selected = $zone_array[0];
- } else {
- $zone_selected = 'Europe';
- }
- }
-
- $timezones = timezone_identifiers_list();
- foreach ($timezones as $timezone) {
- if (strpos($timezone, $zone_selected) !== false) {
- $timezone_country = preg_replace('/^.*\//', '', $timezone);
- $timezone_n[$timezone] = $timezone_country;
- }
- }
-
- $table->data[2][0] = __('Timezone setup').' '.ui_print_help_tip(
- __('Must have the same time zone as the system or database to avoid mismatches of time.'),
- true
- );
- $table->data[2][1] = html_print_select($zone_name, 'zone', $zone_selected, 'show_timezone()', '', '', true);
- $table->data[2][1] .= ' '.html_print_select($timezone_n, 'timezone', $config['timezone'], '', '', '', true);
-
- $table->data[4][0] = __('E-mail for receiving alerts');
- $table->data[4][1] = html_print_input_text('email', $email, '', 50, 255, true);
-
- html_print_table($table);
- echo '
';
-
- echo '
';
- echo '
';
- html_print_submit_button(__('Register'), 'id_dialog_button', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok" style="width:100px;"');
- echo '
';
- echo '
';
- html_print_button(__('Cancel'), 'cancel', false, '', 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok" style="width:100px;"');
- echo '
';
- echo '
';
- echo __('All fields required');
- echo '
';
- echo '
';
-
- echo '
';
-
- ?>
-
-
diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php
new file mode 100644
index 0000000000..106648704e
--- /dev/null
+++ b/pandora_console/general/register.php
@@ -0,0 +1,154 @@
+ 0],
+ ['id_user' => $config['id_user']]
+ );
+
+ // XXX: Also notify UpdateManager.
+ }
+
+ if ($register_newsletter) {
+ $feedback = newsletter_wiz_process();
+ }
+
+ if (is_array($feedback)) {
+ echo json_encode($feedback);
+ }
+
+
+ // Ajax calls finish here.
+ exit();
+}
+
+
+ui_require_css_file('register');
+
+$initial = isset($config['initial_wizard']) !== true
+ || $config['initial_wizard'] != '1';
+
+$newsletter = !db_get_value(
+ 'middlename',
+ 'tusuario',
+ 'id_user',
+ $config['id_user']
+);
+
+$registration = isset($config['pandora_uid']) !== true
+ || $config['pandora_uid'] == '';
+
+
+if ($initial) {
+ // Show all forms in order.
+ // 1- Ask for email, timezone, etc. Fullfill alerts and user mail.
+ config_wiz_modal(
+ false,
+ true,
+ (($registration === true) ? 'show_registration_wizard()' : null)
+ );
+}
+
+
+if ($registration) {
+ // Prepare registration wizard, not launch. leave control to flow.
+ registration_wiz_modal(
+ false,
+ // Launch only if not being launch from 'initial'.
+ !$initial,
+ (($newsletter === true) ? 'show_newsletter_wizard()' : null)
+ );
+}
+
+if ($newsletter) {
+ // Show newsletter wizard for current user.
+ newsletter_wiz_modal(
+ false,
+ // Launch only if not being call from 'registration'.
+ !$registration && !$initial
+ );
+}
+
+?>
+
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 5e87868425..3f0d4217ba 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -208,7 +208,8 @@ if (!isset($config['inventory_changes_blacklist'])) {
if (!isset($config['url_update_manager'])) {
config_update_value(
'url_update_manager',
- 'https://licensing.artica.es/pandoraupdate7/server.php'
+ // 'https://licensing.artica.es/pandoraupdate7/server.php'
+ 'https://172.17.0.3/server.php'
);
}
diff --git a/pandora_console/include/functions_update_manager.php b/pandora_console/include/functions_update_manager.php
index 6912aa05ff..7be4de9cf9 100755
--- a/pandora_console/include/functions_update_manager.php
+++ b/pandora_console/include/functions_update_manager.php
@@ -27,6 +27,894 @@
* ============================================================================
*/
+/*
+ *
+ * Registration functions - Start.
+ *
+ */
+
+
+/**
+ * Parses responses from configuration wizard.
+ *
+ * @return void
+ */
+function config_wiz_process()
+{
+ $email = get_parameter('email', false);
+ $timezone = get_parameter('timezone', false);
+ $language = get_parameter('language', false);
+
+ if ($email !== false) {
+ config_update_value('language', $language);
+ }
+
+ if ($timezone !== false) {
+ config_update_value('timezone', $timezone);
+ }
+
+ if ($email !== false) {
+ db_process_sql_update(
+ 'tusuario',
+ ['email' => $email],
+ ['id_user' => $config['id_user']]
+ );
+ }
+
+ // Update the alert action Mail to XXX/Administrator
+ // if it is set to default.
+ $mail_check = 'yourmail@domain.es';
+ $mail_alert = alerts_get_alert_action_field1(1);
+ if ($mail_check === $mail_alert && $email !== false) {
+ alerts_update_alert_action(
+ 1,
+ [
+ 'field1' => $email,
+ 'field1_recovery' => $email,
+ ]
+ );
+ }
+
+ config_update_value('initial_wizard', 1);
+}
+
+
+/**
+ * Generates base code to print main configuration modal.
+ *
+ * Asks for timezone, mail.
+ *
+ * @param boolean $return Print output or not.
+ * @param boolean $launch Process JS modal.
+ * @param string $callback Call to JS function at end.
+ *
+ * @return string HTML.
+ */
+function config_wiz_modal(
+ $return=false,
+ $launch=true,
+ $callback=false
+) {
+ global $config;
+
+ $email = db_get_value('email', 'tusuario', 'id_user', $config['id_user']);
+ // Avoid to show default email.
+ if ($email == 'admin@example.com') {
+ $email = '';
+ }
+
+ $output = '';
+
+ // Prints first step pandora registration.
+ $output .= '';
+
+ $output .= '
';
+ $output .= __('Please fill the following information in order to configure your %s instance successfully', get_product_name()).'.';
+ $output .= '
';
+
+ $output .= '
';
+ $table = new StdClass();
+ $table->class = 'databox filters';
+ $table->width = '100%';
+ $table->data = [];
+ $table->size = [];
+ $table->size[0] = '40%';
+ $table->style[0] = 'font-weight:bold';
+ $table->size[1] = '60%';
+ $table->border = '5px solid';
+
+ $table->data[0][0] = __('Language code');
+ $table->data[0][1] = html_print_select_from_sql(
+ 'SELECT id_language, name FROM tlanguage',
+ 'language',
+ $config['language'],
+ '',
+ '',
+ '',
+ true
+ );
+
+ $zone_name = [
+ 'Africa' => __('Africa'),
+ 'America' => __('America'),
+ 'Antarctica' => __('Antarctica'),
+ 'Arctic' => __('Arctic'),
+ 'Asia' => __('Asia'),
+ 'Atlantic' => __('Atlantic'),
+ 'Australia' => __('Australia'),
+ 'Europe' => __('Europe'),
+ 'Indian' => __('Indian'),
+ 'Pacific' => __('Pacific'),
+ 'UTC' => __('UTC'),
+ ];
+
+ if ($zone_selected == '') {
+ if ($config['timezone'] != '') {
+ $zone_array = explode('/', $config['timezone']);
+ $zone_selected = $zone_array[0];
+ } else {
+ $zone_selected = 'Europe';
+ }
+ }
+
+ $timezones = timezone_identifiers_list();
+ foreach ($timezones as $timezone) {
+ if (strpos($timezone, $zone_selected) !== false) {
+ $timezone_country = preg_replace('/^.*\//', '', $timezone);
+ $timezone_n[$timezone] = $timezone_country;
+ }
+ }
+
+ $table->data[2][0] = __('Timezone setup').' '.ui_print_help_tip(
+ __('Must have the same time zone as the system or database to avoid mismatches of time.'),
+ true
+ );
+ $table->data[2][1] = html_print_select($zone_name, 'zone', $zone_selected, 'show_timezone()', '', '', true);
+ $table->data[2][1] .= ' '.html_print_select($timezone_n, 'timezone', $config['timezone'], '', '', '', true);
+
+ $table->data[4][0] = __('E-mail for receiving alerts');
+ $table->data[4][1] = html_print_input_text('email', $email, '', 50, 255, true);
+
+ $output .= html_print_table($table, true);
+ $output .= '
';
+
+ $output .= '
';
+ $output .= html_print_submit_button(
+ __('Cancel'),
+ 'cancel',
+ false,
+ 'class="ui-widget ui-state-default ui-corner-all ui-button-text-only sub cancel submit-cancel" style="width:100px;"',
+ true
+ );
+ $output .= '
';
+ $output .= '
';
+ $output .= html_print_submit_button(
+ __('Continue'),
+ 'register-next',
+ false,
+ 'class="ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next" style="width:100px;"',
+ true
+ );
+ $output .= '
';
+ $output .= '
';
+ $output .= __('All fields required');
+ $output .= '
';
+ $output .= '
';
+
+ $output .= '';
+
+ // Verification modal.
+ $output .= '';
+ $output .= '
';
+ $output .= __('Are you sure you don\'t want to configure a base email?');
+ $output .= '
';
+ $output .= __('You could change this options later in "alert actions" and setting your account.');
+ $output .= '
';
+ $output .= '
';
+ $output .= '
';
+
+ ob_start();
+ ?>
+
+
+
+ true,
+ 'message' => '',
+ ];
+
+ // Pandora register update.
+ $um_message = update_manager_register_instance();
+ $ui_feedback['message'] .= $um_message['message'].'
';
+ $ui_feedback['status'] = $um_message['success'] && $ui_feedback['status'];
+
+ if ($ui_feedback['status']) {
+ // Store next identification reminder.
+ config_update_value(
+ 'identification_reminder_timestamp',
+ $next_check
+ );
+ }
+
+ return $ui_feedback;
+}
+
+
+/**
+ * Shows a modal to register current console in UpdateManager.
+ *
+ * @param boolean $return Return or show html.
+ * @param boolean $launch Execute wizard.
+ * @param string $callback Call function when done.
+ *
+ * @return string HTML code.
+ */
+function registration_wiz_modal(
+ $return=false,
+ $launch=true,
+ $callback=false
+) {
+ global $config;
+ $output = '';
+
+ $product_name = get_product_name();
+
+ $output .= '';
+ $output .= '
';
+ $output .= html_print_image('images/pandora_circle_big.png', true);
+ $output .= '
';
+
+ $output .= '
';
+ $output .= __(
+ 'Keep this %s console up to date with latest updates.',
+ $product_name
+ );
+ $output .= '
';
+
+ $output .= '
';
+ $output .= '
';
+ $output .= __('When you subscribe to the %s Update Manager service, you accept that we register your %s instance as an identifier on a database owned by %s. This data will solely be used to provide you with information about %s and will not be conceded to third parties. You can unregister from said database at any time from the Update Manager options.', $product_name, $product_name, $product_name, $product_name);
+ $output .= '
';
+ $output .= '
';
+
+ $output .= '
';
+
+ $output .= '
';
+ $output .= '
';
+ $output .= '
';
+
+ // Verification modal.
+ $output .= '';
+ $output .= '
';
+ $output .= __('Are you sure you don\'t want to use update manager?');
+ $output .= '
';
+ $output .= __('You will need to update your system manually, through source code or RPM packages to be up to date with latest updates.');
+ $output .= '
';
+ $output .= '
';
+ $output .= '
';
+
+ // Results modal.
+ $output .= '';
+ $output .= '
';
+ $output .= '
';
+ $output .= '
';
+
+ ob_start();
+ ?>
+
+
+ 1],
+ ['id_user' => $config['id_user']]
+ );
+ $ui_feedback['status'] = $um_message['success'];
+ } else {
+ $ui_feedback['status'] = false;
+ }
+
+ return $ui_feedback;
+}
+
+
+/**
+ * Show a modal allowing the user register into newsletter.
+ *
+ * @param boolean $return Print content o return it.
+ * @param boolean $launch Launch directly on load or not.
+ * @param string $callback Call function when done.
+ *
+ * @return string HTML code.
+ */
+function newsletter_wiz_modal(
+ $return=false,
+ $launch=true,
+ $callback=false
+) {
+ global $config;
+
+ $output = '';
+
+ $product_name = get_product_name();
+ $email = db_get_value(
+ 'email',
+ 'tusuario',
+ 'id_user',
+ $config['id_user']
+ );
+
+ // Avoid to show default email.
+ if ($email == 'admin@example.com') {
+ $email = '';
+ }
+
+ $output .= '';
+ $output .= '
';
+ $output .= html_print_image('images/pandora_circle_big.png', true);
+ $output .= '
';
+
+ $output .= '
';
+ $output .= __(
+ 'Keep this %s up to date with latest updates.',
+ $product_name
+ );
+ $output .= '
';
+
+ $output .= '
';
+ $output .= '
';
+ $output .= __('In the same fashion, when subscribed to the newsletter you accept that your email will pass on to a database property of %s. This data will solely be used to provide you with information about %s and will not be conceded to third parties. You can unregister from said database at any time from the newsletter subscription options.', $product_name, $product_name);
+ $output .= '
';
+
+ $output .= '
';
+ // Show regiter to newsletter state.
+ $show_newsletter = ($display_newsletter !== true) ? 'inline-block' : 'none';
+
+ $output .= '
';
+ $output .= '
';
+ $output .= ''.__('Email').' ';
+ $output .= html_print_input_text_extended(
+ 'email-newsletter',
+ $email,
+ 'text-email-newsletter',
+ '',
+ 30,
+ 255,
+ false,
+ '',
+ ['style' => 'display:'.$show_newsletter.'; width: 200px;'],
+ true
+ );
+ $output .= '
';
+
+ $output .= '
';
+
+ $output .= '
';
+ $output .= '
';
+ $output .= '
';
+ $output .= '
';
+
+ // Verification modal.
+ $output .= '';
+ $output .= '
';
+ $output .= __('Are you sure you don\'t want to subscribe?');
+ $output .= '
';
+ $output .= __('You will miss all news about amazing features and fixes!');
+ $output .= '
';
+ $output .= '
';
+ $output .= '
';
+
+ // Results modal.
+ $output .= '';
+ $output .= '
';
+ $output .= '
';
+ $output .= '
';
+
+ ob_start();
+ ?>
+
+
+