{= # # # save_new_field.cfv (new field wizard) # # include "templates.util.base_util"; include "templates.util.rbac.rbac_util"; include "templates.config_pages.new_field_wizard.save_new_field_util"; include "templates.util.backup_util"; include "templates.util.profiles.get_profile_data_util"; debug_message("\n#### save_new_field.cfv START \n"); string profile_name = internal.profile_name; string session_id = volatile.session_id; bool is_root_admin = get_is_root_admin(); string page_token = v.fp.page_token; # # Check RBAC permissions # # The new field wizard has no edit but only view permission! if ((is_root_admin or get_config_feature_permission(session_id, profile_name, "new_field_wizard", "view")) and get_is_valid_page_token(session_id, "new_field_wizard", page_token)) then ( debug_message("\n" . node_as_string("v.fp") . "\n"); string user_node_name = node_name(volatile.authenticated_user_node_path); string client_profiles_list_checksum = v.fp.profiles_list_checksum; # Get profiles checksum before the profile becomes saved! string profiles_list_checksum_before_profile_modification = get_profiles_list_checksum(session_id, is_root_admin, user_node_name); node profile = "profiles." . profile_name; string new_field_name = v.fp.general.field_name; string new_field_label = v.fp.general.label; # # # Create log field # # string new_log_field_path = profile . ".log.fields." . new_field_name; clone_node("v.fp.log_field", new_log_field_path); # # # Create database field # # string new_db_field_path = profile . ".database.fields." . new_field_name; clone_node("v.fp.database_field", new_db_field_path); # # # Create report field # # string new_report_field_path = profile . ".statistics.report_fields." . new_field_name; clone_node("v.fp.report_field", new_report_field_path); # # # Create cross references group # # create_new_cross_reference_group_in_save_new_field(profile, new_field_name, new_field_label); # # # Create log filter # # string new_log_filter_name = v.fp.log_filter.name; create_new_log_filter_in_save_new_field(profile, new_field_name, new_log_filter_name); # # # Create report # # string new_report_name = v.fp.report.name; string new_report_label = v.fp.report.label; create_new_report_in_save_new_field(profile, new_field_name, new_report_name, new_report_label); # # # Create report menu # # string new_report_menu_name = v.fp.general.report_menu_name; string new_report_menu_path = profile . ".statistics.reports_menu." . new_report_menu_name; clone_node("v.fp.reports_menu", new_report_menu_path); # # Save changes and send response # # KHP 08/Aug/2013 - Changed save_node() to save_and_backup_profile() # save_node(profile); save_and_backup_profile(profile_name, profile); # Get profile_changes_dat, also in case of an error! string profile_changes_dat = get_profiles_list_data_after_profiles_changes( session_id, is_root_admin, user_node_name, client_profiles_list_checksum, profiles_list_checksum_before_profile_modification, profile_name, "save_profile"); # Response string dat = "{"; dat .= add_json("profileChanges", profile_changes_dat, "obj"); dat = close_json(dat); "newFieldWizard.saveNewFieldResponse(" . dat . ")\n"; ) else ( # No permission to access this resource (URL) display_no_permission_html(); ); =}