{= # # # # save_data.cfv (report options) # # # include "templates.util.base_util"; include "templates.util.rbac.rbac_util"; include "templates.util.backup_util"; include "templates.util.profiles.get_profile_data_util"; 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 # if ((is_root_admin or get_config_feature_permission(session_id, profile_name, "report_options", "edit")) and get_is_valid_page_token(session_id, "report_options", page_token)) then ( debug_message("#### save_data.cfv\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); # remove page_token and profiles_list_checksum node # so that it doesn't become saved in the profile. delete_node("v.fp.page_token"); delete_node("v.fp.profiles_list_checksum"); node profile = "profiles." . profile_name; subroutine(override_report_options_in_profile( node source_node, node profile), ( node item; string item_path; foreach item source_node ( if (num_subnodes(item) == 0) then ( # Override profile option profile . replace_first(item, "v.fp", "") = @item; ) else ( # Recursively call override_report_options_in_profile override_report_options_in_profile(item, profile); ); ); )); override_report_options_in_profile("v.fp", profile); # debug_message("\n" . node_as_string(profile{"statistics"}) . "\n"); # debug_message("\n" . node_as_string(profile{"output"}) . "\n"); # 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); "reportOptions.saveReportOptionsResponse(" . dat . ")\n"; ) else ( # No permission to access this resource (URL) display_no_permission_html(); ); =}