Esempio n. 1
0
    /// <summary>
    /// Stick thread event handler.
    /// </summary>
    protected void btnStickThread_Click(object sender, EventArgs e)
    {
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        if (PostInfo != null)
        {
            if (PostInfo.PostStickOrder > 0)
            {
                ForumPostInfoProvider.UnstickThread(PostInfo);
            }
            else
            {
                ForumPostInfoProvider.StickThread(PostInfo);
            }

            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_tree'].location.href = 'ForumPost_Tree.aspx?postid=" + PostInfo.PostId + "&forumid=" + PostInfo.PostForumID + "';");
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_edit'].location.href = 'ForumPost_View.aspx?postid=" + PostID + mListingParameter + "';");
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Handle actions.
    /// </summary>
    protected void actionsElem_ActionPerformed(object sender, CommandEventArgs e)
    {
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        switch (e.CommandName.ToLowerCSafe())
        {
        case "stick":

            ForumPostInfoProvider.StickThread(post);

            // Get the post object with updated info
            post = ForumPostInfoProvider.GetForumPostInfo(post.PostId);
            DisplayControl("view");
            break;

        case "unstick":

            ForumPostInfoProvider.UnstickThread(post);

            // Get the post object with updated info
            post = ForumPostInfoProvider.GetForumPostInfo(post.PostId);
            DisplayControl("view");
            break;

        case "split":

            ForumPostInfoProvider.SplitThread(post);

            // Get the post object with updated info
            post = ForumPostInfoProvider.GetForumPostInfo(post.PostId);
            DisplayControl("view");
            break;

        case "lockunlock":
            // Lock or unlock post
            post.PostIsLocked = !post.PostIsLocked;
            ForumPostInfoProvider.SetForumPostInfo(post);
            DisplayControl("view");
            break;

        case "edit":
            // Edit
            DisplayControl("edit");
            break;

        case "delete":
            // Delete post
            ForumPostInfoProvider.DeleteForumPostInfo(postId);
            postNew.ClearForm();
            DisplayControl("new");
            break;

        case "reply":
            // Reply
            DisplayControl("reply");
            break;

        case "approve":
            // Approve action
            if (MembershipContext.AuthenticatedUser != null)
            {
                post.PostApprovedByUserID = MembershipContext.AuthenticatedUser.UserID;
                post.PostApproved         = true;
                ForumPostInfoProvider.SetForumPostInfo(post);
            }

            DisplayControl("view");
            break;

        case "reject":
            // Reject action
            post.PostApprovedByUserID = 0;
            post.PostApproved         = false;
            ForumPostInfoProvider.SetForumPostInfo(post);

            DisplayControl("view");
            break;

        case "approvesubtree":
            // Approve subtree
            if ((post != null) && (MembershipContext.AuthenticatedUser != null))
            {
                post.PostApprovedByUserID = MembershipContext.AuthenticatedUser.UserID;
                post.PostApproved         = true;
                ForumPostInfoProvider.SetForumPostInfo(post);

                DataSet ds = ForumPostInfoProvider.GetChildPosts(post.PostId);

                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    // All posts under current post
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        ForumPostInfo mfpi = new ForumPostInfo(dr);
                        if (!mfpi.PostApproved)
                        {
                            mfpi.PostApprovedByUserID = MembershipContext.AuthenticatedUser.UserID;
                            mfpi.PostApproved         = true;
                            ForumPostInfoProvider.SetForumPostInfo(mfpi);
                        }
                    }
                }

                DisplayControl("view");
            }

            break;

        case "rejectsubtree":
            // Reject subtree
            if (post != null)
            {
                post.PostApprovedByUserID = 0;
                post.PostApproved         = false;
                ForumPostInfoProvider.SetForumPostInfo(post);

                DataSet ds = ForumPostInfoProvider.GetChildPosts(post.PostId);

                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    // All posts under current post
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        ForumPostInfo mfpi = new ForumPostInfo(dr);
                        if (mfpi.PostApproved)
                        {
                            mfpi.PostApprovedByUserID = 0;
                            mfpi.PostApproved         = false;
                            ForumPostInfoProvider.SetForumPostInfo(mfpi);
                        }
                    }
                }
                DisplayControl("view");
            }

            break;
        }

        hdnPost.Value = postId.ToString();
    }