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

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

                ForumManager.DeleteTopic(forumTopic.ForumTopicID);

                string forumURL = SEOHelper.GetForumURL(forumTopic.ForumID);
                Response.Redirect(forumURL);
            }
        }
Exemplo n.º 2
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;
            }
        }
 protected void btnCancel_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.AddTopic)
         {
             Forum forum = ForumManager.GetForumByID(this.ForumID);
             if (forum != null)
             {
                 string forumUrl = SEOHelper.GetForumURL(forum);
                 Response.Redirect(forumUrl);
             }
             else
             {
                 Response.Redirect(SEOHelper.GetForumMainURL());
             }
         }
         else if (this.EditTopic)
         {
             ForumTopic forumTopic = ForumManager.GetTopicByID(this.ForumTopicID);
             if (forumTopic != null)
             {
                 string topicUrl = SEOHelper.GetForumTopicURL(forumTopic.ForumTopicID);
                 Response.Redirect(topicUrl);
             }
             else
             {
                 Response.Redirect(SEOHelper.GetForumMainURL());
             }
         }
         else if (this.AddPost)
         {
             ForumTopic forumTopic = ForumManager.GetTopicByID(this.ForumTopicID);
             if (forumTopic != null)
             {
                 string topicUrl = SEOHelper.GetForumTopicURL(forumTopic.ForumTopicID);
                 Response.Redirect(topicUrl);
             }
             else
             {
                 Response.Redirect(SEOHelper.GetForumMainURL());
             }
         }
         else if (this.EditPost)
         {
             ForumPost forumPost = ForumManager.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);
     }
 }