Exemplo n.º 1
0
    /// <summary>
    /// Reloads the data of the forum control.
    /// </summary>
    public override void ReloadData()
    {
        base.ReloadData();

        this.UniPager1.Enabled  = this.EnableThreadPaging;
        this.UniPager1.PageSize = this.ThreadPageSize;

        // Hide selected area if forum is AdHoc
        if (this.IsAdHocForum)
        {
            plcHeader.Visible = false;
            if (ForumContext.CurrentForum.ForumID == 0)
            {
                plcContent.Visible = false;
            }
        }

        // Get thread and subscribe link url
        bool newThread       = base.IsAvailable(null, ForumActionType.NewThread);
        bool newSubscription = base.IsAvailable(null, ForumActionType.SubscribeToForum);
        bool newFavorites    = base.IsAvailable(null, ForumActionType.AddForumToFavorites);
        bool newBreadCrumbs  = (ForumBreadcrumbs1.GenerateBreadcrumbs() != "");

        // Hide separators according to the link visibility
        // Each separator is hidden if the item preceeding the separator is invisible or
        // no item is behind the separator.
        if (!newThread || (!newSubscription && !newFavorites && !newBreadCrumbs))
        {
            plcActionSeparator.Visible = false;
        }
        if (!newSubscription || (!newFavorites && !newBreadCrumbs))
        {
            plcAddToFavoritesSeparator.Visible = false;
        }
        if (!newFavorites || !newBreadCrumbs)
        {
            plcBreadcrumbsSeparator.Visible = false;
        }

        if ((ForumContext.CurrentForum != null) && (ForumContext.CurrentForum.ForumID > 0))
        {
            string orderBy = "PostStickOrder Desc, PostThreadLastPostTime DESC";
            if (ForumContext.UserIsModerator(this.ForumID, this.CommunityGroupID))
            {
                orderBy = "PostStickOrder Desc, PostThreadLastPostTimeAbsolute DESC";
            }

            // Retrieve data just for the current page
            int currentOffset = EnablePostsPaging ? ThreadPageSize * (UniPager1.CurrentPage - 1) : 0;
            int maxRecords    = EnablePostsPaging ? ThreadPageSize : 0;
            int totalRecords  = 0;

            listForums.DataSource = ForumPostInfoProvider.SelectForumPosts(this.ForumID, "/%", null, orderBy, 0, !ForumContext.UserIsModerator(this.ForumID, this.CommunityGroupID), -1, null, currentOffset, maxRecords, ref totalRecords);

            // Set the total number of records to the pager
            UniPager1.PagedControl.PagerForceNumberOfResults = totalRecords;

            listForums.DataBind();
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Reloads the data of the forum control.
    /// </summary>
    public override void ReloadData()
    {
        base.ReloadData();

        // Enable Inline macros resolving only if the dialogs are allowed
        if (ForumContext.CurrentForum != null)
        {
            if (ForumContext.CurrentForum.ForumEnableAdvancedImage)
            {
                allowedInlineControls = ControlsHelper.ALLOWED_FORUM_CONTROLS;
            }
        }

        this.UniPager1.Enabled  = this.EnablePostsPaging;
        this.UniPager1.PageSize = this.PostsPageSize;

        // Hide selected area if forum is AdHoc
        if (this.IsAdHocForum)
        {
            plcHeader.Visible = false;
        }

        this.ForumViewModeSelector1.Text = "<span>" + GetString("flatforum.modeslabel") + "</span>&nbsp;";

        if (ForumContext.CurrentMode != ForumMode.TopicMove)
        {
            this.plcMoveThread.Visible = false;
        }
        else
        {
            this.plcMoveThread.Visible  = true;
            this.threadMove.TopicMoved += new EventHandler(TopicMoved);
        }

        listForums.OuterData = ForumContext.CurrentForum;
        onlyPublish          = !ForumContext.UserIsModerator(this.ForumID, this.CommunityGroupID);

        // Retrieve data just for the current page
        int currentOffset = EnablePostsPaging ? PostsPageSize * (UniPager1.CurrentPage - 1) : 0;
        int maxRecords    = EnablePostsPaging ? PostsPageSize : 0;
        int totalRecords  = 0;

        listForums.DataSource = ForumPostInfoProvider.SelectForumPosts(this.ForumID, "/%", "PostIDPath Like '" + ForumPostInfoProvider.GetPath(null, this.ThreadID) + "%'", this.ThreadOrderBy, this.MaxRelativeLevel, onlyPublish, -1, null, currentOffset, maxRecords, ref totalRecords);

        // Set the total number of records to the pager
        UniPager1.PagedControl.PagerForceNumberOfResults = totalRecords;

        // Redirect to the upper level if there is no post
        if (DataHelper.DataSourceIsEmpty(listForums.DataSource))
        {
            ForumInfo fi = ForumContext.CurrentForum;
            if (fi != null)
            {
                string url = GetURL(fi, ForumActionType.Forum);
                if (!String.IsNullOrEmpty(url))
                {
                    URLHelper.Redirect(url);
                }
            }

            URLHelper.Redirect(URLHelper.RemoveParameterFromUrl(URLHelper.CurrentURL, "threadid"));
        }

        listForums.DataBind();
    }