📄 moderationmenu.cs
字号:
if( canModerate )
{
// set the EditUser url
//
if (null != EditUser)
{
// Set the text for the hyperlink
EditUser.Text = ResourceManager.GetString("ModeratePost_EditUser");
EditUser.NavigateUrl = Globals.GetSiteUrls().AdminUserEdit(this.Post.User.UserID);
}
// Toggle Moderate / Unmoderate User
//
if (null != ToggleModerateUnModerateUser)
{
// TODO: Get a fresh copy of user data to have moderation status working right
//
//User freshUserData = Users.GetUser( this.Post.User.UserID, false, false );
//switch (freshUserData.ModerationLevel)
switch (this.Post.User.ModerationLevel)
{
case ModerationLevel.Unmoderated:
ToggleModerateUnModerateUser.Text = ResourceManager.GetString("ModerateThread_Moderate_User");
break;
case ModerationLevel.Moderated:
ToggleModerateUnModerateUser.Text = ResourceManager.GetString("ModerateThread_UnModerate_User");
break;
default:
ToggleModerateUnModerateUser.Enabled = false;
break;
}
ToggleModerateUnModerateUser.Click += new EventHandler(ModerateUnModerateUser_Click);
ToggleModerateUnModerateUser.CommandArgument = this.Post.User.UserID.ToString();
}
// Set the ModerationHistory url.
//
if (null != ModerationHistory)
{
ModerationHistory.Text = ResourceManager.GetString("ModeratePost_ModerationHistory");
ModerationHistory.NavigateUrl = Globals.GetSiteUrls().ModerationHistory(Post.PostID, HttpUtility.UrlEncode(HttpContext.Current.Request.Url.PathAndQuery));
}
}
else
{
if( EditUser != null )
EditUser.Enabled = false;
if( ToggleModerateUnModerateUser != null )
ToggleModerateUnModerateUser.Enabled = false;
if( ModerationHistory != null )
ModerationHistory.Enabled = false;
}
}
#endregion
#region Event Handlers
// *********************************************************************
// Approve_Click
//
/// <summary>
/// Event handler for approving a post
/// </summary>
// ***********************************************************************/
private void Approve_Click(object sender, EventArgs e)
{
// Approve the post.
Moderate.ApprovePost(this.Post, csContext.User.UserID);
Context.Response.Redirect(Globals.GetSiteUrls().ModerateForum(csContext.ForumID));
Context.Response.End();
}
// *********************************************************************
// UnModerateUser_Click
//
/// <summary>
/// Event handler for unmoderating a user.
/// </summary>
// ***********************************************************************/
void ModerateUnModerateUser_Click (object sender, EventArgs e)
{
LinkButton b = (LinkButton) sender;
User user = Users.GetUser(int.Parse(b.CommandArgument), false, false);
Moderate.ToggleUserSettings( ModerateUserSetting.ToggleModerate, user, CSContext.Current.User.UserID);
//Basically, if in mod menu then redirect to mod menu - otherwise, you are in forum so redirect to where you are
if (this.UsePathToRedirect)
{
Context.Response.Redirect(Globals.GetSiteUrls().ModerateForum(csContext.ForumID));
Context.Response.End();
}
else
{
Context.Response.Redirect(Context.Request.RawUrl);
Context.Response.End();
}
}
// *********************************************************************
// LockUnlock_Click
//
/// <summary>
/// Event handler for approving a post and replying to the post.
/// </summary>
// ***********************************************************************/
void LockUnlock_Click (object sender, EventArgs e)
{
LinkButton b = (LinkButton) sender;
int postID = int.Parse(b.CommandArgument);
ForumPost post = Posts.GetPost(postID, CSContext.Current.User.UserID);
// Check for access before submitting
Permissions.AccessCheck( post.Section, Permission.Moderate, CSContext.Current.User, post );
// Doing this twice just in case the exception thrown from the access check doesn't fully abort execution
if(Permissions.ValidatePermissions(post.Section, Permission.Moderate, CSContext.Current.User, post))
Moderate.TogglePostSettings(ModeratePostSetting.ToggleLock, post, CSContext.Current.User.UserID);
// Fire an event to refresh the thread
OnPostModerateRefresh(e);
}
// *********************************************************************
// ApproveReply_Click
//
/// <summary>
/// Event handler for approving a post and replying to the post.
/// </summary>
// ***********************************************************************/
private void ApproveReply_Click(object sender, EventArgs e)
{
// Approve the post.
Moderate.ApprovePost(this.Post, csContext.User.UserID);
// Redirect the user to the PostReply url.
Context.Response.Redirect(Globals.GetSiteUrls().PostReply(this.Post.PostID));
Context.Response.End();
}
// *********************************************************************
// ApproveEdit_Click
//
/// <summary>
/// Event handler for approving a post and editing the post.
/// </summary>
// ***********************************************************************/
private void ApproveEdit_Click(object sender, EventArgs e)
{
// Approve the post.
Moderate.ApprovePost(this.Post, csContext.User.UserID);
// Redirect the user to the edit post url.
Context.Response.Redirect(Globals.GetSiteUrls().ModeratePostEdit(this.Post.PostID, Context.Request.Url.PathAndQuery));
Context.Response.End();
}
#endregion
#region Public properties
// *********************************************************************
// Post
//
/// <summary>
/// Gets or sets the post to moderate.
/// </summary>
// ***********************************************************************/
public ForumPost Post
{
get
{
if ( post == null )
{
Object state = ViewState["Post"];
if ( state != null )
{
Int32 postID = (Int32)state;
post = Posts.GetPost( postID, CSContext.Current.User.UserID, false );
}
}
return post;
}
set
{
post = value;
if ( post != null )
{
ViewState[ "Post" ] = post.PostID;
}
else
{
ViewState.Remove( "Post" );
}
}
}
// *********************************************************************
// Forum
//
/// <summary>
/// Gets or sets the forum the post is in..
/// </summary>
// ***********************************************************************/
public Forum Forum
{
get
{
if ( forum == null )
{
Object state = ViewState["SectionID"];
if ( state != null )
{
Int32 sectionID = (Int32)state;
forum = Forums.GetForum(sectionID);
}
}
return forum;
}
set
{
forum = value;
if ( forum != null )
{
ViewState[ "SectionID" ] = forum.SectionID;
}
else
{
ViewState.Remove( "SectionID" );
}
}
}
#endregion
#region Events
public event EventHandler PostModerateRefresh;
private void OnPostModerateRefresh(EventArgs e)
{
if(PostModerateRefresh != null)
PostModerateRefresh(null, e);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -