private void UpdateUser() { userEmail = siteUser.Email; if ( (siteUser.Email != txtEmail.Text) && (SiteUser.EmailExistsInDB(siteSettings.SiteId, txtEmail.Text)) ) { message.ErrorMessage = ResourceHelper.GetResourceString("Resource", "DuplicateEmailMessage"); return; } if ((siteSettings.AllowUserEditorPreference) && (divEditorPreference.Visible)) { siteUser.EditorPreference = ddEditorProviders.SelectedValue; } if (siteSettings.AllowUserFullNameChange) { siteUser.Name = txtName.Text; } siteUser.Email = txtEmail.Text; if (WebConfigSettings.LogIpAddressForEmailChanges) { if ((siteUser.UserId != -1) && (userEmail != siteUser.Email)) { log.Info("email for user changed from " + userEmail + " to " + siteUser.Email + " from ip address " + SiteUtils.GetIP4Address()); } } if (pnlSecurityQuestion.Visible) { siteUser.PasswordQuestion = this.txtPasswordQuestion.Text; siteUser.PasswordAnswer = this.txtPasswordAnswer.Text; } else { if (siteUser.PasswordQuestion.Length == 0) { siteUser.PasswordQuestion = ResourceHelper.GetResourceString("Resource", "ManageUsersDefaultSecurityQuestion"); siteUser.PasswordAnswer = ResourceHelper.GetResourceString("Resource", "ManageUsersDefaultSecurityAnswer"); } } if (siteUser.LiveMessengerId.Length > 0) { siteUser.EnableLiveMessengerOnProfile = chkEnableLiveMessengerOnProfile.Checked; } else { siteUser.EnableLiveMessengerOnProfile = false; } #if !MONO ISettingControl setting = timeZoneSetting as ISettingControl; if (setting != null) { siteUser.TimeZoneId = setting.GetValue(); } #endif if (siteUser.Save()) { gbProfileConfiguration profileConfig = gbProfileConfiguration.GetConfig(); foreach (gbProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions) { if ( (propertyDefinition.EditableByUser) && ( (propertyDefinition.OnlyAvailableForRoles.Length == 0) || (WebUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles)) ) ) { gbProfilePropertyDefinition.SaveProperty( siteUser, pnlProfileProperties, propertyDefinition, timeOffset, timeZone); } } siteUser.UpdateLastActivityTime(); if ((userEmail != siteUser.Email) && (siteSettings.UseEmailForLogin) && (!siteSettings.UseLdapAuth)) { FormsAuthentication.SetAuthCookie(siteUser.Email, false); } ProfileUpdatedEventArgs u = new ProfileUpdatedEventArgs(siteUser, false); OnUserUpdated(u); WebUtils.SetupRedirect(this, Request.RawUrl); return; } }
private void PopulateProfileControls() { if (siteUser == null) { return; } gbProfileConfiguration profileConfig = gbProfileConfiguration.GetConfig(); if (profileConfig != null) { foreach (gbProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions) { #if !MONO if (propertyDefinition.Name == gbProfilePropertyDefinition.TimeOffsetHoursKey) { continue; } #endif if (propertyDefinition.Name == gbProfilePropertyDefinition.TimeZoneIdKey) { continue; } if ( (propertyDefinition.VisibleToUser) && ( (propertyDefinition.OnlyAvailableForRoles.Length == 0) || (siteUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles)) ) ) { object propValue = siteUser.GetProperty(propertyDefinition.Name, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); if (propValue != null) { if (propertyDefinition.EditableByUser) { gbProfilePropertyDefinition.SetupPropertyControl( this, pnlProfileProperties, propertyDefinition, propValue.ToString(), timeOffset, timeZone, SiteRoot); } else { gbProfilePropertyDefinition.SetupReadOnlyPropertyControl( pnlProfileProperties, propertyDefinition, propValue.ToString(), timeOffset, timeZone); } } else { if (propertyDefinition.EditableByUser) { gbProfilePropertyDefinition.SetupPropertyControl( this, pnlProfileProperties, propertyDefinition, propertyDefinition.DefaultValue, timeOffset, timeZone, SiteRoot); } else { gbProfilePropertyDefinition.SetupReadOnlyPropertyControl( pnlProfileProperties, propertyDefinition, propertyDefinition.DefaultValue, timeOffset, timeZone); } } } } } }