public static ShortMonthSelections ( ITranslator translator ) : object>>.List |
||
translator | ITranslator | |
리턴 | object>>.List |
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>(); var settings = webInterface.GetWebUISettings(); bool adminUser = Authenticator.CheckAdminAuthentication(httpRequest, Constants.USER_GOD_CUSTOMER_SERVICE); bool allowRegistration = settings.WebRegistration; bool anonymousLogins; // allow configuration to override the web settings var simBase = webInterface.Registry.RequestModuleInterface <ISimulationBase>(); IConfig loginServerConfig = simBase.ConfigSource.Configs["LoginService"]; if (loginServerConfig != null) { anonymousLogins = loginServerConfig.GetBoolean("AllowAnonymousLogin", allowRegistration); allowRegistration = (allowRegistration || anonymousLogins); } if (!adminUser && !allowRegistration) { vars.Add("ErrorMessage", ""); vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText")); vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled")); vars.Add("Registrations", false); vars.Add("NoRegistrations", true); return(vars); } if (requestParameters.ContainsKey("Submit")) { string AvatarName = requestParameters["AvatarName"].ToString(); string AvatarPassword = requestParameters["AvatarPassword"].ToString(); string AvatarPasswordCheck = requestParameters["AvatarPassword2"].ToString(); string FirstName = requestParameters["FirstName"].ToString(); string LastName = requestParameters["LastName"].ToString(); //removed - greythane - deemed not used //string UserAddress = requestParameters["UserAddress"].ToString(); //string UserZip = requestParameters["UserZip"].ToString(); string UserCity = requestParameters["UserCity"].ToString(); string UserEmail = requestParameters["UserEmail"].ToString(); string UserHomeRegion = requestParameters["UserHomeRegion"].ToString(); string UserDOBMonth = requestParameters["UserDOBMonth"].ToString(); string UserDOBDay = requestParameters["UserDOBDay"].ToString(); string UserDOBYear = requestParameters["UserDOBYear"].ToString(); string AvatarArchive = requestParameters.ContainsKey("AvatarArchive") ? requestParameters["AvatarArchive"].ToString() : ""; bool ToSAccept = requestParameters.ContainsKey("ToSAccept") && requestParameters["ToSAccept"].ToString() == "Accepted"; string UserType = requestParameters.ContainsKey("UserType") // only admins can set membership ? requestParameters ["UserType"].ToString() : "Resident"; // revise UserDOBMonth to a number UserDOBMonth = ShortMonthToNumber(UserDOBMonth); // revise Type flags int UserFlags = WebHelpers.UserTypeToUserFlags(UserType); // a bit of idiot proofing if (AvatarName == "") { response = "<h3>" + translator.GetTranslatedString("AvatarNameError") + "</h3>"; return(null); } if ((AvatarPassword == "") || (AvatarPassword != AvatarPasswordCheck)) { response = "<h3>" + translator.GetTranslatedString("AvatarPasswordError") + "</h3>"; return(null); } if (UserEmail == "") { response = "<h3>" + translator.GetTranslatedString("AvatarEmailError") + "</h3>"; return(null); } // Thish - Only one space is allowed in the name to seperate First and Last of the avatar name if (AvatarName.Split(' ').Length != 2) { response = "<h3>" + translator.GetTranslatedString("AvatarNameSpacingError") + "</h3>"; return(null); } // so far so good... if (ToSAccept) { AvatarPassword = Util.Md5Hash(AvatarPassword); IUserAccountService accountService = webInterface.Registry.RequestModuleInterface <IUserAccountService>(); UUID userID = UUID.Random(); string error = accountService.CreateUser(userID, settings.DefaultScopeID, AvatarName, AvatarPassword, UserEmail); if (error == "") { // set the user account type UserAccount userAcct = accountService.GetUserAccount(null, userID); userAcct.UserFlags = UserFlags; accountService.StoreUserAccount(userAcct); // create and save agent info IAgentConnector con = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector> (); con.CreateNewAgent(userID); IAgentInfo agent = con.GetAgent(userID); agent.OtherAgentInformation ["RLFirstName"] = FirstName; agent.OtherAgentInformation ["RLLastName"] = LastName; //agent.OtherAgentInformation ["RLAddress"] = UserAddress; agent.OtherAgentInformation ["RLCity"] = UserCity; //agent.OtherAgentInformation ["RLZip"] = UserZip; agent.OtherAgentInformation ["UserDOBMonth"] = UserDOBMonth; agent.OtherAgentInformation ["UserDOBDay"] = UserDOBDay; agent.OtherAgentInformation ["UserDOBYear"] = UserDOBYear; agent.OtherAgentInformation ["UserFlags"] = UserFlags; /*if (activationRequired) * { * UUID activationToken = UUID.Random(); * agent.OtherAgentInformation["WebUIActivationToken"] = Util.Md5Hash(activationToken.ToString() + ":" + PasswordHash); * resp["WebUIActivationToken"] = activationToken; * }*/ con.UpdateAgent(agent); // create user profile details 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); } if (AvatarArchive != "") { profile.AArchiveName = AvatarArchive; List <AvatarArchive> avarchives = webInterface.Registry.RequestModuleInterface <IAvatarAppearanceArchiver>().GetAvatarArchives(); UUID snapshotUUID = UUID.Zero; foreach (var archive in avarchives) { if (archive.FolderName == AvatarArchive) { snapshotUUID = archive.Snapshot; } } if (snapshotUUID != UUID.Zero) { profile.Image = snapshotUUID; } } profile.MembershipGroup = WebHelpers.UserFlagToType(UserFlags, webInterface.EnglishTranslator); // membership is english profile.IsNewUser = true; profileData.UpdateUserProfile(profile); } IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService> (); Vector3 position = new Vector3(128, 128, 25); Vector3 lookAt = new Vector3(0, 0, 22); if (agentInfoService != null) { agentInfoService.SetHomePosition(userID.ToString(), (UUID)UserHomeRegion, position, lookAt); } vars.Add("ErrorMessage", "Successfully created account, redirecting to main page"); response = "<h3>Successfully created account, redirecting to main page</h3>" + "<script language=\"javascript\">" + "setTimeout(function() {window.location.href = \"index.html\";}, 3000);" + "</script>"; } else { vars.Add("ErrorMessage", "<h3>" + error + "</h3>"); response = "<h3>" + error + "</h3>"; } } else { response = "<h3>You did not accept the Terms of Service agreement.</h3>"; } return(null); } List <Dictionary <string, object> > daysArgs = new List <Dictionary <string, object> >(); for (int i = 1; i <= 31; i++) { daysArgs.Add(new Dictionary <string, object> { { "Value", i } }); } List <Dictionary <string, object> > yearsArgs = new List <Dictionary <string, object> >(); for (int i = 1950; i <= 2013; i++) { yearsArgs.Add(new Dictionary <string, object> { { "Value", i } }); } vars.Add("Days", daysArgs); vars.Add("Months", WebHelpers.ShortMonthSelections(translator)); //.monthsArgs); vars.Add("Years", yearsArgs); var sortBy = new Dictionary <string, bool>(); sortBy.Add("RegionName", true); var RegionListVars = new List <Dictionary <string, object> >(); var regions = Framework.Utilities.DataManager.RequestPlugin <IRegionData>().GetList((RegionFlags)0, RegionFlags.Hyperlink | RegionFlags.Foreign | RegionFlags.Hidden, null, null, sortBy); foreach (var region in regions) { RegionListVars.Add(new Dictionary <string, object> { { "RegionName", region.RegionName }, { "RegionUUID", region.RegionID } }); } vars.Add("RegionList", RegionListVars); vars.Add("UserHomeRegionText", translator.GetTranslatedString("UserHomeRegionText")); vars.Add("UserTypeText", translator.GetTranslatedString("UserTypeText")); vars.Add("UserType", WebHelpers.UserTypeArgs(translator)); vars.Add("AvatarArchive", WebHelpers.AvatarSelections(webInterface.Registry)); string tosLocation = ""; if (loginServerConfig != null && loginServerConfig.GetBoolean("UseTermsOfServiceOnFirstLogin", false)) { tosLocation = loginServerConfig.GetString("FileNameOfTOS", ""); tosLocation = PathHelpers.VerifyReadFile(tosLocation, ".txt", simBase.DefaultDataPath); } string ToS = "There are no Terms of Service currently. This may be changed at any point in the future."; if (tosLocation != "") { StreamReader reader = new StreamReader(Path.Combine(Environment.CurrentDirectory, tosLocation)); try { ToS = reader.ReadToEnd(); } finally { reader.Close(); } } // check for user name seed string[] m_userNameSeed = null; if (loginServerConfig != null) { string userNameSeed = loginServerConfig.GetString("UserNameSeed", ""); if (userNameSeed != "") { m_userNameSeed = userNameSeed.Split(','); } } Utilities.MarkovNameGenerator ufNames = new Utilities.MarkovNameGenerator(); Utilities.MarkovNameGenerator ulNames = new Utilities.MarkovNameGenerator(); string[] nameSeed = m_userNameSeed == null ? Utilities.UserNames : m_userNameSeed; string firstName = ufNames.FirstName(nameSeed, 3, 4); string lastName = ulNames.FirstName(nameSeed, 5, 6); string enteredName = firstName + " " + lastName; vars.Add("AvatarName", enteredName); vars.Add("ToSMessage", ToS); vars.Add("TermsOfServiceAccept", translator.GetTranslatedString("TermsOfServiceAccept")); vars.Add("TermsOfServiceText", translator.GetTranslatedString("TermsOfServiceText")); vars.Add("RegistrationsDisabled", ""); //vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled")); vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText")); vars.Add("AvatarNameText", translator.GetTranslatedString("AvatarNameText")); vars.Add("AvatarPasswordText", translator.GetTranslatedString("Password")); vars.Add("AvatarPasswordConfirmationText", translator.GetTranslatedString("PasswordConfirmation")); vars.Add("AvatarScopeText", translator.GetTranslatedString("AvatarScopeText")); vars.Add("FirstNameText", translator.GetTranslatedString("FirstNameText")); vars.Add("LastNameText", translator.GetTranslatedString("LastNameText")); vars.Add("UserAddressText", translator.GetTranslatedString("UserAddressText")); vars.Add("UserZipText", translator.GetTranslatedString("UserZipText")); vars.Add("UserCityText", translator.GetTranslatedString("UserCityText")); vars.Add("UserCountryText", translator.GetTranslatedString("UserCountryText")); vars.Add("UserDOBText", translator.GetTranslatedString("UserDOBText")); vars.Add("UserEmailText", translator.GetTranslatedString("UserEmailText")); vars.Add("Accept", translator.GetTranslatedString("Accept")); vars.Add("Submit", translator.GetTranslatedString("Submit")); vars.Add("SubmitURL", "register.html"); vars.Add("ErrorMessage", ""); vars.Add("Registrations", true); vars.Add("NoRegistrations", false); return(vars); }