$templates.shared.doctype {= include "templates.shared.util.build_top_header_bar"; include "templates.shared.util.convert_to_valid_node_name"; include "templates.shared.util.get_unique_node_name_28char"; include "templates.shared.util.check_license_expired"; if (node_exists("volatile.setup_wizard")) then ( debug_message("\n" . node_as_string("volatile.setup_wizard") . "\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 license_expired = false; 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 ( # If a valid license exists (pre-installed license) don't show the licensing page! bool valid_license_exists = false; if (node_exists("licenses") and (num_subnodes("licenses") > 0)) then ( # check each license node node existing_license; node existing_license_validation_node; foreach existing_license "licenses" ( v.x = ""; clone_node(existing_license, "v.x"); existing_license_validation_node = "v.x"; v.license_info = ""; get_license_info(existing_license_validation_node, "v.license_info"); if (node_value("v.license_info.valid")) then ( valid_license_exists = true; last; ); ); ); if (!valid_license_exists) then ( next_client_page = "licensing_page"; wizard_label = lang_admin.licensing.label; ) else ( next_client_page = "password_page"; wizard_label = lang_admin.authentication.choose_password_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. # Note, we need to set trial_is_active here as well because create_trial_license() # does not return a value in case that trial expired and so license_info wont # indicate if it is a trial license trial_is_active = true; if (!node_exists("system.temp_setup_data.trial_license")) then ( # create the license and save it in the system node. license = create_trial_license(); # if the license has no value then trial is not anymore possible, though # give it a value so that the license node is not empty when validating! if (license eq "") then ( 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"); ); ); # ---------------------------- # set appropriate license node # ---------------------------- # node license_node = license_string_to_license_node(license); node license_node; if (!contains(license, "=")) then ( # license as single string v.0 = license; license_node = "v.0"; ) else ( # license as node structure license_node = string_to_node(license); ); debug_message("\n\nlicense_node:\n" . node_as_string(license_node) . "\n"); # ---------------- # validate license # ---------------- # Note, before passing the license_node to get_license_info() we clone the node to # license_node_for_validation_only which is exlusively used for license_info() because # license_info() modifies the original node where the checksum node becomes omitted! # Though we need the checksum node in license_node to temporary save the license_node, # hence we use a clone for license_info(). # Further, the parent node of license_node_for_validation_only must be "x". v.license_info = ""; get_license_info(license_node, "v.license_info"); # v.license_info = ""; # get_license_info_via_license_node(license_node, "v.license_info"); license_is_valid = node_value("v.license_info.valid"); debug_message("\n\nlicense validation result:\n" . node_as_string("v.license_info") . "\n"); # Recheck 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 clone_node(license_node, "system.temp_setup_data.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 (license ne "-") then ( if (node_value("v.license_info.valid64") or node_value("v.license_info.valid65")) then ( invalid_version_6_license = true; ) else ( # Check if the license expired. # Note, the expiration node does not always exist! if (node_exists("v.license_info.expiration")) then ( string expiration_date = node_value("v.license_info.expiration"); license_expired = check_license_expired(expiration_date); # debug_message("\n\n#### #### license_expired: " . license_expired . "\n\n"); ); ); ); 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_exists("system.temp_setup_data.trial_is_active") and 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 # ------------ if (node_exists("system.temp_setup_data.license")) then ( # license = node_value("system.temp_setup_data.license"); node license_node = "system.temp_setup_data.license"; clone_node(license_node, "licenses.0"); # licenses.0 = license; save_node("licenses"); ); # ------------- # save password # ------------- string username = node_value("system.temp_setup_data.username"); string user_node_name = convert_to_valid_node_name(username); user_node_name = get_unique_node_name_28char("users", user_node_name); "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_exists("system.temp_setup_data.trial_is_active") and 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("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'; '