{= # # # save_profiles_dashboard.cfv # # include "templates.util.base_util"; include "templates.util.rbac.rbac_util"; debug_message("\n\n#### save_profiles_dashboard.cfv \n\n"); debug_message("\n" . node_as_string("v.fp") . "\n"); string session_id = volatile.session_id; bool is_root_admin = get_is_root_admin(); string page_token = v.fp.page_token; if ((is_root_admin or get_admin_feature_permission(session_id, "profiles_dashboard", "edit")) and get_is_valid_page_token(session_id, "profiles", page_token)) then ( # Note, if the user is not the root_admin and has not grants # to edit the profiles dashboard for all profiles than # we need to override the existing profiles_dashboard rather than # replacing it because "v.fp.profiles_dashboard" doesn't contain # all data! string user_grants_path; if (!is_root_admin) then ( user_grants_path = "sessions_cache." . session_id . ".session_info.user_grants"; ); if (is_root_admin or (?(user_grants_path . ".all_profiles_grants.edit_profiles_dashboard") and @(user_grants_path . ".all_profiles_grants.edit_profiles_dashboard")) or !?("profiles_dashboard")) then ( # User has access to all profiles_dashboard data or # "profiles_dashboard" does not yet exist. clone_node("v.fp.profiles_dashboard", "profiles_dashboard"); save_node("profiles_dashboard"); ) else ( # User has limited access to profiles_dashboard data, respectively # has no permission to edit columns. # So we only update profile specific data # of the existing profiles_dashboard. node profiles_dashboard = "profiles_dashboard"; node new_profiles_dashboard = "v.fp.profiles_dashboard"; node columns = new_profiles_dashboard{"columns"}; node column; node column_profiles; node profile_item; string target_path; foreach column columns ( column_profiles = column{"profiles"}; foreach profile_item column_profiles ( # Override profile_item in existing profiles_dashboard target_path = profiles_dashboard . ".columns." . node_name(column) . ".profiles." . node_name(profile_item); clone_node(profile_item, target_path); ); ); save_node(profiles_dashboard); ); # # Send response # 'profilesDashboardEditor.saveProfilesDashboardResponse()'; ) else ( # No permission to view this resource (URL) display_no_permission_html(); ); =}