{= # # # save_macros.cvf # # save_macros.cfv is called from the client when saving changes by Manage Macros. # All macros are re-saved # # include "templates.util.base_util"; include "templates.util.encoding"; debug_message("#### save_macros.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_macros_permission = is_root_admin or get_report_feature_permission(session_id, profile_name, "macros"); string page_token = v.fp.page_token; if (is_macros_permission and get_is_valid_page_token(session_id, "statistics", page_token)) then ( debug_message("\n" . node_as_string("v.fp") . "\n"); node modified_macros = "v.fp.modified_macros"; string user_node_name = node_name(volatile.authenticated_user_node_path); string preferences_path = "users_cache." . user_node_name . ".profiles." . profile_name . ".preferences"; # # Make sure that a macro node exists # if (!?(preferences_path . ".macros")) then ( preferences_path . ".macros" = ""; ); node macros = preferences_path . ".macros"; node item; # # Remove existing macros # foreach item macros ( delete_node(item); ); # # Handle modified macros # if (num_subnodes(modified_macros) > 0) then ( # Sort modified_macros sort(modified_macros, "field:name,integer,ascending"); # Remove the name node which was only used for sorting foreach item modified_macros ( delete_node(item{"name"}); ); # Clone modified_macros to macros clone_node(modified_macros, macros); ); # # Save macros # save_node(preferences_path); # # Handle filters backup # # KHP-RC, re-check if we can delete any filters in macro_item_filters #* if (filter_id ne "") then ( node filter = "filters_cache." . profile_name . "." . filter_id; string macro_item_filters_path = "users_cache." . user_node_name . ".profiles." . profile_name . ".macro_item_filters." . filter_id; clone_node(filter, macro_item_filters_path); save_node(macro_item_filters_path); ); *# # # # Send response # # 'manageMacros.saveMacrosResponse()\n'; ) else ( # No permission to view this resource (URL) display_no_permission_html(); ); =}