moderate.cs
来自「微软的.NET论坛的源代码(COOL!!!)」· CS 代码 · 共 380 行 · 第 1/2 页
CS
380 行
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
MovedPostStatus status = dp.MovePost(postID, moveToForumID, approvedBy);
if (sendEmail) {
if (status == MovedPostStatus.MovedAndApproved) {
// the post was moved to a new forum and automatically approved
// send an email explaining what happened, and send thread tracking emails
Emails.SendThreadTrackingEmails(postID);
Emails.SendMessageMovedAndApprovedEmail(postID);
}
else if (status == MovedPostStatus.MovedButNotApproved) {
// the post was moved, but is still waiting to approval from a moderate in the
// forum is was moved to. Send an email explaining this to the user.
Emails.SendMessageMovedAndNotApprovedEmail(postID);
}
}
return status;
}
// *********************************************************************
// DeletePost
//
/// <summary>
/// This method delets a post and all of its replies. It also includes a reason on why the
/// post was deleted.
/// </summary>
/// <param name="PostID">The post to delete.</param>
/// <param name="ReasonForDeleting">The reason why the post was deleted.</param>
/// <returns>A boolean, indiciating if the post was successfully deleted.</returns>
/// <remarks>The user of the post being deleted is automatically sent an email
/// explaining why his or her post was removed.</remarks>
///
// ********************************************************************/
public static void DeletePost(int postID, string approvedBy, string reasonForDeleting, bool sendEmail) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
// delete the post - if we succeed, send an email to the person who had their
// post deleted, explaining why it was deleted
if (reasonForDeleting.Length == 0) reasonForDeleting = "NO REASON GIVEN.";
// Send email if we delete the post
if (sendEmail)
Emails.SendEmail(((Post) Posts.GetPost(postID, null)).Username, EmailTypeEnum.MessageDeleted, postID, null, reasonForDeleting);
// Delete the post
dp.DeletePost(postID, approvedBy, reasonForDeleting);
}
// *********************************************************************
// ApprovePost
//
/// <summary>
/// Approves a moderated post.
/// </summary>
/// <param name="postID">The post to approve.</param>
/// <param name="approvedBy">Username approving the post.</param>
///
// ********************************************************************/
public static void ApprovePost(int postID, string approvedBy) {
ApprovePost(postID, approvedBy, null);
}
// *********************************************************************
// ApprovePost
//
/// <summary>
/// Approves a moderated post.
/// </summary>
/// <param name="postID">The post to approve.</param>
/// <param name="approvedBy">Username approving the post.</param>
/// <param name="updateUserAsTrusted">Approve the username as no longer requiring moderation</param>
///
// ********************************************************************/
public static void ApprovePost(int postID, string approvedBy, string updateUserAsTrusted) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
bool firstTimeApproved = dp.ApprovePost(postID, approvedBy, updateUserAsTrusted);
if (firstTimeApproved) {
// this means that the post hadn't been approved before, send confirmation
Emails.SendThreadTrackingEmails(postID);
Emails.SendMessageApprovedEmail(postID);
}
}
// *********************************************************************
// CanModerate
//
/// <summary>
/// Determines whether or not a user can moderate any forums.
/// </summary>
/// <param name="Username">The user who you are interested in determining has moderation
/// capabilities.</param>
/// <returns>A boolean, indicating whether or not the user can moderate.</returns>
/// <remarks>This method does not indicate *what* forums a user can moderate, it just serves to
/// determine IF a user can moderate at all.</remarks>
///
// ********************************************************************/
// TODO: REMOVE?
public static bool CanModerate(String Username) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.CanModerate(Username);
}
// *********************************************************************
// CanModerate
//
/// <summary>
/// Determines whether or not a user can moderate any forums.
/// </summary>
/// <param name="Username">The user who you are interested in determining has moderation
/// capabilities.</param>
/// <returns>A boolean, indicating whether or not the user can moderate.</returns>
/// <remarks>This method does not indicate *what* forums a user can moderate, it just serves to
/// determine IF a user can moderate at all.</remarks>
///
// ********************************************************************/
public static bool CanModerate(String username, int forumId) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.CanModerate(username, forumId);
}
// *********************************************************************
// GetPostsAwaitingModeration
//
/// <summary>
/// Returns a SqlDataReader full of the posts that are waiting approval in the forum(s)
/// that a particular user has moderation rights for.
/// </summary>
/// <param name="Username">The user name of the individual currently moderating.</param>
/// <returns>A PostCollection with the unapproved posts that the user can moderate.</returns>
///
// ********************************************************************/
// TODO: REMOVE?
/*
public static PostCollection GetPostsAwaitingModeration(String Username) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.GetPostsAwaitingModeration(Username);
}
*/
// *********************************************************************
// GetPostsAwaitingModeration
//
/// <summary>
/// Returns a bool indicating whether the given user has posts to moderate
/// </summary>
/// <param name="username">The user name of the individual currently moderating.</param>
///
// ********************************************************************/
public static bool UserHasPostsAwaitingModeration(String username) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.UserHasPostsAwaitingModeration(username);
}
/// <summary>
/// This method returns a list of users who can moderate a particular forum
/// </summary>
/// <param name="ForumID">The Forum you are interested in finding those who can moderate it.</param>
/// <returns>A ModeratedForumCollection object that lists the users who can moderate the specified
/// forum.</returns>
// TODO: REMOVE?
public static ModeratedForumCollection GetForumModerators(int ForumID) {
// Create Instance of the IWebForumsDataProviderBase
IWebForumsDataProviderBase dp = DataProvider.Instance();
return dp.GetForumModerators(ForumID);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?