/// <summary>
    /// Handles the Click event of the btnDelete control.
    /// </summary>
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        // Check permissions
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        // Delete the post
        ForumPostInfoProvider.DeleteForumPostInfo(ValidationHelper.GetInteger(PostID, 0));

        // Reload the parent window
        RefreshParentWindow();
    }
    /// <summary>
    /// Approve, reject or delete post.
    /// </summary>
    protected void gridApprove_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLowerCSafe())
        {
        case "deletepost":
            ForumPostInfoProvider.DeleteForumPostInfo(ValidationHelper.GetInteger(actionArgument, 0));
            break;

        case "approve":
            ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(ValidationHelper.GetInteger(actionArgument, 0));
            if (fpi != null)
            {
                fpi.PostApprovedByUserID = MembershipContext.AuthenticatedUser.UserID;
                fpi.PostApproved         = true;
                ForumPostInfoProvider.SetForumPostInfo(fpi);
            }
            break;
        }

        RaiseOnAction(actionName, actionArgument);
    }
Esempio n. 3
0
    /// <summary>
    /// This function is executed by callback initiated by 'Delete' button in menu.
    /// </summary>
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        ForumPostInfoProvider.DeleteForumPostInfo(PostID);

        if (PostInfo.PostParentID == 0)
        {
            //reload post edit frames with actual data
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_tree'].location.href = 'ForumPost_Tree.aspx?forumid=" + PostInfo.PostForumID + "';");
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_edit'].location.href = 'ForumPost_View.aspx?forumid=" + PostInfo.PostForumID + mListingParameter + "';");
        }
        else
        {
            //reload post edit frames with actual data
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_tree'].location.href = 'ForumPost_Tree.aspx?postid=" + PostInfo.PostParentID + "&forumid=" + PostInfo.PostForumID + "';");
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_edit'].location.href = 'ForumPost_View.aspx?postid=" + PostInfo.PostParentID + mListingParameter + "';");
        }
    }
    protected void gridPosts_OnAction(string actionName, object actionArgument)
    {
        int postId = ValidationHelper.GetInteger(actionArgument, 0);

        if (actionName.ToLowerCSafe() == "delete")
        {
            if (CommunityGroupID == 0)
            {
                // Check forums modify permissions
                if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.forums", PERMISSION_MODIFY))
                {
                    RedirectToAccessDenied("cms.forums", PERMISSION_MODIFY);
                }
            }
            else
            {
                // Check group permissions
                CMSDeskPage.CheckGroupPermissions(CommunityGroupID, PERMISSION_MANAGE);
            }

            ForumPostInfoProvider.DeleteForumPostInfo(postId);
        }
    }
    /// <summary>
    /// Deletes forum post. Called when the "Delete post" button is pressed.
    /// Expects the CreateForumPost method to be run first.
    /// </summary>
    private bool DeleteForumPost()
    {
        // Prepare the parameters
        string where = "PostSubject LIKE N'My new post%'";
        string orderBy = "";
        string columns = "";
        int    topN    = 10;

        // Get the data
        DataSet posts = ForumPostInfoProvider.GetForumPosts(where, orderBy, topN, columns);

        if (!DataHelper.DataSourceIsEmpty(posts))
        {
            // Get the forum post
            ForumPostInfo deletePost = new ForumPostInfo(posts.Tables[0].Rows[0]);

            // Delete the forum post
            ForumPostInfoProvider.DeleteForumPostInfo(deletePost);

            return(true);
        }

        return(false);
    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        if (CommunityGroupID == 0)
        {
            // Check forums modify permissions
            if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.forums", PERMISSION_MODIFY))
            {
                RedirectToAccessDenied("cms.forums", PERMISSION_MODIFY);
            }
        }
        else
        {
            // Check group permissions
            CMSDeskPage.CheckGroupPermissions(CommunityGroupID, PERMISSION_MANAGE);
        }

        Action action = (Action)ValidationHelper.GetInteger(drpAction.SelectedValue, 0);
        What   what   = What.Selected; //(What)ValidationHelper.GetInteger(drpWhat.SelectedValue, 0);

        List <int> items = new List <int>();

        switch (what)
        {
        // Only selected posts
        case What.Selected:
            foreach (string item in gridPosts.SelectedItems)
            {
                items.Add(ValidationHelper.GetInteger(item, 0));
            }
            break;

        // On posts in unigrid
        case What.All:
            DataSet ds = gridPosts.GridView.DataSource as DataSet;
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    int postId = ValidationHelper.GetInteger(dr["PostId"], 0);
                    items.Add(postId);
                }
            }
            break;
        }

        // For all specified forum posts
        foreach (int postId in items)
        {
            ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(postId);
            if (fpi != null)
            {
                switch (action)
                {
                // Approve post
                case Action.Approve:
                    fpi.Approve();
                    break;

                // Approve subtree
                case Action.ApproveSubTree:
                    fpi.Approve(MembershipContext.AuthenticatedUser.UserID, true);
                    break;

                // Reject post
                case Action.Reject:
                    fpi.Reject();
                    break;

                // Reject subtree
                case Action.RejectSubTree:
                    fpi.Reject(true);
                    break;

                // Delete post
                case Action.Delete:
                    ForumPostInfoProvider.DeleteForumPostInfo(fpi);
                    break;
                }
            }
        }

        // If something happened
        if (items.Count > 0)
        {
            // Get rid of selection
            gridPosts.ResetSelection();

            // Reload unigrid to see changes
            gridPosts.ReloadData();

            // Force refresh post tree
            ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "RefreshPostTree", ScriptHelper.GetScript("SelectInTree(" + PostId + ", true);"));
        }
    }
Esempio n. 7
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();
    }