⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threadmove.cs

📁 community server 源码
💻 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 
{
    // *********************************************************************
    //  ThreadMove
    //
    /// <summary>
    /// This sever control is used to move a thread from forum to forum.
    /// </summary>
    /// 
    // ********************************************************************/ 
    public class ThreadMove : TemplatedWebControl
    {
        #region Child Controls

        Label subject;
        Label hasReplies;
        Label postedBy;
        ForumListBox moveTo;
        CheckBox sendEmail;
        IButton cancelMove;
        IButton move;
        RequiredFieldValidator moveToValidator;

        CSContext csContext;
        ForumPost postToMove;

        #endregion

        protected override void OnInit(EventArgs e) 
        {
            csContext = CSContext.Current;

            if (SkinName == null)                
                ExternalSkinFileName = "Moderation/View-ThreadMove.ascx";
            else 
                ExternalSkinFileName = SkinName;
			
            if (csContext.ReturnUrl == null) 
            {
                throw new CSException(CSExceptionType.ReturnURLRequired);
            }

            // 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.User, postToMove );

            base.OnInit(e);
        }
		
        protected override void OnLoad(EventArgs e) 
        {
            if (!Page.IsPostBack)
                DataBind();

            base.OnLoad(e);
        }

        #region DataBind

        public override void DataBind() 
        {
            base.DataBind();
            
            // Display subject
            //
            if (null != subject) 
                subject.Text = postToMove.Subject;

            // Has Replies?
            //
            if (null != hasReplies) 
            {                
                if (postToMove.Replies > 0) 
                    hasReplies.Text = ResourceManager.GetString("Yes");
                else 
                    hasReplies.Text = ResourceManager.GetString("No");
            }

            // Posted By
            //
            if (null != postedBy)
				postedBy.Text = postToMove.User.DisplayName + " ";

            // Cancel
            //
            if (null != cancelMove) 
                cancelMove.Text = ResourceManager.GetString("MovePost_CancelMove");

            // Move Post
            //
            if (null != move) 
                move.Text = ResourceManager.GetString("MovePost_MovePost");

            // Send email
            //
            if (null != sendEmail)
                sendEmail.Text = ResourceManager.GetString("MovePost_SendUserEmail");
        }
		
        #endregion		
		
        #region Skin
                
        protected override void AttachChildControls() 
        {
            // Bind controls
            //
            subject = (Label) FindControl("Subject");
            hasReplies = (Label) FindControl("HasReplies");
            postedBy = (Label) FindControl("PostedBy");
            moveTo = (ForumListBox) FindControl("MoveTo");
            cancelMove =  FindButton("CancelMove");
            move =  FindButton("MovePost");
            moveToValidator = (RequiredFieldValidator) FindControl("MoveToValidator");
            sendEmail = (CheckBox) FindControl("SendUserEmail");
			
            InitializeChildControls();
        }

        private void InitializeChildControls() 
        {
            if (null != cancelMove) 
                cancelMove.Click += new EventHandler(Cancel_Click);
		
            if (null != move) 
                move.Click += new System.EventHandler(MoveThread_Click);
        }
		        
        #endregion

        #region Event Handlers

        // *********************************************************************
        //  MoveThread_Click
        //
        /// <summary>
        /// Event handler for deleting a post
        /// </summary>
        /// 
        // ***********************************************************************/
        private void MoveThread_Click(Object sender, EventArgs e) 
        {
            // Make sure their selection is a valid forum.
            if (moveTo.SelectedForum == 0)
            {
                moveToValidator.IsValid = false;
                return;
            }

            // Are we valid?
            Moderate.MovePost(postToMove, moveTo.SelectedForum, csContext.User.UserID, sendEmail.Checked);

            // Force refresh on post to forum cache table which is built in Forums.GetForumByPostID( ... ).
            CSCache.Remove( "PostToForumLookUpTable" );

            // Redirect the user to the return url.
            HttpContext.Current.Response.Redirect(csContext.ReturnUrl);
            HttpContext.Current.Response.End();
        }

        void Cancel_Click(object sender, EventArgs e) 
        {
            moveToValidator.IsValid = true;

            CSContext.Current.Context.Response.Redirect(csContext.ReturnUrl, true);
        }

        #endregion
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -