コード例 #1
0
 private void HandleSubmitedReview()
 {
     if (SaveReview())
     {
         User user    = AbleContext.Current.User;
         bool email   = (ProductReviewHelper.EmailVerificationRequired(_Profile, user));
         bool approve = (ProductReviewHelper.ApprovalRequired(user));
         if (email || approve)
         {
             //ADDITIONAL INSTRUCTIONS MUST BE PROVIDED TO CUSTOMER
             ConfirmPanel.Visible    = true;
             ReviewPanel.Visible     = false;
             ConfirmEmail.Visible    = email;
             ConfirmEmail.Text       = string.Format(ConfirmEmail.Text, _Profile.Email);
             ConfirmApproval.Visible = approve;
         }
         else
         {
             //THE REVIEW WILL APPEAR ON PAGE, NO NEED TO HAVE CONFIRMATION MESSAGE
             this.FormInitialized = false;
             if (ReviewSubmitted != null)
             {
                 ReviewSubmitted(this, new EventArgs());
             }
         }
     }
 }
コード例 #2
0
 protected void SubmitReviewButton_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         //VALIDATE CAPTCHA
         if (ProductReviewHelper.ImageVerificationRequired(AbleContext.Current.User))
         {
             if (CaptchaImage.Authenticate(CaptchaInput.Text))
             {
                 HandleSubmitedReview();
                 ReviewsRepeater.DataBind();
             }
             else
             {
                 CustomValidator invalidInput = new CustomValidator();
                 invalidInput.ID              = Guid.NewGuid().ToString();
                 invalidInput.Text            = "*";
                 invalidInput.ErrorMessage    = "You did not input the number correctly.";
                 invalidInput.IsValid         = false;
                 invalidInput.ValidationGroup = "ProductReviewForm";
                 phCaptchaValidators.Controls.Add(invalidInput);
                 RefreshCaptcha();
             }
             CaptchaInput.Text = string.Empty;
         }
         else
         {
             HandleSubmitedReview();
             ReviewsRepeater.DataBind();
         }
     }
 }
コード例 #3
0
        public void InitializeForm()
        {
            LoginLink.NavigateUrl = NavigationHelper.GetMobileStoreUrl(string.Format("~/Login.aspx?ReturnUrl={0}", Server.UrlEncode("ProductReviews.aspx?ProductId=" + _Product.Id)));

            StoreSettingsManager settings = AbleContext.Current.Store.Settings;

            if (settings.ProductReviewEnabled != UserAuthFilter.None && _Product.AllowReviews)
            {
                if ((settings.ProductReviewEnabled == UserAuthFilter.Registered) && (AbleContext.Current.User.IsAnonymous))
                {
                    RegisterPanel.Visible = true;
                    ReviewPanel.Visible   = false;
                }
                else
                {
                    //THE REVIEW FORM WILL BE ENABLED
                    User user = AbleContext.Current.User;
                    //DETERMINE IF WE NEED TO SUPPORT THE IMAGE CAPTCHA
                    trCaptcha.Visible = (ProductReviewHelper.ImageVerificationRequired(user));
                    if (trCaptcha.Visible)
                    {
                        //GENERATE A RANDOM NUMBER FOR IMAGE VERIFICATION
                        CaptchaImage.ChallengeText = StringHelper.RandomNumber(6);
                    }
                    //CHECK TO SEE IF WE CAN PREPOPULATE THE FORM
                    ReviewerProfile profile = user.ReviewerProfile;
                    if (profile != null)
                    {
                        //EMAIL ADDRESS IS ONLY VISIBLE FOR ANONYMOUS USERS
                        trEmailAddress1.Visible = (user.IsAnonymous || String.IsNullOrEmpty(GetUserEmail()));
                        trEmailAddress2.Visible = (user.IsAnonymous || String.IsNullOrEmpty(GetUserEmail()));
                        Email.Text    = profile.Email;
                        Name.Text     = profile.DisplayName;
                        Location.Text = profile.Location;
                        //CHECK FOR EXISTING REVIEW
                        if (_ProductReview == null)
                        {
                            _ProductReview = ProductReviewDataSource.LoadForProductAndReviewerProfile(_ProductId, profile.Id);
                        }
                        if (_ProductReview != null)
                        {
                            //EXISTING REVIEW FOUND, INITIALIZE FORM VALUES
                            //(THESE VALUES MAY BE OVERRIDEN BY FORM POST)
                            ListItem item = Rating.Items.FindByValue(_ProductReview.Rating.ToString("F0"));
                            if (item != null)
                            {
                                Rating.SelectedIndex = (Rating.Items.IndexOf(item));
                            }
                            ReviewTitle.Text = _ProductReview.ReviewTitle;
                            ReviewBody.Text  = _ProductReview.ReviewBody;
                        }
                    }
                    else if (!user.IsAnonymous)
                    {
                        trEmailAddress1.Visible = String.IsNullOrEmpty(GetUserEmail());
                        trEmailAddress2.Visible = String.IsNullOrEmpty(GetUserEmail());
                        Name.Text     = user.PrimaryAddress.FirstName;
                        Location.Text = user.PrimaryAddress.City;
                    }
                }
            }
            else
            {
                this.Controls.Clear();
            }
            this.FormInitialized = true;
        }