コード例 #1
0
        private void InternalDataBind()
        {
            if (Mode == ModeratedForumMode.ViewForUser)
            {
                // Get the collections of forums this user can moderate/not moderate
                ModeratedForumCollection moderated    = Users.GetForumsModeratedByUser(Username);
                ModeratedForumCollection notmoderated = Users.GetForumsNotModeratedByUser(Username);

                if (moderatedForums != null)
                {
                    moderatedForums.DataSource = moderated;
                    moderatedForums.DataBind();
                }

                if (unmoderatedForums != null)
                {
                    unmoderatedForums.DataSource = notmoderated;
                    unmoderatedForums.DataBind();
                }
            }

            if (Mode == ModeratedForumMode.ViewForForum)
            {
                ModeratedForumCollection moderators = Moderate.GetForumModerators(ForumID);

                if (moderatingUsers != null)
                {
                    moderatingUsers.DataSource = moderators;
                    moderatingUsers.DataBind();
                }
            }
        }
コード例 #2
0
        // *********************************************************************
        //  MovePost_Click
        //
        /// <summary>
        /// Event handler for deleting a post
        /// </summary>
        ///
        // ***********************************************************************/
        private void MovePost_Click(Object sender, EventArgs e)
        {
            // Are we valid?
            Moderate.MovePost(PostID, Convert.ToInt32(moveTo.SelectedItem.Value.Replace("f-", "")), ForumUser.Username, sendEmail.Checked);

            HttpContext.Current.Server.Transfer(ReturnURL);
        }
コード例 #3
0
        // *********************************************************************
        //  OnPreRender
        //
        /// <summary>
        /// This event handler binds the template to the datalist - this action
        /// is only carried out if the user DID NOT specify an ItemTemplate.
        /// In such a case, the default databinding is used.
        /// </summary>
        ///
        // ********************************************************************/
        protected override void OnPreRender(EventArgs e)
        {
            ForumGroupCollection forumGroups;

            // Get all forum groups (cached call)
            forumGroups = Moderate.GetForumGroupsForModeration(ForumUser.Username);

            // Databind if we have values
            if (forumGroups.Count > 0)
            {
                DataSource = forumGroups;
                DataBind();
            }
            else     // No forums
            {
                Label label;

                // Set some properties on the label
                label          = new Label();
                label.CssClass = "normalTextSmallBold";
                label.Text     = "No threads to moderate.";

                // Clear the controls collection and add our label
                Controls.Clear();
                Controls.Add(label);
            }
        }
コード例 #4
0
        // *********************************************************************
        //  ApprovePostAndEdit_Click
        //
        /// <summary>
        /// Event handler to edit a post
        /// </summary>
        // ***********************************************************************/
        public void ApprovePostAndEdit_Click(Object sender, CommandEventArgs e)
        {
            // Approve the post
            Moderate.ApprovePost(PostID, ForumUser.Username);

            // Now go the edit view
            HttpContext.Current.Response.Redirect(Globals.UrlEditPost + PostID);
            HttpContext.Current.Response.End();
        }
コード例 #5
0
        // *********************************************************************
        //  DeletePost_Click
        //
        /// <summary>
        /// Event handler for deleting a post
        /// </summary>
        // ***********************************************************************/
        private void DeletePost_Click(Object sender, EventArgs e)
        {
            // Are we valid?
            if (reasonValidation.IsValid)
            {
                Post post = (Post)Posts.GetPost(PostID, null);
                Moderate.DeletePost(PostID, ForumUser.Username, reasonForDelete.Text, sendEmail.Checked);

                HttpContext.Current.Response.Redirect(Globals.UrlShowForum + post.ForumID);
                HttpContext.Current.Response.End();
            }
        }
コード例 #6
0
        // *********************************************************************
        //  ApprovePostAndMove_Changed
        //
        /// <summary>
        /// Event handler to approve and move a post
        /// </summary>
        // ***********************************************************************/
        public void ApprovePostAndMove_Changed(Object sender, EventArgs e)
        {
            MovedPostStatus status;

            // Move the post
            status = Moderate.MovePost(PostID, Convert.ToInt32(approvePostAndMove.SelectedItem.Value.Replace("f-", "")), ForumUser.Username, true);

            // Approve the post
            if (status != MovedPostStatus.NotMoved)
            {
                Moderate.ApprovePost(PostID, ForumUser.Username);
            }
        }
コード例 #7
0
        // *********************************************************************
        //  CreateChildControls
        //
        /// <summary>
        /// Override create child controls
        /// </summary>
        ///
        // ********************************************************************/
        protected override void CreateChildControls()
        {
            EnableViewState = false;

            // determine if we want to bind to the default template or not
            if (this.ItemTemplate == null)
            {
                // create a new template
                base.ItemTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildItemTemplate));
                base.CreateChildControls();
            }

            base.CreateChildControls();

            // bind the datalist to the SqlDataReader returned by the GetAllForums() method
            DataSource = Moderate.GetForumsForModerationByForumGroupId(ForumGroupID, ForumUser.Username);
            DataBind();
        }
コード例 #8
0
        // *********************************************************************
        //  PerformDataBindingForThreadList()
        //
        /// <summary>
        /// DataBinds the threadlist server control
        /// </summary>
        ///
        // ********************************************************************/
        private void PerformDataBindingForThreadList()
        {
            ThreadCollection threads;

            // User specific data source ... note although we support paging, it's not being used.
            threads = Moderate.GetAllUnmoderatedThreads(ForumID, 25, 0, ForumUser.Username);

            // Do we have data to display?
            if (threads.Count == 0)
            {
                HttpContext.Current.Response.Redirect(Globals.UrlModeration);
                HttpContext.Current.Response.End();
            }
            else
            {
                threadList.DataSource = threads;
                threadList.DataBind();
            }
        }
コード例 #9
0
        // *********************************************************************
        //  InitializeSkin
        //
        /// <summary>
        /// Initialize the control template and populate the control with values
        /// </summary>
        // ***********************************************************************/
        override protected void InitializeSkin(Control skin)
        {
            Label    label;
            Repeater repeater;

            // Get the statistics
            Statistics siteStats = Statistics.GetSiteStatistics();


            // Most active moderator
            repeater = (Repeater)skin.FindControl("TopModerators");
            if (null != repeater)
            {
                repeater.DataSource = Moderate.GetMostActiveModerators();
                repeater.DataBind();
            }

            // Moderator actions
            repeater = (Repeater)skin.FindControl("ModerationAction");
            if (null != repeater)
            {
                repeater.DataSource = Moderate.GetModerationAuditSummary();
                repeater.DataBind();
            }

            // Total Moderators
            label = (Label)skin.FindControl("TotalModerators");
            if (null != label)
            {
                label.Text = siteStats.TotalModerators.ToString("n0");
            }

            // Total Moderated Posts
            label = (Label)skin.FindControl("TotalModeratedPosts");
            if (null != label)
            {
                label.Text = siteStats.TotalModeratedPosts.ToString("n0");
            }
        }
コード例 #10
0
        /***********************************************************************
        *  // DisplayPost
        *  //
        *  /// <summary>
        *  /// When a user replies to a post, the user control that controls the UI
        *  /// is loaded and passed to this method. Elements of the form are then wired
        *  /// up to handle events, such as button clicks
        *  /// </summary>
        *  /// <param name="control">Usercontrol used to control UI formatting</param>
        ***********************************************************************/
        private void DisplayPost(Control controlTemplate)
        {
            Button button;

            // Set the title message
            if (Mode == CreateEditPostMode.NewPost)
            {
                ((Label)controlTemplate.FindControl("PostTitle")).Text = _defaultPostNewMessageText;
            }
            else
            {
                ((Label)controlTemplate.FindControl("PostTitle")).Text = _defaultReplyToMessageText;
            }

            // Set the subject if necessary
            if (Mode == CreateEditPostMode.ReplyToPost)
            {
                HyperLink hyperlink;

                // Get the subject of the message we're replying to
                hyperlink = (HyperLink)controlTemplate.FindControl("ReplySubject");

                // Do we need to prepend 'Re: '?
                if (hyperlink.Text.StartsWith("Re: "))
                {
                    ((TextBox)controlTemplate.FindControl("PostSubject")).Text = Globals.HtmlDecode(hyperlink.Text);
                }
                else
                {
                    ((TextBox)controlTemplate.FindControl("PostSubject")).Text = "Re: " + Globals.HtmlDecode(hyperlink.Text);
                }
            }

            // Set the Username
            ((Label)controlTemplate.FindControl("PostAuthor")).Text = user.Username;

            // Allow pinned posts?
            if (((user.IsAdministrator) || (Moderate.CanModerate(user.Username))) && (Mode != CreateEditPostMode.ReplyToPost))
            {
                controlTemplate.FindControl("AllowPinnedPosts").Visible = true;

                pinnedPost = (DropDownList)controlTemplate.FindControl("PinnedPost");
                pinnedPost.Items.Add(new ListItem("Do not pin post", "0"));
                pinnedPost.Items.Add(new ListItem("1 Day", "1"));
                pinnedPost.Items.Add(new ListItem("3 Days", "3"));
                pinnedPost.Items.Add(new ListItem("1 Week", "7"));
                pinnedPost.Items.Add(new ListItem("2 Weeks", "14"));
                pinnedPost.Items.Add(new ListItem("1 Month", "30"));
                pinnedPost.Items.Add(new ListItem("3 Months", "90"));
                pinnedPost.Items.Add(new ListItem("6 Months", "180"));
                pinnedPost.Items.Add(new ListItem("1 Year", "360"));
                pinnedPost.Items.Add(new ListItem("Announcement", "999"));

                // Do an autopost back incase we need to flip the allowNoReplies checkbox
                pinnedPost.AutoPostBack          = true;
                pinnedPost.SelectedIndexChanged += new System.EventHandler(PinnedPost_Changed);
            }

            // Find the checkbox
            allowNoReplies = (CheckBox)controlTemplate.FindControl("AllowReplies");

            // Wireup the preview button
            button        = (Button)controlTemplate.FindControl("PreviewButton");
            button.Click += new System.EventHandler(PreviewButton_Click);

            // Wire up the cancel button
            button        = (Button)controlTemplate.FindControl("Cancel");
            button.Click += new System.EventHandler(CancelButton_Click);

            // Wire up the post button
            button        = (Button)controlTemplate.FindControl("PostButton");
            button.Click += new System.EventHandler(PostButton_Click);
        }
コード例 #11
0
 public ModerationQueueStatus GetQueueStatus(int forumID, string username)
 {
     return(Moderate.GetQueueStatus(forumID, username));
 }
コード例 #12
0
        private void SkinLogic()
        {
            if (Mode == ModeratedForumMode.ViewForForum)
            {
                ModeratedForumCollection moderators = Moderate.GetForumModerators(ForumID);

                if (moderators.Count > 0)
                {
                    if (moderatedForumsPanel != null)
                    {
                        moderatedForumsPanel.Visible = true;
                    }
                }
                else
                {
                    moderatedForumsPanel.Visible = false;
                }

                if (moderatedForums != null)
                {
                    moderatedForums.Visible = false;
                }

                if (unmoderatedForumsPanel != null)
                {
                    unmoderatedForumsPanel.Visible = false;
                }
            }

            if (Mode == ModeratedForumMode.ViewForUser)
            {
                // Get the collections of forums this user can moderate/not moderate
                ModeratedForumCollection moderated    = Users.GetForumsModeratedByUser(Username);
                ModeratedForumCollection notmoderated = Users.GetForumsNotModeratedByUser(Username);

                if (moderated.Count > 0)
                {
                    if (moderatedForumsPanel != null)
                    {
                        moderatedForumsPanel.Visible = true;
                    }
                }
                else
                {
                    if (moderatedForumsPanel != null)
                    {
                        moderatedForumsPanel.Visible = false;
                    }
                }

                if (notmoderated.Count > 0)
                {
                    if (unmoderatedForumsPanel != null)
                    {
                        unmoderatedForumsPanel.Visible = true;
                    }
                }
                else
                {
                    if (unmoderatedForumsPanel != null)
                    {
                        unmoderatedForumsPanel.Visible = false;
                    }
                }
            }

            // Hook up the Add Forum Button
            if (addForumButton != null)
            {
                addForumButton.Click += new EventHandler(AddForum_Click);
            }

            // Hook up the Moderated Forums Removal Handler
            if (moderatedForums != null)
            {
                moderatedForums.ItemCommand += new DataGridCommandEventHandler(Moderated_Command);
            }
        }
コード例 #13
0
 // *********************************************************************
 //  ApprovePostAndTurnOffModeration_Click
 //
 /// <summary>
 /// Event handler to approve a post and turn off moderation
 /// </summary>
 // ***********************************************************************/
 public void ApprovePostAndTurnOffModeration_Click(Object sender, CommandEventArgs e)
 {
     // Approve the post and turn off moderation for this user
     Moderate.ApprovePost(PostID, ForumUser.Username, UsernamePostedBy);
 }
コード例 #14
0
 // *********************************************************************
 //  ApprovePost_Click
 //
 /// <summary>
 /// Event handler to approve posts
 /// </summary>
 // ***********************************************************************/
 public void ApprovePost_Click(Object sender, CommandEventArgs e)
 {
     // Approve the post
     Moderate.ApprovePost(PostID, ForumUser.Username);
 }