diff --git a/pandora_console/general/register.php b/pandora_console/general/register.php index 41996a31ef..a07504a6bd 100644 --- a/pandora_console/general/register.php +++ b/pandora_console/general/register.php @@ -175,7 +175,7 @@ if (!$config['disabled_newsletter']) { $welcome = !$registration && !$show_newsletter && !$initial; $welcome_window = WelcomeWindow::initialize($welcome); -if ($welcome_window && $config['welcome_started'] === 1) { +if ($welcome_window) { $welcome_window->run(); } diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 1bbf1384c8..f1830744af 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -2266,7 +2266,7 @@ if ($updateGIS) { // ----------------------------------- // Load page depending on tab selected // ----------------------------------- -if (!$_SESSION['create_module']) { +if ($_SESSION['create_module'] && $config['welcome_started'] == 1) { $edit_module = true; } diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index feb52a945c..18a1da00ff 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -321,7 +321,7 @@ if ($id_agent_module) { } else { if (!isset($moduletype)) { $moduletype = (string) get_parameter('moduletype'); - if (!$_SESSION['create_module']) { + if ($_SESSION['create_module'] && $config['welcome_started'] == 1) { $moduletype = 'networkserver'; } diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 43fa894642..0ccb8b4617 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -48,7 +48,10 @@ class WelcomeWindow extends Wizard * * @var array */ - public $AJAXMethods = ['loadWelcomeWindow']; + public $AJAXMethods = [ + 'loadWelcomeWindow', + 'cancelWelcome', + ]; /** * Url of controller. @@ -65,6 +68,21 @@ class WelcomeWindow extends Wizard public $step; + /** + * Generates a JSON error. + * + * @param string $msg Error message. + * + * @return void + */ + public function error($msg) + { + echo json_encode( + ['error' => $msg] + ); + } + + /** * Checks if target method is available to be called using AJAX. * @@ -137,9 +155,30 @@ class WelcomeWindow extends Wizard }, onshow: { page: 'ajaxController; ?>', - method: 'loadWelcomeWindow' + method: 'loadWelcomeWindow', }, + oncancel: { + page: 'ajaxController; ?>', + title: "", + method: 'cancelWelcome', + confirm: function (fn) { + confirmDialog({ + title: '', + message: '', + ok: '', + cancel: '', + onAccept: function() { + // Continue execution. + fn(); + } + }) + }, + callback: function(data) { + console.log(data); + } + } }); + step = 'create_agent'; @@ -406,18 +454,16 @@ class WelcomeWindow extends Wizard /** - * Esto es un constructor realmente... - * se llama desde la navegaciĆ³n normal , no ajax + * This function acts as a constructor. + * Receive the condition to check with the global config (welcome_started) if continues */ public static function initialize($must_run) { global $config; - if ($must_run === false) { + if ($must_run === false || $config['welcome_started'] != WELCOME_STARTED) { // Do not start unless already started. - if ($config['welcome_started'] != WELCOME_STARTED) { return false; - } } // Calculate steps. @@ -515,25 +561,22 @@ class WelcomeWindow extends Wizard /** - * DOCUMENTA!!! + * function that enables the functions to the buttons when its action is completed. + * * Assign the url of each button */ 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(); +}