moderate.cs
来自「微软的.NET论坛的源代码(COOL!!!)」· CS 代码 · 共 380 行 · 第 1/2 页
CS
380 行
using System;
using System.Web;
using AspNetForums;
using AspNetForums.Components;
namespace AspNetForums {
// *********************************************************************
// Moderate
//
/// <summary>
/// This class contains methods that are helpful for moderating posts.
/// </summary>
///
// ********************************************************************/
public class Moderate {
// *********************************************************************
// CanEditPost
//
/// <summary>
/// This method determines whether or not a user can edit a particular post.
/// </summary>
/// <param name="strUsername">The username of the user who you wish to know if he can edit
/// the post.</param>
/// <param name="iPostID">To post you wish to know if the user can edit.</param>
/// <returns>A boolean value: true if the user can edit the post, false otherwise.</returns>
/// <remarks>Moderators can edit posts that are still waiting for approval in the forum(s) they
/// are cleared to moderate. Forum administrators may edit any post, awaiting approval or not,
/// at any time.</remarks>
///
// ********************************************************************/
public static bool CanEditPost(String Username, int PostID) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.CanEditPost(Username, PostID);
}
// *********************************************************************
// GetMostActiveModerators
//
/// <summary>
/// Returns a list of the users that have added the most posts
/// </summary>
/// <returns>A UserCollection</returns>
///
// ********************************************************************/
public static ModeratorCollection GetMostActiveModerators() {
ModeratorCollection moderators;
// Only update once every 24 hours
if (HttpContext.Current.Cache["MostActiveModerators"] == null) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
// Get the collection
moderators = dp.GetMostActiveModerators();
// add to the cache
HttpContext.Current.Cache.Insert("MostActiveModerators", moderators, null, DateTime.Now.AddMinutes(5), TimeSpan.Zero);
}
return (ModeratorCollection) HttpContext.Current.Cache["MostActiveModerators"];
}
// *********************************************************************
// GetModerationAuditSummary
//
/// <summary>
/// Returns a collection of moderation audit items.
/// </summary>
///
// ********************************************************************/
public static ModerationAuditCollection GetModerationAuditSummary() {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.GetModerationAuditSummary();
}
// *********************************************************************
// GetForumGroupsForModeration
//
/// <summary>
/// Returns a collection of forums that require moderation.
/// </summary>
/// <param name="username">Name of user requesting list</param>
/// <returns>A collection of forums that require moderation and that the current
/// user has access to.</returns>
///
// ********************************************************************/
public static ForumGroupCollection GetForumGroupsForModeration(string username) {
ForumGroupCollection forumGroups;
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
// Get the collection
forumGroups = dp.GetForumGroupsForModeration(username);
// Sort the collection
forumGroups.Sort();
return forumGroups;
}
// *********************************************************************
// GetAllUnmoderatedThreads
//
/// <summary>
/// A list of threads for a given forum that need to be moderated.
/// </summary>
/// <param name="forumID">ID of the forum to return threads for</param>
/// <param name="pageSize">How many items to return per request</param>
/// <param name="pageIndex">What location in the page list</param>
/// <param name="username">Username making the request</param>
/// <returns>A collection of threads</returns>
///
// ********************************************************************/
public static ThreadCollection GetAllUnmoderatedThreads(int forumID, int pageSize, int pageIndex, string username) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.GetAllUnmoderatedThreads(forumID, pageSize, pageIndex, username);
}
// *********************************************************************
// GetTotalUnModeratedThreadsInForum
//
/// <summary>
/// A count of all the threads requring moderation in a given forum.
/// </summary>
/// <param name="forumID">ID of the forum to return threads for</param>
/// <param name="maxDateTime">Date constraint</param>
/// <param name="minDateTime">Data constraint</param>
/// <param name="username">Username making the request</param>
/// <returns>A collection of threads</returns>
///
// ********************************************************************/
/* TODO: REMOVE?
public static int GetTotalUnModeratedThreadsInForum(int ForumID, DateTime maxDateTime, DateTime minDateTime, string username, bool unreadThreadsOnly) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.GetTotalUnModeratedThreadsInForum(ForumID, maxDateTime, minDateTime, username, unreadThreadsOnly);
}
*/
// *********************************************************************
// GetForumsForModerationByForumGroupId
//
/// <summary>
/// Returns forums requiring moderation by forum group id
/// </summary>
/// <param name="forumGroupId">Id of the forum group to return forums for</param>
/// <param name="username">Username making the request</param>
///
// ********************************************************************/
public static ModeratedForumCollection GetForumsForModerationByForumGroupId(int forumGroupId, string username) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.GetForumsForModerationByForumGroupId(forumGroupId, username);
}
// *********************************************************************
// MovePost
//
/// <summary>
/// Moves a post from its current forum to another.
/// </summary>
/// <param name="iPostID">The post to move.</param>
/// <param name="MoveToForumID">The forum to move the post to.</param>
/// <param name="Username">The user attempting to move the post.</param>
/// <returns>A MovedPostStatus enumeration member indicating the resulting status:
/// NotMoved, meaning the post was not moved; MovedButNotApproved, meaning the post was
/// moved, but not approved in the new forum; or MovedAndApproved, meaning that the post
/// was moved and approved in the new forum.</returns>
/// <remarks>A post moved from one forum to another is automatically approved if the person
/// moving the post is also a moderate in the forum that the post is being moved to. Moving a
/// post can fail if the user attempts to move a post that has already been approved.</remarks>
///
// ********************************************************************/
public static MovedPostStatus MovePost(int postID, int moveToForumID, String approvedBy, bool sendEmail) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?