/// <summary> /// Updates an existing team member /// </summary> public void UpdateMember() { List <string> userRoles = new List <string>(UserRoles); string roles = "["; for (int i = 0; i < UpdateUserObject.roles.Length; i++) { if (userRoles.Contains(UpdateUserObject.roles[i].name)) { roles += "\"" + UpdateUserObject.roles[i].name + "\""; if (i != UpdateUserObject.roles.Length) { roles += ","; } } } if (RoleDropDownSelection != -1) { roles += "\"" + UserRoles[RoleDropDownSelection] + "\"]"; } else { roles += "]"; } if (UserObject.email == UpdateUserObject.email) { UpdateUserObject.email = string.Empty; } Enjin.UpdateUser(UserObject.id, UserObject.name, UpdateUserObject.email, roles); if (Enjin.ServerResponse == ResponseCodes.SUCCESS) { if (UnityEditor.EditorUtility.DisplayDialog("SUCCESS", "User updated successfully.", "OK")) { ResetTeamList(); } } SelectedRoleIndex = 0; EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADTEAM); EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADIDENTITIES); SetTeamState(TeamState.VIEWLIST); }
/// <summary> /// Removes a give role from the current user /// </summary> public void RemoveRole(string role) { string roles = "["; for (int i = 0; i < UpdateUserObject.roles.Length; i++) { if (UpdateUserObject.roles[i].name == role) { continue; } roles += "\"" + UpdateUserObject.roles[i].name + "\""; if (i != UpdateUserObject.roles.Length) { roles += ","; } } roles += "]"; if (UserObject.email == UpdateUserObject.email) { UpdateUserObject.email = string.Empty; } EnjinEditor.Log("Roles - " + roles); Enjin.UpdateUser(UserObject.id, UserObject.name, UpdateUserObject.email, roles); if (Enjin.ServerResponse == ResponseCodes.SUCCESS) { if (UnityEditor.EditorUtility.DisplayDialog("SUCCESS", "Removed role successfully.", "OK")) { ResetTeamList(); } } SelectedRoleIndex = 0; EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADTEAM); SetTeamState(TeamState.VIEWLIST); }