📄 moderationmenu.cs
字号:
break;
case ModerationLevel.Moderated:
ToggleModerateUnModerateUser.Text = ResourceManager.GetString("ModerateThread_UnModerate_User");
break;
default:
ToggleModerateUnModerateUser.Enabled = false;
break;
}
}
// Set the ModerationHistory url.
//
if (null != ModerationHistory &&
csContext.SiteSettings.EnableUserModerationCounters)
{
ModerationHistory.Text = ResourceManager.GetString("ModeratePost_ModerationHistory");
ModerationHistory.NavigateUrl = string.Format("javascript:DoQuickHistory('{0}')", Globals.GetSiteUrls().ModerationQuickHistory(Post.PostID));
}
else
{
if (null != ModerationHistory)
ModerationHistory.Enabled = false;
}
}
else
{
if (EditUser != null)
EditUser.Enabled = false;
if (ToggleModerateUnModerateUser != null)
ToggleModerateUnModerateUser.Enabled = false;
if (ModerationHistory != null)
ModerationHistory.Enabled = false;
}
}
#endregion
#region Skin
protected override void AttachChildControls()
{
PostID = (Label) FindControl("PostID");
Approve = (HyperLink) FindControl("Approve");
ApproveView = (LinkButton) FindControl("ApproveView");
EditPost = (HyperLink) FindControl("EditPost");
DeletePost = (HyperLink) FindControl("DeletePost");
Move = (HyperLink) FindControl("Move");
MergeSplit = (HyperLink) FindControl("MergeSplit");
ToggleLockUnlockPost = (LinkButton) FindControl("ToggleLockUnlockPost");
EditUser = (HyperLink) FindControl("EditUser");
ToggleModerateUnModerateUser = (HyperLink) FindControl("ToggleModerateUnModerateUser");
ModerationHistory = (HyperLink) FindControl("History");
InitializeChildControls();
}
private void InitializeChildControls()
{
if (null != ApproveView)
ApproveView.Click += new EventHandler(ApproveView_Click);
if (null != ToggleLockUnlockPost)
ToggleLockUnlockPost.Click += new EventHandler(LockUnlock_Click);
}
#endregion
#region Properties
/// <summary>
/// Property UsePathToRedirect (bool)
/// </summary>
public bool UsePathToRedirect
{
get
{
object obj = ViewState["UsePathToRedirect"];
return obj == null ? false : (bool)obj;
}
set { ViewState["UsePathToRedirect"] = value; }
}
// *********************************************************************
// 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
#region Event Handlers
[AjaxMethod(IncludeControlValuesWithCallBack=false)]
public string ApprovePostAjax(int postID)
{
ApprovePost(postID);
// Prepare response (hide approved post)
return postID.ToString();
}
public void ApprovePost(int postID)
{
ForumPost post = Posts.GetPost(postID, csContext.User.UserID);
Moderate.ApprovePost(post, csContext.User.UserID);
}
[AjaxMethod(IncludeControlValuesWithCallBack=false)]
public string[] ToggleModerationAjax(int userID, string controlID)
{
User user = Users.GetUser(userID, false, false);
Moderate.ToggleUserSettings(ModerateUserSetting.ToggleModerate, user, csContext.User.UserID);
// Prepare response (toggle text "moderate user" <--> "unmoderate user")
string text = (user.ModerationLevel == ModerationLevel.Moderated) ? ResourceManager.GetString("ModerateThread_Moderate_User") : ResourceManager.GetString("ModerateThread_UnModerate_User");
return new string[] {controlID, text};
}
// *********************************************************************
// LockUnlock_Click
//
/// <summary>
/// Event handler for approving a post and replying to the post.
/// </summary>
// ***********************************************************************/
private void LockUnlock_Click (object sender, EventArgs e)
{
LinkButton b = (LinkButton) sender;
int postID = int.Parse(b.CommandArgument);
ForumPost post = Posts.GetPost(postID, csContext.User.UserID);
// Check for access before submitting
Permissions.AccessCheck( post.Section, Permission.Moderate, csContext.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.User, post))
Moderate.TogglePostSettings(ModeratePostSetting.ToggleLock, post, csContext.User.UserID);
// Fire an event to refresh the thread
OnPostModerateRefresh(e);
}
// *********************************************************************
// ApproveView_Click
//
/// <summary>
/// Event handler for approving a post and viewing the post.
/// </summary>
// ***********************************************************************/
private void ApproveView_Click(object sender, EventArgs e)
{
LinkButton b = (LinkButton) sender;
int postID = int.Parse(b.CommandArgument);
ApprovePost(postID);
// Redirect the user to the PostReply url.
Context.Response.Redirect(Globals.GetSiteUrls().Post(postID));
Context.Response.End();
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -