/// <summary>
    /// Loads data of edited user from DB.
    /// </summary>
    protected void LoadData()
    {
        if (userInfo == null)
        {
            // User does not exist
            return;
        }

        // Load user picture, even for post-back
        SetUserPictureArea();

        if (RequestHelper.IsPostBack())
        {
            // Do not re-set static content on post-back
            return;
        }

        if ((userInfo.UserSettings != null) && (userInfo.UserSettings.UserActivatedByUserID > 0))
        {
            UserInfo user = UserInfoProvider.GetUserInfo(userInfo.UserSettings.UserActivatedByUserID);
            if (user != null)
            {
                lblUserFullName.Text = HTMLHelper.HTMLEncode(user.FullName);
            }
        }

        if (String.IsNullOrEmpty(lblUserFullName.Text))
        {
            lblUserFullName.Text = GetString("general.na");
        }

        activationDate.SelectedDateTime = userInfo.UserSettings.UserActivationDate;
        txtCampaign.Text          = userInfo.UserCampaign;
        txtMessageNotifEmail.Text = userInfo.UserMessagingNotificationEmail;
        txtNickName.Text          = userInfo.UserNickName;
        LoadRegInfo(userInfo.UserSettings);
        timeZone.Value                     = userInfo.UserSettings.UserTimeZoneID;
        txtURLReferrer.Text                = userInfo.UserURLReferrer;
        txtUserSignature.Text              = userInfo.UserSignature;
        txtUserDescription.Text            = userInfo.UserSettings.UserDescription;
        chkWaitingForActivation.Checked    = userInfo.UserSettings.UserWaitingForApproval;
        chkLogActivities.Checked           = userInfo.UserSettings.UserLogActivities;
        badgeSelector.Value                = userInfo.UserSettings.UserBadgeID;
        txtUserLiveID.Text                 = userInfo.UserSettings.WindowsLiveID;
        txtFacebookUserID.Text             = userInfo.UserSettings.UserFacebookID;
        txtOpenID.Text                     = OpenIDUserInfoProvider.GetOpenIDByUserID(userInfo.UserID);
        txtLinkedInID.Text                 = userInfo.UserSettings.UserLinkedInID;
        chkUserShowIntroTile.Checked       = userInfo.UserSettings.UserShowIntroductionTile;
        txtUserActivityPoints.Text         = userInfo.UserSettings.UserActivityPoints.ToString();
        lblUserForumPostsValue.Text        = userInfo.UserSettings.UserForumPosts.ToString();
        lblUserBlogPostsValue.Text         = userInfo.UserSettings.UserBlogPosts.ToString();
        lblUserBlogCommentsValue.Text      = userInfo.UserSettings.UserBlogComments.ToString();
        rbtnlGender.SelectedValue          = userInfo.UserSettings.UserGender.ToString();
        dtUserDateOfBirth.SelectedDateTime = userInfo.UserSettings.UserDateOfBirth;
        lblUserMessageBoardPostsValue.Text = userInfo.UserSettings.UserMessageBoardPosts.ToString();
        txtUserSkype.Text                  = userInfo.UserSettings.UserSkype;
        txtUserIM.Text                     = userInfo.UserSettings.UserIM;
        txtPhone.Text    = userInfo.UserSettings.UserPhone;
        txtPosition.Text = userInfo.UserSettings.UserPosition;
    }
Example #2
0
    /// <summary>
    /// Updates OpenID for given user.
    /// </summary>
    private void UpdateOpenID(UserInfo ui)
    {
        if (ui != null)
        {
            string oldOpenID = OpenIDUserInfoProvider.GetOpenIDByUserID(ui.UserID) ?? "";
            string newOpenID = txtOpenID.Text.Trim();

            // Only update if Open ID has changed
            if (newOpenID != oldOpenID)
            {
                UserInfo uiUpdated = OpenIDUserInfoProvider.GetUserInfoByOpenID(newOpenID);

                // Make sure that only non-existing OpenID identifier can be saved
                if ((uiUpdated == null) || (uiUpdated.UserID == ui.UserID))
                {
                    // Update or delete given OpenID related to user
                    OpenIDUserInfoProvider.UpdateOpenIDUserInfo(oldOpenID, newOpenID, ui.UserID);
                }
                else
                {
                    ShowError(GetString("mem.openid.idassignedto") + uiUpdated.UserName);
                }
            }
        }
    }
    /// <summary>
    /// Loads data of edited user from DB.
    /// </summary>
    protected void LoadData()
    {
        //Check if user exists
        if (ui != null)
        {
            if (!RequestHelper.IsPostBack())
            {
                if ((ui.UserSettings != null) && (ui.UserSettings.UserActivatedByUserID > 0))
                {
                    UserInfo user = UserInfoProvider.GetUserInfo(ui.UserSettings.UserActivatedByUserID);
                    if (user != null)
                    {
                        lblUserFullName.Text = HTMLHelper.HTMLEncode(user.FullName);
                    }
                }

                if (String.IsNullOrEmpty(lblUserFullName.Text))
                {
                    lblUserFullName.Text = GetString("general.na");
                }

                activationDate.SelectedDateTime = ui.UserSettings.UserActivationDate;
                txtCampaign.Text          = ui.UserCampaign;
                txtMessageNotifEmail.Text = ui.UserMessagingNotificationEmail;
                txtNickName.Text          = ui.UserNickName;
                //txtCustomData.Text = ui.UserCustomData.GetData();
                //txtPreferences.Text = ui.UserSettings.UserPreferences.Value;
                LoadRegInfo(ui.UserSettings);
                timeZone.Value                     = ui.UserSettings.UserTimeZoneID;
                txtURLReferrer.Text                = ui.UserURLReferrer;
                txtUserSignature.Text              = ui.UserSignature;
                txtUserDescription.Text            = ui.UserSettings.UserDescription;
                chkWaitingForActivation.Checked    = ui.UserSettings.UserWaitingForApproval;
                chkLogActivities.Checked           = ui.UserSettings.UserLogActivities;
                badgeSelector.Value                = ui.UserSettings.UserBadgeID;
                txtUserLiveID.Text                 = ui.UserSettings.WindowsLiveID;
                txtFacebookUserID.Text             = ui.UserSettings.UserFacebookID;
                txtOpenID.Text                     = OpenIDUserInfoProvider.GetOpenIDByUserID(ui.UserID);
                txtLinkedInID.Text                 = ui.UserSettings.UserLinkedInID;
                chkUserShowSplashScreen.Checked    = ui.UserSettings.UserShowSplashScreen;
                txtUserActivityPoints.Text         = ui.UserSettings.UserActivityPoints.ToString();
                lblUserForumPostsValue.Text        = ui.UserSettings.UserForumPosts.ToString();
                lblUserBlogPostsValue.Text         = ui.UserSettings.UserBlogPosts.ToString();
                lblUserBlogCommentsValue.Text      = ui.UserSettings.UserBlogComments.ToString();
                rbtnlGender.SelectedValue          = ui.UserSettings.UserGender.ToString();
                dtUserDateOfBirth.SelectedDateTime = ui.UserSettings.UserDateOfBirth;
                lblUserMessageBoardPostsValue.Text = ui.UserSettings.UserMessageBoardPosts.ToString();
                txtUserSkype.Text                  = ValidationHelper.GetString(ui.UserSettings.GetValue("UserSkype"), "");
                txtUserIM.Text                     = ValidationHelper.GetString(ui.UserSettings.GetValue("UserIM"), "");
                txtPhone.Text    = ValidationHelper.GetString(ui.UserSettings.GetValue("UserPhone"), "");
                txtPosition.Text = ValidationHelper.GetString(ui.UserSettings.GetValue("UserPosition"), "");
            }

            // Load user picture, even for postback
            SetUserPictureArea(ui);
        }
    }
Example #4
0
    /// <summary>
    /// Handles btnOkExist click, joins existing user with OpenID.
    /// </summary>
    protected void btnOkExist_Click(object sender, EventArgs e)
    {
        // OpenID response object must be retrieved from session
        if (response != null)
        {
            if (txtUserName.Text != String.Empty)
            {
                // Try to authenticate user
                UserInfo ui = AuthenticationHelper.AuthenticateUser(txtUserName.Text, txtPassword.Text, CMSContext.CurrentSiteName);

                // Check banned IPs
                BannedIPInfoProvider.CheckIPandRedirect(CMSContext.CurrentSiteName, BanControlEnum.Login);

                if (ui != null)
                {
                    // Check if user is not already registered with different OpenID provider
                    string openID = OpenIDUserInfoProvider.GetOpenIDByUserID(ui.UserID);
                    if (String.IsNullOrEmpty(openID))
                    {
                        // Add OpenID token to user
                        OpenIDUserInfoProvider.AddOpenIDToUser((string)response["ClaimedIdentifier"], userProviderUrl, ui.UserID);

                        // Remove user info from session
                        SessionHelper.Remove(SESSION_NAME_USERDATA);
                        SessionHelper.Remove(SESSION_NAME_URL);

                        // Set authentication cookie and redirect to page
                        SetAuthCookieAndRedirect(ui);
                    }
                    // User is already registered under different OpenID provider
                    else
                    {
                        lblError.Text    = GetString("mem.openid.alreadyregistered");
                        plcError.Visible = true;
                    }
                }
                else // Invalid credentials
                {
                    lblError.Text    = GetString("Login_FailureText");
                    plcError.Visible = true;
                }
            }
            else // User did not fill the form
            {
                lblError.Text    = GetString("mem.openid.fillloginform");
                plcError.Visible = true;
            }
        }
    }
    /// <summary>
    /// Updates OpenID for given user.
    /// </summary>
    private void UpdateOpenID(UserInfo ui)
    {
        if (ui != null)
        {
            string   oldOpenID = OpenIDUserInfoProvider.GetOpenIDByUserID(ui.UserID);
            string   newOpenID = txtOpenID.Text.Trim();
            UserInfo uiUpdated = OpenIDUserInfoProvider.GetUserInfoByOpenID(newOpenID);

            // Make sure that only non-existing OpenID identificator can be saved
            if ((uiUpdated == null) || (uiUpdated.UserID == ui.UserID))
            {
                // Update or delete given OpenID related to user
                OpenIDUserInfoProvider.UpdateOpenIDUserInfo(oldOpenID, newOpenID, ui.UserID);
            }
            else
            {
                lblError.Text    = GetString("mem.openid.idassignedto") + uiUpdated.UserName;
                lblError.Visible = true;
            }
        }
    }
    /// <summary>
    /// Displays buttons depending on web part settings.
    /// </summary>
    protected void DisplayButtons()
    {
        // If user is already authenticated
        if (AuthenticationHelper.IsAuthenticated())
        {
            var openId = CacheHelper.Cache(cs =>
            {
                var id = OpenIDUserInfoProvider.GetOpenIDByUserID(MembershipContext.AuthenticatedUser.UserID);

                if (cs.Cached)
                {
                    var dependencyKey  = UserSettingsInfo.OBJECT_TYPE + "|byid|" + MembershipContext.AuthenticatedUser.UserSettings.UserSettingsID;
                    cs.CacheDependency = CacheHelper.GetCacheDependency(dependencyKey);
                }

                return(id);
            },
                                           new CacheSettings(CacheMinutes, UserSettingsInfo.OBJECT_TYPE, "openid", MembershipContext.AuthenticatedUser.UserSettings.UserSettingsID)
                                           );

            var isOpenIdUser = !String.IsNullOrEmpty(openId);

            // Signout is visible when ShowSignOut set to true and user has OpenID registered (this is ignored for design mode)
            if ((ShowSignOut && isOpenIdUser) || PortalContext.IsDesignMode(ViewMode))
            {
                // If text is set use text/button link
                if (!string.IsNullOrEmpty(SignOutText))
                {
                    // Button link
                    if (ShowAsButton)
                    {
                        pnlLogon.DefaultButton = btnSignOut.ID;
                        btnSignOut.Text        = SignOutText;
                        btnSignOut.Visible     = true;
                    }
                    // Text link
                    else
                    {
                        pnlLogon.DefaultButton = btnSignOutLink.ID;
                        btnSignOutLink.Text    = SignOutText;
                        btnSignOutLink.Visible = true;
                    }
                }
                // Image link
                else
                {
                    pnlLogon.DefaultButton   = btnSignOutImage.ID;
                    btnSignOutImage.ImageUrl = ResolveUrl(SignOutImageURL);
                    btnSignOutImage.Visible  = true;
                    btnSignOutImage.ToolTip  = GetString("webparts_membership_signoutbutton.signout");
                    btnSignOut.Text          = GetString("webparts_membership_signoutbutton.signout");
                }
            }
            else
            {
                Visible = false;
            }

            txtInput.Visible              = false;
            ltlScript.Visible             = false;
            ltlProvidersVariables.Visible = false;
        }
        else
        {
            // If text is set use text/button link
            if (!string.IsNullOrEmpty(SignInText))
            {
                // Button link
                if (ShowAsButton)
                {
                    pnlLogon.DefaultButton = btnSignIn.ID;
                    btnSignIn.Text         = SignInText;
                    btnSignIn.Visible      = true;
                }
                // Text link
                else
                {
                    pnlLogon.DefaultButton = btnSignInLink.ID;
                    btnSignInLink.Text     = SignInText;
                    btnSignInLink.Visible  = true;
                }
            }
            // Image link
            else
            {
                pnlLogon.DefaultButton  = btnSignInImage.ID;
                btnSignInImage.ImageUrl = ResolveUrl(SignInImageURL);
                btnSignInImage.Visible  = true;
                btnSignInImage.ToolTip  = GetString("webparts_membership_signoutbutton.signin");
                btnSignIn.Text          = GetString("webparts_membership_signoutbutton.signin");
            }

            txtInput.Visible              = true;
            ltlScript.Visible             = true;
            ltlProvidersVariables.Visible = true;
        }

        // Hide textbox when applicable
        if (!DisplayTextbox)
        {
            txtInput.Visible = false;
        }
    }
    /// <summary>
    /// Loads data of edited user from DB.
    /// </summary>
    protected void LoadData()
    {
        //Check if user exists
        if (ui != null)
        {
            if (!RequestHelper.IsPostBack())
            {
                if ((ui.UserSettings != null) && (ui.UserSettings.UserActivatedByUserID > 0))
                {
                    UserInfo user = UserInfoProvider.GetUserInfo(ui.UserSettings.UserActivatedByUserID);
                    if (user != null)
                    {
                        lblUserFullName.Text = HTMLHelper.HTMLEncode(user.FullName);
                    }
                }

                if (String.IsNullOrEmpty(lblUserFullName.Text))
                {
                    lblUserFullName.Text = GetString("general.na");
                }

                activationDate.SelectedDateTime = ui.UserSettings.UserActivationDate;
                txtCampaign.Text          = ui.UserCampaign;
                txtMessageNotifEmail.Text = ui.UserMessagingNotificationEmail;
                txtNickName.Text          = ui.UserNickName;
                //txtCustomData.Text = ui.UserCustomData.GetData();
                //txtPreferences.Text = ui.UserSettings.UserPreferences.Value;
                LoadRegInfo(ui.UserSettings);
                timeZone.Value                    = ui.UserSettings.UserTimeZoneID;
                txtURLReferrer.Text               = ui.UserURLReferrer;
                txtUserSignature.Text             = ui.UserSignature;
                txtUserDescription.Text           = ui.UserSettings.UserDescription;
                chkWaitingForActivation.Checked   = ui.UserSettings.UserWaitingForApproval;
                chkLogActivities.Checked          = ui.UserSettings.UserLogActivities;
                badgeSelector.Value               = ui.UserSettings.UserBadgeID;
                txtUserLiveID.Text                = ui.UserSettings.WindowsLiveID;
                txtFacebookUserID.Text            = ui.UserSettings.UserFacebookID;
                txtOpenID.Text                    = OpenIDUserInfoProvider.GetOpenIDByUserID(ui.UserID);
                txtLinkedInID.Text                = ui.UserSettings.UserLinkedInID;
                chkUserShowSplashScreen.Checked   = ui.UserSettings.UserShowSplashScreen;
                chkUserShowWebPartToolbar.Checked = ui.UserSettings.UserWebPartToolbarEnabled;
                chkUserShowWebPartToolbar.Attributes.Add("onclick", "javascript: document.getElementById('" + lblUserWebPartToolbarPosition.ClientID + "').style.display = document.getElementById('" + drpUserWebPartToolbarPosition.ClientID + "').style.display = (this.checked ? 'block' : 'none');");
                LoadWebPartToolbarPositions();
                drpUserWebPartToolbarPosition.SelectedValue = WebPartToolbarPositionEnumFunctions.GetWebPartToolbarPositionString(ui.UserSettings.UserWebPartToolbarPosition);
                if (!chkUserShowWebPartToolbar.Checked)
                {
                    lblUserWebPartToolbarPosition.Style.Add("display", "none");
                    drpUserWebPartToolbarPosition.Style.Add("display", "none");
                }

                txtUserActivityPoints.Text         = ui.UserSettings.UserActivityPoints.ToString();
                lblUserForumPostsValue.Text        = ui.UserSettings.UserForumPosts.ToString();
                lblUserBlogPostsValue.Text         = ui.UserSettings.UserBlogPosts.ToString();
                lblUserBlogCommentsValue.Text      = ui.UserSettings.UserBlogComments.ToString();
                rbtnlGender.SelectedValue          = ui.UserSettings.UserGender.ToString();
                dtUserDateOfBirth.SelectedDateTime = ui.UserSettings.UserDateOfBirth;
                lblUserMessageBoardPostsValue.Text = ui.UserSettings.UserMessageBoardPosts.ToString();
                txtUserSkype.Text = ValidationHelper.GetString(ui.UserSettings.GetValue("UserSkype"), "");
                txtUserIM.Text    = ValidationHelper.GetString(ui.UserSettings.GetValue("UserIM"), "");
                txtPhone.Text     = ValidationHelper.GetString(ui.UserSettings.GetValue("UserPhone"), "");
                txtPosition.Text  = ValidationHelper.GetString(ui.UserSettings.GetValue("UserPosition"), "");
            }

            // Load user picture, even for postback
            SetUserPictureArea(ui);
        }
    }