📄 threadsplit.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CommunityServer.Components;
using CommunityServer.Controls;
using CommunityServer.Discussions.Components;
namespace CommunityServer.Discussions.Controls
{
// *********************************************************************
// ThreadSplit
//
/// <summary>
/// This sever control is used to split a thread into a new thread.
/// </summary>
///
// ********************************************************************/
public class ThreadSplit : SkinnedWebControl
{
#region Member Variables & constructor
CSContext csContext = CSContext.Current;
string skinFilename = "Moderation\\View-ThreadSplit.ascx";
ForumPost postToMove = null;
TextBox subject;
Label hasReplies;
Label postedBy;
Label body;
ForumListBox moveTo;
CheckBox sendEmail;
HyperLink cancelMove;
LinkButton move;
RequiredFieldValidator moveToValidator;
// *********************************************************************
// ThreadSplit
//
/// <summary>
/// Constuctor
/// </summary>
///
// ***********************************************************************/
public ThreadSplit() : base()
{
// Set the skin file
if (SkinFilename == null)
SkinFilename = skinFilename;
if (csContext.ReturnUrl == null)
{
throw new CSException(CSExceptionType.ReturnURLRequired);
}
}
#endregion
#region Initialize Skin
// *********************************************************************
// InitializeSkin
//
/// <summary>
/// Initialize the control template and populate the control with values
/// </summary>
/// <param name="skin">Control instance of the skin</param>
///
// ***********************************************************************/
override protected void InitializeSkin(Control skin)
{
// Get the post we want to move
postToMove = Posts.GetPost(csContext.PostID, csContext.User.UserID);
// Do an access check
Permissions.AccessCheck( postToMove.Section, Permission.Moderate, CSContext.Current.User, postToMove );
// Display subject
subject = (TextBox) skin.FindControl("Subject");
if (null != subject)
{
subject.Text = postToMove.Subject;
}
// Has Replies?
hasReplies = (Label) skin.FindControl("HasReplies");
if (null != hasReplies)
{
if (postToMove.Replies > 0)
{
hasReplies.Text = ResourceManager.GetString("Yes") + " (" + postToMove.Replies + ") ";
}
else
{
hasReplies.Text = ResourceManager.GetString("No");
}
}
// Posted By
postedBy = (Label) skin.FindControl("PostedBy");
if (null != postedBy)
{
postedBy.Text = postToMove.Username + " ";
}
// Body
body = (Label) skin.FindControl("Body");
if (null != body)
{
body.Text = postToMove.FormattedBody;
}
// Display the move to drop down list
moveTo = (ForumListBox) skin.FindControl("MoveTo");
// Cancel
cancelMove = (HyperLink) skin.FindControl("CancelMove");
if (null != cancelMove)
{
cancelMove.NavigateUrl = csContext.ReturnUrl;
cancelMove.Text = ResourceManager.GetString("MovePost_CancelMove");
}
// Move Post
move = (LinkButton) skin.FindControl("MovePost");
if (null != move)
{
move.Click += new System.EventHandler(SplitThread_Click);
move.Text = ResourceManager.GetString("ThreadSplit_SplitThread");
}
// Validator
moveToValidator = (RequiredFieldValidator) skin.FindControl("MoveToValidator");
// Send email
sendEmail = (CheckBox) skin.FindControl("SendUserEmail");
sendEmail.Text = ResourceManager.GetString("ThreadSplit_SendUserEmail");
}
#endregion
#region Split Event
// *********************************************************************
// SplitThread_Click
//
/// <summary>
/// Event handler for splitting a thread
/// </summary>
///
// ***********************************************************************/
private void SplitThread_Click(Object sender, EventArgs e)
{
// Make sure their selection is a valid forum.
if(moveTo.SelectedForum == 0)
{
moveToValidator.IsValid = false;
return;
}
// Did the subject change?
if (subject.Text != postToMove.Subject)
{
postToMove.Subject = subject.Text;
Posts.UpdatePost(postToMove, csContext.User.UserID);
}
// Split the thread
Moderate.ThreadSplit (postToMove, moveTo.SelectedForum, csContext.User.UserID, sendEmail.Checked);
// Redirect the user to the return url.
HttpContext.Current.Response.Redirect( Globals.GetSiteUrls().Post(csContext.PostID) );
HttpContext.Current.Response.End();
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -