Exemple #1
0
        protected void BindData()
        {
            Forum forum = ForumManager.GetForumByID(this.ForumID);

            if (forum != null)
            {
                //hlNewTopic.Visible = ForumManager.IsUserAllowedToCreateTopic(NopContext.Current.User, forum);

                lblForumName.Text        = Server.HtmlEncode(forum.Name);
                lblForumDescription.Text = Server.HtmlEncode(forum.Description);

                hlNewTopic.NavigateUrl = SEOHelper.GetNewForumTopicURL(forum.ForumID);

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

                ForumTopicCollection forumTopics = ForumManager.GetAllTopics(forum.ForumID, 0, string.Empty,
                                                                             false, pageSize, this.CurrentPageIndex, out totalRecords);
                if (forumTopics.Count > 0)
                {
                    this.topicsPager1.PageSize     = pageSize;
                    this.topicsPager1.TotalRecords = totalRecords;
                    this.topicsPager1.PageIndex    = this.CurrentPageIndex;

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

                    rptrTopics.DataSource = forumTopics;
                    rptrTopics.DataBind();
                }

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

                    if (forumSubscription == null)
                    {
                        btnWatchForum.Text = GetLocaleResourceString("Forum.WatchForum");
                    }
                    else
                    {
                        btnWatchForum.Text = GetLocaleResourceString("Forum.UnwatchForum");
                    }
                }
                else
                {
                    btnWatchForum.Visible = false;
                }
            }
            else
            {
                Response.Redirect(SEOHelper.GetForumMainURL());
            }
        }