Ejemplo n.º 1
0
        protected void btnWatchTopic_Click(object sender, EventArgs e)
        {
            ForumTopic forumTopic = ForumManager.GetTopicByID(this.TopicID);

            if (forumTopic == null)
            {
                return;
            }

            if (!ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User))
            {
                string loginURL = CommonHelper.GetLoginPageURL(true);
                Response.Redirect(loginURL);
            }

            ForumSubscription forumSubscription = ForumManager.GetAllSubscriptions(NopContext.Current.User.CustomerID,
                                                                                   0, forumTopic.ForumTopicID, 1, 0).FirstOrDefault();

            if (forumSubscription == null)
            {
                forumSubscription = ForumManager.InsertSubscription(Guid.NewGuid(),
                                                                    NopContext.Current.User.CustomerID, 0, forumTopic.ForumTopicID, DateTime.Now);
            }
            else
            {
                ForumManager.DeleteSubscription(forumSubscription.ForumSubscriptionID);
            }

            CommonHelper.ReloadCurrentPage();
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CommonHelper.EnsureNonSSL();
            }

            ForumTopic forumTopic = ForumManager.GetTopicByID(this.TopicID);

            if (forumTopic != null)
            {
                string title = forumTopic.Subject;
                SEOHelper.RenderTitle(this, title, true);
            }
        }
Ejemplo n.º 3
0
        protected void btnReply_Click(object sender, EventArgs e)
        {
            ForumTopic forumTopic = ForumManager.GetTopicByID(this.TopicID);

            if (forumTopic != null)
            {
                if (!ForumManager.IsUserAllowedToCreatePost(NopContext.Current.User, forumTopic))
                {
                    string loginURL = CommonHelper.GetLoginPageURL(true);
                    Response.Redirect(loginURL);
                }

                string newForumPostURL = SEOHelper.GetNewForumPostURL(forumTopic.ForumTopicID);
                Response.Redirect(newForumPostURL);
            }
        }
Ejemplo n.º 4
0
        protected void btnMoveTopic_Click(object sender, EventArgs e)
        {
            ForumTopic forumTopic = ForumManager.GetTopicByID(this.TopicID);

            if (forumTopic != null)
            {
                if (!ForumManager.IsUserAllowedToMoveTopic(NopContext.Current.User, forumTopic))
                {
                    string loginURL = CommonHelper.GetLoginPageURL(true);
                    Response.Redirect(loginURL);
                }

                string moveForumTopicURL = SEOHelper.GetMoveForumTopicURL(forumTopic);
                Response.Redirect(moveForumTopicURL);
            }
        }
Ejemplo n.º 5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                ForumTopic forumTopic = ForumManager.GetTopicByID(this.ForumTopicID);
                if (forumTopic == null)
                {
                    Response.Redirect(SEOHelper.GetForumMainURL());
                }

                ForumManager.MoveTopic(forumTopic.ForumTopicID, ctrlForumSelector.SelectedForumId);
                string topicURL = SEOHelper.GetForumTopicURL(forumTopic.ForumTopicID);
                Response.Redirect(topicURL);
            }
            catch (Exception exc)
            {
                pnlError.Visible   = true;
                lErrorMessage.Text = Server.HtmlEncode(exc.Message);
            }
        }
Ejemplo n.º 6
0
 protected void btnCancel_Click(object sender, EventArgs e)
 {
     try
     {
         ForumTopic forumTopic = ForumManager.GetTopicByID(this.ForumTopicID);
         if (forumTopic != null)
         {
             string topicUrl = SEOHelper.GetForumTopicURL(forumTopic.ForumTopicID);
             Response.Redirect(topicUrl);
         }
         else
         {
             Response.Redirect(SEOHelper.GetForumMainURL());
         }
     }
     catch (Exception exc)
     {
         pnlError.Visible   = true;
         lErrorMessage.Text = Server.HtmlEncode(exc.Message);
     }
 }
Ejemplo n.º 7
0
        private void BindData()
        {
            pnlError.Visible = false;

            ForumTopic forumTopic = ForumManager.GetTopicByID(this.ForumTopicID);

            if (forumTopic == null)
            {
                Response.Redirect(SEOHelper.GetForumMainURL());
            }

            if (!ForumManager.IsUserAllowedToMoveTopic(NopContext.Current.User, forumTopic))
            {
                string loginURL = CommonHelper.GetLoginPageURL(true);
                Response.Redirect(loginURL);
            }

            ctrlForumBreadcrumb.ForumTopicID = forumTopic.ForumTopicID;
            ctrlForumBreadcrumb.BindData();

            ctrlForumSelector.SelectedForumId = forumTopic.ForumID;
            ctrlForumSelector.BindData();
        }
Ejemplo n.º 8
0
        private void BindData()
        {
            ForumTopic forumTopic = ForumManager.GetTopicByID(this.TopicID, true);

            if (forumTopic != null)
            {
                btnEdit.Visible      = ForumManager.IsUserAllowedToEditTopic(NopContext.Current.User, forumTopic);
                btnDelete.Visible    = ForumManager.IsUserAllowedToDeleteTopic(NopContext.Current.User, forumTopic);
                btnMoveTopic.Visible = ForumManager.IsUserAllowedToMoveTopic(NopContext.Current.User, forumTopic);
                //btnReply.Visible = ForumManager.IsUserAllowedToCreatePost(NopContext.Current.User, forumTopic);

                lblTopicSubject.Text = Server.HtmlEncode(forumTopic.Subject);

                int totalRecords = 0;
                int pageSize     = 10;
                if (ForumManager.PostsPageSize > 0)
                {
                    pageSize = ForumManager.PostsPageSize;
                }

                ForumPostCollection forumPosts = ForumManager.GetAllPosts(forumTopic.ForumTopicID, 0, string.Empty,
                                                                          pageSize, this.CurrentPageIndex, out totalRecords);
                if (forumPosts.Count > 0)
                {
                    this.postsPager1.PageSize     = pageSize;
                    this.postsPager1.TotalRecords = totalRecords;
                    this.postsPager1.PageIndex    = this.CurrentPageIndex;

                    this.postsPager2.PageSize     = pageSize;
                    this.postsPager2.TotalRecords = totalRecords;
                    this.postsPager2.PageIndex    = this.CurrentPageIndex;

                    rptrPosts.DataSource = forumPosts;
                    rptrPosts.DataBind();
                }

                //subsciption
                if (ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User))
                {
                    ForumSubscription forumSubscription = ForumManager.GetAllSubscriptions(NopContext.Current.User.CustomerID,
                                                                                           0, forumTopic.ForumTopicID, 1, 0).FirstOrDefault();

                    if (forumSubscription == null)
                    {
                        btnWatchTopic.Text  = GetLocaleResourceString("Forum.WatchTopic");
                        btnWatchTopic2.Text = GetLocaleResourceString("Forum.WatchTopic");
                    }
                    else
                    {
                        btnWatchTopic.Text  = GetLocaleResourceString("Forum.UnwatchTopic");
                        btnWatchTopic2.Text = GetLocaleResourceString("Forum.UnwatchTopic");
                    }
                }
                else
                {
                    btnWatchTopic.Visible  = false;
                    btnWatchTopic2.Visible = false;
                }
            }
            else
            {
                Response.Redirect(SEOHelper.GetForumMainURL());
            }
        }
Ejemplo n.º 9
0
        public void BindData()
        {
            hlHome.NavigateUrl       = CommonHelper.GetStoreLocation();
            hlForumsHome.NavigateUrl = SEOHelper.GetForumMainURL();

            //topic
            ForumTopic forumTopic = ForumManager.GetTopicByID(this.ForumTopicID);

            if (forumTopic != null)
            {
                hlForumTopic.NavigateUrl = SEOHelper.GetForumTopicURL(forumTopic.ForumTopicID);
                hlForumTopic.Text        = Server.HtmlEncode(forumTopic.Subject);
            }
            else
            {
                phForumTopic.Visible = false;
            }

            //forum
            Forum forum = null;

            if (forumTopic != null)
            {
                forum = ForumManager.GetForumByID(forumTopic.ForumID);
            }
            else
            {
                forum = ForumManager.GetForumByID(this.ForumID);
            }

            if (forum != null)
            {
                hlForum.NavigateUrl = SEOHelper.GetForumURL(forum);
                hlForum.Text        = Server.HtmlEncode(forum.Name);
            }
            else
            {
                phForum.Visible = false;
            }

            //forum group
            ForumGroup forumGroup = null;

            if (forum != null)
            {
                forumGroup = ForumManager.GetForumGroupByID(forum.ForumGroupID);
            }
            else
            {
                forumGroup = ForumManager.GetForumGroupByID(this.ForumGroupID);
            }

            if (forumGroup != null)
            {
                hlForumGroup.NavigateUrl = SEOHelper.GetForumGroupURL(forumGroup);
                hlForumGroup.Text        = Server.HtmlEncode(forumGroup.Name);
            }
            else
            {
                phForumTopic.Visible = false;
            }
        }
Ejemplo n.º 10
0
        private void BindData()
        {
            pnlError.Visible = false;

            txtTopicBodySimple.Visible = false;
            txtTopicBodyBBCode.Visible = false;
            txtTopicBodyHtml.Visible   = false;
            switch (ForumManager.ForumEditor)
            {
            case EditorTypeEnum.SimpleTextBox:
            {
                txtTopicBodySimple.Visible     = true;
                rfvTopicBody.ControlToValidate = "txtTopicBodySimple";
            }
            break;

            case EditorTypeEnum.BBCodeEditor:
            {
                txtTopicBodyBBCode.Visible     = true;
                rfvTopicBody.ControlToValidate = "txtTopicBodyBBCode";
            }
            break;

            case EditorTypeEnum.HtmlEditor:
            {
                txtTopicBodyHtml.Visible = true;
                rfvTopicBody.Enabled     = false;
            }
            break;

            default:
                break;
            }

            if (this.AddTopic)
            {
                #region Adding topic

                Forum forum = ForumManager.GetForumByID(this.ForumID);
                if (forum == null)
                {
                    Response.Redirect(SEOHelper.GetForumMainURL());
                }

                if (!ForumManager.IsUserAllowedToCreateTopic(NopContext.Current.User, forum))
                {
                    string loginURL = CommonHelper.GetLoginPageURL(true);
                    Response.Redirect(loginURL);
                }

                lblTitle.Text         = GetLocaleResourceString("Forum.NewTopic");
                phForumName.Visible   = true;
                lblForumName.Text     = Server.HtmlEncode(forum.Name);
                txtTopicTitle.Visible = true;
                txtTopicTitle.Text    = string.Empty;
                lblTopicTitle.Visible = false;
                lblTopicTitle.Text    = string.Empty;

                ctrlForumBreadcrumb.ForumID = forum.ForumID;
                ctrlForumBreadcrumb.BindData();

                phPriority.Visible  = ForumManager.IsUserAllowedToSetTopicPriority(NopContext.Current.User);
                phSubscribe.Visible = ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User);

                #endregion
            }
            else if (this.EditTopic)
            {
                #region Editing topic
                ForumTopic forumTopic = ForumManager.GetTopicByID(this.ForumTopicID);

                if (forumTopic == null)
                {
                    Response.Redirect(SEOHelper.GetForumMainURL());
                }

                if (!ForumManager.IsUserAllowedToEditTopic(NopContext.Current.User, forumTopic))
                {
                    string loginURL = CommonHelper.GetLoginPageURL(true);
                    Response.Redirect(loginURL);
                }

                Forum forum = forumTopic.Forum;
                if (forum == null)
                {
                    Response.Redirect(SEOHelper.GetForumMainURL());
                }

                lblTitle.Text         = GetLocaleResourceString("Forum.EditTopic");
                phForumName.Visible   = true;
                lblForumName.Text     = Server.HtmlEncode(forum.Name);
                txtTopicTitle.Visible = true;
                txtTopicTitle.Text    = forumTopic.Subject;
                lblTopicTitle.Visible = false;
                lblTopicTitle.Text    = string.Empty;

                ctrlForumBreadcrumb.ForumTopicID = forumTopic.ForumTopicID;
                ctrlForumBreadcrumb.BindData();

                CommonHelper.SelectListItem(this.ddlPriority, forumTopic.TopicTypeID);

                ForumPost firstPost = forumTopic.FirstPost;
                if (firstPost != null)
                {
                    switch (ForumManager.ForumEditor)
                    {
                    case EditorTypeEnum.SimpleTextBox:
                    {
                        txtTopicBodySimple.Text = firstPost.Text;
                    }
                    break;

                    case EditorTypeEnum.BBCodeEditor:
                    {
                        txtTopicBodyBBCode.Text = firstPost.Text;
                    }
                    break;

                    case EditorTypeEnum.HtmlEditor:
                    {
                        txtTopicBodyHtml.Value = firstPost.Text;
                    }
                    break;

                    default:
                        break;
                    }
                }


                phPriority.Visible = ForumManager.IsUserAllowedToSetTopicPriority(NopContext.Current.User);
                //subscription
                if (ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User.CustomerID))
                {
                    phSubscribe.Visible = true;
                    ForumSubscription forumSubscription = ForumManager.GetAllSubscriptions(NopContext.Current.User.CustomerID,
                                                                                           0, forumTopic.ForumTopicID, 1, 0).FirstOrDefault();
                    cbSubscribe.Checked = forumSubscription != null;
                }
                else
                {
                    phSubscribe.Visible = false;
                }
                #endregion
            }
            else if (this.AddPost)
            {
                #region Adding post

                ForumTopic forumTopic = ForumManager.GetTopicByID(this.ForumTopicID);
                if (forumTopic == null)
                {
                    Response.Redirect(SEOHelper.GetForumMainURL());
                }

                if (!ForumManager.IsUserAllowedToCreatePost(NopContext.Current.User, forumTopic))
                {
                    string loginURL = CommonHelper.GetLoginPageURL(true);
                    Response.Redirect(loginURL);
                }

                ctrlForumBreadcrumb.ForumTopicID = forumTopic.ForumTopicID;
                ctrlForumBreadcrumb.BindData();

                lblTitle.Text         = GetLocaleResourceString("Forum.NewPost");
                phForumName.Visible   = false;
                lblForumName.Text     = string.Empty;
                txtTopicTitle.Visible = false;
                txtTopicTitle.Text    = string.Empty;
                lblTopicTitle.Visible = true;
                lblTopicTitle.Text    = Server.HtmlEncode(forumTopic.Subject);

                phPriority.Visible = false;
                //subscription
                if (ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User))
                {
                    phSubscribe.Visible = true;
                    ForumSubscription forumSubscription = ForumManager.GetAllSubscriptions(NopContext.Current.User.CustomerID,
                                                                                           0, forumTopic.ForumTopicID, 1, 0).FirstOrDefault();
                    cbSubscribe.Checked = forumSubscription != null;
                }
                else
                {
                    phSubscribe.Visible = false;
                }
                #endregion
            }
            else if (this.EditPost)
            {
                #region Editing post

                ForumPost forumPost = ForumManager.GetPostByID(this.ForumPostID);

                if (forumPost == null)
                {
                    Response.Redirect(SEOHelper.GetForumMainURL());
                }

                if (!ForumManager.IsUserAllowedToEditPost(NopContext.Current.User, forumPost))
                {
                    string loginURL = CommonHelper.GetLoginPageURL(true);
                    Response.Redirect(loginURL);
                }

                ForumTopic forumTopic = forumPost.Topic;
                if (forumTopic == null)
                {
                    Response.Redirect(SEOHelper.GetForumMainURL());
                }

                lblTitle.Text         = GetLocaleResourceString("Forum.EditPost");
                phForumName.Visible   = false;
                lblForumName.Text     = string.Empty;
                txtTopicTitle.Visible = false;
                txtTopicTitle.Text    = string.Empty;
                lblTopicTitle.Visible = true;
                lblTopicTitle.Text    = Server.HtmlEncode(forumTopic.Subject);

                ctrlForumBreadcrumb.ForumTopicID = forumTopic.ForumTopicID;
                ctrlForumBreadcrumb.BindData();


                switch (ForumManager.ForumEditor)
                {
                case EditorTypeEnum.SimpleTextBox:
                {
                    txtTopicBodySimple.Text = forumPost.Text;
                }
                break;

                case EditorTypeEnum.BBCodeEditor:
                {
                    txtTopicBodyBBCode.Text = forumPost.Text;
                }
                break;

                case EditorTypeEnum.HtmlEditor:
                {
                    txtTopicBodyHtml.Value = forumPost.Text;
                }
                break;

                default:
                    break;
                }

                phPriority.Visible = false;
                //subscription
                if (ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User.CustomerID))
                {
                    phSubscribe.Visible = true;
                    ForumSubscription forumSubscription = ForumManager.GetAllSubscriptions(NopContext.Current.User.CustomerID,
                                                                                           0, forumTopic.ForumTopicID, 1, 0).FirstOrDefault();
                    cbSubscribe.Checked = forumSubscription != null;
                }
                else
                {
                    phSubscribe.Visible = false;
                }
                #endregion
            }
            else
            {
                Response.Redirect(SEOHelper.GetForumMainURL());
            }
        }
Ejemplo n.º 11
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                string text = string.Empty;

                switch (ForumManager.ForumEditor)
                {
                case EditorTypeEnum.SimpleTextBox:
                {
                    text = txtTopicBodySimple.Text.Trim();
                }
                break;

                case EditorTypeEnum.BBCodeEditor:
                {
                    text = txtTopicBodyBBCode.Text.Trim();
                }
                break;

                case EditorTypeEnum.HtmlEditor:
                {
                    text = txtTopicBodyHtml.Value;
                }
                break;

                default:
                    break;
                }

                string             subject   = txtTopicTitle.Text;
                ForumTopicTypeEnum topicType = ForumTopicTypeEnum.Normal;
                bool subscribe = cbSubscribe.Checked;

                string IPAddress = string.Empty;
                if (HttpContext.Current != null && HttpContext.Current.Request != null)
                {
                    IPAddress = HttpContext.Current.Request.UserHostAddress;
                }

                DateTime nowDT = DateTime.Now;

                if (ForumManager.IsUserAllowedToSetTopicPriority(NopContext.Current.User))
                {
                    topicType = (ForumTopicTypeEnum)Enum.ToObject(typeof(ForumTopicTypeEnum), int.Parse(ddlPriority.SelectedItem.Value));
                }

                text = text.Trim();
                if (String.IsNullOrEmpty(text))
                {
                    throw new NopException(GetLocaleResourceString("Forum.TextCannotBeEmpty"));
                }

                if (this.AddTopic)
                {
                    #region Adding topic
                    Forum forum = ForumManager.GetForumByID(this.ForumID);
                    if (forum == null)
                    {
                        Response.Redirect(SEOHelper.GetForumMainURL());
                    }

                    if (!ForumManager.IsUserAllowedToCreateTopic(NopContext.Current.User, forum))
                    {
                        string loginURL = CommonHelper.GetLoginPageURL(true);
                        Response.Redirect(loginURL);
                    }

                    subject = subject.Trim();
                    if (String.IsNullOrEmpty(subject))
                    {
                        throw new NopException(GetLocaleResourceString("Forum.TopicSubjectCannotBeEmpty"));
                    }

                    ForumTopic forumTopic = ForumManager.InsertTopic(forum.ForumID, NopContext.Current.User.CustomerID,
                                                                     topicType, subject, 0, 0, 0, 0, null, nowDT, nowDT, true);

                    ForumPost forumPost = ForumManager.InsertPost(forumTopic.ForumTopicID, NopContext.Current.User.CustomerID,
                                                                  text, IPAddress, nowDT, nowDT, false);

                    forumTopic = ForumManager.UpdateTopic(forumTopic.ForumTopicID, forumTopic.ForumID,
                                                          forumTopic.UserID, forumTopic.TopicType, forumTopic.Subject, 1,
                                                          0, forumPost.ForumPostID, forumTopic.UserID,
                                                          forumPost.CreatedOn, forumTopic.CreatedOn, nowDT);

                    //subscription
                    if (ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User))
                    {
                        if (subscribe)
                        {
                            ForumSubscription forumSubscription = ForumManager.InsertSubscription(Guid.NewGuid(),
                                                                                                  NopContext.Current.User.CustomerID, 0, forumTopic.ForumTopicID, nowDT);
                        }
                    }

                    string topicURL = SEOHelper.GetForumTopicURL(forumTopic.ForumTopicID);
                    Response.Redirect(topicURL);
                    #endregion
                }
                else if (this.EditTopic)
                {
                    #region Editing topic
                    ForumTopic forumTopic = ForumManager.GetTopicByID(this.ForumTopicID);
                    if (forumTopic == null)
                    {
                        Response.Redirect(SEOHelper.GetForumMainURL());
                    }

                    if (!ForumManager.IsUserAllowedToEditTopic(NopContext.Current.User, forumTopic))
                    {
                        string loginURL = CommonHelper.GetLoginPageURL(true);
                        Response.Redirect(loginURL);
                    }

                    subject = subject.Trim();
                    if (String.IsNullOrEmpty(subject))
                    {
                        throw new NopException(GetLocaleResourceString("Forum.TopicSubjectCannotBeEmpty"));
                    }

                    forumTopic = ForumManager.UpdateTopic(forumTopic.ForumTopicID, forumTopic.ForumID,
                                                          forumTopic.UserID, topicType, subject, forumTopic.NumPosts,
                                                          forumTopic.Views, forumTopic.LastPostID, forumTopic.LastPostUserID,
                                                          forumTopic.LastPostTime, forumTopic.CreatedOn, nowDT);

                    ForumPost firstPost = forumTopic.FirstPost;
                    if (firstPost != null)
                    {
                        firstPost = ForumManager.UpdatePost(firstPost.ForumPostID, firstPost.TopicID,
                                                            firstPost.UserID, text, firstPost.IPAddress, firstPost.CreatedOn, nowDT);
                    }
                    else
                    {
                        //error
                        firstPost = ForumManager.InsertPost(forumTopic.ForumTopicID,
                                                            forumTopic.UserID, text, IPAddress, forumTopic.CreatedOn, nowDT, false);
                    }

                    //subscription
                    if (ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User.CustomerID))
                    {
                        ForumSubscription forumSubscription = ForumManager.GetAllSubscriptions(NopContext.Current.User.CustomerID,
                                                                                               0, forumTopic.ForumTopicID, 1, 0).FirstOrDefault();
                        if (subscribe)
                        {
                            if (forumSubscription == null)
                            {
                                forumSubscription = ForumManager.InsertSubscription(Guid.NewGuid(),
                                                                                    NopContext.Current.User.CustomerID, 0, forumTopic.ForumTopicID, nowDT);
                            }
                        }
                        else
                        {
                            if (forumSubscription != null)
                            {
                                ForumManager.DeleteSubscription(forumSubscription.ForumSubscriptionID);
                            }
                        }
                    }

                    string topicURL = SEOHelper.GetForumTopicURL(forumTopic.ForumTopicID);
                    Response.Redirect(topicURL);
                    #endregion
                }
                else if (this.AddPost)
                {
                    #region Adding post
                    ForumTopic forumTopic = ForumManager.GetTopicByID(this.ForumTopicID);
                    if (forumTopic == null)
                    {
                        Response.Redirect(SEOHelper.GetForumMainURL());
                    }

                    if (!ForumManager.IsUserAllowedToCreatePost(NopContext.Current.User, forumTopic))
                    {
                        string loginURL = CommonHelper.GetLoginPageURL(true);
                        Response.Redirect(loginURL);
                    }

                    ForumPost forumPost = ForumManager.InsertPost(this.ForumTopicID, NopContext.Current.User.CustomerID,
                                                                  text, IPAddress, nowDT, nowDT, true);

                    //subscription
                    if (ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User.CustomerID))
                    {
                        ForumSubscription forumSubscription = ForumManager.GetAllSubscriptions(NopContext.Current.User.CustomerID,
                                                                                               0, forumPost.TopicID, 1, 0).FirstOrDefault();
                        if (subscribe)
                        {
                            if (forumSubscription == null)
                            {
                                forumSubscription = ForumManager.InsertSubscription(Guid.NewGuid(),
                                                                                    NopContext.Current.User.CustomerID, 0, forumPost.TopicID, nowDT);
                            }
                        }
                        else
                        {
                            if (forumSubscription != null)
                            {
                                ForumManager.DeleteSubscription(forumSubscription.ForumSubscriptionID);
                            }
                        }
                    }


                    int pageSize = 10;
                    if (ForumManager.PostsPageSize > 0)
                    {
                        pageSize = ForumManager.PostsPageSize;
                    }
                    int    pageIndex = ForumManager.CalculateTopicPageIndex(forumPost.TopicID, pageSize, forumPost.ForumPostID);
                    string topicURL  = SEOHelper.GetForumTopicURL(forumPost.TopicID, "p", pageIndex + 1, forumPost.ForumPostID);
                    Response.Redirect(topicURL);
                    #endregion
                }
                else if (this.EditPost)
                {
                    #region Editing post
                    ForumPost forumPost = ForumManager.GetPostByID(this.ForumPostID);
                    if (forumPost == null)
                    {
                        Response.Redirect(SEOHelper.GetForumMainURL());
                    }

                    if (!ForumManager.IsUserAllowedToEditPost(NopContext.Current.User, forumPost))
                    {
                        string loginURL = CommonHelper.GetLoginPageURL(true);
                        Response.Redirect(loginURL);
                    }

                    forumPost = ForumManager.UpdatePost(forumPost.ForumPostID, forumPost.TopicID,
                                                        forumPost.UserID, text, forumPost.IPAddress, forumPost.CreatedOn, nowDT);

                    //subscription
                    if (ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User.CustomerID))
                    {
                        ForumSubscription forumSubscription = ForumManager.GetAllSubscriptions(NopContext.Current.User.CustomerID,
                                                                                               0, forumPost.TopicID, 1, 0).FirstOrDefault();
                        if (subscribe)
                        {
                            if (forumSubscription == null)
                            {
                                forumSubscription = ForumManager.InsertSubscription(Guid.NewGuid(),
                                                                                    NopContext.Current.User.CustomerID, 0, forumPost.TopicID, nowDT);
                            }
                        }
                        else
                        {
                            if (forumSubscription != null)
                            {
                                ForumManager.DeleteSubscription(forumSubscription.ForumSubscriptionID);
                            }
                        }
                    }

                    int pageSize = 10;
                    if (ForumManager.PostsPageSize > 0)
                    {
                        pageSize = ForumManager.PostsPageSize;
                    }
                    int    pageIndex = ForumManager.CalculateTopicPageIndex(forumPost.TopicID, pageSize, forumPost.ForumPostID);
                    string topicURL  = SEOHelper.GetForumTopicURL(forumPost.TopicID, "p", pageIndex + 1, forumPost.ForumPostID);
                    Response.Redirect(topicURL);
                    #endregion
                }
            }
            catch (Exception exc)
            {
                pnlError.Visible   = true;
                lErrorMessage.Text = Server.HtmlEncode(exc.Message);
            }
        }