Beispiel #1
0
        private void UpdateUser()
        {
            userEmail = siteUser.Email;

            if (
                (siteUser.Email != txtEmail.Text) &&
                (SiteUser.EmailExistsInDB(siteSettings.SiteId, siteUser.UserId, txtEmail.Text))
                )
            {
                lblErrorMessage.Text = 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
            {
                //in case it is ever changed later to require password question and answer after making it not required
                // we need to ensure there is some question and answer.
                if (siteUser.PasswordQuestion.Length == 0)
                {
                    siteUser.PasswordQuestion = Resource.ManageUsersDefaultSecurityQuestion;
                    siteUser.PasswordAnswer   = Resource.ManageUsersDefaultSecurityAnswer;
                }
            }


            if (siteUser.LiveMessengerId.Length > 0)
            {
                siteUser.EnableLiveMessengerOnProfile = chkEnableLiveMessengerOnProfile.Checked;
            }
            else
            {
                siteUser.EnableLiveMessengerOnProfile = false;
            }

            if (allowUserSkin)
            {
                siteUser.Skin = SkinSetting.GetValue();
                //if (ddSkins.SelectedValue != "printerfriendly")
                //{
                //    siteUser.Skin = ddSkins.SelectedValue;
                //}
            }

#if !MONO
            ISettingControl setting = timeZoneSetting as ISettingControl;
            if (setting != null)
            {
                siteUser.TimeZoneId = setting.GetValue();
            }
#endif

            //if ((!disableOldAvatars)&&(!WebConfigSettings.OnlyAdminsCanEditCheesyAvatars))
            //{ siteUser.AvatarUrl = ddAvatars.SelectedValue; }
            siteUser.PasswordFormat = siteSettings.PasswordFormat;

            if (siteUser.Save())
            {
                mojoProfileConfiguration profileConfig = mojoProfileConfiguration.GetConfig();

                foreach (mojoProfilePropertyDefinition propertyDefinition in profileConfig.PropertyDefinitions)
                {
                    if (
                        (propertyDefinition.EditableByUser) &&
                        (
                            (propertyDefinition.OnlyAvailableForRoles.Length == 0) ||
                            (WebUser.IsInRoles(propertyDefinition.OnlyAvailableForRoles))
                        )
                        )
                    {
                        mojoProfilePropertyDefinition.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);

                SiteUtils.SetSkinCookie(siteUser);
                WebUtils.SetupRedirect(this, Request.RawUrl);
                return;
            }
        }
Beispiel #2
0
        private void UpdateSetting(BaseSetting setting, bool wasChanged)
        {
            #region BooleanSettings
            BooleanSetting newValue = setting as BooleanSetting;
            if (newValue != null)
            {
                var oldValue = Settings.FirstOrDefault(set => set.Equals(newValue));
                if (oldValue != null)
                {
                    BooleanSetting oldBoolValue = oldValue as BooleanSetting;
                    if (oldBoolValue != null)
                    {
                        if (wasChanged)
                        {
                            oldBoolValue.ChangeValue(newValue.Value);
                        }
                        else
                        {
                            oldBoolValue.ChangeValue(oldBoolValue.Value);
                        }
                        PublishSettingChangeNotification(setting, wasChanged);
                        return;
                    }
                }
            }
            #endregion

            #region IntegerSettings
            IntegerSetting newIntValue = setting as IntegerSetting;
            if (newIntValue != null)
            {
                var oldValue = Settings.FirstOrDefault(set => set.Equals(newIntValue));
                if (oldValue != null)
                {
                    IntegerSetting oldIntValue = oldValue as IntegerSetting;
                    if (oldIntValue != null)
                    {
                        if (wasChanged)
                        {
                            oldIntValue.ChangeValue(newIntValue.Value);
                        }
                        else
                        {
                            oldIntValue.ChangeValue(oldIntValue.Value);
                        }
                        PublishSettingChangeNotification(setting, wasChanged);
                        return;
                    }
                }
            }
            #endregion

            #region SkinSettings
            SkinSetting newSkinValue = setting as SkinSetting;
            if (newSkinValue != null)
            {
                var oldValue = Settings.FirstOrDefault(set => set.Equals(newSkinValue));
                if (oldValue != null)
                {
                    SkinSetting oldSkinValue = oldValue as SkinSetting;
                    if (oldSkinValue != null)
                    {
                        if (wasChanged)
                        {
                            oldSkinValue.ChangeValue(newSkinValue.Value);
                            Configuration.Skinning.CurrentSkin = newSkinValue.Value;
                        }
                        else
                        {
                            oldSkinValue.ChangeValue(oldSkinValue.Value);
                        }
                        PublishSettingChangeNotification(setting, wasChanged);
                        return;
                    }
                }
            }
            #endregion

            #region LocalizationSettings
            if (setting is LocalizationSetting newLocalizationValue)
            {
                var oldValue = Settings.FirstOrDefault(set => set.Equals(newLocalizationValue));
                if (oldValue != null)
                {
                    if (oldValue is LocalizationSetting oldLocalizationValue)
                    {
                        if (wasChanged)
                        {
                            oldLocalizationValue.ChangeValue(newLocalizationValue.Value);
                            Configuration.Localization.CurrentLanguage = newLocalizationValue.Value;
                        }
                        else
                        {
                            oldLocalizationValue.ChangeValue(oldLocalizationValue.Value);
                        }
                        PublishSettingChangeNotification(setting, wasChanged);
                        return;
                    }
                }
            }
            #endregion
        }
Beispiel #3
0
        private void PopulateControls()
        {
            this.lnkChangePassword.NavigateUrl = SiteRoot + "/Secure/ChangePassword.aspx";
            this.lnkChangePassword.Text        = Resource.UserChangePasswordLabel;
            ListItem listItem;

            if (allowUserSkin)
            {
                if (siteUser != null)
                {
                    SkinSetting.SetValue(siteUser.Skin);
                }
            }

            if ((siteSettings.AllowUserEditorPreference) && (siteUser != null) && (siteUser.EditorPreference.Length > 0))
            {
                listItem = ddEditorProviders.Items.FindByValue(siteUser.EditorPreference);
                if (listItem != null)
                {
                    ddEditorProviders.ClearSelection();
                    listItem.Selected = true;
                }
            }



            if (siteUser != null)
            {
#if !MONO
                ISettingControl setting = timeZoneSetting as ISettingControl;
                if (setting != null)
                {
                    setting.SetValue(siteUser.TimeZoneId);
                }
#endif

                txtName.Text      = SecurityHelper.RemoveMarkup(siteUser.Name);
                txtName.Enabled   = siteSettings.AllowUserFullNameChange;
                lblLoginName.Text = SecurityHelper.RemoveMarkup(siteUser.LoginName);
                txtEmail.Text     = siteUser.Email;
                //gravatar1.Email = siteUser.Email;
                lblOpenID.Text           = siteUser.OpenIdUri;
                txtPasswordQuestion.Text = siteUser.PasswordQuestion;
                txtPasswordAnswer.Text   = siteUser.PasswordAnswer;
                lblCreatedDate.Text      = siteUser.DateCreated.AddHours(timeOffset).ToString();
                lblTotalPosts.Text       = siteUser.TotalPosts.ToString();
                lnkUserPosts.UserId      = siteUser.UserId;
                lnkUserPosts.TotalPosts  = siteUser.TotalPosts;
                //lnkPublicProfile.NavigateUrl = SiteRoot + "/ProfileView.aspx?userid=" + siteUser.UserId.ToInvariantString();
                lnkPubProfile.NavigateUrl = SiteRoot + "/ProfileView.aspx?userid=" + siteUser.UserId.ToInvariantString();

                if (divLiveMessenger.Visible)
                {
                    WindowsLiveLogin     wl = WindowsLiveHelper.GetWindowsLiveLogin();
                    WindowsLiveMessenger m  = new WindowsLiveMessenger(wl);

                    if (WebConfigSettings.TestLiveMessengerDelegation)
                    {
                        lnkAllowLiveMessenger.NavigateUrl = m.ConsentOptInUrl;
                    }
                    else
                    {
                        lnkAllowLiveMessenger.NavigateUrl = m.NonDelegatedSignUpUrl;
                    }

                    if (siteUser.LiveMessengerId.Length > 0)
                    {
                        chkEnableLiveMessengerOnProfile.Checked = siteUser.EnableLiveMessengerOnProfile;
                        chkEnableLiveMessengerOnProfile.Enabled = true;
                    }
                    else
                    {
                        chkEnableLiveMessengerOnProfile.Checked = false;
                        chkEnableLiveMessengerOnProfile.Enabled = false;
                    }
                }


                //if ((!allowGravatars)&&(!disableAvatars))
                //{
                //    if (siteUser.AvatarUrl.Length > 0)
                //    {
                //        imgAvatar.Src = avatarPath + siteUser.AvatarUrl;
                //    }
                //    else
                //    {
                //        imgAvatar.Src = Page.ResolveUrl(WebConfigSettings.DefaultBlankAvatarPath);
                //    }
                //}

                userAvatar.UseGravatar      = allowGravatars;
                userAvatar.Email            = siteUser.Email;
                userAvatar.UserName         = siteUser.Name;
                userAvatar.UserId           = siteUser.UserId;
                userAvatar.AvatarFile       = siteUser.AvatarUrl;
                userAvatar.MaxAllowedRating = MaxAllowedGravatarRating;
                userAvatar.Disable          = disableAvatars;
                userAvatar.SiteId           = siteSettings.SiteId;
                userAvatar.UseLink          = false;
            }

            // this doesn't work
            //DoTabSelection();
        }