$templates.shared.doctype {= include "templates.shared.util.build_top_header_bar"; include "templates.shared.util.convert_to_valid_node_name"; if (node_exists("volatile")) then ( debug_message("\n" . node_as_string("volatile") . "\n"); ); string page_title = lang_admin.setup.label; string wizard_label; string active_client_page; string next_client_page; string license; bool license_is_valid = true; # Default true so that it doesn't show "invalid license" on first load! bool invalid_version_6_license = false; bool trial_is_active = false; bool talkback; # --------------- # handle upgrades # --------------- # Handle upgrades, the problem is that system.setup_done does not exist # but an administrative password and license exists. # If there already exists a password and license then set # the system.setup_done node now and redirect to admin.index bool show_setup_wizard = true; if (node_exists("users") and (num_subnodes("users") > 0) and node_exists("licenses") and (num_subnodes("licenses") > 0)) then ( show_setup_wizard = false; # Set system.setup_done now system.setup_done = true; save_node("system"); ); if (show_setup_wizard) then ( # --------------------------------------- # handle page display and form submission # --------------------------------------- # Note, password, licensing, etc. are only saved upon completion of the setup wizard! # This ensures that system.setup_done is only set if all values are valid and saved. if (node_exists("volatile.setup_wizard.active_client_page")) then ( active_client_page = node_value("volatile.setup_wizard.active_client_page"); if (active_client_page eq "welcome_page") then ( next_client_page = "licensing_page"; wizard_label = lang_admin.licensing.label; ) else if (active_client_page eq "licensing_page") then ( license = node_value("volatile.setup_wizard.license"); if (license eq "") then ( # get trial license! # Note, use create_trial_license() only once because invoking it a second time # wont return anymore a valid trial license. if (!node_exists("system.temp_setup_data.trial_license")) then ( # create the license and save it in the system node. license = create_trial_license(); system.temp_setup_data.trial_license = license; save_node("system"); debug_message("\n\ncreated trial license: " . license . "\n"); ) else ( # read trial license from system node license = node_value("system.temp_setup_data.trial_license"); ); ); # validate license v.license_info = ""; get_license_info(license, "v.license_info"); license_is_valid = node_value("v.license_info.valid"); debug_message("\n\nlicense to validate: " . license . "\n"); debug_message("\n\nlicense validation result:\n" . node_as_string("v.license_info") . "\n"); # Check if this is a trial license if (node_value("v.license_info.type") eq "trial") then ( trial_is_active = true; ); if (license_is_valid) then ( # save licensing data in system node system.temp_setup_data.license = license; system.temp_setup_data.trial_is_active = trial_is_active; save_node("system"); next_client_page = "password_page"; wizard_label = lang_admin.authentication.choose_password_label; ) else ( if (node_value("v.license_info.valid64") or node_value("v.license_info.valid65")) then ( invalid_version_6_license = true; ); next_client_page = "licensing_page"; wizard_label = lang_admin.licensing.label; ); ) else if (active_client_page eq "password_page") then ( # save username and password in system node system.temp_setup_data.username = node_value("volatile.setup_wizard.username"); system.temp_setup_data.password_checksum = md5_digest(node_value("volatile.setup_wizard.password")); save_node("system"); if (node_value("system.temp_setup_data.trial_is_active") and node_value("preferences.miscellaneous.prompt_for_trial_tier")) then ( # show trial selection next_client_page = "trial_selection_page"; wizard_label = lang_admin.trial.label; ) else ( # show talkback page next_client_page = "talkback_page"; wizard_label = lang_admin.talkback.label; ); ) else if (active_client_page eq "trial_selection_page") then ( system.temp_setup_data.trial_licensing_features = node_value("volatile.setup_wizard.trial_licensing_features"); save_node("system"); next_client_page = "talkback_page"; wizard_label = lang_admin.talkback.label; ) else if (active_client_page eq "talkback_page") then ( talkback = false; if (node_exists("volatile.setup_wizard.talkback")) then ( talkback = true; ); system.temp_setup_data.talkback = talkback; save_node("system"); next_client_page = "complete_setup_page"; wizard_label = lang_admin.setup.complete_setup_label; ) else if (active_client_page eq "complete_setup_page") then ( # save all setup data (get data from system.temp_setup_data) # set system.setup_done = true # redirect the user to the admin interface # ------------ # save license # ------------ license = node_value("system.temp_setup_data.license"); licenses.0 = license; # ------------- # save password # ------------- string username = node_value("system.temp_setup_data.username"); string user_node_name = convert_to_valid_node_name(username); "users." . user_node_name . ".username" = username; "users." . user_node_name . ".password_checksum" = node_value("system.temp_setup_data.password_checksum"); "users." . user_node_name . ".administrator" = true; # ---------------------------- # set trial_licensing_features # ---------------------------- # Note, in case that prompt_for_trial_tier is false the node trial_licensing_features does not exist! if (node_value("system.temp_setup_data.trial_is_active") and node_exists("system.temp_setup_data.trial_licensing_features")) then ( preferences.miscellaneous.trial_licensing_features = node_value("system.temp_setup_data.trial_licensing_features"); ); # ------------ # set talkback # ------------ preferences.miscellaneous.talkback = node_value("system.temp_setup_data.talkback"); # -------------- # set setup_done # -------------- delete_node("system.temp_setup_data"); system.setup_done = true; # ---------------- # save setup nodes # ---------------- save_node("licenses"); save_node("users"); save_node("preferences"); save_node("system"); show_setup_wizard = false; ); ) else ( next_client_page = "welcome_page"; wizard_label = lang_admin.setup.welcome_label; ); ); # if show_setup_wizard if (show_setup_wizard) then ( page_title .= "-" . wizard_label; ); '\n'; '
\n'; '