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

📄 moderationmenu.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
📖 第 1 页 / 共 2 页
字号:
//------------------------------------------------------------------------------
// <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 
{

    // *********************************************************************
    //  ModerationMenu
    //
    /// <summary>
    /// This control renders a moderation menu used by forum moderators
    /// to moderate new posts.
    /// </summary>
    // ********************************************************************/ 	
    public class ModerationMenu : SkinnedWebControl 
    {
        
        #region Member variables and constructor
        CSContext csContext = CSContext.Current;
        string skinFilename = "Moderation/Skin-ModerationMenu.ascx";
        bool canModerate = false;
        bool canEdit = false;
        LinkButton Approve;
        LinkButton ApproveReply;
        LinkButton ApproveEdit;
        LinkButton ToggleLockUnlockPost;
        LinkButton ToggleModerateUnModerateUser;
        HyperLink Move;
        HyperLink MergeSplit;
        HyperLink DeletePost;
        HyperLink EditPost;
        HyperLink EditUser;
        HyperLink ModerationHistory;
        ForumPost post;
		Forum forum;

        // *********************************************************************
        //  ModerationMenu
        //
        /// <summary>
        /// Constructor
        /// </summary>
        // ***********************************************************************/
        public ModerationMenu() : base() 
        {

            if (SkinFilename == null)
                SkinFilename = skinFilename;

        }
        #endregion

        /// <summary>
        /// Property UsePathToRedirect (bool)
        /// </summary>
        public bool UsePathToRedirect
        {
            get 
            {  
                object obj = ViewState["UsePathToRedirect"];
                return obj == null ? false : (bool)obj;
            }
            set {  ViewState["UsePathToRedirect"] = value; }
        }

        #region Skinning and render functions
        // *********************************************************************
        //  CreateChildControls
        //
        /// <summary>
        /// This event handler adds the children controls.
        /// </summary>
        // ***********************************************************************/
        protected override void CreateChildControls() 
        {

            // If the current user does not have moderate permissions on the post, return.
            //
            User user = CSContext.Current.User;
            int postID = this.Post.PostID;
            
			// If we don't have the forum, then go get it
			if(forum == null)
				forum = this.Post.Forum;

			// 修改判断方法, 只允许版主或管理员有操作权限
			//
			canModerate = CommunityServer.Discussions.Moderate.IsForumModerator(user, forum.GroupID, forum.SectionID); 
            //canModerate = Permissions.ValidatePermissions( forum, Permission.Moderate, user );
            //canModerate |= user.IsForumAdministrator;
            //canEdit = Permissions.ValidatePermissions( forum, Permission.EditOthers, user );
            if (canModerate || canEdit )
                base.CreateChildControls();
            else
                return;


        }

        // *********************************************************************
        //  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) 
        {

            Label PostID = (Label) skin.FindControl("PostID");
            if (null != PostID) 
            {
                PostID.Text = this.Post.PostID.ToString();
            }

            // Add the Approve click event handler.
            //
            Approve = skin.FindControl("Approve") as LinkButton;
            if (null != Approve) 
            {
                Approve.Text = ResourceManager.GetString("ModerationMenu_Approve");
                Approve.Click += new EventHandler(Approve_Click);
            }

            // Add the ApproveReply click event handler.
            //
            ApproveReply = skin.FindControl("ApproveReply") as LinkButton;
            if (null != ApproveReply) 
            {
                ApproveReply.Text = ResourceManager.GetString("ModerationMenu_ApproveReply");
                ApproveReply.Click += new EventHandler(ApproveReply_Click);
            }

            // Add the ApproveEdit click event handler.
            //
            ApproveEdit = skin.FindControl("ApproveEdit") as LinkButton;
            if (null != ApproveEdit) 
            {
                ApproveEdit.Text = ResourceManager.GetString("ModerationMenu_ApproveEdit");
                ApproveEdit.Click += new EventHandler(ApproveEdit_Click);
            }

            // Set the EditPost url to the ModeratePostEdit url.
            //
            EditPost = (HyperLink) skin.FindControl("EditPost");
            if (null != EditPost) 
            {
                if(Post.PostType == PostType.Poll)
                {
                    EditPost.Visible = false;
                    Control sep = skin.FindControl("EditPostSeperator");
                    if(sep != null)
                        sep.Visible = false;
                }
                else
                {
                    EditPost.Visible = true;
                    // Set the text for the hyperlink
                    EditPost.Text = ResourceManager.GetString("ModeratePost_EditPost");
                    EditPost.NavigateUrl = Globals.GetSiteUrls().ModeratePostEdit(this.Post.PostID, HttpUtility.UrlEncode(HttpContext.Current.Request.Url.PathAndQuery + "#" + this.Post.PostID.ToString()));
                }
            }

            bool trueRedirect = this.UsePathToRedirect;

            // Set the DeleteApprovedPost url based on the post level of the post.
            //
            DeletePost = (HyperLink) skin.FindControl("DeletePost");
            if (null != DeletePost) 
            {
                // Set the text for the hyperlink

                if (this.Post.PostLevel == 1) 
                {
                    DeletePost.Text = ResourceManager.GetString("ModerationMenu_DeleteThread");
                    DeletePost.NavigateUrl = Globals.GetSiteUrls().ModeratePostDelete(this.Post.PostID, trueRedirect ? HttpUtility.UrlEncode(Context.Request.RawUrl) : HttpUtility.UrlEncode(ForumUrls.Instance().Forum(this.Post.SectionID)));
                } 
                else 
                {
                    DeletePost.Text = ResourceManager.GetString("ModerationMenu_DeletePost");
                    if(trueRedirect)
                        DeletePost.NavigateUrl = Globals.GetSiteUrls().ModeratePostDelete(this.Post.PostID, HttpUtility.UrlEncode(Context.Request.RawUrl));
                    else
                        DeletePost.NavigateUrl = Globals.GetSiteUrls().ModeratePostDelete(this.Post.PostID, trueRedirect ? HttpUtility.UrlEncode(Context.Request.RawUrl) : HttpUtility.UrlEncode(Globals.GetSiteUrls().Post(this.Post.ParentID)));
                }
            }

            // Set the Move url to the ModeratePostMove url if the post level is 1, otherwise disable the move control.
            //
            Move = (HyperLink) skin.FindControl("Move");
            if (null != Move) 
            {
				if (this.Post.PostLevel == 1) 
				{
					Move.Text = ResourceManager.GetString("ModeratePost_Move");
					Move.NavigateUrl = Globals.GetSiteUrls().ModeratePostMove(this.Post.PostID, HttpUtility.UrlEncode(HttpContext.Current.Request.Url.PathAndQuery));
				}
				else
				{
					Move.Text = Move.Text = ResourceManager.GetString("ModeratePost_Move");
					Move.NavigateUrl = "";
					Move.ForeColor = System.Drawing.Color.Gray;
				}
            }

            // Set the Split url to the ModerateThreadSplit url
            //
            MergeSplit = (HyperLink) skin.FindControl("MergeSplit");
            if (null != MergeSplit) 
            {
                if (this.Post.PostLevel > 1) 
                {
                    MergeSplit.Text = ResourceManager.GetString("ModerateThread_Split");
                    MergeSplit.NavigateUrl = Globals.GetSiteUrls().ModerateThreadSplit(this.Post.PostID, HttpUtility.UrlEncode(HttpContext.Current.Request.Url.PathAndQuery));
                } 
                else 
                {
                    MergeSplit.NavigateUrl = Globals.GetSiteUrls().ModerateThreadJoin(this.Post.PostID, HttpContext.Current.Request.Url.PathAndQuery);
                    MergeSplit.Text = ResourceManager.GetString("ModerateThread_Join");
                }
            }

            // Toggle Lock / Unlock Post
            //
            ToggleLockUnlockPost = (LinkButton) skin.FindControl("ToggleLockUnlockPost");
            if (null != ToggleLockUnlockPost) 
            {
                if (this.Post.PostLevel > 1) 
                {
					ToggleLockUnlockPost.Visible = false;
					skin.FindControl("HideLockSpan").Visible = false;
				} 
                else 
                {
                    if (this.Post.IsLocked) 
                    {
                        ToggleLockUnlockPost.Text = ResourceManager.GetString("ModerateThread_UnLock_Thread");
                    } 
                    else 
                    {
                        ToggleLockUnlockPost.Text = ResourceManager.GetString("ModerateThread_Lock_Thread");
                    }
                }

                ToggleLockUnlockPost.Click += new EventHandler(LockUnlock_Click);
                ToggleLockUnlockPost.CommandArgument = this.Post.PostID.ToString();

            }

            EditUser = (HyperLink) skin.FindControl("EditUser");
            ToggleModerateUnModerateUser = (LinkButton) skin.FindControl("ToggleModerateUnModerateUser");
            ModerationHistory = (HyperLink) skin.FindControl("History");

⌨️ 快捷键说明

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