diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php
index b1d58aada4..e7097b994e 100644
--- a/pandora_console/general/register.php
+++ b/pandora_console/general/register.php
@@ -30,6 +30,7 @@
global $config;
require_once $config['homedir'].'/include/functions_update_manager.php';
+require_once $config['homedir'].'/include/class/WelcomeWindow.class.php';
if (is_ajax()) {
@@ -122,6 +123,8 @@ if (is_ajax()) {
exit();
}
+
+
ui_require_css_file('register');
$initial = isset($config['initial_wizard']) !== true
@@ -170,6 +173,16 @@ if (!$config['disabled_newsletter']) {
}
}
+$welcome = !$registration && !$show_newsletter && !$initial;
+try {
+ $welcome_window = new WelcomeWindow($welcome);
+ if ($welcome_window !== null) {
+ $welcome_window->run();
+ }
+} catch (Exception $e) {
+ $welcome = false;
+}
+
$newsletter = null;
?>
diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php
index 664b173748..61d33193d3 100644
--- a/pandora_console/godmode/agentes/configurar_agente.php
+++ b/pandora_console/godmode/agentes/configurar_agente.php
@@ -2278,6 +2278,10 @@ if ($updateGIS) {
// -----------------------------------
// Load page depending on tab selected
// -----------------------------------
+if ($_SESSION['create_module'] && $config['welcome_state'] == 1) {
+ $edit_module = true;
+}
+
switch ($tab) {
case 'main':
include 'agent_manager.php';
diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php
index 874fe3a9d1..9428a362bc 100644
--- a/pandora_console/godmode/agentes/module_manager_editor.php
+++ b/pandora_console/godmode/agentes/module_manager_editor.php
@@ -391,6 +391,9 @@ if ($id_agent_module) {
} else {
if (isset($moduletype) === false) {
$moduletype = (string) get_parameter('moduletype');
+ if ($_SESSION['create_module'] && $config['welcome_state'] == 1) {
+ $moduletype = 'networkserver';
+ }
// Clean up specific network modules fields.
$name = '';
diff --git a/pandora_console/include/ajax/welcome_window.php b/pandora_console/include/ajax/welcome_window.php
new file mode 100644
index 0000000000..fc2e278a6f
--- /dev/null
+++ b/pandora_console/include/ajax/welcome_window.php
@@ -0,0 +1,62 @@
+ajaxMethod($method) === true) {
+ $welcome_actions->{$method}();
+ } else {
+ $welcome_actions->error('Unavailable method.');
+ }
+} else {
+ $welcome_actions->error('Method not found. ['.$method.']');
+}
+
+
+// Stop any execution.
+exit;
diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php
new file mode 100644
index 0000000000..1dcdf61377
--- /dev/null
+++ b/pandora_console/include/class/WelcomeWindow.class.php
@@ -0,0 +1,767 @@
+ $msg]
+ );
+ }
+
+
+ /**
+ * Checks if target method is available to be called using AJAX.
+ *
+ * @param string $method Target method.
+ *
+ * @return boolean True allowed, false not.
+ */
+ public function ajaxMethod($method)
+ {
+ global $config;
+
+ // Check access.
+ check_login();
+
+ return in_array($method, $this->AJAXMethods);
+ }
+
+
+ /**
+ * Constructor.
+ *
+ * @param boolean $must_run Must run or not.
+ * @param string $ajax_controller Controller.
+ *
+ * @return object
+ * @throws Exception On error.
+ */
+ public function __construct(
+ bool $must_run=false,
+ $ajax_controller='include/ajax/welcome_window'
+ ) {
+ $this->ajaxController = $ajax_controller;
+
+ if ($this->initialize($must_run) !== true) {
+ throw new Exception('Must not be shown');
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * Main method.
+ *
+ * @return void
+ */
+ public function run()
+ {
+ ui_require_css_file('new_installation_welcome_window');
+ echo '
';
+
+ ?>
+
+
+ ';
+ }
+
+
+ /**
+ * Method to cancel welcome modal window.
+ *
+ * @return void
+ */
+ public function cancelWelcome()
+ {
+ // Config update value.
+ $this->setStep(WELCOME_FINISHED);
+ }
+
+
+ /**
+ * Return current step.
+ *
+ * @return integer Step.
+ */
+ public function getStep(): int
+ {
+ global $config;
+ $this->step = $config['welcome_state'];
+
+ return $this->step;
+ }
+
+
+ /**
+ * Sets current step.
+ *
+ * @param integer $step Current step.
+ *
+ * @return void
+ */
+ public function setStep(int $step)
+ {
+ $this->step = $step;
+ config_update_value('welcome_state', $step);
+
+ }
+
+
+ /**
+ * Retrieve current welcome agent id.
+ *
+ * @return integer Agent id (created).
+ */
+ public function getWelcomeAgent()
+ {
+ global $config;
+
+ return $config['welcome_id_agent'];
+ }
+
+
+ /**
+ * Saves current welcome agent (latest created).
+ *
+ * @param integer $id_agent Agent id.
+ *
+ * @return void
+ */
+ public function setWelcomeAgent(int $id_agent)
+ {
+ config_update_value('welcome_id_agent', $id_agent);
+ }
+
+
+ /**
+ * Loads a welcome window form
+ *
+ * @return string HTML code for form.
+ *
+ * @return void Runs loadWelcomeWindow (AJAX).
+ */
+ public function loadWelcomeWindow()
+ {
+ global $config;
+ $btn_configure_mail_class = '';
+ $btn_create_agent_class = '';
+ $btn_create_module_class = '';
+ $btn_create_alert_class = '';
+ $btn_create_discovery_class = '';
+
+ switch ($this->step) {
+ case W_CREATE_AGENT:
+ $btn_configure_mail_class = ' completed';
+ $btn_create_agent_class = ' pending';
+ break;
+
+ case W_CREATE_MODULE:
+ $btn_configure_mail_class = ' completed';
+ $btn_create_agent_class = ' completed';
+ $btn_create_module_class = ' pending';
+ break;
+
+ case W_CREATE_ALERT:
+ $btn_configure_mail_class = ' completed';
+ $btn_create_agent_class = ' completed';
+ $btn_create_module_class = ' completed';
+ $btn_create_alert_class = ' pending';
+ break;
+
+ case W_CREATE_TASK:
+ $btn_configure_mail_class = ' completed';
+ $btn_create_agent_class = ' completed';
+ $btn_create_module_class = ' completed';
+ $btn_create_alert_class = ' completed';
+ $btn_create_discovery_class = ' pending';
+ break;
+
+ case WELCOME_FINISHED:
+ // Nothing left to do.
+ $btn_configure_mail_class = ' completed';
+ $btn_create_agent_class = ' completed';
+ $btn_create_module_class = ' completed';
+ $btn_create_alert_class = ' completed';
+ $btn_create_discovery_class = ' completed';
+ break;
+
+ default:
+ case W_CONFIGURE_MAIL:
+ // Nothing done yet.
+ $btn_configure_mail_class = ' pending';
+ break;
+ }
+
+ $form = [
+ 'action' => '#',
+ 'id' => 'welcome_form',
+ 'onsubmit' => 'this.dialog("close");',
+ 'class' => 'modal',
+ ];
+
+ $inputs = [
+ [
+ 'wrapper' => 'div',
+ 'block_id' => 'div_configure_mail',
+ 'class' => 'flex-row w100p',
+ 'direct' => 1,
+ 'block_content' => [
+ [
+ 'label' => __('Please ensure mail configuration matches your needs'),
+ 'arguments' => [
+ 'class' => 'first_lbl',
+ 'name' => 'lbl_create_agent',
+ 'id' => 'lbl_create_agent',
+ ],
+ ],
+ [
+ 'arguments' => [
+ 'label' => '',
+ 'type' => 'button',
+ 'attributes' => 'class="go '.$btn_configure_mail_class.'"',
+ 'name' => 'btn_email_conf',
+ 'id' => 'btn_email_conf',
+ ],
+ ],
+ ],
+ ],[
+ 'wrapper' => 'div',
+ 'block_id' => 'div_create_agent',
+ 'class' => 'flex-row w100p',
+ 'direct' => 1,
+ 'block_content' => [
+ [
+ 'label' => __('Create an agent'),
+ 'arguments' => [
+ 'class' => 'first_lbl',
+ 'name' => 'lbl_create_agent',
+ 'id' => 'lbl_create_agent',
+ ],
+ ],
+ [
+ 'arguments' => [
+ 'label' => '',
+ 'type' => 'button',
+ 'attributes' => 'class="go '.$btn_create_agent_class.'"',
+ 'name' => 'btn_create_agent',
+ 'id' => 'btn_create_agent',
+ ],
+ ],
+ ],
+ ],
+ [
+ 'label' => 'Learn to monitor',
+ 'arguments' => [
+ 'class' => 'class="lbl_learn"',
+ 'name' => 'lbl_learn',
+ 'id' => 'lbl_learn',
+ ],
+ ],
+ [
+ 'wrapper' => 'div',
+ 'block_id' => 'div_monitor_actions',
+ 'class' => 'learn_content_indented flex-row w100p',
+ 'direct' => 1,
+ 'block_content' => [
+ [
+ 'label' => __('Create a module to check if an agent is online'),
+ 'arguments' => [
+ 'class' => 'second_lbl',
+ 'name' => 'lbl_check_agent',
+ 'id' => 'lbl_check_agent',
+ ],
+ ],
+ [
+ 'arguments' => [
+ 'label' => '',
+ 'type' => 'button',
+ 'attributes' => 'class="go '.$btn_create_module_class.'"',
+ 'name' => 'btn_create_module',
+ 'id' => 'btn_create_module',
+ ],
+ ],
+ ],
+ ],
+ [
+ 'wrapper' => 'div',
+ 'block_id' => 'div_monitor_actions',
+ 'class' => 'learn_content_indented flex-row w100p',
+ 'direct' => 1,
+ 'block_content' => [
+ [
+ 'label' => __('Be warned if something is wrong, create an alert on the module'),
+ 'arguments' => [
+ 'class' => 'second_lbl',
+ 'name' => 'lbl_create_alert',
+ 'id' => 'lbl_create_alert',
+ ],
+ ],
+ [
+ 'arguments' => [
+ 'label' => '',
+ 'type' => 'button',
+ 'attributes' => 'class="go '.$btn_create_alert_class.'"',
+ 'name' => 'btn_create_alert',
+ 'id' => 'btn_create_alert',
+ ],
+ ],
+ ],
+ ],
+ [
+ 'wrapper' => 'div',
+ 'block_id' => 'div_discover',
+ 'class' => 'flex-row w100p',
+ 'direct' => 1,
+ 'block_content' => [
+ [
+ 'label' => __('Discover hosts and devices in your network'),
+ 'arguments' => [
+ 'class' => 'first_lbl',
+ 'name' => 'lbl_discover_devices',
+ 'id' => 'lbl_discover_devices',
+ ],
+ ],
+ [
+ 'arguments' => [
+ 'label' => '',
+ 'type' => 'button',
+ 'attributes' => 'class="go '.$btn_create_discovery_class.'"',
+ 'name' => 'btn_discover_devices',
+ 'id' => 'btn_discover_devices',
+ ],
+ ],
+ ],
+ ],
+ [
+ 'wrapper' => 'div',
+ 'block_id' => 'div_not_working',
+ 'class' => 'flex-row w100p',
+ 'direct' => 1,
+ 'block_content' => [
+ [
+ 'label' => __('If something is not working as expected, look for this icon and report!'),
+ 'arguments' => [
+ 'class' => 'first_lbl',
+ 'name' => 'lbl_not_working',
+ 'id' => 'lbl_not_working',
+ ],
+ ],
+ [
+ 'label' => html_print_image('images/feedback-header.png', true),
+
+ ],
+ ],
+ ],
+ ];
+
+ $output = $this->printForm(
+ [
+ 'form' => $form,
+ 'inputs' => $inputs,
+ ],
+ true
+ );
+
+ $output .= $this->loadJS();
+ echo $output;
+
+ // Ajax methods does not continue.
+ exit();
+ }
+
+
+ /**
+ * This function acts as a constructor. Receive the condition to check with
+ * the global config (welcome_state) if continues
+ *
+ * @param boolean $must_run Must be run or not (check register.php).
+ *
+ * @return boolean True if initialized or false if must not run.
+ */
+ public function initialize($must_run)
+ {
+ global $config;
+
+ if ($must_run === false
+ || (isset($config['welcome_state']) === true
+ && $config['welcome_state'] === WELCOME_FINISHED)
+ ) {
+ // Do not start unless not finished.
+ return false;
+ }
+
+ $sec2 = get_parameter('sec2', '');
+ $this->step = $this->getStep();
+ $this->agent = $this->getWelcomeAgent();
+
+ if ($sec2 === '') {
+ // Unless finished.
+ if ($this->step !== WELCOME_FINISHED) {
+ return true;
+ }
+ }
+
+ /*
+ * Configure mail. Control current flow.
+ *
+ * On empty sec2: show current step.
+ * On setup page: do not show.
+ * After mail configuration: enable agent step.
+ */
+
+ if ($this->step == W_CONFIGURE_MAIL) {
+ if ($sec2 === 'godmode/setup/setup'
+ && get_parameter('section', '') == 'general'
+ && get_parameter('update_config', false) !== false
+ ) {
+ // Mail configuration have been processed.
+ $_SESSION['configured_mail'] = true;
+ $this->setStep(W_CREATE_AGENT);
+ } else if ($sec2 === 'godmode/setup/setup'
+ && get_parameter('section', '') === 'general'
+ ) {
+ // Mail configuration is being processed.
+ return false;
+ } else {
+ // Any other page, show welcome.
+ return true;
+ }
+ }
+
+ /*
+ * Create agent. Control current flow.
+ *
+ * On empty sec2: show current step.
+ * On agent creation page: do not show.
+ * After agent creation: enable module step.
+ */
+
+ if ($this->step === W_CREATE_AGENT) {
+ // Create agent is pending.
+ if ($sec2 === 'godmode/agentes/configurar_agente'
+ && get_parameter('create_agent', false) !== false
+ ) {
+ // Agent have been created. Store.
+ $this->setWelcomeAgent(
+ db_get_value(
+ 'MAX(id_agente)',
+ 'tagente'
+ )
+ );
+ $this->setStep(W_CREATE_MODULE);
+ return true;
+ } else if ($sec2 === 'godmode/agentes/configurar_agente') {
+ // Agent is being created.
+ return false;
+ } else {
+ // Any other page, show welcome.
+ return true;
+ }
+ }
+
+ /*
+ * Create module. Control current flow.
+ *
+ * On empty sec2: show current step.
+ * On module creation page: do not show.
+ * After module creation: enable alert step.
+ */
+
+ if ($this->step === W_CREATE_MODULE) {
+ // Create module is pending.
+ if ($sec2 === 'godmode/agentes/configurar_agente'
+ && get_parameter('tab', '') === 'module'
+ && get_parameter('create_module', false) !== false
+ ) {
+ // Module have been created.
+ $this->setStep(W_CREATE_ALERT);
+ return true;
+ } else if ($sec2 === 'godmode/agentes/configurar_agente'
+ && get_parameter('tab', '') === 'module'
+ ) {
+ // Module is being created.
+ return false;
+ } else {
+ // Any other page, show welcome.
+ return true;
+ }
+ }
+
+ /*
+ * Create alert. Control current flow.
+ *
+ * On empty sec2: show current step.
+ * On alert creation page: do not show.
+ * After alert creation: enable discovery task step.
+ */
+
+ if ($this->step === W_CREATE_ALERT) {
+ // Create alert is pending.
+ if ($sec2 === 'godmode/agentes/configurar_agente'
+ && get_parameter('tab', '') === 'alert'
+ && get_parameter('create_alert', false) !== false
+ ) {
+ // Alert have been created.
+ $this->setStep(W_CREATE_TASK);
+ return true;
+ } else if ($sec2 === 'godmode/agentes/configurar_agente'
+ && get_parameter('tab', '') === 'alert'
+ ) {
+ // Alert is being created.
+ return false;
+ } else {
+ // Any other page, show welcome.
+ return true;
+ }
+ }
+
+ /*
+ * Create discovery task. Control current flow.
+ *
+ * On empty sec2: show current step.
+ * On discovery task creation page: do not show.
+ * After discovery task creation: finish.
+ */
+
+ if ($this->step === W_CREATE_TASK) {
+ // Create Discovery task is pending.
+ // Host&Devices finishses on page 2.
+ if ($sec2 === 'godmode/servers/discovery'
+ && get_parameter('page', 0) == 2
+ ) {
+ // Discovery task have been created.
+ $this->setStep(WELCOME_FINISHED);
+
+ // Finished! do not show.
+ return false;
+ } else if ($sec2 == 'godmode/servers/discovery') {
+ // Discovery task is being created.
+ return false;
+ } else {
+ // Any other page, show welcome.
+ return true;
+ }
+ }
+
+ if ($this->step === WELCOME_FINISHED) {
+ // Welcome tutorial finished.
+ return false;
+ }
+
+ // Return a reference to the new object.
+ return false;
+ }
+
+
+ /**
+ * Load JS content.
+ * function that enables the functions to the buttons when its action is
+ * completed.
+ * Assign the url of each button.
+ *
+ * @return string HTML code for javascript functionality.
+ */
+ public function loadJS()
+ {
+ ob_start();
+ ?>
+
+ ' + settings.message + "
"
+ );
+ $("#confirm_" + randomStr);
+ $("#confirm_" + randomStr)
+ .dialog({
+ title: settings.title,
+ close: false,
+ width: 350,
+ modal: true,
+ buttons: [
+ {
+ text: "Cancel",
+ class:
+ "ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel",
+ click: function() {
+ $(this).dialog("close");
+ if (typeof settings.onDeny == "function") settings.onDeny();
+ }
+ },
+ {
+ text: "Ok",
+ class:
+ "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
+ click: function() {
+ $(this).dialog("close");
+ if (typeof settings.onAccept == "function") settings.onAccept();
+ }
+ }
+ ]
+ })
+ .show();
+}
+
/**
* Function to show modal with message Validation.
*
diff --git a/pandora_console/include/styles/new_installation_welcome_window.css b/pandora_console/include/styles/new_installation_welcome_window.css
new file mode 100644
index 0000000000..b61b0976af
--- /dev/null
+++ b/pandora_console/include/styles/new_installation_welcome_window.css
@@ -0,0 +1,70 @@
+/*
+// Pandora FMS - the Flexible Monitoring System
+// =============================================
+// Copyright (c) 2004-2009 Artica Soluciones Tecnológicas S.L
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; version 2
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+.modal {
+ overflow: hidden;
+}
+
+.welcome_modal_window {
+ overflow: hidden;
+}
+label {
+ font-family: "lato-lighter", "Open Sans", sans-serif;
+ letter-spacing: 0.03pt;
+ font-size: 8pt;
+ font-weight: 900;
+}
+.content_position {
+ display: flex;
+ margin-top: 5px;
+ font-family: "lato-lighter", "Open Sans", sans-serif;
+ letter-spacing: 0.03pt;
+ font-size: 8pt;
+ font-weight: 800;
+}
+
+.learn_content_indented {
+ margin-top: 0.5em;
+ text-indent: 2em;
+ font-family: "lato-lighter", "Open Sans", sans-serif;
+ letter-spacing: 0.03pt;
+ font-size: 8pt;
+ font-weight: 800;
+}
+
+#lbl_learn {
+ font-family: "lato-lighter", "Open Sans", sans-serif;
+ letter-spacing: 0.03pt;
+ font-size: 8pt;
+ font-weight: 800;
+}
+
+.go {
+ background-repeat: no-repeat;
+ width: 25px;
+ height: 25px;
+ border: none;
+}
+
+.pending {
+ background-image: url(../../images/darrowright.png);
+}
+
+.completed {
+ background-image: url(../../images/input_tick.png);
+}