protected void btnDelete_Click(object sender, EventArgs e)
        {
            var forumTopic = this.ForumService.GetTopicById(this.TopicId);

            if (forumTopic != null)
            {
                if (!this.ForumService.IsUserAllowedToDeleteTopic(NopContext.Current.User, forumTopic))
                {
                    string loginURL = SEOHelper.GetLoginPageUrl(true);
                    Response.Redirect(loginURL);
                }

                this.ForumService.DeleteTopic(forumTopic.ForumTopicId);

                string forumURL = SEOHelper.GetForumUrl(forumTopic.ForumId);
                Response.Redirect(forumURL);
            }
        }
        protected string GetForumTopicLink(ForumSubscription subscription)
        {
            if (subscription == null)
            {
                return(String.Empty);
            }

            Forum forum = subscription.Forum;

            if (forum != null)
            {
                return(SEOHelper.GetForumUrl(forum));
            }

            ForumTopic topic = subscription.Topic;

            if (topic != null)
            {
                return(SEOHelper.GetForumTopicUrl(topic));
            }

            return(String.Empty);
        }
Пример #3
0
        public void BindData()
        {
            hlHome.NavigateUrl       = CommonHelper.GetStoreLocation();
            hlForumsHome.NavigateUrl = SEOHelper.GetForumMainUrl();

            //topic
            var forumTopic = ForumManager.GetTopicById(this.ForumTopicId);

            if (forumTopic != null)
            {
                hlForumTopic.NavigateUrl = SEOHelper.GetForumTopicUrl(forumTopic);
                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;
            }
        }
 protected void btnCancel_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.AddTopic)
         {
             var forum = this.ForumService.GetForumById(this.ForumId);
             if (forum != null)
             {
                 string forumUrl = SEOHelper.GetForumUrl(forum);
                 Response.Redirect(forumUrl);
             }
             else
             {
                 Response.Redirect(SEOHelper.GetForumMainUrl());
             }
         }
         else if (this.EditTopic)
         {
             var forumTopic = this.ForumService.GetTopicById(this.ForumTopicId);
             if (forumTopic != null)
             {
                 string topicUrl = SEOHelper.GetForumTopicUrl(forumTopic);
                 Response.Redirect(topicUrl);
             }
             else
             {
                 Response.Redirect(SEOHelper.GetForumMainUrl());
             }
         }
         else if (this.AddPost)
         {
             var forumTopic = this.ForumService.GetTopicById(this.ForumTopicId);
             if (forumTopic != null)
             {
                 string topicUrl = SEOHelper.GetForumTopicUrl(forumTopic);
                 Response.Redirect(topicUrl);
             }
             else
             {
                 Response.Redirect(SEOHelper.GetForumMainUrl());
             }
         }
         else if (this.EditPost)
         {
             var forumPost = this.ForumService.GetPostById(this.ForumPostId);
             if (forumPost != null)
             {
                 string topicUrl = SEOHelper.GetForumTopicUrl(forumPost.TopicId);
                 Response.Redirect(topicUrl);
             }
             else
             {
                 Response.Redirect(SEOHelper.GetForumMainUrl());
             }
         }
     }
     catch (Exception exc)
     {
         pnlError.Visible   = true;
         lErrorMessage.Text = Server.HtmlEncode(exc.Message);
     }
 }