/// <summary>
    /// Gets and bulk updates forum posts. Called when the "Get and bulk update posts" button is pressed.
    /// Expects the CreateForumPost method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateForumPosts()
    {
        // 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))
        {
            // Loop through the individual items
            foreach (DataRow postDr in posts.Tables[0].Rows)
            {
                // Create object from DataRow
                ForumPostInfo modifyPost = new ForumPostInfo(postDr);

                // Update the properties
                modifyPost.PostSubject = modifyPost.PostSubject.ToUpper();

                // Save the changes
                ForumPostInfoProvider.SetForumPostInfo(modifyPost);
            }

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Gets and updates forum post. Called when the "Get and update post" button is pressed.
    /// Expects the CreateForumPost method to be run first.
    /// </summary>
    private bool GetAndUpdateForumPost()
    {
        // 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))
        {
            ForumPostInfo updatePost = new ForumPostInfo(posts.Tables[0].Rows[0]);

            // Update the properties
            updatePost.PostSubject = updatePost.PostSubject.ToLower();

            // Save the changes
            ForumPostInfoProvider.SetForumPostInfo(updatePost);

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Creates forum post. Called when the "Create post" button is pressed.
    /// </summary>
    private bool CreateForumPost()
    {
        // Get the forum
        ForumInfo forum = ForumInfoProvider.GetForumInfo("MyNewForum", CMSContext.CurrentSiteID);

        if (forum != null)
        {
            // Create new forum post object
            ForumPostInfo newPost = new ForumPostInfo();

            // Set the properties
            newPost.PostUserID   = CMSContext.CurrentUser.UserID;
            newPost.PostUserMail = CMSContext.CurrentUser.Email;
            newPost.PostUserName = CMSContext.CurrentUser.UserName;
            newPost.PostForumID  = forum.ForumID;
            newPost.PostTime     = DateTime.Now;
            newPost.PostApproved = true;
            newPost.PostText     = "This is my new post";
            newPost.PostSubject  = "My new post";

            // Save the forum post
            ForumPostInfoProvider.SetForumPostInfo(newPost);

            return(true);
        }

        return(false);
    }
Exemple #4
0
    /// <summary>
    /// Lock thread event handler.
    /// </summary>
    protected void btnLockThread_Click(object sender, EventArgs e)
    {
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        if (PostInfo != null)
        {
            PostInfo.PostIsLocked = !PostInfo.PostIsLocked;
            ForumPostInfoProvider.SetForumPostInfo(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 + "';");
        }
    }
    /// <summary>
    /// Handles the Click event of the btnApprove control.
    /// </summary>
    protected void btnApprove_Click(object sender, EventArgs e)
    {
        // Check permissions
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        // Approve the post
        ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(ValidationHelper.GetInteger(PostID, 0));

        if (fpi != null)
        {
            fpi.PostApprovedByUserID = MembershipContext.AuthenticatedUser.UserID;
            fpi.PostApproved         = true;
            ForumPostInfoProvider.SetForumPostInfo(fpi);
        }

        // 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);
    }
Exemple #7
0
    /// <summary>
    /// Btn OK handler.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        if (editPi == null)
        {
            editPi = ForumPostInfoProvider.GetForumPostInfo(EditPostID);
        }

        // Sets the current or parent post id
        int subscibePostId = 0;

        if (editPi != null)
        {
            editPi.PostLastEdit    = DateTime.Now;
            editPi.PostIsAnswer    = ValidationHelper.GetInteger(txtPostIsAnswer.Text, editPi.PostIsAnswer);
            editPi.PostIsNotAnswer = ValidationHelper.GetInteger(txtPostIsNotAnswer.Text, editPi.PostIsNotAnswer);
        }
        else
        {
            // Create new post
            editPi = new ForumPostInfo();

            // Set as reply
            if (replyPi != null)
            {
                editPi.PostParentID = replyPi.PostId;
                subscibePostId      = replyPi.PostId;
            }

            editPi.PostUserID           = CMSContext.CurrentUser.UserID;
            editPi.PostForumID          = fi.ForumID;
            editPi.PostTime             = DateTime.Now;
            editPi.PostApproved         = true;
            editPi.PostApprovedByUserID = CMSContext.CurrentUser.UserID;
        }


        #region "Security"

        string result = new Validator().NotEmpty(txtSubject.Text, rfvSubject.ErrorMessage).NotEmpty(txtUserName, rfvUserName.ErrorMessage).Result;

        // Check if is some text in TextArea or in HTMLEditor
        if (result == "")
        {
            if (fi.ForumHTMLEditor)
            {
                if (htmlTemplateBody.ResolvedValue.Trim() == "")
                {
                    result = rfvText.ErrorMessage;
                }
                editPi.PostText = htmlTemplateBody.ResolvedValue;
            }
            else
            {
                if (DiscussionMacroHelper.RemoveTags(ucBBEditor.Text).Trim() == "")
                {
                    result = rfvText.ErrorMessage;
                }
                editPi.PostText = ucBBEditor.Text;
            }
        }

        if ((fi.ForumRequireEmail || chkSubscribe.Checked || (txtEmail.Text != String.Empty)) && result == "")
        {
            result = new Validator().IsEmail(txtEmail.Text, rfvEmail.ErrorMessage).Result;
            if (!String.IsNullOrEmpty(result))
            {
                ShowError(result);
                if (chkSubscribe.Checked && String.IsNullOrEmpty(txtEmail.Text))
                {
                    ShowError(GetString("Forums.Emailsubscribe"));
                }
                Visible = true;
                return;
            }
        }

        #endregion


        // Check subscriptions
        if ((chkSubscribe.Checked) && (!String.IsNullOrEmpty(txtEmail.Text)) && (ForumSubscriptionInfoProvider.IsSubscribed(txtEmail.Text.Trim(), editPi.PostForumID, subscibePostId)))
        {
            // Post of the forum is already subscribed to this email -> show an error
            result = GetString("Forums.EmailAlreadySubscribed");
            chkSubscribe.Checked = false;
        }

        if (String.IsNullOrEmpty(result))
        {
            if (fi.ForumType == 0)
            {
                editPi.PostType = (radTypeQuestion.Checked) ? 1 : 0;
            }

            editPi.PostUserName      = TextHelper.LimitLength(txtUserName.Text, POST_USERNAME_LENGTH, "");
            editPi.PostSubject       = TextHelper.LimitLength(txtSubject.Text, POST_SUBJECT_LENGTH, "");
            editPi.PostUserMail      = txtEmail.Text;
            editPi.PostUserSignature = txtSignature.Text;

            ForumPostInfoProvider.SetForumPostInfo(editPi);
            EditPostID = editPi.PostId;


            #region "Subscription"

            if ((chkSubscribe.Checked) && (!String.IsNullOrEmpty(editPi.PostUserMail)))
            {
                ForumSubscriptionInfo fsi = new ForumSubscriptionInfo();
                fsi.SubscriptionForumID = ForumID;
                fsi.SubscriptionEmail   = editPi.PostUserMail;
                fsi.SubscriptionPostID  = editPi.PostId;
                fsi.SubscriptionUserID  = CMSContext.CurrentUser.UserID;
                fsi.SubscriptionGUID    = Guid.NewGuid();

                ForumSubscriptionInfoProvider.Subscribe(fsi, DateTime.Now, true, true);
            }

            #endregion


            ClearForm();

            if (OnInsertPost != null)
            {
                OnInsertPost(this, null);
            }

            RaiseOnSaved();
        }
        else
        {
            ShowError(result);
            return;
        }
    }
    /// <summary>
    /// OK click hadler.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        #region "Security"

        // Check whether forum exists
        if (ForumContext.CurrentForum == null)
        {
            return;
        }

        // Check security
        bool securityCheck = true;
        switch (ForumContext.CurrentState)
        {
        case ForumStateEnum.NewThread:
            securityCheck = IsAvailable(ForumContext.CurrentForum, ForumActionType.NewThread);
            break;

        case ForumStateEnum.ReplyToPost:
            securityCheck = IsAvailable(ForumContext.CurrentForum, ForumActionType.Reply);
            break;

        case ForumStateEnum.EditPost:
            securityCheck = ForumContext.CurrentPost != null && IsAvailable(ForumContext.CurrentPost, ForumActionType.Edit);
            break;
        }

        if (!securityCheck)
        {
            ShowError(GetString("ForumNewPost.PermissionDenied"));
            return;
        }


        #region "Captcha"

        // Check security code if is required
        if ((ForumContext.CurrentForum.ForumUseCAPTCHA) && (!SecurityCode1.IsValid()) && (ForumContext.CurrentState != ForumStateEnum.EditPost))
        {
            ShowError(GetString("ForumNewPost.InvalidCaptcha"));
            return;
        }

        #endregion



        #region "Email field"

        // Create instance of validator
        Validator validator = new Validator();

        // Check whether email is valid
        string result = validator.IsEmail(txtEmail.Text, rfvEmail.ErrorMessage).Result;

        // Check whether email is present with correct format if email is required
        // or when subscribtion to current post is checked
        if ((ForumContext.CurrentForum.ForumRequireEmail || chkSubscribe.Checked) && (!String.IsNullOrEmpty(result)))
        {
            ShowError(result);
            return;
        }

        // Check if email is added if is in correct format
        if ((txtEmail.Text.Trim() != "") && (!String.IsNullOrEmpty(result)))
        {
            ShowError(rfvEmail.ErrorMessage);
            return;
        }

        #endregion


        #region "Subject"

        // Check whether subject is filled
        if (txtSubject.Text.Trim() == "")
        {
            ShowError(rfvSubject.ErrorMessage);
            return;
        }

        #endregion


        #region "Text"

        validator = new Validator();

        // Check post text in HTML editor or text area
        if (!ForumContext.CurrentForum.ForumHTMLEditor)
        {
            // Check whether post text is added in text area
            if ((result = validator.NotEmpty(DiscussionMacroHelper.RemoveTags(ucBBEditor.Text), rfvText.ErrorMessage).Result) != "")
            {
                ShowError(result);
                return;
            }
        }
        else
        {
            // Check whether post text is added in HTML editor
            if ((result = validator.NotEmpty(htmlTemplateBody.ResolvedValue, rfvText.ErrorMessage).Result) != "")
            {
                ShowError(result);
                return;
            }
        }

        #endregion


        #region "User name"

        // Check whether user name is filled if user name field is visible
        if (ForumContext.CurrentForum.ForumAllowChangeName || MembershipContext.AuthenticatedUser.IsPublic() || ((ForumContext.CurrentForum != null) && (ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, ForumContext.CommunityGroupID))))
        {
            validator = new Validator();

            if (!String.IsNullOrEmpty(result = validator.NotEmpty(txtUserName.Text, rfvUserName.ErrorMessage).Result))
            {
                ShowError(result);
                return;
            }
        }

        #endregion


        #endregion


        #region "Forum post properties"

        bool newPost = false;

        // Current forum info object
        ForumInfo fi = ForumContext.CurrentForum;

        // Forum post info object
        ForumPostInfo fp = null;

        // Get forum post info with dependence on current state
        if (ForumContext.CurrentState == ForumStateEnum.EditPost)
        {
            // Get existing object
            fp = ForumContext.CurrentPost;
            fp.PostLastEdit = DateTime.Now;
        }
        else
        {
            // Create new forum post info object
            fp      = new ForumPostInfo();
            newPost = true;
        }


        #region "Ad-hoc forum"

        if (IsAdHocForum && (ForumContext.CurrentForum.ForumID == 0))
        {
            if (DocumentContext.CurrentDocument == null)
            {
                ShowError(GetString("forums.documentdoesnotexist"));
                return;
            }

            fi.ForumGroupID     = ForumGroupInfoProvider.GetAdHocGroupInfo(SiteID).GroupID;
            fi.ForumName        = "AdHoc-" + Guid.NewGuid();
            fi.ForumDisplayName = TextHelper.LimitLength(DocumentContext.CurrentDocument.GetDocumentName(), POST_USERNAME_LENGTH, String.Empty);
            fi.ForumOpen        = true;
            fi.ForumModerated   = false;
            fi.ForumAccess      = 040000;
            fi.ForumThreads     = 0;
            fi.ForumPosts       = 0;
            fi.ForumLogActivity = LogActivity;
            ForumInfoProvider.SetForumInfo(fi);

            ForumContext.CurrentForum.ForumID = fi.ForumID;
            ForumContext.ForumID = fi.ForumID;
            ForumID = fi.ForumID;
        }

        #endregion


        // Post forum
        fp.PostForumID = ForumContext.CurrentForum.ForumID;
        // Get forum post info with dependence on current state
        if (ForumContext.CurrentState != ForumStateEnum.EditPost)
        {
            // Post time
            fp.PostTime = DateTime.Now;
            // User IP address
            fp.PostInfo.IPAddress = RequestContext.UserHostAddress;
            // User agent
            fp.PostInfo.Agent = Request.UserAgent;
            // Post user id
            if (!MembershipContext.AuthenticatedUser.IsPublic())
            {
                fp.PostUserID = MembershipContext.AuthenticatedUser.UserID;
            }

            // Post signature
            fp.PostUserSignature = txtSignature.Text;
        }

        // Post subject
        fp.PostSubject = txtSubject.Text;
        // Post user email
        fp.PostUserMail = txtEmail.Text;


        // Post type
        int forumType = ForumContext.CurrentForum.ForumType;
        if (forumType == 0)
        {
            if (ForumContext.CurrentReplyThread == null)
            {
                // New thread - use type which user chosen
                fp.PostType = (radTypeDiscussion.Checked ? 0 : 1);
            }
            else
            {
                // Reply - use parent type
                fp.PostType = ForumContext.CurrentReplyThread.PostType;
            }
        }
        else
        {
            // Fixed type - use the forum setting
            fp.PostType = forumType - 1;
        }

        bool newThread = (ForumContext.CurrentReplyThread == null);

        // Set username if change name is allowed
        if (fi.ForumAllowChangeName || MembershipContext.AuthenticatedUser.IsPublic() || ForumContext.UserIsModerator(fp.PostForumID, ForumContext.CommunityGroupID))
        {
            fp.PostUserName = TextHelper.LimitLength(txtUserName.Text, POST_USERNAME_LENGTH, "");
        }
        else
        {
            // Get forum post info with dependence on current state
            if (ForumContext.CurrentState != ForumStateEnum.EditPost)
            {
                fp.PostUserName = UserName;
            }
        }

        // Post parent id -> reply to
        if (ForumContext.CurrentReplyThread != null)
        {
            fp.PostParentID = ForumContext.CurrentReplyThread.PostId;

            // Check max relative level
            if ((MaxRelativeLevel > -1) && (ForumContext.CurrentReplyThread.PostLevel >= MaxRelativeLevel))
            {
                ShowError(GetString("Forums.MaxRelativeLevelError"));
                return;
            }
        }

        // Get post text from HTML editor if is enabled
        fp.PostText = ForumContext.CurrentForum.ForumHTMLEditor ? htmlTemplateBody.ResolvedValue : ucBBEditor.Text;

        // Approve post if forum is not moderated
        if (newPost)
        {
            if (!ForumContext.CurrentForum.ForumModerated)
            {
                fp.PostApproved = true;
            }
            else
            {
                if (ForumContext.UserIsModerator(fp.PostForumID, CommunityGroupID))
                {
                    fp.PostApproved         = true;
                    fp.PostApprovedByUserID = MembershipContext.AuthenticatedUser.UserID;
                }
            }
        }

        // If signature is enabled then
        if (EnableSignature)
        {
            fp.PostUserSignature = MembershipContext.AuthenticatedUser.UserSignature;
        }

        #endregion


        if (!BadWordInfoProvider.CanUseBadWords(MembershipContext.AuthenticatedUser, SiteContext.CurrentSiteName))
        {
            // Prepare columns to check
            Dictionary <string, int> columns = new Dictionary <string, int>();
            columns.Add("PostText", 0);
            columns.Add("PostSubject", 450);
            columns.Add("PostUserSignature", 0);
            columns.Add("PostUserName", 200);

            // Perform bad words check
            string badMessage = BadWordsHelper.CheckBadWords(fp, columns, "PostApproved", "PostApprovedByUserID", fp.PostText, MembershipContext.AuthenticatedUser.UserID, () => { return(ValidatePost(fp)); });

            if (String.IsNullOrEmpty(badMessage))
            {
                if (!ValidatePost(fp))
                {
                    badMessage = GetString("ForumNewPost.EmptyBadWord");
                }
            }

            if (!String.IsNullOrEmpty(badMessage))
            {
                ShowError(badMessage);
                return;
            }
        }



        // Flood protection
        if (FloodProtectionHelper.CheckFlooding(SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
        {
            ShowError(GetString("General.FloodProtection"));
            return;
        }

        // Check banned ip
        if (!BannedIPInfoProvider.IsAllowed(SiteContext.CurrentSiteName, BanControlEnum.AllNonComplete))
        {
            ShowError(GetString("General.BannedIP"));
            return;
        }

        string baseUrl = ForumContext.CurrentForum.ForumBaseUrl;
        if (String.IsNullOrEmpty(baseUrl))
        {
            baseUrl = FriendlyBaseURL;
        }

        string unsubscriptionUrl = ForumContext.CurrentForum.ForumUnsubscriptionUrl;
        if (String.IsNullOrEmpty(unsubscriptionUrl))
        {
            unsubscriptionUrl = UnsubscriptionURL;
        }

        // USe parent post id for new post
        int subscibePostId = newPost ? fp.PostParentID : fp.PostId;

        // Check subscriptions
        if ((chkSubscribe.Checked) && (!String.IsNullOrEmpty(txtEmail.Text)) && (ForumSubscriptionInfoProvider.IsSubscribed(txtEmail.Text.Trim(), fp.PostForumID, subscibePostId)))
        {
            // Post of the forum is already subscribed to this email -> show an error
            chkSubscribe.Checked = false;
            ShowError(GetString("Forums.EmailAlreadySubscribed"));
            return;
        }

        // Save post object
        ForumPostInfoProvider.SetForumPostInfo(fp, baseUrl, unsubscriptionUrl);
        LogPostActivity(fp, fi);


        #region "Subscription"

        // If subscribe is checked create new subscription to the current post
        if ((chkSubscribe.Checked) && (!ForumSubscriptionInfoProvider.IsSubscribed(fp.PostUserMail, fp.PostForumID, fp.PostId)))
        {
            // Create new subscription info object
            ForumSubscriptionInfo fsi = new ForumSubscriptionInfo();
            // Set info properties
            fsi.SubscriptionForumID = fp.PostForumID;
            fsi.SubscriptionEmail   = fp.PostUserMail;
            fsi.SubscriptionPostID  = fp.PostId;
            fsi.SubscriptionUserID  = fp.PostUserID;
            fsi.SubscriptionGUID    = Guid.NewGuid();

            // Save subscription
            ForumSubscriptionInfoProvider.Subscribe(fsi, DateTime.Now, true, true);

            if (fsi.SubscriptionApproved)
            {
                LogSubscriptionActivity(fsi, fi);
            }
        }

        #endregion

        bool moderationRequired = false;
        if ((!fp.PostApproved) && (!ForumContext.UserIsModerator(fp.PostForumID, CommunityGroupID)))
        {
            moderationRequired = true;
            if (OnModerationRequired != null)
            {
                OnModerationRequired(this, null);
            }
        }

        // Keep current user info
        CurrentUserInfo currentUser = MembershipContext.AuthenticatedUser;

        if (currentUser.IsAuthenticated() && chkAttachFile.Checked && (currentUser.IsGlobalAdministrator || ForumContext.CurrentForum.AllowAttachFiles != SecurityAccessEnum.Nobody))
        {
            // Redirect to the post attachments
            string attachmentUrl = GetURL(fp, ForumActionType.Attachment);
            if (moderationRequired)
            {
                attachmentUrl = URLHelper.AddParameterToUrl(attachmentUrl, "moderated", "1");
            }
            URLHelper.Redirect(attachmentUrl);
        }
        else
        {
            if (!StopProcessing)
            {
                // Redirect back to the forum or forum thread
                URLHelper.Redirect(ClearURL());
            }
        }
    }
    /// <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();
    }