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

📄 section.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
📖 第 1 页 / 共 2 页
字号:
        // *********************************************************************
        //  DisplayMask
        //
        /// <summary>
        /// Bit mask used to control what forums to display for the current user
        /// </summary>
        // ********************************************************************/
        public byte[] DisplayMask 
		{
            get { 
                return displayMask; 
            }
            set {
                displayMask = value;
            }
        }

               
        public int GroupID {
            get { return groupId; }
            set {
                if (value < 0)
                    groupId = 0;
                else
                    groupId = value;
            }
        }

        public int SortOrder {
            get { return sortOrder; }
            set { sortOrder = value; }
        }

        /// <summary>
        /// Indicates how many total posts the forum has received.
        /// </summary>
        public int TotalPosts {
            get { return totalPosts; }
            set {
                if (value < 0)
                    totalPosts = -1;
                else
                    totalPosts = value;
            }
        }


        /// <summary>
        /// Specifies the date/time of the most recent post to the forum.
        /// </summary>
        public DateTime MostRecentPostDate {
            get { return mostRecentPostDate; }
            set {
                mostRecentPostDate = value;
            }
        }

        /// <summary>
        /// Specifies the most recent post to the forum.
        /// </summary>
        public int MostRecentPostID {
            get { return mostRecentPostId; }
            set {
                mostRecentPostId = value;
            }
        }

        /// <summary>
        /// Specifies the most recent thread id to the forum.
        /// </summary>
        public int MostRecentThreadID {
            get { return mostRecentThreadId; }
            set {
                mostRecentThreadId = value;
            }
        }

        public int MostRecentThreadReplies {
            get { return mostRecentThreadReplies ; }
            set { mostRecentThreadReplies  = value; }

        }

        /// <summary>
        /// Specifies the author of the most recent post to the forum.
        /// </summary>
        public String MostRecentPostAuthor {
            get { return mostRecentUser; }
            set {
                mostRecentUser = value;
            }
        }

        /// <summary>
        /// Specifies the author of the most recent post to the forum.
        /// </summary>
        public String MostRecentPostSubject {
            get { return mostRecentPostSubject; }
            set {
                mostRecentPostSubject = value;
            }
        }

        /// <summary>
        /// Specifies the author of the most recent post to the forum.
        /// </summary>
        public int MostRecentPostAuthorID {
            get { return mostRecentAuthorID; }
            set {
                mostRecentAuthorID = value;
            }
        }

        /// <summary>
        /// Indicates how many total threads are in the forum.  A thread is a top-level post.
        /// </summary>
        public int TotalThreads {
            get { return totalThreads; }
            set {
                if (value < 0)
                    totalThreads = -1;
                else
                    totalThreads = value;
            }
        }

        /// <summary>
        /// Specifies how many days worth of posts to view per page when listing a forum's posts.
        /// </summary>
        public ThreadDateFilterMode DefaultThreadDateFilter {
            get { return threadDateFilter; }
            set { threadDateFilter = value; }
        }

        /// <summary>
        /// Specifies the name of the forum.
        /// </summary>
        public String Name {
            get { return name; }
            set { name = value; }
        }

        /// <summary>
        /// Specifies the description of the forum.
        /// </summary>
        public String Description {
            get { return description; }
            set { description = value; }
        }

        /// <summary>
        /// Specifies if the forum is isModerated or not.
        /// </summary>
        public bool IsModerated {
            get { return isModerated; }
            set { isModerated = value; }
        }

        /// <summary>
        /// Specifies if the forum is currently isActive or not.  InisActive forums do not appear in the
        /// ForumListView Web control listing.
        /// </summary>
        public bool IsActive {
            get { return isActive; }
            set { isActive = value; }
        }

        /// <summary>
        /// Returns the date/time the forum was created.
        /// </summary>
        public DateTime DateCreated {
            get { return dateCreated; }
            set { dateCreated = value; }
        }

        #endregion


        
        /// <summary>
        /// Property Owners (string)
        /// </summary>
        public string Owners
        {
            get {  return GetExtendedAttribute("SectionOwners"); }
            set
            {
                if(value != null && value.Trim().Length > 0)
                {
                    //Convert ; + zero or more spaces to just ;
                    SetExtendedAttribute("SectionOwners", Regex.Replace(value,";\\s*",";"));
                }
                else
                    SetExtendedAttribute("SectionOwners", null);
            }
        }

        /****************************************************************************/
		/// <summary>
		/// Property to access the collection of ForumPermissions applied to this forum. Use RoleName as the lookup
		/// </summary>
		public Hashtable PermissionSet 
        {
			get { return this.permissions; }
			set { permissions = value; }
		}

        public bool HasPermissions
        {
            get{ return (this.PermissionSet != null && this.PermissionSet.Count > 0);}
        }

        /// <summary>
        /// Each section type must return it's permission type
        /// </summary>
        public abstract PermissionBase DefaultRolePermission
        {
            get;
        }

        /// <summary>
        /// Provides the Method implementing the AccessCheckDelegate signature
        /// </summary>
        public abstract AccessCheckDelegate AccessCheck
        {
            get;
        }

        /// <summary>
        /// Provides the Method implementing the ValidateDelegate signature
        /// </summary>
        public abstract ValidatePermissionsDelegate ValidatePermissions
        {
            get;
        }

        public virtual PermissionBase OwnerPermission
        {
			get
			{
				throw new NotImplementedException("OwerPermission is not implemented on this Section");
			}
        }


        public virtual PermissionBase RolePermission( string roleName )
        {
            PermissionBase pb = PermissionSet[roleName] as PermissionBase;
            if(pb == null)
                pb = DefaultRolePermission;

            return pb;
        }

        string[] ownerArray = null;

		/// <summary>
		/// Validates if a user the owner of the current section. Owners are users who have
		/// elevated permissions but no specific roles assigned. If the user is the owner, 
		/// their role based security will be ignored
		/// </summary>
		/// <param name="user">User to evaluate</param>
		/// <returns>True if the user's UserName exists as part of the Owners property (split into an array)</returns>
        protected virtual bool IsOwner(User user)
        {
             if(ownerArray == null)
                ownerArray = Owners.Split(';');
     
            if(ownerArray != null && ownerArray[0].Length > 0)
            {
                foreach(string owner in ownerArray)
                {
                    if(string.Compare(owner,user.Username,true) == 0)
                        return true;
                }
            }

            return false;
        }

        

		/// <summary>
		/// A user can be in multiple roles. Resolved Permission Merges the permissions
		/// for the user and those valid for the current section
		/// </summary>
		/// <param name="user">User we are evaluating</param>
		/// <returns>A single unified permission for the section/user combination</returns>
        public PermissionBase ResolvePermission( User user ) 
        {
            if(IsOwner(user))
                return OwnerPermission;

            PermissionBase pbMaster = DefaultRolePermission;

            string[] roles = Roles.GetUserRoleNames(user.Username);
            PermissionBase pb = null;
            foreach(string role in roles)
            {
                pb = PermissionSet[role] as PermissionBase;  
                if(pb !=null)
                    pbMaster.Merge(pb);
            }

            return pbMaster;
        }		
        
        /// <summary>
        /// Specifies if autheticated users are able to post as anonymous.
        /// </summary>
        public bool EnableAnonymousPostingForUsers {
            get {
                try {
                    return bool.Parse( GetExtendedAttribute( "EnableAnonymousPostingForUsers" ) ); 
                } catch {
                    return false;
                }
            }
            set {
                SetExtendedAttribute( "EnableAnonymousPostingForUsers", value.ToString() );
            }
        }
    }
}

⌨️ 快捷键说明

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