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);"));
        }
    }