{= # # # save_report_changes.cvf # # save_report_changes.cfv is called from the client upon "Save Report Changes" # This saves any report changes which are saved in sessions_cache to the profile # or the users_cache node, depending on user permissions. # As the web browser session data could be already out of date (i.e. via changes of a report in a different web browser window or tab) # we use the report_info to save the current report properties to the profile or to user info. include "templates.util.base_util"; include "templates.statistics.save_report_changes.save_report_changes_util"; debug_message("#### save_report_changes.cvf START \n"); string profile_name = internal.profile_name; string session_id = volatile.session_id; bool is_root_admin = get_is_root_admin(); bool is_save_report_changes_permission = is_root_admin or get_report_feature_permission(session_id, profile_name, "save_report_changes"); string page_token = v.sys.page_token; if (is_save_report_changes_permission and get_is_valid_page_token(session_id, "statistics", page_token)) then ( debug_message("\n" . node_as_string("v.sys") . "\n"); string user_node_name = node_name(volatile.authenticated_user_node_path); string web_browser_session_id = v.sys.web_browser_session_id; bool is_save_report_changes_to_profile_permission = v.sys.is_save_report_changes_to_profile_permission; string report_name = v.sys.report_name; string report_info_id = v.sys.report_info_id; bool set_skip_save_report_changes_dialog_in_future = v.sys.set_skip_save_report_changes_dialog_in_future; string sessions_profile_path = "sessions_cache." . session_id . ".profiles." . profile_name; string web_browser_session_path = sessions_profile_path . ".web_browser_sessions." . web_browser_session_id; debug_message("#### is_save_report_changes_to_profile_permission: " . is_save_report_changes_to_profile_permission . "\n"); # # # Clear report in web browser session # (We only clear it in the current web browser session but not in the sessions of other tabs or windows) # if (?(web_browser_session_path . ".reports." . report_name)) then ( delete_node(web_browser_session_path . ".reports." . report_name); save_node(web_browser_session_path); ); # # # # Save latest report element data to profile or users_cache # # # node report_info = sessions_profile_path . ".report_infos." . report_info_id; node report_in_profile = "profiles." . profile_name . ".statistics.reports." . report_name; if (is_save_report_changes_to_profile_permission) then ( # # # Save report elements to profile # # # Delete existing report elements delete_node(report_in_profile{"report_elements"}); # Clone report_elements of report_info to report clone_node(report_info{"report_elements"}, report_in_profile . ".report_elements"); # Remove the starting_row and ending_row in the report elements node item; node report_elements_in_profile = report_in_profile{"report_elements"}; foreach item report_elements_in_profile ( if (item?{"starting_row"}) then ( delete_node(item{"starting_row"}); delete_node(item{"ending_row"}); ); ); save_node("profiles." . profile_name); ) else ( # # # Save report elements to users_cache for this user only # # # KHP-RC, verify correct users_cache data handling save_report_changes_in_user_info( user_node_name, profile_name, report_name, report_info, report_in_profile ); ); # # # # Handle set_skip_save_report_changes_dialog_in_future # # # if (set_skip_save_report_changes_dialog_in_future) then ( "users_cache." . user_node_name . ".preferences.skip_save_report_changes_dialog" = true; save_node("users_cache." . user_node_name . ".preferences"); ); # # # Send response # # 'saveReportControl.saveChangesResponse()\n'; ) else ( # No permission to view this resource (URL) display_no_permission_html(); ); =}