public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary <string, object>(); string username = filename.Split('/').LastOrDefault(); UserAccount account = null; if (httpRequest.Query.ContainsKey("userid")) { string userid = httpRequest.Query["userid"].ToString(); account = webInterface.Registry.RequestModuleInterface <IUserAccountService>(). GetUserAccount(null, UUID.Parse(userid)); } else if (httpRequest.Query.ContainsKey("name")) { string name = httpRequest.Query.ContainsKey("name") ? httpRequest.Query["name"].ToString() : username; name = name.Replace('.', ' '); name = name.Replace("%20", " "); account = webInterface.Registry.RequestModuleInterface <IUserAccountService>(). GetUserAccount(null, name); } else { username = username.Replace("%20", " "); webInterface.Redirect(httpResponse, "/webprofile/?name=" + username); return(vars); } if (account == null) { return(vars); } vars.Add("UserName", account.Name); // TODO: User Profile inworld shows this as the standard mm/dd/yyyy // Do we want this to be localised into the users Localisation or keep it as standard ? vars.Add("UserBorn", Util.ToDateTime(account.Created).ToShortDateString()); IUserProfileInfo profile = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>(). GetUserProfile(account.PrincipalID); string picUrl = "../images/icons/no_avatar.jpg"; if (profile != null) { vars.Add("UserType", profile.MembershipGroup == "" ? "Resident" : profile.MembershipGroup); if (profile.Partner != UUID.Zero) { account = webInterface.Registry.RequestModuleInterface <IUserAccountService> (). GetUserAccount(null, profile.Partner); vars.Add("UserPartner", account.Name); } else { vars.Add("UserPartner", "No partner"); } vars.Add("UserAboutMe", profile.AboutText == "" ? "Nothing here" : profile.AboutText); IWebHttpTextureService webhttpService = webInterface.Registry.RequestModuleInterface <IWebHttpTextureService> (); if (webhttpService != null && profile.Image != UUID.Zero) { picUrl = webhttpService.GetTextureURL(profile.Image); } } else { // no profile yet vars.Add("UserType", "Guest"); vars.Add("UserPartner", "Not specified yet"); vars.Add("UserAboutMe", "Nothing here yet"); } vars.Add("UserPictureURL", picUrl); // TODO: This is only showing online status if you are logged in ?? UserAccount ourAccount = Authenticator.GetAuthentication(httpRequest); if (ourAccount != null) { IFriendsService friendsService = webInterface.Registry.RequestModuleInterface <IFriendsService>(); var friends = friendsService.GetFriends(account.PrincipalID); UUID friendID = UUID.Zero; if (friends.Any(f => UUID.TryParse(f.Friend, out friendID) && friendID == ourAccount.PrincipalID)) { IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService>(); IGridService gridService = webInterface.Registry.RequestModuleInterface <IGridService>(); UserInfo ourInfo = agentInfoService.GetUserInfo(account.PrincipalID.ToString()); if (ourInfo != null && ourInfo.IsOnline) { vars.Add("OnlineLocation", gridService.GetRegionByUUID(null, ourInfo.CurrentRegionID).RegionName); } vars.Add("UserIsOnline", ourInfo != null && ourInfo.IsOnline); vars.Add("IsOnline", ourInfo != null && ourInfo.IsOnline ? translator.GetTranslatedString("Online") : translator.GetTranslatedString("Offline")); } else { vars.Add("OnlineLocation", ""); vars.Add("UserIsOnline", false); vars.Add("IsOnline", translator.GetTranslatedString("Offline")); } } else { vars.Add("OnlineLocation", ""); vars.Add("UserIsOnline", false); vars.Add("IsOnline", translator.GetTranslatedString("Offline")); } // Menus vars.Add("MenuProfileTitle", translator.GetTranslatedString("MenuProfileTitle")); vars.Add("TooltipsMenuProfile", translator.GetTranslatedString("TooltipsMenuProfile")); vars.Add("MenuGroupTitle", translator.GetTranslatedString("MenuGroupTitle")); vars.Add("TooltipsMenuGroups", translator.GetTranslatedString("TooltipsMenuGroups")); vars.Add("MenuPicksTitle", translator.GetTranslatedString("MenuPicksTitle")); vars.Add("TooltipsMenuPicks", translator.GetTranslatedString("TooltipsMenuPicks")); vars.Add("MenuRegionsTitle", translator.GetTranslatedString("MenuRegionsTitle")); vars.Add("TooltipsMenuRegions", translator.GetTranslatedString("TooltipsMenuRegions")); // User data vars.Add("UserProfileFor", translator.GetTranslatedString("UserProfileFor")); vars.Add("ResidentSince", translator.GetTranslatedString("ResidentSince")); vars.Add("AccountType", translator.GetTranslatedString("AccountType")); vars.Add("PartnersName", translator.GetTranslatedString("PartnersName")); vars.Add("AboutMe", translator.GetTranslatedString("AboutMe")); vars.Add("IsOnlineText", translator.GetTranslatedString("IsOnlineText")); vars.Add("OnlineLocationText", translator.GetTranslatedString("OnlineLocationText")); // Style Switcher vars.Add("styles1", translator.GetTranslatedString("styles1")); vars.Add("styles2", translator.GetTranslatedString("styles2")); vars.Add("styles3", translator.GetTranslatedString("styles3")); vars.Add("styles4", translator.GetTranslatedString("styles4")); vars.Add("styles5", translator.GetTranslatedString("styles5")); vars.Add("StyleSwitcherStylesText", translator.GetTranslatedString("StyleSwitcherStylesText")); vars.Add("StyleSwitcherLanguagesText", translator.GetTranslatedString("StyleSwitcherLanguagesText")); vars.Add("StyleSwitcherChoiceText", translator.GetTranslatedString("StyleSwitcherChoiceText")); // Language Switcher vars.Add("en", translator.GetTranslatedString("en")); vars.Add("fr", translator.GetTranslatedString("fr")); vars.Add("de", translator.GetTranslatedString("de")); vars.Add("it", translator.GetTranslatedString("it")); vars.Add("es", translator.GetTranslatedString("es")); vars.Add("nl", translator.GetTranslatedString("nl")); var settings = webInterface.GetWebUISettings(); vars.Add("ShowLanguageTranslatorBar", !settings.HideLanguageTranslatorBar); vars.Add("ShowStyleBar", !settings.HideStyleBar); return(vars); }
public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary <string, object>(); string error = ""; UUID userID = httpRequest.Query.ContainsKey("userid") ? UUID.Parse(httpRequest.Query["userid"].ToString()) : UUID.Parse(requestParameters["userid"].ToString()); IUserAccountService userService = webInterface.Registry.RequestModuleInterface <IUserAccountService>(); var agentService = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>(); UserAccount account = userService.GetUserAccount(null, userID); IAgentInfo agent = agentService.GetAgent(userID); if (agent == null) { error = "No agent information is available"; } // Set user type if (requestParameters.ContainsKey("Submit") && requestParameters["Submit"].ToString() == "SubmitSetUserType") { string UserType = requestParameters ["UserType"].ToString(); int UserFlags = webInterface.UserTypeToUserFlags(UserType); // set the user account type account.UserFlags = UserFlags; userService.StoreUserAccount(account); if (agent != null) { agent.OtherAgentInformation ["UserFlags"] = UserFlags; agentService.UpdateAgent(agent); response = "User has been updated."; } else { response = "Agent information is not available! Has the user logged in yet?"; } IProfileConnector profileData = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>(); if (profileData != null) { IUserProfileInfo profile = profileData.GetUserProfile(userID); if (profile == null) { profileData.CreateNewProfile(userID); profile = profileData.GetUserProfile(userID); } profile.MembershipGroup = webInterface.UserFlagToType(UserFlags, webInterface.EnglishTranslator); // membership is english profileData.UpdateUserProfile(profile); } response = "User has been updated."; return(null); } // Password change if (requestParameters.ContainsKey("Submit") && requestParameters["Submit"].ToString() == "SubmitPasswordChange") { string password = requestParameters["password"].ToString(); string passwordconf = requestParameters["passwordconf"].ToString(); if (password != passwordconf) { response = "Passwords do not match"; } else { IAuthenticationService authService = webInterface.Registry.RequestModuleInterface <IAuthenticationService>(); if (authService != null) { response = authService.SetPassword(userID, "UserAccount", password) ? "Successfully set password" : "Failed to set your password, try again later"; } else { response = "No authentication service was available to change your password"; } } return(null); } // Email change if (requestParameters.ContainsKey("Submit") && requestParameters["Submit"].ToString() == "SubmitEmailChange") { string email = requestParameters["email"].ToString(); if (userService != null) { account.Email = email; userService.StoreUserAccount(account); response = "Successfully updated email"; } else { response = "No authentication service was available to change your password"; } return(null); } // Delete user if (requestParameters.ContainsKey("Submit") && requestParameters["Submit"].ToString() == "SubmitDeleteUser") { string username = requestParameters["username"].ToString(); response = "Deleted user successfully"; if (username == account.Name) { userService.DeleteUser(account.PrincipalID, account.Name, "", false, false); } else { response = "The user name did not match"; } return(null); } // Temp Ban user if (requestParameters.ContainsKey("Submit") && requestParameters["Submit"].ToString() == "SubmitTempBanUser") { int timeDays = int.Parse(requestParameters["TimeDays"].ToString()); int timeHours = int.Parse(requestParameters["TimeHours"].ToString()); int timeMinutes = int.Parse(requestParameters["TimeMinutes"].ToString()); if (agent != null) { agent.Flags |= IAgentFlags.TempBan; DateTime until = DateTime.Now.AddDays(timeDays).AddHours(timeHours).AddMinutes(timeMinutes); agent.OtherAgentInformation ["TemperaryBanInfo"] = until; agentService.UpdateAgent(agent); response = "User has been banned."; } else { response = "Agent information is not available! Has the user logged in yet?"; } return(null); } // Ban user if (requestParameters.ContainsKey("Submit") && requestParameters["Submit"].ToString() == "SubmitBanUser") { if (agent != null) { agent.Flags |= IAgentFlags.PermBan; agentService.UpdateAgent(agent); response = "User has been banned."; } else { response = "Agent information is not available! Has the user logged in yet?"; } return(null); } //UnBan user if (requestParameters.ContainsKey("Submit") && requestParameters["Submit"].ToString() == "SubmitUnbanUser") { if (agent != null) { agent.Flags &= ~IAgentFlags.TempBan; agent.Flags &= ~IAgentFlags.PermBan; agent.OtherAgentInformation.Remove("TemperaryBanInfo"); agentService.UpdateAgent(agent); response = "User has been unbanned."; } else { response = "Agent information is not available! Has the user logged in yet?"; } return(null); } // Login as user if (requestParameters.ContainsKey("Submit") && requestParameters["Submit"].ToString() == "SubmitLoginAsUser") { Authenticator.ChangeAuthentication(httpRequest, account); webInterface.Redirect(httpResponse, "/"); return(vars); } // Kick user if (requestParameters.ContainsKey("Submit") && requestParameters["Submit"].ToString() == "SubmitKickUser") { string message = requestParameters["KickMessage"].ToString(); IGridWideMessageModule messageModule = webInterface.Registry.RequestModuleInterface <IGridWideMessageModule>(); if (messageModule != null) { messageModule.KickUser(account.PrincipalID, message); } response = "User has been kicked."; return(null); } // Message user if (requestParameters.ContainsKey("Submit") && requestParameters["Submit"].ToString() == "SubmitMessageUser") { string message = requestParameters["Message"].ToString(); IGridWideMessageModule messageModule = webInterface.Registry.RequestModuleInterface <IGridWideMessageModule>(); if (messageModule != null) { messageModule.MessageUser(account.PrincipalID, message); } response = "User has been sent the message."; return(null); } // page variables string bannedUntil = ""; bool userBanned = agent == null ? false : ((agent.Flags & IAgentFlags.PermBan) == IAgentFlags.PermBan || (agent.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan); bool TempUserBanned = false; if (userBanned) { if ((agent.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan && agent.OtherAgentInformation["TemperaryBanInfo"].AsDate() < DateTime.Now.ToUniversalTime()) { userBanned = false; agent.Flags &= ~IAgentFlags.TempBan; agent.Flags &= ~IAgentFlags.PermBan; agent.OtherAgentInformation.Remove("TemperaryBanInfo"); agentService.UpdateAgent(agent); } else { DateTime bannedTime = agent.OtherAgentInformation["TemperaryBanInfo"].AsDate(); TempUserBanned = bannedTime != Util.UnixEpoch; bannedUntil = string.Format("{0} {1}", bannedTime.ToShortDateString(), bannedTime.ToLongTimeString()); } } bool userOnline = false; IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService>(); if (agentInfoService != null) { UserInfo info = agentInfoService.GetUserInfo(account.PrincipalID.ToString()); userOnline = info != null ? info.IsOnline : false; } vars.Add("UserOnline", userOnline); vars.Add("NotUserBanned", !userBanned); vars.Add("UserBanned", userBanned); vars.Add("TempUserBanned", TempUserBanned); vars.Add("BannedUntil", bannedUntil); vars.Add("EmailValue", account.Email); vars.Add("UserID", account.PrincipalID); vars.Add("UserName", account.Name); vars.Add("ErrorMessage", error); vars.Add("ChangeUserInformationText", translator.GetTranslatedString("ChangeUserInformationText")); vars.Add("ChangePasswordText", translator.GetTranslatedString("ChangePasswordText")); vars.Add("NewPasswordText", translator.GetTranslatedString("NewPasswordText")); vars.Add("NewPasswordConfirmationText", translator.GetTranslatedString("NewPasswordConfirmationText")); vars.Add("ChangeEmailText", translator.GetTranslatedString("ChangeEmailText")); vars.Add("NewEmailText", translator.GetTranslatedString("NewEmailText")); vars.Add("UserNameText", translator.GetTranslatedString("UserNameText")); vars.Add("PasswordText", translator.GetTranslatedString("PasswordText")); vars.Add("DeleteUserText", translator.GetTranslatedString("DeleteUserText")); vars.Add("DeleteText", translator.GetTranslatedString("DeleteText")); vars.Add("DeleteUserInfoText", translator.GetTranslatedString("DeleteUserInfoText")); vars.Add("Submit", translator.GetTranslatedString("Submit")); vars.Add("Login", translator.GetTranslatedString("Login")); vars.Add("TypeUserNameToConfirm", translator.GetTranslatedString("TypeUserNameToConfirm")); vars.Add("AdminUserTypeInfoText", translator.GetTranslatedString("AdminUserTypeInfoText")); vars.Add("AdminSetUserTypeText", translator.GetTranslatedString("UserTypeText")); vars.Add("AdminLoginInAsUserText", translator.GetTranslatedString("AdminLoginInAsUserText")); vars.Add("AdminLoginInAsUserInfoText", translator.GetTranslatedString("AdminLoginInAsUserInfoText")); vars.Add("AdminDeleteUserText", translator.GetTranslatedString("AdminDeleteUserText")); vars.Add("AdminDeleteUserInfoText", translator.GetTranslatedString("AdminDeleteUserInfoText")); vars.Add("AdminUnbanUserText", translator.GetTranslatedString("AdminUnbanUserText")); vars.Add("AdminTempBanUserText", translator.GetTranslatedString("AdminTempBanUserText")); vars.Add("AdminTempBanUserInfoText", translator.GetTranslatedString("AdminTempBanUserInfoText")); vars.Add("AdminBanUserText", translator.GetTranslatedString("AdminBanUserText")); vars.Add("AdminBanUserInfoText", translator.GetTranslatedString("AdminBanUserInfoText")); vars.Add("BanText", translator.GetTranslatedString("BanText")); vars.Add("UnbanText", translator.GetTranslatedString("UnbanText")); vars.Add("TimeUntilUnbannedText", translator.GetTranslatedString("TimeUntilUnbannedText")); vars.Add("EdittingText", translator.GetTranslatedString("EdittingText")); vars.Add("BannedUntilText", translator.GetTranslatedString("BannedUntilText")); vars.Add("KickAUserInfoText", translator.GetTranslatedString("KickAUserInfoText")); vars.Add("KickAUserText", translator.GetTranslatedString("KickAUserText")); vars.Add("KickMessageText", translator.GetTranslatedString("KickMessageText")); vars.Add("KickUserText", translator.GetTranslatedString("KickUserText")); vars.Add("MessageAUserText", translator.GetTranslatedString("MessageAUserText")); vars.Add("MessageAUserInfoText", translator.GetTranslatedString("MessageAUserInfoText")); vars.Add("MessageUserText", translator.GetTranslatedString("MessageUserText")); List <Dictionary <string, object> > daysArgs = new List <Dictionary <string, object> >(); for (int i = 0; i <= 100; i++) { daysArgs.Add(new Dictionary <string, object> { { "Value", i } }); } List <Dictionary <string, object> > hoursArgs = new List <Dictionary <string, object> >(); for (int i = 0; i <= 23; i++) { hoursArgs.Add(new Dictionary <string, object> { { "Value", i } }); } List <Dictionary <string, object> > minutesArgs = new List <Dictionary <string, object> >(); for (int i = 0; i <= 59; i++) { minutesArgs.Add(new Dictionary <string, object> { { "Value", i } }); } vars.Add("Days", daysArgs); vars.Add("Hours", hoursArgs); vars.Add("Minutes", minutesArgs); vars.Add("DaysText", translator.GetTranslatedString("DaysText")); vars.Add("HoursText", translator.GetTranslatedString("HoursText")); vars.Add("MinutesText", translator.GetTranslatedString("MinutesText")); vars.Add("UserType", webInterface.UserTypeArgs(translator)); return(vars); }