コード例 #1
0
        protected void rptComments_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                Comment comment = (Comment)e.Item.DataItem;
                Panel pnlAuthor = (Panel)e.FindControlAs<Panel>("pnlAuthor");
                Panel pnlComment = (Panel)e.FindControlAs<Panel>("pnlComment");

                HyperLink hlTitle = e.FindControlAs<HyperLink>("hlTitle");
                ContentPageItem item = Sitecore.Context.Database.GetItem(comment.SitecoreId);
                if (item != null)
                {
                    hlTitle.NavigateUrl = item.GetUrl();
                    hlTitle.Text = item.PageTitle.Rendered;
                }

                Literal litDate = e.FindControlAs<Literal>("litDate");
                litDate.Text = UnderstoodDotOrg.Common.Helpers.DataFormatHelper.FormatDate(comment.CommentDate);

                Literal litComment = e.FindControlAs<Literal>("litComment");
                litComment.Text = UnderstoodDotOrg.Common.Helpers.TextHelper.TruncateText(
                    Sitecore.StringUtil.RemoveTags(HttpUtility.HtmlDecode(comment.Body)), commentCharLimit);

                Literal litLikeCount = e.FindControlAs<Literal>("litLikeCount");
                litLikeCount.Text = comment.Likes;

                if (e.Item.ItemIndex == 0 && DisplayAuthorInfo && ProfileMember != null)
                {
                    pnlAuthor.Visible = true;

                    Literal litScreenName = e.FindControlAs<Literal>("litScreenName");
                    litScreenName.Text = ProfileMember.ScreenName;

                    Literal litLastUpdated = e.FindControlAs<Literal>("litLastUpdated");
                    MembershipManager mm = new MembershipManager();
                    var user = mm.GetUser(ProfileMember.MemberId);
                    litLastUpdated.Text = user.LastActivityDate.ToString("hh:mmtt on MMM dd yyyy");
                }
                else
                {
                    pnlComment.CssClass += " offset-6";
                }
            }
        }
コード例 #2
0
        private void Page_Load(object sender, EventArgs e)
        {
            if (this.CurrentMember == null && this.CurrentUser == null)
            {
                if (!string.IsNullOrEmpty(CurrentPage.SignInPage.Url))
                {
                    Response.Redirect(CurrentPage.SignInPage.Url);
                }
                else
                {
                    Response.Redirect("/");
                }
            }

            if (!IsPostBack)
            {
                //update member
                MembershipManager membershipManager = new MembershipManager();
                this.CurrentMember = membershipManager.GetMember(this.CurrentMember.MemberId);
                this.CurrentUser = membershipManager.GetUser(this.CurrentMember.MemberId, true);

                MyProfileItem context = (MyProfileItem)Sitecore.Context.Item;
                HyperLink myHL = (HyperLink)this.FindControl("uxAddChild");
                myHL.Text = context.AddChildText;

                SetLabels();
                SetRole();

                uxChildList.DataSource = this.CurrentMember.Children;
                uxChildList.DataBind();

                //disable new children if you already have 6 or more
                if (this.CurrentMember.Children.Count >= 6)
                {
                    uxAddChild.Visible = false;
                }

                SetInterests();

                uxEmailAddress.Text = txtEmail.Text = this.CurrentUser.UserName;


                SetJourney();

                uxPassword.Text = replacePassword("digitalpulp!");

                string phoneNumber = string.Empty;

                if (!string.IsNullOrEmpty(this.CurrentMember.MobilePhoneNumber))
                {
                    phoneNumber = this.CurrentMember.MobilePhoneNumber.Replace("-", string.Empty).Trim();

                    //if (phoneNumber.Length == 10 && !phoneNumber.Contains("-"))
                    //{
                    phoneNumber = phoneNumber.Insert(3, "-");
                    phoneNumber = phoneNumber.Insert(7, "-");
                    //}
                }
                else
                {
                    //10 points to Gryffindor if you know where this phone number comes from
                    txtPhoneNumber.Attributes["placeholder"] = "212-555-2368";
                }

                uxPhoneNumber.Text = phoneNumber;
                txtPhoneNumber.Text = phoneNumber;

                uxPrivacyLevel.Text = this.CurrentMember.allowConnections ? DictionaryConstants.OpenToConnect : DictionaryConstants.NotOpenToConnect;

                uxScreenname.Text = this.CurrentMember.ScreenName;

                uxZipcode.Text = this.CurrentMember.ZipCode.Trim();

                uxAddChild.Text = string.Format(uxAddChild.Text, ((ChildCount)this.CurrentMember.Children.Count).ToString());
                uxAddChild.NavigateUrl = MyProfileStepTwoItem.GetCompleteMyProfileStepTwo().GetUrl() + "?" + Constants.QueryStrings.Registration.Mode + "=" + Constants.QueryStrings.Registration.ModeAdd;

                if (Session["PostReloadScript"] != null)
                {
                    string reloadScript = Session["PostReloadScript"].ToString();

                    if (reloadScript != "")
                    {
                        ltlJS.Text = string.Format("<script type=\"text/javascript\">{0}</script>", reloadScript);
                        Session["PostReloadScript"] = null;
                    }
                }

                //top of edit interests
                hypEditCommunityAboutMe.NavigateUrl = String.Format(MyProfileStepFourItem.GetCompleteMyProfileStepFour().GetUrl() + "?{0}={1}", Constants.QueryStrings.Registration.Mode, Constants.QueryStrings.Registration.ModeEdit);

                //jump to edit community
                hypEditCommunity.NavigateUrl = hypCompleteYourProfile.NavigateUrl = String.Format(MyProfileStepFourItem.GetCompleteMyProfileStepFour().GetUrl() + "?{0}={1}#community", Constants.QueryStrings.Registration.Mode, Constants.QueryStrings.Registration.ModeEdit);

                if (!string.IsNullOrEmpty(this.CurrentMember.ScreenName))
                {
                    hypViewAsVisitors.NavigateUrl = MembershipHelper.GetPublicProfileAsVisitorUrl(CurrentMember.ScreenName);
                    hypViewAsMembers.NavigateUrl = MembershipHelper.GetPublicProfileAsMemberUrl(CurrentMember.ScreenName);
                    hypViewAsFriends.NavigateUrl = MembershipHelper.GetPublicProfileUrl(CurrentMember.ScreenName);
                }
                else
                {
                    uxNoProfile.Visible = true;
                    uxPublicView.Visible = false;
                }
            }
        }
コード例 #3
0
        protected void lbSaveEmailPassword_Click(object sender, EventArgs e)
        {
            var action = false;

            try
            {
                if (!string.IsNullOrEmpty(this.txtEmail.Text))
                {
                    if (Regex.IsMatch(this.txtEmail.Text, Constants.Validators.Email))
                    {
                        //matched regex
                        if (this.UpdateEmail())
                        {
                            action = true;
                            
                            var membershipManager = new MembershipManager();

                            this.CurrentMember = membershipManager.GetMember(this.CurrentMember.MemberId);
                            this.CurrentUser = membershipManager.GetUser(this.CurrentMember.MemberId, true);
                        }
                        else
                        {
                            throw new Exception(DictionaryConstants.SomethingFailedError);
                        }
                    }
                    else
                    {
                        //did not match regex and not empty
                        throw new Exception(DictionaryConstants.PasswordErrorMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                litEmailPasswordError.Text += ex.Message;
            }

            try
            {

                if (!string.IsNullOrEmpty(this.txtOldPassword.Text) && !string.IsNullOrEmpty(this.txtNewPassword.Text) && !string.IsNullOrEmpty(this.txtConfirmNewPassword.Text))
                {
                    if (this.txtNewPassword.Text == this.txtConfirmNewPassword.Text 
                        && Regex.IsMatch(this.txtNewPassword.Text, Constants.Validators.Password) 
                        && Regex.IsMatch(this.txtOldPassword.Text, Constants.Validators.Password))
                    {
                        if (this.UpdatePassword())
                        {
                            action = true;
                        }
                        else
                        {
                            throw new Exception(DictionaryConstants.SomethingFailedError);
                        }
                    }
                    else
                    {
                        //new passwords don't match
                        throw new Exception(DictionaryConstants.PasswordMatchError);
                    }
                }
            }
            catch (Exception ex)
            {
                litEmailPasswordError.Text += ex.Message;
            }


            if (action)
            {
                Response.Redirect(Request.RawUrl, true);
            }
        }
コード例 #4
0
        private void doLogin()
        {

            //blow out any existing member when someone tries to sign in
            try
            {
                //Reset session backed my groups from Whats Happening Now
                Session["_selectedGroups"] = null;
               
                //lets make sure to reset all user&member info before we start inflating it
                this.FlushCurrentMemberUser();

                var membershipManager = new MembershipManager();

                var currentMember = new Member();

                if (!string.IsNullOrEmpty(AccessToken))
                {
                    var client = new Facebook.FacebookClient(AccessToken);
                    dynamic me = client.Get("me", new { fields = "email" });

                    currentMember = membershipManager.GetMember(me.email);
                }
                else
                {
                    currentMember = membershipManager.AuthenticateUser(uxEmailAddress.Text, uxPassword.Text);
                }

                if (currentMember != null)
                {
                    this.CurrentMember = currentMember;
                    this.CurrentUser = membershipManager.GetUser(currentMember.MemberId, true);

                    this.ProfileRedirect(Constants.UserPermission.AgreedToTerms, null, true);

                    //Redirect used here for profile??
                    this.ReturnRedirect();

                    var item = Sitecore.Context.Database.GetItem(Constants.Pages.MyAccount);
                    // if you get this far, clear the redirect session URL 

                    Response.Redirect(Sitecore.Links.LinkManager.GetItemUrl(item));
                }
            }
            catch (Exception ex)
            {
                uxError.Text = ex.Message;
            }
        }
コード例 #5
0
        protected void uxSubmit_Click(object sender, EventArgs e)
        {
            // server-side validation
            string name = string.Empty;
            string email = string.Empty;
            string password = string.Empty;
            
            string zip = uxZipCode.Text.RemoveHTML();
            bool newsletter = uxNewsletterSignup.Checked;
            bool isFacebookUser = !string.IsNullOrEmpty(AccessToken);

            if (!string.IsNullOrEmpty(uxFirstName.Text))
            {
                name = uxFirstName.Text.RemoveHTML();
            }

            if (!string.IsNullOrEmpty(uxEmailAddress.Text))
            {
                email = uxEmailAddress.Text;
            }

            if (isFacebookUser)
            {
                password = Constants.FacebookMember_Password;
            }
            else if (!string.IsNullOrEmpty(uxPassword.Text) && !string.IsNullOrEmpty(uxPasswordConfirm.Text) && uxPassword.Text == uxPasswordConfirm.Text)
            {
                password = uxPassword.Text;
            }

            if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password))
            {                
                // damnit barry, this is how you get ants. 
                // the site keeps breaking when we test, and its breaking ugly.
                // if someone clicks to create a new user, we have to blow up the existing user or we're going to have a problem.
                this.FlushRegisteringUser();

                //everything's cool
                if (this.registeringUser == null)
                {
                    this.registeringUser = new Domain.Membership.Member();
                }

                this.registeringUser.FirstName = name;
                
                //bg: adding in zip code
                this.registeringUser.ZipCode = zip.Trim();

                //adding marker for FB users
                this.registeringUser.isFacebookUser = isFacebookUser;

                var membershipManager = new MembershipManager();

                try
                {
                    // helps to call the right addMember method...
                    this.registeringUser = membershipManager.AddMember(this.registeringUser, email, password);
                }
                catch (Exception ex)
                {
                    uxErrorMessage.Text = ex.Message;
                    return;
                }

                this.CurrentMember = this.registeringUser;
                this.CurrentUser = membershipManager.GetUser(this.CurrentMember.MemberId);

                Response.Redirect(TermsandConditionsItem.GetTermsAndConditionsPage().GetUrl());
            }
            else
            {
                //something failed...
                uxErrorMessage.Text = DictionaryConstants.SomethingFailedError;
            }
        }
コード例 #6
0
        private void updateMember()
        {
            var membershipManager = new MembershipManager();

            try
            {
                //set current user/member
                this.CurrentMember = membershipManager.UpdateMember(this.registeringUser);

                if (mode != Constants.QueryStrings.Registration.ModeEdit)
                {
                    this.CurrentUser = membershipManager.GetUser(this.CurrentMember.MemberId);


                    //SalesforceManager sfMgr = new SalesforceManager("*****@*****.**",
                    //                                                 "8f9C3Ayq",
                    //                                                 "hlY0jOIILtogz3sQlLUtmERlu");

                    SalesforceManager sfMgr = new SalesforceManager(Constants.SALESFORCE_USERNAME,
                                                                    Constants.SALESFORCE_PASSWORD,
                                                                    Constants.SALESFORCE_TOKEN);
                    if (sfMgr.LoggedIn)
                    {
                        try
                        {
                            SalesforceActionResult result = sfMgr.CreateWebsiteMemberAsContact(this.CurrentMember, CurrentUser.Email);
                            if (result.Success == false)
                            {
                                Response.Write("<!-- Error 401 -->");
                            }
                        }
                        catch (Exception)
                        {
                            Response.Write("<!-- Error 501 -->");
                        }
                    }
                    else
                    {
                        Response.Write("<!-- Error 601 -->");
                    }
                    
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }