# # # # new_profile_util.cfv # # # # add_new_profile_to_access_item() # add_new_profile_to_user() # # # # # # # add_new_profile_to_access_item() # # # # subroutine(add_new_profile_to_access_item( node access_item, string new_profile_name), ( node profile_items = access_item{"profiles"}; int new_node_name = num_subnodes(profile_items); # Make sure the new_node_name is unique while (profile_items?{new_node_name}) ( new_node_name++; ); profile_items . "." . new_node_name = new_profile_name; )); # # # # # add_new_profile_to_user() # # # # subroutine(add_new_profile_to_user( string licensing_tier, string user_node_name, string new_profile_name), ( node lai_roles = if (licensing_tier eq "enterprise") then ("roles_enterprise") else ("roles_standard"); node user_access = "users." . user_node_name . ".access"; bool is_all_profiles; node access_item; node user_access_roles; string role_name; node user_access_role_item; node the_lai_role; foreach access_item user_access ( is_all_profiles = @access_item{"all_profiles"}; # If is_all_profiles then the user has automatically access to the new profile. # If not is_all_profiles we need to check all roles of the access pair # and add the profile to profile if one role allows to create a new profile. if (!is_all_profiles) then ( user_access_roles = access_item{"roles"}; foreach user_access_role_item user_access_roles ( role_name = @user_access_role_item; if (lai_roles?{role_name}) then ( the_lai_role = lai_roles{role_name}; if (?(the_lai_role . ".features.admin.profiles.add") and @(the_lai_role . ".features.admin.profiles.add")) then ( add_new_profile_to_access_item(access_item, new_profile_name); last; ); ); ); ); ); # # Save the user node # save_node("users"); ));